mwifiex: set default regulatory domain
authorAmitkumar Karwar <akarwar@marvell.com>
Tue, 10 Apr 2012 03:06:54 +0000 (20:06 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 12 Apr 2012 19:10:28 +0000 (15:10 -0400)
Driver gets region code from FW during initialisation. This patch
makes use of it for settting default regulatory domain using
regulatory_hint() API.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kiran Divekar <dkiran@marvell.com>
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/cfp.c
drivers/net/wireless/mwifiex/main.h

index c7e8918..bd07030 100644 (file)
@@ -1422,6 +1422,7 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv)
        void *wdev_priv;
        struct wireless_dev *wdev;
        struct ieee80211_sta_ht_cap *ht_info;
+       u8 *country_code;
 
        wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
        if (!wdev) {
@@ -1484,6 +1485,11 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv)
                        "info: successfully registered wiphy device\n");
        }
 
+       country_code = mwifiex_11d_code_2_region(priv->adapter->region_code);
+       if (country_code && regulatory_hint(wdev->wiphy, country_code))
+               dev_err(priv->adapter->dev,
+                       "%s: regulatory_hint failed\n", __func__);
+
        priv->wdev = wdev;
 
        return ret;
index 2fe1c33..560871b 100644 (file)
@@ -71,6 +71,37 @@ u16 region_code_index[MWIFIEX_MAX_REGION_CODE] = { 0x10, 0x20, 0x30,
 
 static u8 supported_rates_n[N_SUPPORTED_RATES] = { 0x02, 0x04, 0 };
 
+struct region_code_mapping {
+       u8 code;
+       u8 region[IEEE80211_COUNTRY_STRING_LEN];
+};
+
+static struct region_code_mapping region_code_mapping_t[] = {
+       { 0x10, "US " }, /* US FCC */
+       { 0x20, "CA " }, /* IC Canada */
+       { 0x30, "EU " }, /* ETSI */
+       { 0x31, "ES " }, /* Spain */
+       { 0x32, "FR " }, /* France */
+       { 0x40, "JP " }, /* Japan */
+       { 0x41, "JP " }, /* Japan */
+       { 0x50, "CN " }, /* China */
+};
+
+/* This function converts integer code to region string */
+u8 *mwifiex_11d_code_2_region(u8 code)
+{
+       u8 i;
+       u8 size = sizeof(region_code_mapping_t)/
+                               sizeof(struct region_code_mapping);
+
+       /* Look for code in mapping table */
+       for (i = 0; i < size; i++)
+               if (region_code_mapping_t[i].code == code)
+                       return region_code_mapping_t[i].region;
+
+       return NULL;
+}
+
 /*
  * This function maps an index in supported rates table into
  * the corresponding data rate.
index fcccf6b..e601c46 100644 (file)
@@ -965,6 +965,7 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
                                        u32 *flags, struct vif_params *params);
 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev);
 
+u8 *mwifiex_11d_code_2_region(u8 code);
 
 #ifdef CONFIG_DEBUG_FS
 void mwifiex_debugfs_init(void);