net: wireless: bcmdhd: Update wiphy bands on band change
authorDmitry Shmidt <dimitrysh@google.com>
Mon, 9 Jul 2012 18:14:42 +0000 (11:14 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Thu, 12 Jul 2012 17:45:49 +0000 (10:45 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcmdhd/dhd_linux.c
drivers/net/wireless/bcmdhd/wl_cfg80211.c
drivers/net/wireless/bcmdhd/wl_cfg80211.h
drivers/net/wireless/bcmdhd/wldev_common.c
drivers/net/wireless/bcmdhd/wldev_common.h

index 1cee01dda4cace281744dc97cdbc6cf6b8c5d68c..4d763c9e41f1090bce3bb590ebc0544b8a7460da 100644 (file)
@@ -4536,7 +4536,18 @@ void dhd_bus_country_set(struct net_device *dev, wl_country_t *cspec)
        if (dhd && dhd->pub.up) {
                memcpy(&dhd->pub.dhd_cspec, cspec, sizeof(wl_country_t));
 #ifdef WL_CFG80211
-               wl_update_wiphybands(NULL);
+               wl_update_wiphybands(NULL, cspec->ccode);
+#endif
+       }
+}
+
+void dhd_bus_band_set(struct net_device *dev, uint band)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       if (dhd && dhd->pub.up) {
+#ifdef WL_CFG80211
+               wl_update_wiphybands(NULL, NULL);
 #endif
        }
 }
index 121f3bb90986f01c80753d1bf045c116c6a27f07..5e61aa42739ad1c72836601ff545e56fe72abc12 100644 (file)
@@ -7138,7 +7138,7 @@ static int wl_construct_reginfo(struct wl_priv *wl, s32 bw_cap)
        return err;
 }
 
-s32 wl_update_wiphybands(struct wl_priv *wl)
+s32 wl_update_wiphybands(struct wl_priv *wl, char *country_code)
 {
        struct wiphy *wiphy;
        struct net_device *dev;
@@ -7149,6 +7149,7 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        int nmode = 0;
        int bw_cap = 0;
        int index = 0;
+       struct regulatory_request *new_request;
        bool rollback_lock = false;
 
        WL_DBG(("Entry"));
@@ -7216,6 +7217,24 @@ s32 wl_update_wiphybands(struct wl_priv *wl)
        }
 
        wiphy_apply_custom_regulatory(wiphy, &brcm_regdom);
+
+       if (country_code != NULL) {
+               WL_DBG(("country_code[0]=%c, country_code[1]=%c\n", country_code[0], country_code[1]));
+               /* Allocate a requlatory request to update cfg80211 for the supported channels */
+               new_request = kzalloc(sizeof(struct regulatory_request),
+                                       GFP_KERNEL);
+               if (!new_request) {
+                       WL_ERR(("error Memory alloc for requlatory request failed\n"));
+                       err = -ENOMEM;
+               } else {
+                       new_request->alpha2[0] = country_code[0];
+                       new_request->alpha2[1] = country_code[1];
+                       WL_DBG(("Send an event to cfg80211 to update supplicant to take the new channel list"));
+                       nl80211_send_reg_change_event(new_request);
+                       kfree(new_request);
+               }
+       }
+
 end_bands:
        if (rollback_lock)
                mutex_unlock(&wl->usr_sync);
@@ -7238,7 +7257,7 @@ static s32 __wl_cfg80211_up(struct wl_priv *wl)
        if (unlikely(err && err != -EINPROGRESS)) {
                WL_ERR(("wl_config_ifmode failed\n"));
        }
-       err = wl_update_wiphybands(wl);
+       err = wl_update_wiphybands(wl, NULL);
        if (unlikely(err)) {
                WL_ERR(("wl_update_wiphybands failed\n"));
        }
index 49bed703062af5da9da3f7901de9d7db428cdef6..c3281ec79dfb0d36eb6f4c7f1387b1a89e368711 100644 (file)
@@ -669,6 +669,7 @@ extern int wl_cfg80211_hang(struct net_device *dev, u16 reason);
 extern s32 wl_mode_to_nl80211_iftype(s32 mode);
 int wl_cfg80211_do_driver_init(struct net_device *net);
 void wl_cfg80211_enable_trace(int level);
-extern s32 wl_update_wiphybands(struct wl_priv *wl);
+extern s32 wl_update_wiphybands(struct wl_priv *wl, char *country_code);
 extern s32 wl_cfg80211_if_is_group_owner(void);
+extern void nl80211_send_reg_change_event(struct regulatory_request *request);
 #endif                         /* _wl_cfg80211_h_ */
index a1156fffe7e6ee7fd5122c6538d35419ebc3fb8f..51a80645fb349ff945475c18b246982d5a0bf27b 100644 (file)
@@ -320,6 +320,8 @@ int wldev_set_band(
 
        if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
                error = wldev_ioctl(dev, WLC_SET_BAND, &band, sizeof(band), 1);
+               if (!error)
+                       dhd_bus_band_set(dev, band);
        }
        return error;
 }
index f586609444202017648a78453c53ae250345a459..dd3c899d12ca990a507b93dc571ab2ed013d5e12 100644 (file)
@@ -85,6 +85,7 @@ s32 wldev_iovar_setint_bsscfg(
 
 extern void get_customized_country_code(char *country_iso_code, wl_country_t *cspec);
 extern void dhd_bus_country_set(struct net_device *dev, wl_country_t *cspec);
+extern void dhd_bus_band_set(struct net_device *dev, uint band);
 extern int wldev_set_country(struct net_device *dev, char *country_code);
 extern int net_os_wake_lock(struct net_device *dev);
 extern int net_os_wake_unlock(struct net_device *dev);