aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/scan.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-08 15:04:36 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:19 -0500
commitaa21c004f80bdf943736c62dccf0c0398d7824f3 (patch)
tree6815328775d3b5ec46bb342c4c256cde0f223863 /drivers/net/wireless/libertas/scan.c
parentf86a93e1b2d05a7a38a48c91f8fb8fc7e8f1c734 (diff)
libertas: kill struct lbs_adapter
There seems to be no reason for a separate structure; move it all into struct lbs_private. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/scan.c')
-rw-r--r--drivers/net/wireless/libertas/scan.c188
1 files changed, 90 insertions, 98 deletions
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 90c18889b717..8b6ce61aba43 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -190,13 +190,13 @@ static inline int is_same_network(struct bss_descriptor *src,
190 * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP 190 * 0 0 0 0 !=NONE 1 0 0 yes Dynamic WEP
191 * 191 *
192 * 192 *
193 * @param adapter A pointer to struct lbs_adapter 193 * @param priv A pointer to struct lbs_private
194 * @param index Index in scantable to check against current driver settings 194 * @param index Index in scantable to check against current driver settings
195 * @param mode Network mode: Infrastructure or IBSS 195 * @param mode Network mode: Infrastructure or IBSS
196 * 196 *
197 * @return Index in scantable, or error code if negative 197 * @return Index in scantable, or error code if negative
198 */ 198 */
199static int is_network_compatible(struct lbs_adapter *adapter, 199static int is_network_compatible(struct lbs_private *priv,
200 struct bss_descriptor * bss, u8 mode) 200 struct bss_descriptor * bss, u8 mode)
201{ 201{
202 int matched = 0; 202 int matched = 0;
@@ -206,31 +206,31 @@ static int is_network_compatible(struct lbs_adapter *adapter,
206 if (bss->mode != mode) 206 if (bss->mode != mode)
207 goto done; 207 goto done;
208 208
209 if ((matched = match_bss_no_security(&adapter->secinfo, bss))) { 209 if ((matched = match_bss_no_security(&priv->secinfo, bss))) {
210 goto done; 210 goto done;
211 } else if ((matched = match_bss_static_wep(&adapter->secinfo, bss))) { 211 } else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) {
212 goto done; 212 goto done;
213 } else if ((matched = match_bss_wpa(&adapter->secinfo, bss))) { 213 } else if ((matched = match_bss_wpa(&priv->secinfo, bss))) {
214 lbs_deb_scan( 214 lbs_deb_scan(
215 "is_network_compatible() WPA: wpa_ie 0x%x " 215 "is_network_compatible() WPA: wpa_ie 0x%x "
216 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " 216 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s "
217 "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], 217 "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0],
218 adapter->secinfo.wep_enabled ? "e" : "d", 218 priv->secinfo.wep_enabled ? "e" : "d",
219 adapter->secinfo.WPAenabled ? "e" : "d", 219 priv->secinfo.WPAenabled ? "e" : "d",
220 adapter->secinfo.WPA2enabled ? "e" : "d", 220 priv->secinfo.WPA2enabled ? "e" : "d",
221 (bss->capability & WLAN_CAPABILITY_PRIVACY)); 221 (bss->capability & WLAN_CAPABILITY_PRIVACY));
222 goto done; 222 goto done;
223 } else if ((matched = match_bss_wpa2(&adapter->secinfo, bss))) { 223 } else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) {
224 lbs_deb_scan( 224 lbs_deb_scan(
225 "is_network_compatible() WPA2: wpa_ie 0x%x " 225 "is_network_compatible() WPA2: wpa_ie 0x%x "
226 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " 226 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s "
227 "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], 227 "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0],
228 adapter->secinfo.wep_enabled ? "e" : "d", 228 priv->secinfo.wep_enabled ? "e" : "d",
229 adapter->secinfo.WPAenabled ? "e" : "d", 229 priv->secinfo.WPAenabled ? "e" : "d",
230 adapter->secinfo.WPA2enabled ? "e" : "d", 230 priv->secinfo.WPA2enabled ? "e" : "d",
231 (bss->capability & WLAN_CAPABILITY_PRIVACY)); 231 (bss->capability & WLAN_CAPABILITY_PRIVACY));
232 goto done; 232 goto done;
233 } else if ((matched = match_bss_dynamic_wep(&adapter->secinfo, bss))) { 233 } else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) {
234 lbs_deb_scan( 234 lbs_deb_scan(
235 "is_network_compatible() dynamic WEP: " 235 "is_network_compatible() dynamic WEP: "
236 "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", 236 "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n",
@@ -244,9 +244,9 @@ static int is_network_compatible(struct lbs_adapter *adapter,
244 "is_network_compatible() FAILED: wpa_ie 0x%x " 244 "is_network_compatible() FAILED: wpa_ie 0x%x "
245 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", 245 "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n",
246 bss->wpa_ie[0], bss->rsn_ie[0], 246 bss->wpa_ie[0], bss->rsn_ie[0],
247 adapter->secinfo.wep_enabled ? "e" : "d", 247 priv->secinfo.wep_enabled ? "e" : "d",
248 adapter->secinfo.WPAenabled ? "e" : "d", 248 priv->secinfo.WPAenabled ? "e" : "d",
249 adapter->secinfo.WPA2enabled ? "e" : "d", 249 priv->secinfo.WPA2enabled ? "e" : "d",
250 (bss->capability & WLAN_CAPABILITY_PRIVACY)); 250 (bss->capability & WLAN_CAPABILITY_PRIVACY));
251 251
252done: 252done:
@@ -298,7 +298,6 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
298 u8 filteredscan) 298 u8 filteredscan)
299{ 299{
300 300
301 struct lbs_adapter *adapter = priv->adapter;
302 struct region_channel *scanregion; 301 struct region_channel *scanregion;
303 struct chan_freq_power *cfp; 302 struct chan_freq_power *cfp;
304 int rgnidx; 303 int rgnidx;
@@ -314,22 +313,22 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
314 */ 313 */
315 scantype = CMD_SCAN_TYPE_ACTIVE; 314 scantype = CMD_SCAN_TYPE_ACTIVE;
316 315
317 for (rgnidx = 0; rgnidx < ARRAY_SIZE(adapter->region_channel); rgnidx++) { 316 for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) {
318 if (priv->adapter->enable11d && 317 if (priv->enable11d &&
319 (adapter->connect_status != LBS_CONNECTED) && 318 (priv->connect_status != LBS_CONNECTED) &&
320 (adapter->mesh_connect_status != LBS_CONNECTED)) { 319 (priv->mesh_connect_status != LBS_CONNECTED)) {
321 /* Scan all the supported chan for the first scan */ 320 /* Scan all the supported chan for the first scan */
322 if (!adapter->universal_channel[rgnidx].valid) 321 if (!priv->universal_channel[rgnidx].valid)
323 continue; 322 continue;
324 scanregion = &adapter->universal_channel[rgnidx]; 323 scanregion = &priv->universal_channel[rgnidx];
325 324
326 /* clear the parsed_region_chan for the first scan */ 325 /* clear the parsed_region_chan for the first scan */
327 memset(&adapter->parsed_region_chan, 0x00, 326 memset(&priv->parsed_region_chan, 0x00,
328 sizeof(adapter->parsed_region_chan)); 327 sizeof(priv->parsed_region_chan));
329 } else { 328 } else {
330 if (!adapter->region_channel[rgnidx].valid) 329 if (!priv->region_channel[rgnidx].valid)
331 continue; 330 continue;
332 scanregion = &adapter->region_channel[rgnidx]; 331 scanregion = &priv->region_channel[rgnidx];
333 } 332 }
334 333
335 for (nextchan = 0; 334 for (nextchan = 0;
@@ -337,10 +336,10 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv,
337 336
338 cfp = scanregion->CFP + nextchan; 337 cfp = scanregion->CFP + nextchan;
339 338
340 if (priv->adapter->enable11d) { 339 if (priv->enable11d) {
341 scantype = 340 scantype =
342 lbs_get_scan_type_11d(cfp->channel, 341 lbs_get_scan_type_11d(cfp->channel,
343 &adapter-> 342 &priv->
344 parsed_region_chan); 343 parsed_region_chan);
345 } 344 }
346 345
@@ -540,7 +539,6 @@ int lbs_scan_networks(struct lbs_private *priv,
540 const struct lbs_ioctl_user_scan_cfg *user_cfg, 539 const struct lbs_ioctl_user_scan_cfg *user_cfg,
541 int full_scan) 540 int full_scan)
542{ 541{
543 struct lbs_adapter *adapter = priv->adapter;
544 int ret = -ENOMEM; 542 int ret = -ENOMEM;
545 struct chanscanparamset *chan_list; 543 struct chanscanparamset *chan_list;
546 struct chanscanparamset *curr_chans; 544 struct chanscanparamset *curr_chans;
@@ -598,12 +596,12 @@ int lbs_scan_networks(struct lbs_private *priv,
598 596
599 /* Prepare to continue an interrupted scan */ 597 /* Prepare to continue an interrupted scan */
600 lbs_deb_scan("chan_count %d, last_scanned_channel %d\n", 598 lbs_deb_scan("chan_count %d, last_scanned_channel %d\n",
601 chan_count, adapter->last_scanned_channel); 599 chan_count, priv->last_scanned_channel);
602 curr_chans = chan_list; 600 curr_chans = chan_list;
603 /* advance channel list by already-scanned-channels */ 601 /* advance channel list by already-scanned-channels */
604 if (adapter->last_scanned_channel > 0) { 602 if (priv->last_scanned_channel > 0) {
605 curr_chans += adapter->last_scanned_channel; 603 curr_chans += priv->last_scanned_channel;
606 chan_count -= adapter->last_scanned_channel; 604 chan_count -= priv->last_scanned_channel;
607 } 605 }
608 606
609 /* Send scan command(s) 607 /* Send scan command(s)
@@ -627,12 +625,12 @@ int lbs_scan_networks(struct lbs_private *priv,
627 /* somehow schedule the next part of the scan */ 625 /* somehow schedule the next part of the scan */
628 if (chan_count && 626 if (chan_count &&
629 !full_scan && 627 !full_scan &&
630 !priv->adapter->surpriseremoved) { 628 !priv->surpriseremoved) {
631 /* -1 marks just that we're currently scanning */ 629 /* -1 marks just that we're currently scanning */
632 if (adapter->last_scanned_channel < 0) 630 if (priv->last_scanned_channel < 0)
633 adapter->last_scanned_channel = to_scan; 631 priv->last_scanned_channel = to_scan;
634 else 632 else
635 adapter->last_scanned_channel += to_scan; 633 priv->last_scanned_channel += to_scan;
636 cancel_delayed_work(&priv->scan_work); 634 cancel_delayed_work(&priv->scan_work);
637 queue_delayed_work(priv->work_thread, &priv->scan_work, 635 queue_delayed_work(priv->work_thread, &priv->scan_work,
638 msecs_to_jiffies(300)); 636 msecs_to_jiffies(300));
@@ -646,24 +644,24 @@ int lbs_scan_networks(struct lbs_private *priv,
646 644
647#ifdef CONFIG_LIBERTAS_DEBUG 645#ifdef CONFIG_LIBERTAS_DEBUG
648 /* Dump the scan table */ 646 /* Dump the scan table */
649 mutex_lock(&adapter->lock); 647 mutex_lock(&priv->lock);
650 lbs_deb_scan("scan table:\n"); 648 lbs_deb_scan("scan table:\n");
651 list_for_each_entry(iter, &adapter->network_list, list) 649 list_for_each_entry(iter, &priv->network_list, list)
652 lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", 650 lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
653 i++, print_mac(mac, iter->bssid), (s32) iter->rssi, 651 i++, print_mac(mac, iter->bssid), (s32) iter->rssi,
654 escape_essid(iter->ssid, iter->ssid_len)); 652 escape_essid(iter->ssid, iter->ssid_len));
655 mutex_unlock(&adapter->lock); 653 mutex_unlock(&priv->lock);
656#endif 654#endif
657 655
658out2: 656out2:
659 adapter->last_scanned_channel = 0; 657 priv->last_scanned_channel = 0;
660 658
661out: 659out:
662 if (adapter->connect_status == LBS_CONNECTED) { 660 if (priv->connect_status == LBS_CONNECTED) {
663 netif_carrier_on(priv->dev); 661 netif_carrier_on(priv->dev);
664 netif_wake_queue(priv->dev); 662 netif_wake_queue(priv->dev);
665 } 663 }
666 if (priv->mesh_dev && (adapter->mesh_connect_status == LBS_CONNECTED)) { 664 if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED)) {
667 netif_carrier_on(priv->mesh_dev); 665 netif_carrier_on(priv->mesh_dev);
668 netif_wake_queue(priv->mesh_dev); 666 netif_wake_queue(priv->mesh_dev);
669 } 667 }
@@ -931,13 +929,13 @@ done:
931 * 929 *
932 * Used in association code 930 * Used in association code
933 * 931 *
934 * @param adapter A pointer to struct lbs_adapter 932 * @param priv A pointer to struct lbs_private
935 * @param bssid BSSID to find in the scan list 933 * @param bssid BSSID to find in the scan list
936 * @param mode Network mode: Infrastructure or IBSS 934 * @param mode Network mode: Infrastructure or IBSS
937 * 935 *
938 * @return index in BSSID list, or error return code (< 0) 936 * @return index in BSSID list, or error return code (< 0)
939 */ 937 */
940struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter, 938struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv,
941 u8 * bssid, u8 mode) 939 u8 * bssid, u8 mode)
942{ 940{
943 struct bss_descriptor * iter_bss; 941 struct bss_descriptor * iter_bss;
@@ -955,14 +953,14 @@ struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter,
955 * continue past a matched bssid that is not compatible in case there 953 * continue past a matched bssid that is not compatible in case there
956 * is an AP with multiple SSIDs assigned to the same BSSID 954 * is an AP with multiple SSIDs assigned to the same BSSID
957 */ 955 */
958 mutex_lock(&adapter->lock); 956 mutex_lock(&priv->lock);
959 list_for_each_entry (iter_bss, &adapter->network_list, list) { 957 list_for_each_entry (iter_bss, &priv->network_list, list) {
960 if (compare_ether_addr(iter_bss->bssid, bssid)) 958 if (compare_ether_addr(iter_bss->bssid, bssid))
961 continue; /* bssid doesn't match */ 959 continue; /* bssid doesn't match */
962 switch (mode) { 960 switch (mode) {
963 case IW_MODE_INFRA: 961 case IW_MODE_INFRA:
964 case IW_MODE_ADHOC: 962 case IW_MODE_ADHOC:
965 if (!is_network_compatible(adapter, iter_bss, mode)) 963 if (!is_network_compatible(priv, iter_bss, mode))
966 break; 964 break;
967 found_bss = iter_bss; 965 found_bss = iter_bss;
968 break; 966 break;
@@ -971,7 +969,7 @@ struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter,
971 break; 969 break;
972 } 970 }
973 } 971 }
974 mutex_unlock(&adapter->lock); 972 mutex_unlock(&priv->lock);
975 973
976out: 974out:
977 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); 975 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss);
@@ -983,14 +981,14 @@ out:
983 * 981 *
984 * Used in association code 982 * Used in association code
985 * 983 *
986 * @param adapter A pointer to struct lbs_adapter 984 * @param priv A pointer to struct lbs_private
987 * @param ssid SSID to find in the list 985 * @param ssid SSID to find in the list
988 * @param bssid BSSID to qualify the SSID selection (if provided) 986 * @param bssid BSSID to qualify the SSID selection (if provided)
989 * @param mode Network mode: Infrastructure or IBSS 987 * @param mode Network mode: Infrastructure or IBSS
990 * 988 *
991 * @return index in BSSID list 989 * @return index in BSSID list
992 */ 990 */
993struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter, 991struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv,
994 u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, 992 u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode,
995 int channel) 993 int channel)
996{ 994{
@@ -1001,9 +999,9 @@ struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter,
1001 999
1002 lbs_deb_enter(LBS_DEB_SCAN); 1000 lbs_deb_enter(LBS_DEB_SCAN);
1003 1001
1004 mutex_lock(&adapter->lock); 1002 mutex_lock(&priv->lock);
1005 1003
1006 list_for_each_entry (iter_bss, &adapter->network_list, list) { 1004 list_for_each_entry (iter_bss, &priv->network_list, list) {
1007 if ( !tmp_oldest 1005 if ( !tmp_oldest
1008 || (iter_bss->last_scanned < tmp_oldest->last_scanned)) 1006 || (iter_bss->last_scanned < tmp_oldest->last_scanned))
1009 tmp_oldest = iter_bss; 1007 tmp_oldest = iter_bss;
@@ -1019,7 +1017,7 @@ struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter,
1019 switch (mode) { 1017 switch (mode) {
1020 case IW_MODE_INFRA: 1018 case IW_MODE_INFRA:
1021 case IW_MODE_ADHOC: 1019 case IW_MODE_ADHOC:
1022 if (!is_network_compatible(adapter, iter_bss, mode)) 1020 if (!is_network_compatible(priv, iter_bss, mode))
1023 break; 1021 break;
1024 1022
1025 if (bssid) { 1023 if (bssid) {
@@ -1044,7 +1042,7 @@ struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter,
1044 } 1042 }
1045 1043
1046out: 1044out:
1047 mutex_unlock(&adapter->lock); 1045 mutex_unlock(&priv->lock);
1048 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss); 1046 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss);
1049 return found_bss; 1047 return found_bss;
1050} 1048}
@@ -1055,12 +1053,12 @@ out:
1055 * Search the scan table for the best SSID that also matches the current 1053 * Search the scan table for the best SSID that also matches the current
1056 * adapter network preference (infrastructure or adhoc) 1054 * adapter network preference (infrastructure or adhoc)
1057 * 1055 *
1058 * @param adapter A pointer to struct lbs_adapter 1056 * @param priv A pointer to struct lbs_private
1059 * 1057 *
1060 * @return index in BSSID list 1058 * @return index in BSSID list
1061 */ 1059 */
1062static struct bss_descriptor *lbs_find_best_ssid_in_list( 1060static struct bss_descriptor *lbs_find_best_ssid_in_list(
1063 struct lbs_adapter *adapter, 1061 struct lbs_private *priv,
1064 u8 mode) 1062 u8 mode)
1065{ 1063{
1066 u8 bestrssi = 0; 1064 u8 bestrssi = 0;
@@ -1069,13 +1067,13 @@ static struct bss_descriptor *lbs_find_best_ssid_in_list(
1069 1067
1070 lbs_deb_enter(LBS_DEB_SCAN); 1068 lbs_deb_enter(LBS_DEB_SCAN);
1071 1069
1072 mutex_lock(&adapter->lock); 1070 mutex_lock(&priv->lock);
1073 1071
1074 list_for_each_entry (iter_bss, &adapter->network_list, list) { 1072 list_for_each_entry (iter_bss, &priv->network_list, list) {
1075 switch (mode) { 1073 switch (mode) {
1076 case IW_MODE_INFRA: 1074 case IW_MODE_INFRA:
1077 case IW_MODE_ADHOC: 1075 case IW_MODE_ADHOC:
1078 if (!is_network_compatible(adapter, iter_bss, mode)) 1076 if (!is_network_compatible(priv, iter_bss, mode))
1079 break; 1077 break;
1080 if (SCAN_RSSI(iter_bss->rssi) <= bestrssi) 1078 if (SCAN_RSSI(iter_bss->rssi) <= bestrssi)
1081 break; 1079 break;
@@ -1092,7 +1090,7 @@ static struct bss_descriptor *lbs_find_best_ssid_in_list(
1092 } 1090 }
1093 } 1091 }
1094 1092
1095 mutex_unlock(&adapter->lock); 1093 mutex_unlock(&priv->lock);
1096 lbs_deb_leave_args(LBS_DEB_SCAN, "best_bss %p", best_bss); 1094 lbs_deb_leave_args(LBS_DEB_SCAN, "best_bss %p", best_bss);
1097 return best_bss; 1095 return best_bss;
1098} 1096}
@@ -1110,17 +1108,16 @@ static struct bss_descriptor *lbs_find_best_ssid_in_list(
1110int lbs_find_best_network_ssid(struct lbs_private *priv, 1108int lbs_find_best_network_ssid(struct lbs_private *priv,
1111 u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) 1109 u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode)
1112{ 1110{
1113 struct lbs_adapter *adapter = priv->adapter;
1114 int ret = -1; 1111 int ret = -1;
1115 struct bss_descriptor * found; 1112 struct bss_descriptor * found;
1116 1113
1117 lbs_deb_enter(LBS_DEB_SCAN); 1114 lbs_deb_enter(LBS_DEB_SCAN);
1118 1115
1119 lbs_scan_networks(priv, NULL, 1); 1116 lbs_scan_networks(priv, NULL, 1);
1120 if (adapter->surpriseremoved) 1117 if (priv->surpriseremoved)
1121 goto out; 1118 goto out;
1122 1119
1123 found = lbs_find_best_ssid_in_list(adapter, preferred_mode); 1120 found = lbs_find_best_ssid_in_list(priv, preferred_mode);
1124 if (found && (found->ssid_len > 0)) { 1121 if (found && (found->ssid_len > 0)) {
1125 memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE); 1122 memcpy(out_ssid, &found->ssid, IW_ESSID_MAX_SIZE);
1126 *out_ssid_len = found->ssid_len; 1123 *out_ssid_len = found->ssid_len;
@@ -1150,7 +1147,6 @@ out:
1150int lbs_send_specific_ssid_scan(struct lbs_private *priv, 1147int lbs_send_specific_ssid_scan(struct lbs_private *priv,
1151 u8 *ssid, u8 ssid_len, u8 clear_ssid) 1148 u8 *ssid, u8 ssid_len, u8 clear_ssid)
1152{ 1149{
1153 struct lbs_adapter *adapter = priv->adapter;
1154 struct lbs_ioctl_user_scan_cfg scancfg; 1150 struct lbs_ioctl_user_scan_cfg scancfg;
1155 int ret = 0; 1151 int ret = 0;
1156 1152
@@ -1166,7 +1162,7 @@ int lbs_send_specific_ssid_scan(struct lbs_private *priv,
1166 scancfg.clear_ssid = clear_ssid; 1162 scancfg.clear_ssid = clear_ssid;
1167 1163
1168 lbs_scan_networks(priv, &scancfg, 1); 1164 lbs_scan_networks(priv, &scancfg, 1);
1169 if (adapter->surpriseremoved) { 1165 if (priv->surpriseremoved) {
1170 ret = -1; 1166 ret = -1;
1171 goto out; 1167 goto out;
1172 } 1168 }
@@ -1192,7 +1188,6 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
1192 char *start, char *stop, 1188 char *start, char *stop,
1193 struct bss_descriptor *bss) 1189 struct bss_descriptor *bss)
1194{ 1190{
1195 struct lbs_adapter *adapter = priv->adapter;
1196 struct chan_freq_power *cfp; 1191 struct chan_freq_power *cfp;
1197 char *current_val; /* For rates */ 1192 char *current_val; /* For rates */
1198 struct iw_event iwe; /* Temporary buffer */ 1193 struct iw_event iwe; /* Temporary buffer */
@@ -1204,7 +1199,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
1204 1199
1205 lbs_deb_enter(LBS_DEB_SCAN); 1200 lbs_deb_enter(LBS_DEB_SCAN);
1206 1201
1207 cfp = lbs_find_cfp_by_band_and_channel(adapter, 0, bss->channel); 1202 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, bss->channel);
1208 if (!cfp) { 1203 if (!cfp) {
1209 lbs_deb_scan("Invalid channel number %d\n", bss->channel); 1204 lbs_deb_scan("Invalid channel number %d\n", bss->channel);
1210 start = NULL; 1205 start = NULL;
@@ -1247,25 +1242,25 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
1247 if (iwe.u.qual.qual > 100) 1242 if (iwe.u.qual.qual > 100)
1248 iwe.u.qual.qual = 100; 1243 iwe.u.qual.qual = 100;
1249 1244
1250 if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { 1245 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
1251 iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; 1246 iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
1252 } else { 1247 } else {
1253 iwe.u.qual.noise = 1248 iwe.u.qual.noise =
1254 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1249 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
1255 } 1250 }
1256 1251
1257 /* Locally created ad-hoc BSSs won't have beacons if this is the 1252 /* Locally created ad-hoc BSSs won't have beacons if this is the
1258 * only station in the adhoc network; so get signal strength 1253 * only station in the adhoc network; so get signal strength
1259 * from receive statistics. 1254 * from receive statistics.
1260 */ 1255 */
1261 if ((adapter->mode == IW_MODE_ADHOC) 1256 if ((priv->mode == IW_MODE_ADHOC)
1262 && adapter->adhoccreate 1257 && priv->adhoccreate
1263 && !lbs_ssid_cmp(adapter->curbssparams.ssid, 1258 && !lbs_ssid_cmp(priv->curbssparams.ssid,
1264 adapter->curbssparams.ssid_len, 1259 priv->curbssparams.ssid_len,
1265 bss->ssid, bss->ssid_len)) { 1260 bss->ssid, bss->ssid_len)) {
1266 int snr, nf; 1261 int snr, nf;
1267 snr = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; 1262 snr = priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
1268 nf = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; 1263 nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
1269 iwe.u.qual.level = CAL_RSSI(snr, nf); 1264 iwe.u.qual.level = CAL_RSSI(snr, nf);
1270 } 1265 }
1271 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN); 1266 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
@@ -1294,10 +1289,10 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
1294 stop, &iwe, IW_EV_PARAM_LEN); 1289 stop, &iwe, IW_EV_PARAM_LEN);
1295 } 1290 }
1296 if ((bss->mode == IW_MODE_ADHOC) 1291 if ((bss->mode == IW_MODE_ADHOC)
1297 && !lbs_ssid_cmp(adapter->curbssparams.ssid, 1292 && !lbs_ssid_cmp(priv->curbssparams.ssid,
1298 adapter->curbssparams.ssid_len, 1293 priv->curbssparams.ssid_len,
1299 bss->ssid, bss->ssid_len) 1294 bss->ssid, bss->ssid_len)
1300 && adapter->adhoccreate) { 1295 && priv->adhoccreate) {
1301 iwe.u.bitrate.value = 22 * 500000; 1296 iwe.u.bitrate.value = 22 * 500000;
1302 current_val = iwe_stream_add_value(start, current_val, 1297 current_val = iwe_stream_add_value(start, current_val,
1303 stop, &iwe, IW_EV_PARAM_LEN); 1298 stop, &iwe, IW_EV_PARAM_LEN);
@@ -1356,7 +1351,6 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
1356 struct iw_param *wrqu, char *extra) 1351 struct iw_param *wrqu, char *extra)
1357{ 1352{
1358 struct lbs_private *priv = dev->priv; 1353 struct lbs_private *priv = dev->priv;
1359 struct lbs_adapter *adapter = priv->adapter;
1360 1354
1361 lbs_deb_enter(LBS_DEB_SCAN); 1355 lbs_deb_enter(LBS_DEB_SCAN);
1362 1356
@@ -1380,9 +1374,9 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
1380 queue_delayed_work(priv->work_thread, &priv->scan_work, 1374 queue_delayed_work(priv->work_thread, &priv->scan_work,
1381 msecs_to_jiffies(50)); 1375 msecs_to_jiffies(50));
1382 /* set marker that currently a scan is taking place */ 1376 /* set marker that currently a scan is taking place */
1383 adapter->last_scanned_channel = -1; 1377 priv->last_scanned_channel = -1;
1384 1378
1385 if (adapter->surpriseremoved) 1379 if (priv->surpriseremoved)
1386 return -EIO; 1380 return -EIO;
1387 1381
1388 lbs_deb_leave(LBS_DEB_SCAN); 1382 lbs_deb_leave(LBS_DEB_SCAN);
@@ -1405,7 +1399,6 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
1405{ 1399{
1406#define SCAN_ITEM_SIZE 128 1400#define SCAN_ITEM_SIZE 128
1407 struct lbs_private *priv = dev->priv; 1401 struct lbs_private *priv = dev->priv;
1408 struct lbs_adapter *adapter = priv->adapter;
1409 int err = 0; 1402 int err = 0;
1410 char *ev = extra; 1403 char *ev = extra;
1411 char *stop = ev + dwrq->length; 1404 char *stop = ev + dwrq->length;
@@ -1415,17 +1408,17 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
1415 lbs_deb_enter(LBS_DEB_SCAN); 1408 lbs_deb_enter(LBS_DEB_SCAN);
1416 1409
1417 /* iwlist should wait until the current scan is finished */ 1410 /* iwlist should wait until the current scan is finished */
1418 if (adapter->last_scanned_channel) 1411 if (priv->last_scanned_channel)
1419 return -EAGAIN; 1412 return -EAGAIN;
1420 1413
1421 /* Update RSSI if current BSS is a locally created ad-hoc BSS */ 1414 /* Update RSSI if current BSS is a locally created ad-hoc BSS */
1422 if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate) { 1415 if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) {
1423 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, 1416 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
1424 CMD_OPTION_WAITFORRSP, 0, NULL); 1417 CMD_OPTION_WAITFORRSP, 0, NULL);
1425 } 1418 }
1426 1419
1427 mutex_lock(&adapter->lock); 1420 mutex_lock(&priv->lock);
1428 list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) { 1421 list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) {
1429 char * next_ev; 1422 char * next_ev;
1430 unsigned long stale_time; 1423 unsigned long stale_time;
1431 1424
@@ -1442,7 +1435,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
1442 stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; 1435 stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE;
1443 if (time_after(jiffies, stale_time)) { 1436 if (time_after(jiffies, stale_time)) {
1444 list_move_tail (&iter_bss->list, 1437 list_move_tail (&iter_bss->list,
1445 &adapter->network_free_list); 1438 &priv->network_free_list);
1446 clear_bss_descriptor(iter_bss); 1439 clear_bss_descriptor(iter_bss);
1447 continue; 1440 continue;
1448 } 1441 }
@@ -1453,7 +1446,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
1453 continue; 1446 continue;
1454 ev = next_ev; 1447 ev = next_ev;
1455 } 1448 }
1456 mutex_unlock(&adapter->lock); 1449 mutex_unlock(&priv->lock);
1457 1450
1458 dwrq->length = (ev - extra); 1451 dwrq->length = (ev - extra);
1459 dwrq->flags = 0; 1452 dwrq->flags = 0;
@@ -1538,7 +1531,6 @@ int lbs_cmd_80211_scan(struct lbs_private *priv,
1538 */ 1531 */
1539int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp) 1532int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp)
1540{ 1533{
1541 struct lbs_adapter *adapter = priv->adapter;
1542 struct cmd_ds_802_11_scan_rsp *pscan; 1534 struct cmd_ds_802_11_scan_rsp *pscan;
1543 struct bss_descriptor * iter_bss; 1535 struct bss_descriptor * iter_bss;
1544 struct bss_descriptor * safe; 1536 struct bss_descriptor * safe;
@@ -1552,11 +1544,11 @@ int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp)
1552 lbs_deb_enter(LBS_DEB_SCAN); 1544 lbs_deb_enter(LBS_DEB_SCAN);
1553 1545
1554 /* Prune old entries from scan table */ 1546 /* Prune old entries from scan table */
1555 list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) { 1547 list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) {
1556 unsigned long stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; 1548 unsigned long stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE;
1557 if (time_before(jiffies, stale_time)) 1549 if (time_before(jiffies, stale_time))
1558 continue; 1550 continue;
1559 list_move_tail (&iter_bss->list, &adapter->network_free_list); 1551 list_move_tail (&iter_bss->list, &priv->network_free_list);
1560 clear_bss_descriptor(iter_bss); 1552 clear_bss_descriptor(iter_bss);
1561 } 1553 }
1562 1554
@@ -1609,7 +1601,7 @@ int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp)
1609 } 1601 }
1610 1602
1611 /* Try to find this bss in the scan table */ 1603 /* Try to find this bss in the scan table */
1612 list_for_each_entry (iter_bss, &adapter->network_list, list) { 1604 list_for_each_entry (iter_bss, &priv->network_list, list) {
1613 if (is_same_network(iter_bss, &new)) { 1605 if (is_same_network(iter_bss, &new)) {
1614 found = iter_bss; 1606 found = iter_bss;
1615 break; 1607 break;
@@ -1623,16 +1615,16 @@ int lbs_ret_80211_scan(struct lbs_private *priv, struct cmd_ds_command *resp)
1623 if (found) { 1615 if (found) {
1624 /* found, clear it */ 1616 /* found, clear it */
1625 clear_bss_descriptor(found); 1617 clear_bss_descriptor(found);
1626 } else if (!list_empty(&adapter->network_free_list)) { 1618 } else if (!list_empty(&priv->network_free_list)) {
1627 /* Pull one from the free list */ 1619 /* Pull one from the free list */
1628 found = list_entry(adapter->network_free_list.next, 1620 found = list_entry(priv->network_free_list.next,
1629 struct bss_descriptor, list); 1621 struct bss_descriptor, list);
1630 list_move_tail(&found->list, &adapter->network_list); 1622 list_move_tail(&found->list, &priv->network_list);
1631 } else if (oldest) { 1623 } else if (oldest) {
1632 /* If there are no more slots, expire the oldest */ 1624 /* If there are no more slots, expire the oldest */
1633 found = oldest; 1625 found = oldest;
1634 clear_bss_descriptor(found); 1626 clear_bss_descriptor(found);
1635 list_move_tail(&found->list, &adapter->network_list); 1627 list_move_tail(&found->list, &priv->network_list);
1636 } else { 1628 } else {
1637 continue; 1629 continue;
1638 } 1630 }