提交 9558a407 编写于 作者: A Amitkumar Karwar 提交者: John W. Linville

mwifiex: code cleanup in BSS handling

Rearrange some code to save extra parameters to the functions.
Signed-off-by: NAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: NBing Zhao <bzhao@marvell.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 ce84bb69
...@@ -953,13 +953,10 @@ int mwifiex_bss_set_channel(struct mwifiex_private *, ...@@ -953,13 +953,10 @@ int mwifiex_bss_set_channel(struct mwifiex_private *,
int mwifiex_get_bss_info(struct mwifiex_private *, int mwifiex_get_bss_info(struct mwifiex_private *,
struct mwifiex_bss_info *); struct mwifiex_bss_info *);
int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
u8 *bssid, s32 rssi, u8 *ie_buf, struct cfg80211_bss *bss,
size_t ie_len, u16 beacon_period,
u16 cap_info_bitmap, u8 band,
struct mwifiex_bssdescriptor *bss_desc); struct mwifiex_bssdescriptor *bss_desc);
int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
struct mwifiex_bssdescriptor *bss_entry, struct mwifiex_bssdescriptor *bss_entry);
u8 *ie_buf, u32 ie_len);
int mwifiex_check_network_compatibility(struct mwifiex_private *priv, int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
struct mwifiex_bssdescriptor *bss_desc); struct mwifiex_bssdescriptor *bss_desc);
......
...@@ -1048,10 +1048,8 @@ mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter, ...@@ -1048,10 +1048,8 @@ mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter,
* This function parses provided beacon buffer and updates * This function parses provided beacon buffer and updates
* respective fields in bss descriptor structure. * respective fields in bss descriptor structure.
*/ */
int int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, struct mwifiex_bssdescriptor *bss_entry)
struct mwifiex_bssdescriptor *bss_entry,
u8 *ie_buf, u32 ie_len)
{ {
int ret = 0; int ret = 0;
u8 element_id; u8 element_id;
...@@ -1073,10 +1071,8 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, ...@@ -1073,10 +1071,8 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
found_data_rate_ie = false; found_data_rate_ie = false;
rate_size = 0; rate_size = 0;
current_ptr = ie_buf; current_ptr = bss_entry->beacon_buf;
bytes_left = ie_len; bytes_left = bss_entry->beacon_buf_size;
bss_entry->beacon_buf = ie_buf;
bss_entry->beacon_buf_size = ie_len;
/* Process variable IE */ /* Process variable IE */
while (bytes_left >= 2) { while (bytes_left >= 2) {
...@@ -1447,15 +1443,12 @@ int mwifiex_check_network_compatibility(struct mwifiex_private *priv, ...@@ -1447,15 +1443,12 @@ int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
return ret; return ret;
} }
static int static int mwifiex_update_curr_bss_params(struct mwifiex_private *priv,
mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, struct cfg80211_bss *bss)
s32 rssi, const u8 *ie_buf, size_t ie_len,
u16 beacon_period, u16 cap_info_bitmap, u8 band)
{ {
struct mwifiex_bssdescriptor *bss_desc; struct mwifiex_bssdescriptor *bss_desc;
int ret; int ret;
unsigned long flags; unsigned long flags;
u8 *beacon_ie;
/* Allocate and fill new bss descriptor */ /* Allocate and fill new bss descriptor */
bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
...@@ -1465,16 +1458,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, ...@@ -1465,16 +1458,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
return -ENOMEM; return -ENOMEM;
} }
beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL); ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
if (!beacon_ie) {
kfree(bss_desc);
dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
return -ENOMEM;
}
ret = mwifiex_fill_new_bss_desc(priv, bssid, rssi, beacon_ie,
ie_len, beacon_period,
cap_info_bitmap, band, bss_desc);
if (ret) if (ret)
goto done; goto done;
...@@ -1514,7 +1498,6 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, ...@@ -1514,7 +1498,6 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
done: done:
kfree(bss_desc); kfree(bss_desc);
kfree(beacon_ie);
return 0; return 0;
} }
...@@ -1744,17 +1727,13 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1744,17 +1727,13 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
cap_info_bitmap, beacon_period, cap_info_bitmap, beacon_period,
ie_buf, ie_len, rssi, GFP_KERNEL); ie_buf, ie_len, rssi, GFP_KERNEL);
*(u8 *)bss->priv = band; *(u8 *)bss->priv = band;
cfg80211_put_bss(bss);
if (priv->media_connected && if (priv->media_connected &&
!memcmp(bssid, !memcmp(bssid,
priv->curr_bss_params.bss_descriptor priv->curr_bss_params.bss_descriptor
.mac_address, ETH_ALEN)) .mac_address, ETH_ALEN))
mwifiex_update_curr_bss_params mwifiex_update_curr_bss_params(priv,
(priv, bssid, rssi, bss);
ie_buf, ie_len, cfg80211_put_bss(bss);
beacon_period,
cap_info_bitmap, band);
} }
} else { } else {
dev_dbg(adapter->dev, "missing BSS channel IE\n"); dev_dbg(adapter->dev, "missing BSS channel IE\n");
......
...@@ -155,20 +155,26 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv, ...@@ -155,20 +155,26 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
* information. * information.
*/ */
int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
u8 *bssid, s32 rssi, u8 *ie_buf, struct cfg80211_bss *bss,
size_t ie_len, u16 beacon_period,
u16 cap_info_bitmap, u8 band,
struct mwifiex_bssdescriptor *bss_desc) struct mwifiex_bssdescriptor *bss_desc)
{ {
int ret; int ret;
u8 *beacon_ie;
memcpy(bss_desc->mac_address, bssid, ETH_ALEN); beacon_ie = kmemdup(bss->information_elements, bss->len_beacon_ies,
bss_desc->rssi = rssi; GFP_KERNEL);
bss_desc->beacon_buf = ie_buf; if (!beacon_ie) {
bss_desc->beacon_buf_size = ie_len; dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
bss_desc->beacon_period = beacon_period; return -ENOMEM;
bss_desc->cap_info_bitmap = cap_info_bitmap; }
bss_desc->bss_band = band;
memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN);
bss_desc->rssi = bss->signal;
bss_desc->beacon_buf = beacon_ie;
bss_desc->beacon_buf_size = bss->len_beacon_ies;
bss_desc->beacon_period = bss->beacon_interval;
bss_desc->cap_info_bitmap = bss->capability;
bss_desc->bss_band = *(u8 *)bss->priv;
if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) { if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n"); dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n");
bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP; bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
...@@ -180,9 +186,9 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, ...@@ -180,9 +186,9 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
else else
bss_desc->bss_mode = NL80211_IFTYPE_STATION; bss_desc->bss_mode = NL80211_IFTYPE_STATION;
ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc, ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc);
ie_buf, ie_len);
kfree(beacon_ie);
return ret; return ret;
} }
...@@ -197,7 +203,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -197,7 +203,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
int ret; int ret;
struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_adapter *adapter = priv->adapter;
struct mwifiex_bssdescriptor *bss_desc = NULL; struct mwifiex_bssdescriptor *bss_desc = NULL;
u8 *beacon_ie = NULL;
priv->scan_block = false; priv->scan_block = false;
...@@ -210,19 +215,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -210,19 +215,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
return -ENOMEM; return -ENOMEM;
} }
beacon_ie = kmemdup(bss->information_elements, ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
bss->len_beacon_ies, GFP_KERNEL);
if (!beacon_ie) {
kfree(bss_desc);
dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
return -ENOMEM;
}
ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal,
beacon_ie, bss->len_beacon_ies,
bss->beacon_interval,
bss->capability,
*(u8 *)bss->priv, bss_desc);
if (ret) if (ret)
goto done; goto done;
} }
...@@ -269,7 +262,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -269,7 +262,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
(!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
ssid, &bss_desc->ssid))) { ssid, &bss_desc->ssid))) {
kfree(bss_desc); kfree(bss_desc);
kfree(beacon_ie);
return 0; return 0;
} }
...@@ -304,7 +296,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -304,7 +296,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
done: done:
kfree(bss_desc); kfree(bss_desc);
kfree(beacon_ie);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册