diff mbox series

staging: wilc1000: use cfg80211 ssid list instead of repacking it

Message ID 20190325222636.29708-1-adham.abozaeid@microchip.com (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show
Series staging: wilc1000: use cfg80211 ssid list instead of repacking it | expand

Commit Message

Adham Abozaeid March 25, 2019, 10:27 p.m. UTC
From: Adham Abozaeid <adham.abozaeid@microchip.com>

Avoid repacking ssid values into struct wilc_probe_ssid, and use the
cfg80211 provided struct to pass the ssid list to wilc_scan.
With this change, struct wilc_probe_ssid, struct wilc_probe_ssid_info
and function wilc_wfi_cfg_alloc_fill_ssid will not be needed anymore.

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c     | 32 ++++-----
 drivers/staging/wilc1000/host_interface.h     | 14 +---
 .../staging/wilc1000/wilc_wfi_cfgoperations.c | 69 +------------------
 3 files changed, 20 insertions(+), 95 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 44556b22613e..91ea16a6ae2e 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -229,10 +229,10 @@  static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt)
 }
 
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
-	      u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len,
+	      u8 *ch_freq_list, u8 ch_list_len,
 	      void (*scan_result_fn)(enum scan_event,
 				     struct wilc_rcvd_net_info *, void *),
-	      void *user_arg, struct wilc_probe_ssid *search)
+	      void *user_arg, struct cfg80211_scan_request *request)
 {
 	int result = 0;
 	struct wid wid_list[5];
@@ -258,9 +258,9 @@  int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
 
 	hif_drv->usr_scan_req.ch_cnt = 0;
 
-	if (search) {
-		for (i = 0; i < search->n_ssids; i++)
-			valuesize += ((search->ssid_info[i].ssid_len) + 1);
+	if (request->n_ssids) {
+		for (i = 0; i < request->n_ssids; i++)
+			valuesize += ((request->ssids[i].ssid_len) + 1);
 		search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL);
 		if (search_ssid_vals) {
 			wid_list[index].id = WID_SSID_PROBE_REQ;
@@ -268,13 +268,13 @@  int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
 			wid_list[index].val = search_ssid_vals;
 			buffer = wid_list[index].val;
 
-			*buffer++ = search->n_ssids;
+			*buffer++ = request->n_ssids;
 
-			for (i = 0; i < search->n_ssids; i++) {
-				*buffer++ = search->ssid_info[i].ssid_len;
-				memcpy(buffer, search->ssid_info[i].ssid,
-				       search->ssid_info[i].ssid_len);
-				buffer += search->ssid_info[i].ssid_len;
+			for (i = 0; i < request->n_ssids; i++) {
+				*buffer++ = request->ssids[i].ssid_len;
+				memcpy(buffer, request->ssids[i].ssid,
+				       request->ssids[i].ssid_len);
+				buffer += request->ssids[i].ssid_len;
 			}
 			wid_list[index].size = (s32)(valuesize + 1);
 			index++;
@@ -283,8 +283,8 @@  int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
 
 	wid_list[index].id = WID_INFO_ELEMENT_PROBE;
 	wid_list[index].type = WID_BIN_DATA;
-	wid_list[index].val = (s8 *)ies;
-	wid_list[index].size = ies_len;
+	wid_list[index].val = (s8 *)request->ie;
+	wid_list[index].size = request->ie_len;
 	index++;
 
 	wid_list[index].id = WID_SCAN_TYPE;
@@ -328,10 +328,8 @@  int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
 		  jiffies + msecs_to_jiffies(WILC_HIF_SCAN_TIMEOUT_MS));
 
 error:
-	if (search) {
-		kfree(search->ssid_info);
-		kfree(search_ssid_vals);
-	}
+
+	kfree(search_ssid_vals);
 
 	return result;
 }
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 678e62312215..a907c6d33012 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -115,16 +115,6 @@  struct wilc_rcvd_net_info {
 	struct ieee80211_mgmt *mgmt;
 };
 
-struct wilc_probe_ssid_info {
-	u8 ssid_len;
-	u8 *ssid;
-};
-
-struct wilc_probe_ssid {
-	struct wilc_probe_ssid_info *ssid_info;
-	u8 n_ssids;
-	u32 size;
-};
 
 struct wilc_user_scan_req {
 	void (*scan_result)(enum scan_event evt,
@@ -205,10 +195,10 @@  int wilc_disconnect(struct wilc_vif *vif);
 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
-	      u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len,
+	      u8 *ch_freq_list, u8 ch_list_len,
 	      void (*scan_result_fn)(enum scan_event,
 				     struct wilc_rcvd_net_info *, void *),
-	      void *user_arg, struct wilc_probe_ssid *search);
+	      void *user_arg, struct cfg80211_scan_request *request);
 int wilc_hif_set_cfg(struct wilc_vif *vif,
 		     struct cfg_param_attr *cfg_param);
 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 75ec752b5059..f6825727bf77 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -214,50 +214,6 @@  static int set_channel(struct wiphy *wiphy,
 	return result;
 }
 
-static inline int
-wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request,
-			     struct wilc_probe_ssid *search)
-{
-	int i;
-	int slot_id = 0;
-
-	search->ssid_info = kcalloc(request->n_ssids,
-				    sizeof(*search->ssid_info), GFP_KERNEL);
-	if (!search->ssid_info)
-		goto out;
-
-	search->n_ssids = request->n_ssids;
-
-	for (i = 0; i < request->n_ssids; i++) {
-		if (request->ssids[i].ssid_len > 0) {
-			struct wilc_probe_ssid_info *info;
-
-			info = &search->ssid_info[slot_id];
-			info->ssid = kmemdup(request->ssids[i].ssid,
-					     request->ssids[i].ssid_len,
-					     GFP_KERNEL);
-			if (!info->ssid)
-				goto out_free;
-
-			info->ssid_len = request->ssids[i].ssid_len;
-			slot_id++;
-		} else {
-			search->n_ssids -= 1;
-		}
-	}
-	return 0;
-
-out_free:
-
-	for (i = 0; i < slot_id; i++)
-		kfree(search->ssid_info[i].ssid);
-
-	kfree(search->ssid_info);
-out:
-
-	return -ENOMEM;
-}
-
 static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 {
 	struct wilc_priv *priv = wiphy_priv(wiphy);
@@ -265,7 +221,6 @@  static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 	u32 i;
 	int ret = 0;
 	u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH];
-	struct wilc_probe_ssid probe_ssid;
 
 	if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) {
 		netdev_err(priv->dev, "Requested scanned channels over\n");
@@ -280,28 +235,10 @@  static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 		scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
 	}
 
-	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 {
-		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);
-	}
+	ret = wilc_scan(vif, WILC_FW_USER_SCAN, WILC_FW_ACTIVE_SCAN,
+			scan_ch_list, request->n_channels, cfg_scan_result,
+			(void *)priv, request);
 
-out:
 	if (ret) {
 		priv->scan_req = NULL;
 		priv->cfg_scanning = false;