wifi: wilc1000: Register wiphy after reading out chipid
authorMarek Vasut <marex@denx.de>
Fri, 4 Oct 2024 11:44:15 +0000 (13:44 +0200)
committerKalle Valo <kvalo@kernel.org>
Thu, 17 Oct 2024 16:47:42 +0000 (19:47 +0300)
Register wiphy after reading out chipid, so the chipid can be
used to determine chip features and not advertise WPA3/SAE
support to userspace on WILC3000. Note that wilc_netdev_cleanup()
will deregister the wiphy in fail path.

Tested-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Tested-on: WILC1000SD 07 SDIO WILC_WIFI_FW_REL_16_1_2
Tested-on: WILC3000 A SDIO WILC_WIFI_FW_REL_16_1_1
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20241004114551.40236-6-marex@denx.de
drivers/net/wireless/microchip/wilc1000/cfg80211.c
drivers/net/wireless/microchip/wilc1000/cfg80211.h
drivers/net/wireless/microchip/wilc1000/sdio.c
drivers/net/wireless/microchip/wilc1000/spi.c

index 11e0f8a473467ec6efb76b6097786853545f78b2..283f8df046884b12387ac37f6e75ea77dcea9398 100644 (file)
@@ -1761,7 +1761,6 @@ static struct wilc *wilc_create_wiphy(struct device *dev)
 {
        struct wiphy *wiphy;
        struct wilc *wl;
-       int ret;
 
        wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(*wl));
        if (!wiphy)
@@ -1804,14 +1803,8 @@ static struct wilc *wilc_create_wiphy(struct device *dev)
                                BIT(NL80211_IFTYPE_P2P_GO) |
                                BIT(NL80211_IFTYPE_P2P_CLIENT);
        wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
-       wiphy->features |= NL80211_FEATURE_SAE;
        set_wiphy_dev(wiphy, dev);
        wl->wiphy = wiphy;
-       ret = wiphy_register(wiphy);
-       if (ret) {
-               wiphy_free(wiphy);
-               return NULL;
-       }
        return wl;
 }
 
@@ -1855,12 +1848,19 @@ free_cfg:
 
 free_wl:
        wlan_deinit_locks(wl);
-       wiphy_unregister(wl->wiphy);
        wiphy_free(wl->wiphy);
        return ret;
 }
 EXPORT_SYMBOL_GPL(wilc_cfg80211_init);
 
+int wilc_cfg80211_register(struct wilc *wilc)
+{
+       wilc->wiphy->features |= NL80211_FEATURE_SAE;
+
+       return wiphy_register(wilc->wiphy);
+}
+EXPORT_SYMBOL_GPL(wilc_cfg80211_register);
+
 int wilc_init_host_int(struct net_device *net)
 {
        int ret;
index fc04cc6615c1fa4567d3c314ad628e2194b98780..2dc9c1c42d60964b6409c60f13565cf4fbc49b04 100644 (file)
@@ -10,6 +10,7 @@
 
 int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
                       const struct wilc_hif_func *ops);
+int wilc_cfg80211_register(struct wilc *wilc);
 void wilc_deinit_host_int(struct net_device *net);
 int wilc_init_host_int(struct net_device *net);
 void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size);
index 9173f6f3beabf07d8079af9486f631c641078175..56a929281d6a709ca03fe1cd0120a8de10474ed1 100644 (file)
@@ -186,6 +186,10 @@ static int wilc_sdio_probe(struct sdio_func *func,
        if (ret)
                goto dispose_irq;
 
+       ret = wilc_cfg80211_register(wilc);
+       if (ret)
+               goto dispose_irq;
+
        ret = wilc_load_mac_from_nv(wilc);
        if (ret) {
                pr_err("Can not retrieve MAC address from chip\n");
index 81cf82c9175efe10cb5d81e9736877bf70444f1c..28d211ee6009694f72b59110bdbd5caaebff0cc5 100644 (file)
@@ -249,6 +249,10 @@ static int wilc_bus_probe(struct spi_device *spi)
        if (ret)
                goto power_down;
 
+       ret = wilc_cfg80211_register(wilc);
+       if (ret)
+               goto power_down;
+
        ret = wilc_load_mac_from_nv(wilc);
        if (ret) {
                pr_err("Can not retrieve MAC address from chip\n");