From efb3116f2ae80eb87d23c02308863d326a50c573 Mon Sep 17 00:00:00 2001 From: Dedy Lansky Date: Mon, 2 Dec 2019 16:04:02 +0200 Subject: [PATCH] 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: Dedy Lansky Signed-off-by: Lior David Signed-off-by: Maya Erez [liord@codeaurora.org: merge conflicts, checkpatch errors] Signed-off-by: Lior David Signed-off-by: Alexei Avshalom Lazar --- drivers/net/wireless/ath/wil6210/main.c | 1 + drivers/net/wireless/ath/wil6210/sysfs.c | 45 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/net/wireless/ath/wil6210/main.c b/drivers/net/wireless/ath/wil6210/main.c index a2243027cd24..c0c4f913115d 100644 --- a/drivers/net/wireless/ath/wil6210/main.c +++ b/drivers/net/wireless/ath/wil6210/main.c @@ -832,6 +832,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); kfree(wil->brd_info); } diff --git a/drivers/net/wireless/ath/wil6210/sysfs.c b/drivers/net/wireless/ath/wil6210/sysfs.c index 501ee1f1bf5e..f872e8358033 100644 --- a/drivers/net/wireless/ath/wil6210/sysfs.c +++ b/drivers/net/wireless/ath/wil6210/sysfs.c @@ -81,6 +81,50 @@ ftm_txrx_offset_store(struct device *dev, static DEVICE_ATTR_RW(ftm_txrx_offset); +static ssize_t +board_file_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 +board_file_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_RW(board_file); + static ssize_t thermal_throttling_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -291,6 +335,7 @@ static DEVICE_ATTR_RW(snr_thresh); 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,