From: Ajay Singh <ajay.kat...@microchip.com>

Refactor scan() cfg80211 callback function and use correct value for
valid channel number limit.

Signed-off-by: Ajay Singh <ajay.kat...@microchip.com>
---
 drivers/staging/wilc1000/host_interface.h         |  2 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 55 +++++++++++------------
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.h 
b/drivers/staging/wilc1000/host_interface.h
index 8fa97a7..0feb63f 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -18,7 +18,7 @@ enum {
 };
 
 #define WILC_MAX_NUM_STA                       9
-#define MAX_NUM_SCANNED_NETWORKS               100
+#define WILC_MAX_NUM_SCANNED_CH                        14
 #define WILC_MAX_NUM_PROBED_SSID               10
 
 #define TX_MIC_KEY_LEN                         8
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index faffcc8..08b60ddd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -266,42 +266,41 @@ static int scan(struct wiphy *wiphy, struct 
cfg80211_scan_request *request)
        struct wilc_vif *vif = netdev_priv(priv->dev);
        u32 i;
        int ret = 0;
-       u8 scan_ch_list[MAX_NUM_SCANNED_NETWORKS];
+       u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH];
        struct wilc_probe_ssid probe_ssid;
 
-       priv->scan_req = request;
+       if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) {
+               netdev_err(priv->dev, "Requested scanned channels over\n");
+               return -EINVAL;
+       }
 
+       priv->scan_req = request;
        priv->cfg_scanning = true;
-       if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) {
-               for (i = 0; i < request->n_channels; i++) {
-                       u16 freq = request->channels[i]->center_freq;
-
-                       scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
-               }
+       for (i = 0; i < request->n_channels; i++) {
+               u16 freq = request->channels[i]->center_freq;
 
-               if (request->n_ssids >= 1) {
-                       if (wilc_wfi_cfg_alloc_fill_ssid(request,
-                                                        &probe_ssid)) {
-                               ret = -ENOMEM;
-                               goto out;
-                       }
+               scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
+       }
 
-                       ret = wilc_scan(vif, WILC_FW_USER_SCAN,
-                                       WILC_FW_ACTIVE_SCAN, scan_ch_list,
-                                       request->n_channels,
-                                       (const u8 *)request->ie,
-                                       request->ie_len, cfg_scan_result,
-                                       (void *)priv, &probe_ssid);
-               } else {
-                       ret = wilc_scan(vif, WILC_FW_USER_SCAN,
-                                       WILC_FW_ACTIVE_SCAN, scan_ch_list,
-                                       request->n_channels,
-                                       (const u8 *)request->ie,
-                                       request->ie_len, cfg_scan_result,
-                                       (void *)priv, NULL);
+       if (request->n_ssids >= 1) {
+               if (wilc_wfi_cfg_alloc_fill_ssid(request, &probe_ssid)) {
+                       ret = -ENOMEM;
+                       goto out;
                }
+
+               ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+                               WILC_FW_ACTIVE_SCAN, scan_ch_list,
+                               request->n_channels,
+                               (const u8 *)request->ie,
+                               request->ie_len, cfg_scan_result,
+                               (void *)priv, &probe_ssid);
        } else {
-               netdev_err(priv->dev, "Requested scanned channels over\n");
+               ret = wilc_scan(vif, WILC_FW_USER_SCAN,
+                               WILC_FW_ACTIVE_SCAN, scan_ch_list,
+                               request->n_channels,
+                               (const u8 *)request->ie,
+                               request->ie_len, cfg_scan_result,
+                               (void *)priv, NULL);
        }
 
 out:
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to