linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] staging: wfx: drop module version
@ 2019-10-17  9:40 Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h Jerome Pouiller
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

wfx_version.h says that this code is same same than driver 2.3.1 hosted
on github:

    https://github.com/siliconlabs/wfx-linux-driver/tree/2.3.1-public

However, it is inaccurate, driver in-tree contains multiple small
patches ahead 2.3.1.

I prefer to drop this confusing information.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/TODO          | 3 ---
 drivers/staging/wfx/main.c        | 4 ----
 drivers/staging/wfx/wfx_version.h | 3 ---
 3 files changed, 10 deletions(-)
 delete mode 100644 drivers/staging/wfx/wfx_version.h

diff --git a/drivers/staging/wfx/TODO b/drivers/staging/wfx/TODO
index be990e8f18b1..e44772289af8 100644
--- a/drivers/staging/wfx/TODO
+++ b/drivers/staging/wfx/TODO
@@ -1,9 +1,6 @@
 This is a list of things that need to be done to get this driver out of the
 staging directory.
 
-  - wfx_version.h is still there in order to ensure synchronization with github.
-    It can be dropped as soon as development is entirely in kernel
-
   - I have to take a decision about secure link support. I can:
       - drop completely
       - keep it in an external patch (my preferred option)
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index d2508bc950fa..157e0fc0107e 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -33,14 +33,12 @@
 #include "secure_link.h"
 #include "hif_tx_mib.h"
 #include "hif_api_cmd.h"
-#include "wfx_version.h"
 
 #define WFX_PDS_MAX_SIZE 1500
 
 MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx");
 MODULE_AUTHOR("Jérôme Pouiller <jerome.pouiller@silabs.com>");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(WFX_LABEL);
 
 static int gpio_wakeup = -2;
 module_param(gpio_wakeup, int, 0644);
@@ -480,8 +478,6 @@ static int __init wfx_core_init(void)
 {
 	int ret = 0;
 
-	pr_info("wfx: Silicon Labs " WFX_LABEL "\n");
-
 	if (IS_ENABLED(CONFIG_SPI))
 		ret = spi_register_driver(&wfx_spi_driver);
 	if (IS_ENABLED(CONFIG_MMC) && !ret)
diff --git a/drivers/staging/wfx/wfx_version.h b/drivers/staging/wfx/wfx_version.h
deleted file mode 100644
index 6e7f30207c73..000000000000
--- a/drivers/staging/wfx/wfx_version.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! */
-#define WFX_LABEL "2.3.1"
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h
  2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
@ 2019-10-17  9:40 ` Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 5/6] staging: wfx: fix setting MAC address from DT Jerome Pouiller
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

"Secure link" feature is not available in in-tree driver (because it
depends on mbedtls). Thus, secure_link.h only empty functions.

Module parameter "slk_key" and associated function wfx_fill_sl_key() had
an unjustifiable place in main.c. This patch relocate them to
secure_link.h.

BTW, content of wfx_fill_sl_key() is now useless. Just keep a warning if
user try to use "slk_key" attribute (unsupported by this driver).

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/main.c        | 29 +----------------------------
 drivers/staging/wfx/main.h        |  1 -
 drivers/staging/wfx/secure_link.h |  9 +++++++++
 3 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 157e0fc0107e..3a43f190d96a 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -44,10 +44,6 @@ static int gpio_wakeup = -2;
 module_param(gpio_wakeup, int, 0644);
 MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none.");
 
-static char *slk_key;
-module_param(slk_key, charp, 0600);
-MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexadecimal digits).");
-
 #define RATETAB_ENT(_rate, _rateid, _flags) { \
 	.bitrate  = (_rate),   \
 	.hw_value = (_rateid), \
@@ -194,29 +190,6 @@ struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *lab
 	return ret;
 }
 
-static void wfx_fill_sl_key(struct device *dev, struct wfx_platform_data *pdata)
-{
-	const char *ascii_key = NULL;
-	int ret = 0;
-
-	if (slk_key)
-		ascii_key = slk_key;
-	if (!ascii_key)
-		ret = of_property_read_string(dev->of_node, "slk_key", &ascii_key);
-	if (ret == -EILSEQ || ret == -ENODATA)
-		dev_err(dev, "ignoring malformatted key from DT\n");
-	if (!ascii_key)
-		return;
-
-	ret = hex2bin(pdata->slk_key, ascii_key, sizeof(pdata->slk_key));
-	if (ret) {
-		dev_err(dev, "ignoring malformatted key: %s\n", ascii_key);
-		memset(pdata->slk_key, 0, sizeof(pdata->slk_key));
-		return;
-	}
-	dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n");
-}
-
 /* NOTE: wfx_send_pds() destroy buf */
 int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len)
 {
@@ -334,7 +307,7 @@ struct wfx_dev *wfx_init_common(struct device *dev,
 	memcpy(&wdev->pdata, pdata, sizeof(*pdata));
 	of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds);
 	wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup");
-	wfx_fill_sl_key(dev, &wdev->pdata);
+	wfx_sl_fill_pdata(dev, &wdev->pdata);
 
 	mutex_init(&wdev->conf_mutex);
 	mutex_init(&wdev->rx_stats_lock);
diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h
index f2b07ed1627c..875f8c227803 100644
--- a/drivers/staging/wfx/main.h
+++ b/drivers/staging/wfx/main.h
@@ -22,7 +22,6 @@ struct wfx_platform_data {
 	/* Keyset and ".sec" extention will appended to this string */
 	const char *file_fw;
 	const char *file_pds;
-	unsigned char slk_key[API_KEY_VALUE_SIZE];
 	struct gpio_desc *gpio_wakeup;
 	/*
 	 * if true HIF D_out is sampled on the rising edge of the clock
diff --git a/drivers/staging/wfx/secure_link.h b/drivers/staging/wfx/secure_link.h
index e2da1c73c760..376d7bc4c0c4 100644
--- a/drivers/staging/wfx/secure_link.h
+++ b/drivers/staging/wfx/secure_link.h
@@ -5,6 +5,8 @@
 #ifndef WFX_SECURE_LINK_H
 #define WFX_SECURE_LINK_H
 
+#include <linux/of.h>
+
 #include "hif_api_general.h"
 
 struct wfx_dev;
@@ -33,6 +35,13 @@ static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, uint8_t *ncp_pubkey,
 	return -EIO;
 }
 
+static inline void wfx_sl_fill_pdata(struct device *dev,
+				     struct wfx_platform_data *pdata)
+{
+	if (of_find_property(dev->of_node, "slk_key", NULL))
+		dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n");
+}
+
 static inline int wfx_sl_init(struct wfx_dev *wdev)
 {
 	return -EIO;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y
  2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
                   ` (2 preceding siblings ...)
  2019-10-17  9:40 ` [PATCH 4/6] staging: wfx: fix Oops when CONFIG_OF_NET is not set Jerome Pouiller
@ 2019-10-17  9:40 ` Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 6/6] staging: wfx: fix number of available tx_policies Jerome Pouiller
  4 siblings, 0 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller, zhong jiang

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

If CONFIG_MMC=m and CONFIG_WFX=y, compilation complains with undefined
references:

    drivers/staging/wfx/main.o: In function `wfx_core_init': /linux/drivers/staging/wfx/main.c:488: undefined reference to `sdio_register_driver'
    drivers/staging/wfx/main.o: In function `wfx_core_exit': /linux/drivers/staging/wfx/main.c:496: undefined reference to `sdio_unregister_driver'
    drivers/staging/wfx/main.o:(.debug_addr+0x1a8): undefined reference to `sdio_register_driver'
    drivers/staging/wfx/main.o:(.debug_addr+0x6f0): undefined reference to `sdio_unregister_driver'

Indeed, symbols sdio_* are not present in kernel image.

This patch disallows CONFIG_WFX=y if CONFIG_MMC=m.

This solution impacts users who want to use SPI bus with configuration:
CONFIG_WFX=y + CONFIG_SPI=y + CONFIG_MMC=m. However, I think this is a
twisted case. So, I think it won't be missed.

Reported-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/wfx/Kconfig b/drivers/staging/wfx/Kconfig
index 9b8a1c7a9e90..83ee4d0ca8c6 100644
--- a/drivers/staging/wfx/Kconfig
+++ b/drivers/staging/wfx/Kconfig
@@ -1,6 +1,7 @@
 config WFX
 	tristate "Silicon Labs wireless chips WF200 and further"
 	depends on MAC80211
+	depends on MMC || !MMC # do not allow WFX=y if MMC=m
 	depends on (SPI || MMC)
 	help
 	  This is a driver for Silicons Labs WFxxx series (WF200 and further)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] staging: wfx: fix Oops when CONFIG_OF_NET is not set
  2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 5/6] staging: wfx: fix setting MAC address from DT Jerome Pouiller
@ 2019-10-17  9:40 ` Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 3/6] staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 6/6] staging: wfx: fix number of available tx_policies Jerome Pouiller
  4 siblings, 0 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

In most case, of_get_mac_address() return NULL in case of error.
However, if CONFIG_OF_NET is not set, it return -ENODEV.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 3a43f190d96a..205b5bc8872e 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -407,7 +407,7 @@ int wfx_probe(struct wfx_dev *wdev)
 	for (i = 0; i < ARRAY_SIZE(wdev->addresses); i++) {
 		eth_zero_addr(wdev->addresses[i].addr);
 		macaddr = of_get_mac_address(wdev->dev->of_node);
-		if (macaddr) {
+		if (!IS_ERR_OR_NULL(macaddr)) {
 			ether_addr_copy(wdev->addresses[i].addr, macaddr);
 			wdev->addresses[i].addr[ETH_ALEN - 1] += i;
 		}
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] staging: wfx: fix setting MAC address from DT
  2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h Jerome Pouiller
@ 2019-10-17  9:40 ` Jerome Pouiller
  2019-10-17  9:40 ` [PATCH 4/6] staging: wfx: fix Oops when CONFIG_OF_NET is not set Jerome Pouiller
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller, Marc Dorval

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

MAC address read from chip is unconditionally used even if a MAC
address is configured in device tree.

Reported-by: Marc Dorval <marc.dorval@silabs.com>
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 205b5bc8872e..18f07f7ad347 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -410,8 +410,9 @@ int wfx_probe(struct wfx_dev *wdev)
 		if (!IS_ERR_OR_NULL(macaddr)) {
 			ether_addr_copy(wdev->addresses[i].addr, macaddr);
 			wdev->addresses[i].addr[ETH_ALEN - 1] += i;
+		} else {
+			ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]);
 		}
-		ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]);
 		if (!is_valid_ether_addr(wdev->addresses[i].addr)) {
 			dev_warn(wdev->dev, "using random MAC address\n");
 			eth_random_addr(wdev->addresses[i].addr);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] staging: wfx: fix number of available tx_policies
  2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
                   ` (3 preceding siblings ...)
  2019-10-17  9:40 ` [PATCH 3/6] staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y Jerome Pouiller
@ 2019-10-17  9:40 ` Jerome Pouiller
  4 siblings, 0 replies; 6+ messages in thread
From: Jerome Pouiller @ 2019-10-17  9:40 UTC (permalink / raw)
  To: devel; +Cc: linux-kernel, Greg Kroah-Hartman, Jerome Pouiller, Alban Jeantheau

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Original API declares 16 tx_policies. But in fact, the 16th is used
internally by the firmware. So, only 15 tx_policies are available for
driver.

Reported-by: Alban Jeantheau <alban.jeantheau@silabs.com>
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_api_mib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h
index 3c56ef2978a2..af657555f894 100644
--- a/drivers/staging/wfx/hif_api_mib.h
+++ b/drivers/staging/wfx/hif_api_mib.h
@@ -507,7 +507,7 @@ struct hif_mib_tx_rate_retry_policy {
 	uint8_t    rates[12];
 } __packed;
 
-#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES    16
+#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES    15
 
 struct hif_mib_set_tx_rate_retry_policy {
 	uint8_t    num_tx_rate_policies;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-17  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17  9:40 [PATCH 1/6] staging: wfx: drop module version Jerome Pouiller
2019-10-17  9:40 ` [PATCH 2/6] staging: wfx: relocate wfx_fill_sl_key() in secure_link.h Jerome Pouiller
2019-10-17  9:40 ` [PATCH 5/6] staging: wfx: fix setting MAC address from DT Jerome Pouiller
2019-10-17  9:40 ` [PATCH 4/6] staging: wfx: fix Oops when CONFIG_OF_NET is not set Jerome Pouiller
2019-10-17  9:40 ` [PATCH 3/6] staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y Jerome Pouiller
2019-10-17  9:40 ` [PATCH 6/6] staging: wfx: fix number of available tx_policies Jerome Pouiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).