net: wireless: bcmdhd: Add country private command
authorDmitry Shmidt <dimitrysh@google.com>
Tue, 12 Jul 2011 18:19:48 +0000 (11:19 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Wed, 13 Jul 2011 23:00:01 +0000 (16:00 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcmdhd/wl_android.c
drivers/net/wireless/bcmdhd/wldev_common.c
drivers/net/wireless/bcmdhd/wldev_common.h

index 14bd8284710cb4a2781e41c3947252666e349e08..6826a4c0d74819045e9f23a6b0325ec2a5369e00 100644 (file)
@@ -68,6 +68,7 @@
 #define CMD_SETFWPATH          "SETFWPATH"
 #define CMD_SETBAND            "SETBAND"
 #define CMD_GETBAND            "GETBAND"
+#define CMD_COUNTRY            "COUNTRY"
 
 typedef struct android_wifi_priv_cmd {
        char *buf;
@@ -335,6 +336,10 @@ int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
        }
        else if (strnicmp(command, CMD_GETBAND, strlen(CMD_GETBAND)) == 0) {
                bytes_written = wl_android_get_band(net, command, priv_cmd->total_len);
+       }
+       else if (strnicmp(command, CMD_COUNTRY, strlen(CMD_COUNTRY)) == 0) {
+               char *country_code = command + strlen(CMD_COUNTRY) + 1;
+               bytes_written = wldev_set_country(net, country_code);
        } else {
                DHD_ERROR(("Unknown PRIVATE command %s - ignored\n", command));
                snprintf(command, 3, "OK");
index 3c9f6582d6fdcb9af3949193a2a31c70206600fd..31e8f3cb86fda1413bda8a17d8d8984282c5c52e 100644 (file)
@@ -308,3 +308,37 @@ int wldev_set_band(
        }
        return error;
 }
+
+int wldev_set_country(
+       struct net_device *dev, char *country_code)
+{
+       int error = -1;
+       wl_country_t cspec = {{0}, 0, {0}};
+       scb_val_t scbval;
+       char smbuf[WLC_IOCTL_SMLEN];
+
+       if (!country_code)
+               return error;
+
+       bzero(&scbval, sizeof(scb_val_t));
+       error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), 1);
+       if (error < 0) {
+               DHD_ERROR(("%s: set country failed due to Disassoc error\n", __FUNCTION__));
+               return error;
+       }
+       cspec.rev = -1;
+       memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ);
+       memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ);
+       get_customized_country_code((char *)&cspec.country_abbrev, &cspec);
+       error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec),
+                                       smbuf, sizeof(smbuf));
+       if (error < 0) {
+               DHD_ERROR(("%s: set country for %s as %s rev %d failed\n",
+                       __FUNCTION__, country_code, cspec.ccode, cspec.rev));
+               return error;
+       }
+       dhd_bus_country_set(dev, &cspec);
+       DHD_INFO(("%s: set country for %s as %s rev %d\n",
+               __FUNCTION__, country_code, cspec.ccode, cspec.rev));
+       return 0;
+}
index 70249f489d316af31f43d9d20e5baecfab317311..28346cf30284bff2570741cd8009aa9fd29ded9c 100644 (file)
@@ -83,6 +83,10 @@ s32 wldev_iovar_getint_bsscfg(
 s32 wldev_iovar_setint_bsscfg(
        struct net_device *dev, s8 *iovar, s32 val, s32 bssidx);
 
+void get_customized_country_code(char *country_iso_code, wl_country_t *cspec);
+void dhd_bus_country_set(struct net_device *dev, wl_country_t *cspec);
+int wldev_set_country(struct net_device *dev, char *country_code);
+
 /* Get the link speed from dongle, speed is in kpbs */
 int wldev_get_link_speed(struct net_device *dev, int *plink_speed);