mwifiex: send regulatory domain info to firmware only if alpha2 changed
authorBing Zhao <bzhao@marvell.com>
Sat, 14 Dec 2013 02:32:59 +0000 (18:32 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 18 Dec 2013 20:23:06 +0000 (15:23 -0500)
On cfg80211 regulatory domain change, drivers gets alpha2 country
code or "00" in driver's notification handler.

In most cases, the pattern will be US, 00, US, 00, US, 00, US, ...
There is no need to send domain info to firmware in case of "00" or
with the same alpha2 country code.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/sta_ioctl.c

index 3ff28c2149ceb6c5b88502c830c6670e9fdd1b2f..ae12aaa793a1c6d30d806de9ee6430b901c47276 100644 (file)
@@ -542,19 +542,26 @@ static void mwifiex_reg_notifier(struct wiphy *wiphy,
        wiphy_dbg(wiphy, "info: cfg80211 regulatory domain callback for %c%c\n",
                  request->alpha2[0], request->alpha2[1]);
 
-       memcpy(adapter->country_code, request->alpha2, sizeof(request->alpha2));
-
        switch (request->initiator) {
        case NL80211_REGDOM_SET_BY_DRIVER:
        case NL80211_REGDOM_SET_BY_CORE:
        case NL80211_REGDOM_SET_BY_USER:
-               break;
-               /* Todo: apply driver specific changes in channel flags based
-                  on the request initiator if necessary. */
        case NL80211_REGDOM_SET_BY_COUNTRY_IE:
                break;
+       default:
+               wiphy_err(wiphy, "unknown regdom initiator: %d\n",
+                         request->initiator);
+               return;
+       }
+
+       /* Don't send world or same regdom info to firmware */
+       if (strncmp(request->alpha2, "00", 2) &&
+           strncmp(request->alpha2, adapter->country_code,
+                   sizeof(request->alpha2))) {
+               memcpy(adapter->country_code, request->alpha2,
+                      sizeof(request->alpha2));
+               mwifiex_send_domain_info_cmd_fw(wiphy);
        }
-       mwifiex_send_domain_info_cmd_fw(wiphy);
 }
 
 /*
index a09398fe9e2a67218f50530af8a0b4616443cbbb..85f419825ecf8c929aa6f57ba25b2e7e1387e9b7 100644 (file)
@@ -205,6 +205,14 @@ static int mwifiex_process_country_ie(struct mwifiex_private *priv,
                return 0;
        }
 
+       if (!strncmp(priv->adapter->country_code, &country_ie[2], 2)) {
+               rcu_read_unlock();
+               wiphy_dbg(priv->wdev->wiphy,
+                         "11D: skip setting domain info in FW\n");
+               return 0;
+       }
+       memcpy(priv->adapter->country_code, &country_ie[2], 2);
+
        domain_info->country_code[0] = country_ie[2];
        domain_info->country_code[1] = country_ie[3];
        domain_info->country_code[2] = ' ';