diff options
author | Amitkumar Karwar <akarwar@marvell.com> | 2012-04-17 00:36:51 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-17 14:57:14 -0400 |
commit | 9558a407dd00f6cd7f93b923768e8ee255fa4444 (patch) | |
tree | 68037de0b1ef7591bfb561206eecfe4a691c4cf4 /drivers/net/wireless | |
parent | ce84bb69f50e6f6cfeabc9b965365290f4184417 (diff) |
mwifiex: code cleanup in BSS handling
Rearrange some code to save extra parameters to the functions.
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mwifiex/main.h | 7 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/scan.c | 41 | ||||
-rw-r--r-- | drivers/net/wireless/mwifiex/sta_ioctl.c | 47 |
3 files changed, 31 insertions, 64 deletions
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 46c298e2e240..fa8af582edd9 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h | |||
@@ -953,13 +953,10 @@ int mwifiex_bss_set_channel(struct mwifiex_private *, | |||
953 | int mwifiex_get_bss_info(struct mwifiex_private *, | 953 | int mwifiex_get_bss_info(struct mwifiex_private *, |
954 | struct mwifiex_bss_info *); | 954 | struct mwifiex_bss_info *); |
955 | int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, | 955 | int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, |
956 | u8 *bssid, s32 rssi, u8 *ie_buf, | 956 | struct cfg80211_bss *bss, |
957 | size_t ie_len, u16 beacon_period, | ||
958 | u16 cap_info_bitmap, u8 band, | ||
959 | struct mwifiex_bssdescriptor *bss_desc); | 957 | struct mwifiex_bssdescriptor *bss_desc); |
960 | int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, | 958 | int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, |
961 | struct mwifiex_bssdescriptor *bss_entry, | 959 | struct mwifiex_bssdescriptor *bss_entry); |
962 | u8 *ie_buf, u32 ie_len); | ||
963 | int mwifiex_check_network_compatibility(struct mwifiex_private *priv, | 960 | int mwifiex_check_network_compatibility(struct mwifiex_private *priv, |
964 | struct mwifiex_bssdescriptor *bss_desc); | 961 | struct mwifiex_bssdescriptor *bss_desc); |
965 | 962 | ||
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index ef84a1a6742f..f6bec2f4ae53 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c | |||
@@ -1048,10 +1048,8 @@ mwifiex_ret_802_11_scan_get_tlv_ptrs(struct mwifiex_adapter *adapter, | |||
1048 | * This function parses provided beacon buffer and updates | 1048 | * This function parses provided beacon buffer and updates |
1049 | * respective fields in bss descriptor structure. | 1049 | * respective fields in bss descriptor structure. |
1050 | */ | 1050 | */ |
1051 | int | 1051 | int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, |
1052 | mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, | 1052 | struct mwifiex_bssdescriptor *bss_entry) |
1053 | struct mwifiex_bssdescriptor *bss_entry, | ||
1054 | u8 *ie_buf, u32 ie_len) | ||
1055 | { | 1053 | { |
1056 | int ret = 0; | 1054 | int ret = 0; |
1057 | u8 element_id; | 1055 | u8 element_id; |
@@ -1073,10 +1071,8 @@ mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter, | |||
1073 | 1071 | ||
1074 | found_data_rate_ie = false; | 1072 | found_data_rate_ie = false; |
1075 | rate_size = 0; | 1073 | rate_size = 0; |
1076 | current_ptr = ie_buf; | 1074 | current_ptr = bss_entry->beacon_buf; |
1077 | bytes_left = ie_len; | 1075 | bytes_left = bss_entry->beacon_buf_size; |
1078 | bss_entry->beacon_buf = ie_buf; | ||
1079 | bss_entry->beacon_buf_size = ie_len; | ||
1080 | 1076 | ||
1081 | /* Process variable IE */ | 1077 | /* Process variable IE */ |
1082 | while (bytes_left >= 2) { | 1078 | while (bytes_left >= 2) { |
@@ -1447,15 +1443,12 @@ int mwifiex_check_network_compatibility(struct mwifiex_private *priv, | |||
1447 | return ret; | 1443 | return ret; |
1448 | } | 1444 | } |
1449 | 1445 | ||
1450 | static int | 1446 | static int mwifiex_update_curr_bss_params(struct mwifiex_private *priv, |
1451 | mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, | 1447 | struct cfg80211_bss *bss) |
1452 | s32 rssi, const u8 *ie_buf, size_t ie_len, | ||
1453 | u16 beacon_period, u16 cap_info_bitmap, u8 band) | ||
1454 | { | 1448 | { |
1455 | struct mwifiex_bssdescriptor *bss_desc; | 1449 | struct mwifiex_bssdescriptor *bss_desc; |
1456 | int ret; | 1450 | int ret; |
1457 | unsigned long flags; | 1451 | unsigned long flags; |
1458 | u8 *beacon_ie; | ||
1459 | 1452 | ||
1460 | /* Allocate and fill new bss descriptor */ | 1453 | /* Allocate and fill new bss descriptor */ |
1461 | bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), | 1454 | bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), |
@@ -1465,16 +1458,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, | |||
1465 | return -ENOMEM; | 1458 | return -ENOMEM; |
1466 | } | 1459 | } |
1467 | 1460 | ||
1468 | beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL); | 1461 | ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc); |
1469 | if (!beacon_ie) { | ||
1470 | kfree(bss_desc); | ||
1471 | dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n"); | ||
1472 | return -ENOMEM; | ||
1473 | } | ||
1474 | |||
1475 | ret = mwifiex_fill_new_bss_desc(priv, bssid, rssi, beacon_ie, | ||
1476 | ie_len, beacon_period, | ||
1477 | cap_info_bitmap, band, bss_desc); | ||
1478 | if (ret) | 1462 | if (ret) |
1479 | goto done; | 1463 | goto done; |
1480 | 1464 | ||
@@ -1514,7 +1498,6 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid, | |||
1514 | 1498 | ||
1515 | done: | 1499 | done: |
1516 | kfree(bss_desc); | 1500 | kfree(bss_desc); |
1517 | kfree(beacon_ie); | ||
1518 | return 0; | 1501 | return 0; |
1519 | } | 1502 | } |
1520 | 1503 | ||
@@ -1744,17 +1727,13 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, | |||
1744 | cap_info_bitmap, beacon_period, | 1727 | cap_info_bitmap, beacon_period, |
1745 | ie_buf, ie_len, rssi, GFP_KERNEL); | 1728 | ie_buf, ie_len, rssi, GFP_KERNEL); |
1746 | *(u8 *)bss->priv = band; | 1729 | *(u8 *)bss->priv = band; |
1747 | cfg80211_put_bss(bss); | ||
1748 | |||
1749 | if (priv->media_connected && | 1730 | if (priv->media_connected && |
1750 | !memcmp(bssid, | 1731 | !memcmp(bssid, |
1751 | priv->curr_bss_params.bss_descriptor | 1732 | priv->curr_bss_params.bss_descriptor |
1752 | .mac_address, ETH_ALEN)) | 1733 | .mac_address, ETH_ALEN)) |
1753 | mwifiex_update_curr_bss_params | 1734 | mwifiex_update_curr_bss_params(priv, |
1754 | (priv, bssid, rssi, | 1735 | bss); |
1755 | ie_buf, ie_len, | 1736 | cfg80211_put_bss(bss); |
1756 | beacon_period, | ||
1757 | cap_info_bitmap, band); | ||
1758 | } | 1737 | } |
1759 | } else { | 1738 | } else { |
1760 | dev_dbg(adapter->dev, "missing BSS channel IE\n"); | 1739 | dev_dbg(adapter->dev, "missing BSS channel IE\n"); |
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index d12ed13b0bb5..f80622b479cd 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c | |||
@@ -155,20 +155,26 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv, | |||
155 | * information. | 155 | * information. |
156 | */ | 156 | */ |
157 | int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, | 157 | int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, |
158 | u8 *bssid, s32 rssi, u8 *ie_buf, | 158 | struct cfg80211_bss *bss, |
159 | size_t ie_len, u16 beacon_period, | ||
160 | u16 cap_info_bitmap, u8 band, | ||
161 | struct mwifiex_bssdescriptor *bss_desc) | 159 | struct mwifiex_bssdescriptor *bss_desc) |
162 | { | 160 | { |
163 | int ret; | 161 | int ret; |
162 | u8 *beacon_ie; | ||
164 | 163 | ||
165 | memcpy(bss_desc->mac_address, bssid, ETH_ALEN); | 164 | beacon_ie = kmemdup(bss->information_elements, bss->len_beacon_ies, |
166 | bss_desc->rssi = rssi; | 165 | GFP_KERNEL); |
167 | bss_desc->beacon_buf = ie_buf; | 166 | if (!beacon_ie) { |
168 | bss_desc->beacon_buf_size = ie_len; | 167 | dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n"); |
169 | bss_desc->beacon_period = beacon_period; | 168 | return -ENOMEM; |
170 | bss_desc->cap_info_bitmap = cap_info_bitmap; | 169 | } |
171 | bss_desc->bss_band = band; | 170 | |
171 | memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN); | ||
172 | bss_desc->rssi = bss->signal; | ||
173 | bss_desc->beacon_buf = beacon_ie; | ||
174 | bss_desc->beacon_buf_size = bss->len_beacon_ies; | ||
175 | bss_desc->beacon_period = bss->beacon_interval; | ||
176 | bss_desc->cap_info_bitmap = bss->capability; | ||
177 | bss_desc->bss_band = *(u8 *)bss->priv; | ||
172 | if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) { | 178 | if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) { |
173 | dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n"); | 179 | dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n"); |
174 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP; | 180 | 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 | else | 186 | else |
181 | bss_desc->bss_mode = NL80211_IFTYPE_STATION; | 187 | bss_desc->bss_mode = NL80211_IFTYPE_STATION; |
182 | 188 | ||
183 | ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc, | 189 | ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc); |
184 | ie_buf, ie_len); | ||
185 | 190 | ||
191 | kfree(beacon_ie); | ||
186 | return ret; | 192 | return ret; |
187 | } | 193 | } |
188 | 194 | ||
@@ -197,7 +203,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, | |||
197 | int ret; | 203 | int ret; |
198 | struct mwifiex_adapter *adapter = priv->adapter; | 204 | struct mwifiex_adapter *adapter = priv->adapter; |
199 | struct mwifiex_bssdescriptor *bss_desc = NULL; | 205 | struct mwifiex_bssdescriptor *bss_desc = NULL; |
200 | u8 *beacon_ie = NULL; | ||
201 | 206 | ||
202 | priv->scan_block = false; | 207 | priv->scan_block = false; |
203 | 208 | ||
@@ -210,19 +215,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, | |||
210 | return -ENOMEM; | 215 | return -ENOMEM; |
211 | } | 216 | } |
212 | 217 | ||
213 | beacon_ie = kmemdup(bss->information_elements, | 218 | ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc); |
214 | bss->len_beacon_ies, GFP_KERNEL); | ||
215 | if (!beacon_ie) { | ||
216 | kfree(bss_desc); | ||
217 | dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n"); | ||
218 | return -ENOMEM; | ||
219 | } | ||
220 | |||
221 | ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal, | ||
222 | beacon_ie, bss->len_beacon_ies, | ||
223 | bss->beacon_interval, | ||
224 | bss->capability, | ||
225 | *(u8 *)bss->priv, bss_desc); | ||
226 | if (ret) | 219 | if (ret) |
227 | goto done; | 220 | goto done; |
228 | } | 221 | } |
@@ -269,7 +262,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, | |||
269 | (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. | 262 | (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. |
270 | ssid, &bss_desc->ssid))) { | 263 | ssid, &bss_desc->ssid))) { |
271 | kfree(bss_desc); | 264 | kfree(bss_desc); |
272 | kfree(beacon_ie); | ||
273 | return 0; | 265 | return 0; |
274 | } | 266 | } |
275 | 267 | ||
@@ -304,7 +296,6 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, | |||
304 | 296 | ||
305 | done: | 297 | done: |
306 | kfree(bss_desc); | 298 | kfree(bss_desc); |
307 | kfree(beacon_ie); | ||
308 | return ret; | 299 | return ret; |
309 | } | 300 | } |
310 | 301 | ||