Commit ac118d87 authored by Adham Abozaeid's avatar Adham Abozaeid Committed by Greg Kroah-Hartman

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

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: default avatarAdham Abozaeid <adham.abozaeid@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ffb99752
...@@ -229,10 +229,10 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) ...@@ -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, 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, void (*scan_result_fn)(enum scan_event,
struct wilc_rcvd_net_info *, void *), 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; int result = 0;
struct wid wid_list[5]; struct wid wid_list[5];
...@@ -258,9 +258,9 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, ...@@ -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; hif_drv->usr_scan_req.ch_cnt = 0;
if (search) { if (request->n_ssids) {
for (i = 0; i < search->n_ssids; i++) for (i = 0; i < request->n_ssids; i++)
valuesize += ((search->ssid_info[i].ssid_len) + 1); valuesize += ((request->ssids[i].ssid_len) + 1);
search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL); search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL);
if (search_ssid_vals) { if (search_ssid_vals) {
wid_list[index].id = WID_SSID_PROBE_REQ; 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, ...@@ -268,13 +268,13 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
wid_list[index].val = search_ssid_vals; wid_list[index].val = search_ssid_vals;
buffer = wid_list[index].val; buffer = wid_list[index].val;
*buffer++ = search->n_ssids; *buffer++ = request->n_ssids;
for (i = 0; i < search->n_ssids; i++) { for (i = 0; i < request->n_ssids; i++) {
*buffer++ = search->ssid_info[i].ssid_len; *buffer++ = request->ssids[i].ssid_len;
memcpy(buffer, search->ssid_info[i].ssid, memcpy(buffer, request->ssids[i].ssid,
search->ssid_info[i].ssid_len); request->ssids[i].ssid_len);
buffer += search->ssid_info[i].ssid_len; buffer += request->ssids[i].ssid_len;
} }
wid_list[index].size = (s32)(valuesize + 1); wid_list[index].size = (s32)(valuesize + 1);
index++; index++;
...@@ -283,8 +283,8 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, ...@@ -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].id = WID_INFO_ELEMENT_PROBE;
wid_list[index].type = WID_BIN_DATA; wid_list[index].type = WID_BIN_DATA;
wid_list[index].val = (s8 *)ies; wid_list[index].val = (s8 *)request->ie;
wid_list[index].size = ies_len; wid_list[index].size = request->ie_len;
index++; index++;
wid_list[index].id = WID_SCAN_TYPE; wid_list[index].id = WID_SCAN_TYPE;
...@@ -328,10 +328,8 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 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)); jiffies + msecs_to_jiffies(WILC_HIF_SCAN_TIMEOUT_MS));
error: error:
if (search) {
kfree(search->ssid_info);
kfree(search_ssid_vals); kfree(search_ssid_vals);
}
return result; return result;
} }
......
...@@ -115,16 +115,6 @@ struct wilc_rcvd_net_info { ...@@ -115,16 +115,6 @@ struct wilc_rcvd_net_info {
struct ieee80211_mgmt *mgmt; 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 { struct wilc_user_scan_req {
void (*scan_result)(enum scan_event evt, void (*scan_result)(enum scan_event evt,
...@@ -205,10 +195,10 @@ int wilc_disconnect(struct wilc_vif *vif); ...@@ -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_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, 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, void (*scan_result_fn)(enum scan_event,
struct wilc_rcvd_net_info *, void *), 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, int wilc_hif_set_cfg(struct wilc_vif *vif,
struct cfg_param_attr *cfg_param); struct cfg_param_attr *cfg_param);
int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
......
...@@ -214,50 +214,6 @@ static int set_channel(struct wiphy *wiphy, ...@@ -214,50 +214,6 @@ static int set_channel(struct wiphy *wiphy,
return result; 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) static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
{ {
struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_priv *priv = wiphy_priv(wiphy);
...@@ -265,7 +221,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) ...@@ -265,7 +221,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
u32 i; u32 i;
int ret = 0; int ret = 0;
u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH];
struct wilc_probe_ssid probe_ssid;
if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) {
netdev_err(priv->dev, "Requested scanned channels over\n"); netdev_err(priv->dev, "Requested scanned channels over\n");
...@@ -280,28 +235,10 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) ...@@ -280,28 +235,10 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
scan_ch_list[i] = ieee80211_frequency_to_channel(freq); scan_ch_list[i] = ieee80211_frequency_to_channel(freq);
} }
if (request->n_ssids >= 1) { ret = wilc_scan(vif, WILC_FW_USER_SCAN, WILC_FW_ACTIVE_SCAN,
if (wilc_wfi_cfg_alloc_fill_ssid(request, &probe_ssid)) { scan_ch_list, request->n_channels, cfg_scan_result,
ret = -ENOMEM; (void *)priv, request);
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);
}
out:
if (ret) { if (ret) {
priv->scan_req = NULL; priv->scan_req = NULL;
priv->cfg_scanning = false; priv->cfg_scanning = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment