net: wireless: bcmdhd: Add setband/getband private commands
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 8 Jul 2011 22:33:58 +0000 (15:33 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Mon, 11 Jul 2011 18:27:42 +0000 (11:27 -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 924627271cbe1a566b5dac7d68819d6aeb6f7d5e..14bd8284710cb4a2781e41c3947252666e349e08 100644 (file)
@@ -66,6 +66,8 @@
 #define CMD_BTCOEXMODE         "BTCOEXMODE"
 #define CMD_SETSUSPENDOPT      "SETSUSPENDOPT"
 #define CMD_SETFWPATH          "SETFWPATH"
+#define CMD_SETBAND            "SETBAND"
+#define CMD_GETBAND            "GETBAND"
 
 typedef struct android_wifi_priv_cmd {
        char *buf;
@@ -161,6 +163,19 @@ static int wl_android_set_suspendopt(struct net_device *dev, char *command, int
        return ret;
 }
 
+static int wl_android_get_band(struct net_device *dev, char *command, int total_len)
+{
+       uint band;
+       int bytes_written;
+       int error;
+
+       error = wldev_get_band(dev, &band);
+       if (error)
+               return -1;
+       bytes_written = snprintf(command, total_len, "Band %d", band);
+       return bytes_written;
+}
+
 /**
  * Global function definitions (declared in wl_android.h)
  */
@@ -313,6 +328,13 @@ int wl_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
        }
        else if (strnicmp(command, CMD_SETSUSPENDOPT, strlen(CMD_SETSUSPENDOPT)) == 0) {
                bytes_written = wl_android_set_suspendopt(net, command, priv_cmd->total_len);
+       }
+       else if (strnicmp(command, CMD_SETBAND, strlen(CMD_SETBAND)) == 0) {
+               uint band = *(command + strlen(CMD_SETBAND) + 1) - '0';
+               bytes_written = wldev_set_band(net, band);
+       }
+       else if (strnicmp(command, CMD_GETBAND, strlen(CMD_GETBAND)) == 0) {
+               bytes_written = wl_android_get_band(net, command, priv_cmd->total_len);
        } else {
                DHD_ERROR(("Unknown PRIVATE command %s - ignored\n", command));
                snprintf(command, 3, "OK");
index a39bdaacb8cf55e85dfd9824001250bdaea64a7c..3c9f6582d6fdcb9af3949193a2a31c70206600fd 100644 (file)
@@ -288,3 +288,23 @@ int wldev_get_ssid(
        pssid->SSID_len = dtoh32(pssid->SSID_len);
        return error;
 }
+
+int wldev_get_band(
+       struct net_device *dev, uint *pband)
+{
+       int error;
+
+       error = wldev_ioctl(dev, WLC_GET_BAND, pband, sizeof(uint), 0);
+       return error;
+}
+
+int wldev_set_band(
+       struct net_device *dev, uint band)
+{
+       int error = -1;
+
+       if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
+               error = wldev_ioctl(dev, WLC_SET_BAND, &band, sizeof(band), 1);
+       }
+       return error;
+}
index 344875b72d8e6cf5ba7b477fad4af8b64d1c6b93..70249f489d316af31f43d9d20e5baecfab317311 100644 (file)
@@ -90,4 +90,8 @@ int wldev_get_rssi(struct net_device *dev, int *prssi);
 
 int wldev_get_ssid(struct net_device *dev, wlc_ssid_t *pssid);
 
+int wldev_get_band(struct net_device *dev, uint *pband);
+
+int wldev_set_band(struct net_device *dev, uint band);
+
 #endif /* __WLDEV_COMMON_H__ */