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/mwifiex/scan.c | |
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/mwifiex/scan.c')
-rw-r--r-- | drivers/net/wireless/mwifiex/scan.c | 41 |
1 files changed, 10 insertions, 31 deletions
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"); |