staging: rtl8188eu: use table to get channel plan from country code
authorHari Prasath Gujulan Elango <hgujulan@visteon.com>
Mon, 1 Jun 2015 12:43:01 +0000 (12:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Jun 2015 20:38:56 +0000 (13:38 -0700)
Use a table to get a channel plan from a given country code.This was a
TODO mentioned as a comment in the driver.

Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@visteon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
drivers/staging/rtl8188eu/include/rtw_mlme_ext.h

index 969150a48661344387dbf16e840f9c7adfceaf03..8c05cb021c46a467c644af2efb4b289744a7f314 100644 (file)
@@ -642,21 +642,18 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter)
 */
 int rtw_set_country(struct adapter *adapter, const char *country_code)
 {
+       int i;
        int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G;
 
        DBG_88E("%s country_code:%s\n", __func__, country_code);
+       for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
+               if (0 == strcmp(channel_table[i].name, country_code)) {
+                       channel_plan = channel_table[i].channel_plan;
+                       break;
+               }
+       }
 
-       /* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */
-       /* TODO: should consider 2-character and 3-character country code */
-       if (0 == strcmp(country_code, "US"))
-               channel_plan = RT_CHANNEL_DOMAIN_FCC;
-       else if (0 == strcmp(country_code, "EU"))
-               channel_plan = RT_CHANNEL_DOMAIN_ETSI;
-       else if (0 == strcmp(country_code, "JP"))
-               channel_plan = RT_CHANNEL_DOMAIN_MKK;
-       else if (0 == strcmp(country_code, "CN"))
-               channel_plan = RT_CHANNEL_DOMAIN_CHINA;
-       else
+       if (i == ARRAY_SIZE(channel_table))
                DBG_88E("%s unknown country_code:%s\n", __func__, country_code);
 
        return rtw_set_chplan_cmd(adapter, channel_plan, 1);
index 2bebf46b053af68a34ed97952786cfe8512d6336..2bd11acb4c034fcc9db58a9d4feea7396564aa65 100644 (file)
@@ -191,6 +191,14 @@ struct rt_channel_plan_map {
        unsigned char   Index2G;
 };
 
+static const struct {
+       int channel_plan;
+       char *name;
+} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" },
+       { RT_CHANNEL_DOMAIN_ETSI, "EU" },
+       { RT_CHANNEL_DOMAIN_MKK, "JP" },
+       { RT_CHANNEL_DOMAIN_CHINA, "CN"} };
+
 enum Associated_AP {
        atherosAP       = 0,
        broadcomAP      = 1,