Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b89284c authored by Dedy Lansky's avatar Dedy Lansky Committed by Maya Erez
Browse files

wil6210: support configurable board file via sysfs



Add a sysfs allowing to override the board file containing
the RF characteristics of the 11ad device.
The new board file will be used the next time the interface
is brought up.
This change is intended to support platforms with multiple
11ad devices connected. Each 11ad device can be connected
to a different antenna module and the HW cannot automatically
detect the type of antenna connected, so the board file must
be explicitly specified for each device.

Change-Id: I40746032d9314057c64575bca96f3445816e5457
Signed-off-by: default avatarDedy Lansky <dlansky@codeaurora.org>
Signed-off-by: default avatarLior David <liord@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
parent 0600f1dc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -699,6 +699,7 @@ void wil_priv_deinit(struct wil6210_priv *wil)
	wmi_event_flush(wil);
	destroy_workqueue(wil->wq_service);
	destroy_workqueue(wil->wmi_wq);
	kfree(wil->board_file);
}

static void wil_shutdown_bl(struct wil6210_priv *wil)
@@ -1136,7 +1137,8 @@ void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r)
/* construct actual board file name to use */
void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len)
{
	const char *board_file = WIL_BOARD_FILE_NAME;
	const char *board_file = wil->board_file ?
					wil->board_file : WIL_BOARD_FILE_NAME;
	const char *ext;
	int prefix_len;

+47 −0
Original line number Diff line number Diff line
@@ -96,6 +96,52 @@ static DEVICE_ATTR(ftm_txrx_offset, 0644,
		   wil_ftm_txrx_offset_sysfs_show,
		   wil_ftm_txrx_offset_sysfs_store);

static ssize_t
wil_board_file_sysfs_show(struct device *dev,
			  struct device_attribute *attr,
			  char *buf)
{
	struct wil6210_priv *wil = dev_get_drvdata(dev);

	wil_get_board_file(wil, buf, PAGE_SIZE);
	strlcat(buf, "\n", PAGE_SIZE);
	return strlen(buf);
}

static ssize_t
wil_board_file_sysfs_store(struct device *dev,
			   struct device_attribute *attr,
			   const char *buf, size_t count)
{
	struct wil6210_priv *wil = dev_get_drvdata(dev);
	size_t len;

	mutex_lock(&wil->mutex);

	kfree(wil->board_file);
	wil->board_file = NULL;

	len = count;
	if (buf[count - 1] == '\n')
		len--;
	len = strnlen(buf, len);
	if (len > 0) {
		wil->board_file = kmalloc(len + 1, GFP_KERNEL);
		if (!wil->board_file) {
			mutex_unlock(&wil->mutex);
			return -ENOMEM;
		}
		strlcpy(wil->board_file, buf, len + 1);
	}
	mutex_unlock(&wil->mutex);

	return count;
}

static DEVICE_ATTR(board_file, 0644,
		   wil_board_file_sysfs_show,
		   wil_board_file_sysfs_store);

static ssize_t
wil_tt_sysfs_show(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -310,6 +356,7 @@ static DEVICE_ATTR(snr_thresh, 0644,

static struct attribute *wil6210_sysfs_entries[] = {
	&dev_attr_ftm_txrx_offset.attr,
	&dev_attr_board_file.attr,
	&dev_attr_thermal_throttling.attr,
	&dev_attr_fst_link_loss.attr,
	&dev_attr_snr_thresh.attr,