net: wireless: bcmdhd: Add setband/getband private commands
authorDmitry Shmidt <dimitrysh@google.com>
Fri, 8 Jul 2011 22:33:58 +0000 (15:33 -0700)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:09:55 +0000 (12:09 -0800)
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 9246272..14bd828 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 a39bdaa..3c9f658 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 344875b..70249f4 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__ */