aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/net/wireless/libertas/11d.c68
-rw-r--r--drivers/net/wireless/libertas/assoc.c136
-rw-r--r--drivers/net/wireless/libertas/assoc.h2
-rw-r--r--drivers/net/wireless/libertas/cmd.c278
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c336
-rw-r--r--drivers/net/wireless/libertas/debugfs.c56
-rw-r--r--drivers/net/wireless/libertas/decl.h7
-rw-r--r--drivers/net/wireless/libertas/dev.h97
-rw-r--r--drivers/net/wireless/libertas/ethtool.c19
-rw-r--r--drivers/net/wireless/libertas/if_cs.c21
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c20
-rw-r--r--drivers/net/wireless/libertas/if_usb.c27
-rw-r--r--drivers/net/wireless/libertas/join.c150
-rw-r--r--drivers/net/wireless/libertas/main.c326
-rw-r--r--drivers/net/wireless/libertas/rx.c78
-rw-r--r--drivers/net/wireless/libertas/scan.c188
-rw-r--r--drivers/net/wireless/libertas/scan.h6
-rw-r--r--drivers/net/wireless/libertas/tx.c63
-rw-r--r--drivers/net/wireless/libertas/wext.c372
19 files changed, 1046 insertions, 1204 deletions
diff --git a/drivers/net/wireless/libertas/11d.c b/drivers/net/wireless/libertas/11d.c
index 013965d40519..5e10ce0d351c 100644
--- a/drivers/net/wireless/libertas/11d.c
+++ b/drivers/net/wireless/libertas/11d.c
@@ -432,8 +432,8 @@ u8 lbs_get_scan_type_11d(u8 chan,
432 432
433void lbs_init_11d(struct lbs_private *priv) 433void lbs_init_11d(struct lbs_private *priv)
434{ 434{
435 priv->adapter->enable11d = 0; 435 priv->enable11d = 0;
436 memset(&(priv->adapter->parsed_region_chan), 0, 436 memset(&(priv->parsed_region_chan), 0,
437 sizeof(struct parsed_region_chan_11d)); 437 sizeof(struct parsed_region_chan_11d));
438 return; 438 return;
439} 439}
@@ -447,7 +447,7 @@ static int set_domain_info_11d(struct lbs_private *priv)
447{ 447{
448 int ret; 448 int ret;
449 449
450 if (!priv->adapter->enable11d) { 450 if (!priv->enable11d) {
451 lbs_deb_11d("dnld domain Info with 11d disabled\n"); 451 lbs_deb_11d("dnld domain Info with 11d disabled\n");
452 return 0; 452 return 0;
453 } 453 }
@@ -469,22 +469,21 @@ static int set_domain_info_11d(struct lbs_private *priv)
469*/ 469*/
470int lbs_set_universaltable(struct lbs_private *priv, u8 band) 470int lbs_set_universaltable(struct lbs_private *priv, u8 band)
471{ 471{
472 struct lbs_adapter *adapter = priv->adapter;
473 u16 size = sizeof(struct chan_freq_power); 472 u16 size = sizeof(struct chan_freq_power);
474 u16 i = 0; 473 u16 i = 0;
475 474
476 memset(adapter->universal_channel, 0, 475 memset(priv->universal_channel, 0,
477 sizeof(adapter->universal_channel)); 476 sizeof(priv->universal_channel));
478 477
479 adapter->universal_channel[i].nrcfp = 478 priv->universal_channel[i].nrcfp =
480 sizeof(channel_freq_power_UN_BG) / size; 479 sizeof(channel_freq_power_UN_BG) / size;
481 lbs_deb_11d("BG-band nrcfp %d\n", 480 lbs_deb_11d("BG-band nrcfp %d\n",
482 adapter->universal_channel[i].nrcfp); 481 priv->universal_channel[i].nrcfp);
483 482
484 adapter->universal_channel[i].CFP = channel_freq_power_UN_BG; 483 priv->universal_channel[i].CFP = channel_freq_power_UN_BG;
485 adapter->universal_channel[i].valid = 1; 484 priv->universal_channel[i].valid = 1;
486 adapter->universal_channel[i].region = UNIVERSAL_REGION_CODE; 485 priv->universal_channel[i].region = UNIVERSAL_REGION_CODE;
487 adapter->universal_channel[i].band = band; 486 priv->universal_channel[i].band = band;
488 i++; 487 i++;
489 488
490 return 0; 489 return 0;
@@ -505,8 +504,7 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
505 struct cmd_ds_802_11d_domain_info *pdomaininfo = 504 struct cmd_ds_802_11d_domain_info *pdomaininfo =
506 &cmd->params.domaininfo; 505 &cmd->params.domaininfo;
507 struct mrvlietypes_domainparamset *domain = &pdomaininfo->domain; 506 struct mrvlietypes_domainparamset *domain = &pdomaininfo->domain;
508 struct lbs_adapter *adapter = priv->adapter; 507 u8 nr_subband = priv->domainreg.nr_subband;
509 u8 nr_subband = adapter->domainreg.nr_subband;
510 508
511 lbs_deb_enter(LBS_DEB_11D); 509 lbs_deb_enter(LBS_DEB_11D);
512 510
@@ -523,7 +521,7 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
523 } 521 }
524 522
525 domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN); 523 domain->header.type = cpu_to_le16(TLV_TYPE_DOMAIN);
526 memcpy(domain->countrycode, adapter->domainreg.countrycode, 524 memcpy(domain->countrycode, priv->domainreg.countrycode,
527 sizeof(domain->countrycode)); 525 sizeof(domain->countrycode));
528 526
529 domain->header.len = 527 domain->header.len =
@@ -531,7 +529,7 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
531 sizeof(domain->countrycode)); 529 sizeof(domain->countrycode));
532 530
533 if (nr_subband) { 531 if (nr_subband) {
534 memcpy(domain->subband, adapter->domainreg.subband, 532 memcpy(domain->subband, priv->domainreg.subband,
535 nr_subband * sizeof(struct ieeetypes_subbandset)); 533 nr_subband * sizeof(struct ieeetypes_subbandset));
536 534
537 cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) + 535 cmd->size = cpu_to_le16(sizeof(pdomaininfo->action) +
@@ -605,24 +603,23 @@ int lbs_parse_dnld_countryinfo_11d(struct lbs_private *priv,
605 struct bss_descriptor * bss) 603 struct bss_descriptor * bss)
606{ 604{
607 int ret; 605 int ret;
608 struct lbs_adapter *adapter = priv->adapter;
609 606
610 lbs_deb_enter(LBS_DEB_11D); 607 lbs_deb_enter(LBS_DEB_11D);
611 if (priv->adapter->enable11d) { 608 if (priv->enable11d) {
612 memset(&adapter->parsed_region_chan, 0, 609 memset(&priv->parsed_region_chan, 0,
613 sizeof(struct parsed_region_chan_11d)); 610 sizeof(struct parsed_region_chan_11d));
614 ret = parse_domain_info_11d(&bss->countryinfo, 0, 611 ret = parse_domain_info_11d(&bss->countryinfo, 0,
615 &adapter->parsed_region_chan); 612 &priv->parsed_region_chan);
616 613
617 if (ret == -1) { 614 if (ret == -1) {
618 lbs_deb_11d("error parsing domain_info from AP\n"); 615 lbs_deb_11d("error parsing domain_info from AP\n");
619 goto done; 616 goto done;
620 } 617 }
621 618
622 memset(&adapter->domainreg, 0, 619 memset(&priv->domainreg, 0,
623 sizeof(struct lbs_802_11d_domain_reg)); 620 sizeof(struct lbs_802_11d_domain_reg));
624 generate_domain_info_11d(&adapter->parsed_region_chan, 621 generate_domain_info_11d(&priv->parsed_region_chan,
625 &adapter->domainreg); 622 &priv->domainreg);
626 623
627 ret = set_domain_info_11d(priv); 624 ret = set_domain_info_11d(priv);
628 625
@@ -646,18 +643,17 @@ done:
646int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv) 643int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
647{ 644{
648 int ret; 645 int ret;
649 struct lbs_adapter *adapter = priv->adapter;
650 struct region_channel *region_chan; 646 struct region_channel *region_chan;
651 u8 j; 647 u8 j;
652 648
653 lbs_deb_enter(LBS_DEB_11D); 649 lbs_deb_enter(LBS_DEB_11D);
654 lbs_deb_11d("curbssparams.band %d\n", adapter->curbssparams.band); 650 lbs_deb_11d("curbssparams.band %d\n", priv->curbssparams.band);
655 651
656 if (priv->adapter->enable11d) { 652 if (priv->enable11d) {
657 /* update parsed_region_chan_11; dnld domaininf to FW */ 653 /* update parsed_region_chan_11; dnld domaininf to FW */
658 654
659 for (j = 0; j < ARRAY_SIZE(adapter->region_channel); j++) { 655 for (j = 0; j < ARRAY_SIZE(priv->region_channel); j++) {
660 region_chan = &adapter->region_channel[j]; 656 region_chan = &priv->region_channel[j];
661 657
662 lbs_deb_11d("%d region_chan->band %d\n", j, 658 lbs_deb_11d("%d region_chan->band %d\n", j,
663 region_chan->band); 659 region_chan->band);
@@ -665,28 +661,28 @@ int lbs_create_dnld_countryinfo_11d(struct lbs_private *priv)
665 if (!region_chan || !region_chan->valid 661 if (!region_chan || !region_chan->valid
666 || !region_chan->CFP) 662 || !region_chan->CFP)
667 continue; 663 continue;
668 if (region_chan->band != adapter->curbssparams.band) 664 if (region_chan->band != priv->curbssparams.band)
669 continue; 665 continue;
670 break; 666 break;
671 } 667 }
672 668
673 if (j >= ARRAY_SIZE(adapter->region_channel)) { 669 if (j >= ARRAY_SIZE(priv->region_channel)) {
674 lbs_deb_11d("region_chan not found, band %d\n", 670 lbs_deb_11d("region_chan not found, band %d\n",
675 adapter->curbssparams.band); 671 priv->curbssparams.band);
676 ret = -1; 672 ret = -1;
677 goto done; 673 goto done;
678 } 674 }
679 675
680 memset(&adapter->parsed_region_chan, 0, 676 memset(&priv->parsed_region_chan, 0,
681 sizeof(struct parsed_region_chan_11d)); 677 sizeof(struct parsed_region_chan_11d));
682 lbs_generate_parsed_region_chan_11d(region_chan, 678 lbs_generate_parsed_region_chan_11d(region_chan,
683 &adapter-> 679 &priv->
684 parsed_region_chan); 680 parsed_region_chan);
685 681
686 memset(&adapter->domainreg, 0, 682 memset(&priv->domainreg, 0,
687 sizeof(struct lbs_802_11d_domain_reg)); 683 sizeof(struct lbs_802_11d_domain_reg));
688 generate_domain_info_11d(&adapter->parsed_region_chan, 684 generate_domain_info_11d(&priv->parsed_region_chan,
689 &adapter->domainreg); 685 &priv->domainreg);
690 686
691 ret = set_domain_info_11d(priv); 687 ret = set_domain_info_11d(priv);
692 688
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 88da68ee0f02..63bd692c7239 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -18,7 +18,6 @@ static const u8 bssid_off[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
18static int assoc_helper_essid(struct lbs_private *priv, 18static int assoc_helper_essid(struct lbs_private *priv,
19 struct assoc_request * assoc_req) 19 struct assoc_request * assoc_req)
20{ 20{
21 struct lbs_adapter *adapter = priv->adapter;
22 int ret = 0; 21 int ret = 0;
23 struct bss_descriptor * bss; 22 struct bss_descriptor * bss;
24 int channel = -1; 23 int channel = -1;
@@ -38,7 +37,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
38 lbs_send_specific_ssid_scan(priv, assoc_req->ssid, 37 lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
39 assoc_req->ssid_len, 0); 38 assoc_req->ssid_len, 0);
40 39
41 bss = lbs_find_ssid_in_list(adapter, assoc_req->ssid, 40 bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
42 assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel); 41 assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel);
43 if (bss != NULL) { 42 if (bss != NULL) {
44 memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor)); 43 memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
@@ -54,7 +53,7 @@ static int assoc_helper_essid(struct lbs_private *priv,
54 assoc_req->ssid_len, 1); 53 assoc_req->ssid_len, 1);
55 54
56 /* Search for the requested SSID in the scan table */ 55 /* Search for the requested SSID in the scan table */
57 bss = lbs_find_ssid_in_list(adapter, assoc_req->ssid, 56 bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
58 assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel); 57 assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel);
59 if (bss != NULL) { 58 if (bss != NULL) {
60 lbs_deb_assoc("SSID found, will join\n"); 59 lbs_deb_assoc("SSID found, will join\n");
@@ -78,7 +77,6 @@ static int assoc_helper_essid(struct lbs_private *priv,
78static int assoc_helper_bssid(struct lbs_private *priv, 77static int assoc_helper_bssid(struct lbs_private *priv,
79 struct assoc_request * assoc_req) 78 struct assoc_request * assoc_req)
80{ 79{
81 struct lbs_adapter *adapter = priv->adapter;
82 int ret = 0; 80 int ret = 0;
83 struct bss_descriptor * bss; 81 struct bss_descriptor * bss;
84 DECLARE_MAC_BUF(mac); 82 DECLARE_MAC_BUF(mac);
@@ -87,7 +85,7 @@ static int assoc_helper_bssid(struct lbs_private *priv,
87 print_mac(mac, assoc_req->bssid)); 85 print_mac(mac, assoc_req->bssid));
88 86
89 /* Search for index position in list for requested MAC */ 87 /* Search for index position in list for requested MAC */
90 bss = lbs_find_bssid_in_list(adapter, assoc_req->bssid, 88 bss = lbs_find_bssid_in_list(priv, assoc_req->bssid,
91 assoc_req->mode); 89 assoc_req->mode);
92 if (bss == NULL) { 90 if (bss == NULL) {
93 lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, " 91 lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, "
@@ -138,21 +136,20 @@ static int assoc_helper_associate(struct lbs_private *priv,
138static int assoc_helper_mode(struct lbs_private *priv, 136static int assoc_helper_mode(struct lbs_private *priv,
139 struct assoc_request * assoc_req) 137 struct assoc_request * assoc_req)
140{ 138{
141 struct lbs_adapter *adapter = priv->adapter;
142 int ret = 0; 139 int ret = 0;
143 140
144 lbs_deb_enter(LBS_DEB_ASSOC); 141 lbs_deb_enter(LBS_DEB_ASSOC);
145 142
146 if (assoc_req->mode == adapter->mode) 143 if (assoc_req->mode == priv->mode)
147 goto done; 144 goto done;
148 145
149 if (assoc_req->mode == IW_MODE_INFRA) { 146 if (assoc_req->mode == IW_MODE_INFRA) {
150 if (adapter->psstate != PS_STATE_FULL_POWER) 147 if (priv->psstate != PS_STATE_FULL_POWER)
151 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); 148 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
152 adapter->psmode = LBS802_11POWERMODECAM; 149 priv->psmode = LBS802_11POWERMODECAM;
153 } 150 }
154 151
155 adapter->mode = assoc_req->mode; 152 priv->mode = assoc_req->mode;
156 ret = lbs_prepare_and_send_command(priv, 153 ret = lbs_prepare_and_send_command(priv,
157 CMD_802_11_SNMP_MIB, 154 CMD_802_11_SNMP_MIB,
158 0, CMD_OPTION_WAITFORRSP, 155 0, CMD_OPTION_WAITFORRSP,
@@ -191,7 +188,6 @@ void lbs_sync_channel(struct work_struct *work)
191static int assoc_helper_channel(struct lbs_private *priv, 188static int assoc_helper_channel(struct lbs_private *priv,
192 struct assoc_request * assoc_req) 189 struct assoc_request * assoc_req)
193{ 190{
194 struct lbs_adapter *adapter = priv->adapter;
195 int ret = 0; 191 int ret = 0;
196 192
197 lbs_deb_enter(LBS_DEB_ASSOC); 193 lbs_deb_enter(LBS_DEB_ASSOC);
@@ -201,11 +197,11 @@ static int assoc_helper_channel(struct lbs_private *priv,
201 lbs_deb_assoc("ASSOC: channel: error getting channel."); 197 lbs_deb_assoc("ASSOC: channel: error getting channel.");
202 } 198 }
203 199
204 if (assoc_req->channel == adapter->curbssparams.channel) 200 if (assoc_req->channel == priv->curbssparams.channel)
205 goto done; 201 goto done;
206 202
207 lbs_deb_assoc("ASSOC: channel: %d -> %d\n", 203 lbs_deb_assoc("ASSOC: channel: %d -> %d\n",
208 adapter->curbssparams.channel, assoc_req->channel); 204 priv->curbssparams.channel, assoc_req->channel);
209 205
210 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RF_CHANNEL, 206 ret = lbs_prepare_and_send_command(priv, CMD_802_11_RF_CHANNEL,
211 CMD_OPT_802_11_RF_CHANNEL_SET, 207 CMD_OPT_802_11_RF_CHANNEL_SET,
@@ -219,7 +215,7 @@ static int assoc_helper_channel(struct lbs_private *priv,
219 lbs_deb_assoc("ASSOC: channel: error getting channel."); 215 lbs_deb_assoc("ASSOC: channel: error getting channel.");
220 } 216 }
221 217
222 if (assoc_req->channel != adapter->curbssparams.channel) { 218 if (assoc_req->channel != priv->curbssparams.channel) {
223 lbs_deb_assoc("ASSOC: channel: failed to update channel to %d", 219 lbs_deb_assoc("ASSOC: channel: failed to update channel to %d",
224 assoc_req->channel); 220 assoc_req->channel);
225 goto done; 221 goto done;
@@ -246,7 +242,6 @@ done:
246static int assoc_helper_wep_keys(struct lbs_private *priv, 242static int assoc_helper_wep_keys(struct lbs_private *priv,
247 struct assoc_request * assoc_req) 243 struct assoc_request * assoc_req)
248{ 244{
249 struct lbs_adapter *adapter = priv->adapter;
250 int i; 245 int i;
251 int ret = 0; 246 int ret = 0;
252 247
@@ -275,23 +270,23 @@ static int assoc_helper_wep_keys(struct lbs_private *priv,
275 270
276 /* enable/disable the MAC's WEP packet filter */ 271 /* enable/disable the MAC's WEP packet filter */
277 if (assoc_req->secinfo.wep_enabled) 272 if (assoc_req->secinfo.wep_enabled)
278 adapter->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE; 273 priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE;
279 else 274 else
280 adapter->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE; 275 priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE;
281 ret = lbs_set_mac_packet_filter(priv); 276 ret = lbs_set_mac_packet_filter(priv);
282 if (ret) 277 if (ret)
283 goto out; 278 goto out;
284 279
285 mutex_lock(&adapter->lock); 280 mutex_lock(&priv->lock);
286 281
287 /* Copy WEP keys into adapter wep key fields */ 282 /* Copy WEP keys into priv wep key fields */
288 for (i = 0; i < 4; i++) { 283 for (i = 0; i < 4; i++) {
289 memcpy(&adapter->wep_keys[i], &assoc_req->wep_keys[i], 284 memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i],
290 sizeof(struct enc_key)); 285 sizeof(struct enc_key));
291 } 286 }
292 adapter->wep_tx_keyidx = assoc_req->wep_tx_keyidx; 287 priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx;
293 288
294 mutex_unlock(&adapter->lock); 289 mutex_unlock(&priv->lock);
295 290
296out: 291out:
297 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 292 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
@@ -301,14 +296,13 @@ out:
301static int assoc_helper_secinfo(struct lbs_private *priv, 296static int assoc_helper_secinfo(struct lbs_private *priv,
302 struct assoc_request * assoc_req) 297 struct assoc_request * assoc_req)
303{ 298{
304 struct lbs_adapter *adapter = priv->adapter;
305 int ret = 0; 299 int ret = 0;
306 u32 do_wpa; 300 u32 do_wpa;
307 u32 rsn = 0; 301 u32 rsn = 0;
308 302
309 lbs_deb_enter(LBS_DEB_ASSOC); 303 lbs_deb_enter(LBS_DEB_ASSOC);
310 304
311 memcpy(&adapter->secinfo, &assoc_req->secinfo, 305 memcpy(&priv->secinfo, &assoc_req->secinfo,
312 sizeof(struct lbs_802_11_security)); 306 sizeof(struct lbs_802_11_security));
313 307
314 ret = lbs_set_mac_packet_filter(priv); 308 ret = lbs_set_mac_packet_filter(priv);
@@ -396,17 +390,16 @@ out:
396static int assoc_helper_wpa_ie(struct lbs_private *priv, 390static int assoc_helper_wpa_ie(struct lbs_private *priv,
397 struct assoc_request * assoc_req) 391 struct assoc_request * assoc_req)
398{ 392{
399 struct lbs_adapter *adapter = priv->adapter;
400 int ret = 0; 393 int ret = 0;
401 394
402 lbs_deb_enter(LBS_DEB_ASSOC); 395 lbs_deb_enter(LBS_DEB_ASSOC);
403 396
404 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) { 397 if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) {
405 memcpy(&adapter->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len); 398 memcpy(&priv->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len);
406 adapter->wpa_ie_len = assoc_req->wpa_ie_len; 399 priv->wpa_ie_len = assoc_req->wpa_ie_len;
407 } else { 400 } else {
408 memset(&adapter->wpa_ie, 0, MAX_WPA_IE_LEN); 401 memset(&priv->wpa_ie, 0, MAX_WPA_IE_LEN);
409 adapter->wpa_ie_len = 0; 402 priv->wpa_ie_len = 0;
410 } 403 }
411 404
412 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 405 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
@@ -414,14 +407,14 @@ static int assoc_helper_wpa_ie(struct lbs_private *priv,
414} 407}
415 408
416 409
417static int should_deauth_infrastructure(struct lbs_adapter *adapter, 410static int should_deauth_infrastructure(struct lbs_private *priv,
418 struct assoc_request * assoc_req) 411 struct assoc_request * assoc_req)
419{ 412{
420 int ret = 0; 413 int ret = 0;
421 414
422 lbs_deb_enter(LBS_DEB_ASSOC); 415 lbs_deb_enter(LBS_DEB_ASSOC);
423 416
424 if (adapter->connect_status != LBS_CONNECTED) 417 if (priv->connect_status != LBS_CONNECTED)
425 return 0; 418 return 0;
426 419
427 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { 420 if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
@@ -431,7 +424,7 @@ static int should_deauth_infrastructure(struct lbs_adapter *adapter,
431 } 424 }
432 425
433 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 426 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
434 if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) { 427 if (priv->secinfo.auth_mode != assoc_req->secinfo.auth_mode) {
435 lbs_deb_assoc("Deauthenticating due to new security\n"); 428 lbs_deb_assoc("Deauthenticating due to new security\n");
436 ret = 1; 429 ret = 1;
437 goto out; 430 goto out;
@@ -466,16 +459,16 @@ out:
466} 459}
467 460
468 461
469static int should_stop_adhoc(struct lbs_adapter *adapter, 462static int should_stop_adhoc(struct lbs_private *priv,
470 struct assoc_request * assoc_req) 463 struct assoc_request * assoc_req)
471{ 464{
472 lbs_deb_enter(LBS_DEB_ASSOC); 465 lbs_deb_enter(LBS_DEB_ASSOC);
473 466
474 if (adapter->connect_status != LBS_CONNECTED) 467 if (priv->connect_status != LBS_CONNECTED)
475 return 0; 468 return 0;
476 469
477 if (lbs_ssid_cmp(adapter->curbssparams.ssid, 470 if (lbs_ssid_cmp(priv->curbssparams.ssid,
478 adapter->curbssparams.ssid_len, 471 priv->curbssparams.ssid_len,
479 assoc_req->ssid, assoc_req->ssid_len) != 0) 472 assoc_req->ssid, assoc_req->ssid_len) != 0)
480 return 1; 473 return 1;
481 474
@@ -486,7 +479,7 @@ static int should_stop_adhoc(struct lbs_adapter *adapter,
486 } 479 }
487 480
488 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) { 481 if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
489 if (assoc_req->channel != adapter->curbssparams.channel) 482 if (assoc_req->channel != priv->curbssparams.channel)
490 return 1; 483 return 1;
491 } 484 }
492 485
@@ -499,7 +492,6 @@ void lbs_association_worker(struct work_struct *work)
499{ 492{
500 struct lbs_private *priv = container_of(work, struct lbs_private, 493 struct lbs_private *priv = container_of(work, struct lbs_private,
501 assoc_work.work); 494 assoc_work.work);
502 struct lbs_adapter *adapter = priv->adapter;
503 struct assoc_request * assoc_req = NULL; 495 struct assoc_request * assoc_req = NULL;
504 int ret = 0; 496 int ret = 0;
505 int find_any_ssid = 0; 497 int find_any_ssid = 0;
@@ -507,11 +499,11 @@ void lbs_association_worker(struct work_struct *work)
507 499
508 lbs_deb_enter(LBS_DEB_ASSOC); 500 lbs_deb_enter(LBS_DEB_ASSOC);
509 501
510 mutex_lock(&adapter->lock); 502 mutex_lock(&priv->lock);
511 assoc_req = adapter->pending_assoc_req; 503 assoc_req = priv->pending_assoc_req;
512 adapter->pending_assoc_req = NULL; 504 priv->pending_assoc_req = NULL;
513 adapter->in_progress_assoc_req = assoc_req; 505 priv->in_progress_assoc_req = assoc_req;
514 mutex_unlock(&adapter->lock); 506 mutex_unlock(&priv->lock);
515 507
516 if (!assoc_req) 508 if (!assoc_req)
517 goto done; 509 goto done;
@@ -569,8 +561,8 @@ void lbs_association_worker(struct work_struct *work)
569 * Check if the attributes being changing require deauthentication 561 * Check if the attributes being changing require deauthentication
570 * from the currently associated infrastructure access point. 562 * from the currently associated infrastructure access point.
571 */ 563 */
572 if (adapter->mode == IW_MODE_INFRA) { 564 if (priv->mode == IW_MODE_INFRA) {
573 if (should_deauth_infrastructure(adapter, assoc_req)) { 565 if (should_deauth_infrastructure(priv, assoc_req)) {
574 ret = lbs_send_deauthentication(priv); 566 ret = lbs_send_deauthentication(priv);
575 if (ret) { 567 if (ret) {
576 lbs_deb_assoc("Deauthentication due to new " 568 lbs_deb_assoc("Deauthentication due to new "
@@ -578,8 +570,8 @@ void lbs_association_worker(struct work_struct *work)
578 ret); 570 ret);
579 } 571 }
580 } 572 }
581 } else if (adapter->mode == IW_MODE_ADHOC) { 573 } else if (priv->mode == IW_MODE_ADHOC) {
582 if (should_stop_adhoc(adapter, assoc_req)) { 574 if (should_stop_adhoc(priv, assoc_req)) {
583 ret = lbs_stop_adhoc_network(priv); 575 ret = lbs_stop_adhoc_network(priv);
584 if (ret) { 576 if (ret) {
585 lbs_deb_assoc("Teardown of AdHoc network due to " 577 lbs_deb_assoc("Teardown of AdHoc network due to "
@@ -643,7 +635,7 @@ void lbs_association_worker(struct work_struct *work)
643 success = 0; 635 success = 0;
644 } 636 }
645 637
646 if (adapter->connect_status != LBS_CONNECTED) { 638 if (priv->connect_status != LBS_CONNECTED) {
647 lbs_deb_assoc("ASSOC: association unsuccessful, " 639 lbs_deb_assoc("ASSOC: association unsuccessful, "
648 "not connected\n"); 640 "not connected\n");
649 success = 0; 641 success = 0;
@@ -651,9 +643,9 @@ void lbs_association_worker(struct work_struct *work)
651 643
652 if (success) { 644 if (success) {
653 lbs_deb_assoc("ASSOC: associated to '%s', %s\n", 645 lbs_deb_assoc("ASSOC: associated to '%s', %s\n",
654 escape_essid(adapter->curbssparams.ssid, 646 escape_essid(priv->curbssparams.ssid,
655 adapter->curbssparams.ssid_len), 647 priv->curbssparams.ssid_len),
656 print_mac(mac, adapter->curbssparams.bssid)); 648 print_mac(mac, priv->curbssparams.bssid));
657 lbs_prepare_and_send_command(priv, 649 lbs_prepare_and_send_command(priv,
658 CMD_802_11_RSSI, 650 CMD_802_11_RSSI,
659 0, CMD_OPTION_WAITFORRSP, 0, NULL); 651 0, CMD_OPTION_WAITFORRSP, 0, NULL);
@@ -672,9 +664,9 @@ out:
672 ret); 664 ret);
673 } 665 }
674 666
675 mutex_lock(&adapter->lock); 667 mutex_lock(&priv->lock);
676 adapter->in_progress_assoc_req = NULL; 668 priv->in_progress_assoc_req = NULL;
677 mutex_unlock(&adapter->lock); 669 mutex_unlock(&priv->lock);
678 kfree(assoc_req); 670 kfree(assoc_req);
679 671
680done: 672done:
@@ -685,15 +677,15 @@ done:
685/* 677/*
686 * Caller MUST hold any necessary locks 678 * Caller MUST hold any necessary locks
687 */ 679 */
688struct assoc_request *lbs_get_association_request(struct lbs_adapter *adapter) 680struct assoc_request *lbs_get_association_request(struct lbs_private *priv)
689{ 681{
690 struct assoc_request * assoc_req; 682 struct assoc_request * assoc_req;
691 683
692 lbs_deb_enter(LBS_DEB_ASSOC); 684 lbs_deb_enter(LBS_DEB_ASSOC);
693 if (!adapter->pending_assoc_req) { 685 if (!priv->pending_assoc_req) {
694 adapter->pending_assoc_req = kzalloc(sizeof(struct assoc_request), 686 priv->pending_assoc_req = kzalloc(sizeof(struct assoc_request),
695 GFP_KERNEL); 687 GFP_KERNEL);
696 if (!adapter->pending_assoc_req) { 688 if (!priv->pending_assoc_req) {
697 lbs_pr_info("Not enough memory to allocate association" 689 lbs_pr_info("Not enough memory to allocate association"
698 " request!\n"); 690 " request!\n");
699 return NULL; 691 return NULL;
@@ -703,57 +695,57 @@ struct assoc_request *lbs_get_association_request(struct lbs_adapter *adapter)
703 /* Copy current configuration attributes to the association request, 695 /* Copy current configuration attributes to the association request,
704 * but don't overwrite any that are already set. 696 * but don't overwrite any that are already set.
705 */ 697 */
706 assoc_req = adapter->pending_assoc_req; 698 assoc_req = priv->pending_assoc_req;
707 if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) { 699 if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
708 memcpy(&assoc_req->ssid, &adapter->curbssparams.ssid, 700 memcpy(&assoc_req->ssid, &priv->curbssparams.ssid,
709 IW_ESSID_MAX_SIZE); 701 IW_ESSID_MAX_SIZE);
710 assoc_req->ssid_len = adapter->curbssparams.ssid_len; 702 assoc_req->ssid_len = priv->curbssparams.ssid_len;
711 } 703 }
712 704
713 if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) 705 if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
714 assoc_req->channel = adapter->curbssparams.channel; 706 assoc_req->channel = priv->curbssparams.channel;
715 707
716 if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags)) 708 if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags))
717 assoc_req->band = adapter->curbssparams.band; 709 assoc_req->band = priv->curbssparams.band;
718 710
719 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) 711 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
720 assoc_req->mode = adapter->mode; 712 assoc_req->mode = priv->mode;
721 713
722 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 714 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
723 memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, 715 memcpy(&assoc_req->bssid, priv->curbssparams.bssid,
724 ETH_ALEN); 716 ETH_ALEN);
725 } 717 }
726 718
727 if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) { 719 if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) {
728 int i; 720 int i;
729 for (i = 0; i < 4; i++) { 721 for (i = 0; i < 4; i++) {
730 memcpy(&assoc_req->wep_keys[i], &adapter->wep_keys[i], 722 memcpy(&assoc_req->wep_keys[i], &priv->wep_keys[i],
731 sizeof(struct enc_key)); 723 sizeof(struct enc_key));
732 } 724 }
733 } 725 }
734 726
735 if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) 727 if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags))
736 assoc_req->wep_tx_keyidx = adapter->wep_tx_keyidx; 728 assoc_req->wep_tx_keyidx = priv->wep_tx_keyidx;
737 729
738 if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { 730 if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
739 memcpy(&assoc_req->wpa_mcast_key, &adapter->wpa_mcast_key, 731 memcpy(&assoc_req->wpa_mcast_key, &priv->wpa_mcast_key,
740 sizeof(struct enc_key)); 732 sizeof(struct enc_key));
741 } 733 }
742 734
743 if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) { 735 if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
744 memcpy(&assoc_req->wpa_unicast_key, &adapter->wpa_unicast_key, 736 memcpy(&assoc_req->wpa_unicast_key, &priv->wpa_unicast_key,
745 sizeof(struct enc_key)); 737 sizeof(struct enc_key));
746 } 738 }
747 739
748 if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 740 if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
749 memcpy(&assoc_req->secinfo, &adapter->secinfo, 741 memcpy(&assoc_req->secinfo, &priv->secinfo,
750 sizeof(struct lbs_802_11_security)); 742 sizeof(struct lbs_802_11_security));
751 } 743 }
752 744
753 if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) { 745 if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) {
754 memcpy(&assoc_req->wpa_ie, &adapter->wpa_ie, 746 memcpy(&assoc_req->wpa_ie, &priv->wpa_ie,
755 MAX_WPA_IE_LEN); 747 MAX_WPA_IE_LEN);
756 assoc_req->wpa_ie_len = adapter->wpa_ie_len; 748 assoc_req->wpa_ie_len = priv->wpa_ie_len;
757 } 749 }
758 750
759 lbs_deb_leave(LBS_DEB_ASSOC); 751 lbs_deb_leave(LBS_DEB_ASSOC);
diff --git a/drivers/net/wireless/libertas/assoc.h b/drivers/net/wireless/libertas/assoc.h
index fad00ae0d00d..08372bbf3761 100644
--- a/drivers/net/wireless/libertas/assoc.h
+++ b/drivers/net/wireless/libertas/assoc.h
@@ -6,7 +6,7 @@
6#include "dev.h" 6#include "dev.h"
7 7
8void lbs_association_worker(struct work_struct *work); 8void lbs_association_worker(struct work_struct *work);
9struct assoc_request *lbs_get_association_request(struct lbs_adapter *adapter); 9struct assoc_request *lbs_get_association_request(struct lbs_private *priv);
10void lbs_sync_channel(struct work_struct *work); 10void lbs_sync_channel(struct work_struct *work);
11 11
12#endif /* _LBS_ASSOC_H */ 12#endif /* _LBS_ASSOC_H */
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 6838c9cd856e..49a9aeee2b6a 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -50,7 +50,7 @@ static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd)
50 50
51 cmd->command = cpu_to_le16(CMD_GET_HW_SPEC); 51 cmd->command = cpu_to_le16(CMD_GET_HW_SPEC);
52 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN); 52 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_get_hw_spec) + S_DS_GEN);
53 memcpy(hwspec->permanentaddr, priv->adapter->current_addr, ETH_ALEN); 53 memcpy(hwspec->permanentaddr, priv->current_addr, ETH_ALEN);
54 54
55 lbs_deb_leave(LBS_DEB_CMD); 55 lbs_deb_leave(LBS_DEB_CMD);
56 return 0; 56 return 0;
@@ -123,7 +123,6 @@ static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv,
123 struct cmd_ds_command *cmd, 123 struct cmd_ds_command *cmd,
124 u16 cmd_action) 124 u16 cmd_action)
125{ 125{
126 struct lbs_adapter *adapter = priv->adapter;
127 struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params; 126 struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params;
128 127
129 lbs_deb_enter(LBS_DEB_CMD); 128 lbs_deb_enter(LBS_DEB_CMD);
@@ -133,17 +132,17 @@ static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv,
133 cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS); 132 cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS);
134 133
135 if (cmd_action == CMD_ACT_GET) { 134 if (cmd_action == CMD_ACT_GET) {
136 memset(&adapter->sp, 0, sizeof(struct sleep_params)); 135 memset(&priv->sp, 0, sizeof(struct sleep_params));
137 memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params)); 136 memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params));
138 sp->action = cpu_to_le16(cmd_action); 137 sp->action = cpu_to_le16(cmd_action);
139 } else if (cmd_action == CMD_ACT_SET) { 138 } else if (cmd_action == CMD_ACT_SET) {
140 sp->action = cpu_to_le16(cmd_action); 139 sp->action = cpu_to_le16(cmd_action);
141 sp->error = cpu_to_le16(adapter->sp.sp_error); 140 sp->error = cpu_to_le16(priv->sp.sp_error);
142 sp->offset = cpu_to_le16(adapter->sp.sp_offset); 141 sp->offset = cpu_to_le16(priv->sp.sp_offset);
143 sp->stabletime = cpu_to_le16(adapter->sp.sp_stabletime); 142 sp->stabletime = cpu_to_le16(priv->sp.sp_stabletime);
144 sp->calcontrol = (u8) adapter->sp.sp_calcontrol; 143 sp->calcontrol = (u8) priv->sp.sp_calcontrol;
145 sp->externalsleepclk = (u8) adapter->sp.sp_extsleepclk; 144 sp->externalsleepclk = (u8) priv->sp.sp_extsleepclk;
146 sp->reserved = cpu_to_le16(adapter->sp.sp_reserved); 145 sp->reserved = cpu_to_le16(priv->sp.sp_reserved);
147 } 146 }
148 147
149 lbs_deb_leave(LBS_DEB_CMD); 148 lbs_deb_leave(LBS_DEB_CMD);
@@ -156,7 +155,6 @@ static int lbs_cmd_802_11_set_wep(struct lbs_private *priv,
156 void * pdata_buf) 155 void * pdata_buf)
157{ 156{
158 struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep; 157 struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep;
159 struct lbs_adapter *adapter = priv->adapter;
160 int ret = 0; 158 int ret = 0;
161 struct assoc_request * assoc_req = pdata_buf; 159 struct assoc_request * assoc_req = pdata_buf;
162 160
@@ -212,9 +210,9 @@ static int lbs_cmd_802_11_set_wep(struct lbs_private *priv,
212 wep->action = cpu_to_le16(CMD_ACT_REMOVE); 210 wep->action = cpu_to_le16(CMD_ACT_REMOVE);
213 211
214 /* default tx key index */ 212 /* default tx key index */
215 wep->keyindex = cpu_to_le16((u16)(adapter->wep_tx_keyidx & 213 wep->keyindex = cpu_to_le16((u16)(priv->wep_tx_keyidx &
216 (u32)CMD_WEP_KEY_INDEX_MASK)); 214 (u32)CMD_WEP_KEY_INDEX_MASK));
217 lbs_deb_cmd("SET_WEP: remove key %d\n", adapter->wep_tx_keyidx); 215 lbs_deb_cmd("SET_WEP: remove key %d\n", priv->wep_tx_keyidx);
218 } 216 }
219 217
220 ret = 0; 218 ret = 0;
@@ -415,7 +413,6 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
415 int cmd_oid, void *pdata_buf) 413 int cmd_oid, void *pdata_buf)
416{ 414{
417 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib; 415 struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib;
418 struct lbs_adapter *adapter = priv->adapter;
419 u8 ucTemp; 416 u8 ucTemp;
420 417
421 lbs_deb_enter(LBS_DEB_CMD); 418 lbs_deb_enter(LBS_DEB_CMD);
@@ -507,7 +504,7 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
507 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET); 504 pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
508 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16)); 505 pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
509 *((__le16 *)(pSNMPMIB->value)) = 506 *((__le16 *)(pSNMPMIB->value)) =
510 cpu_to_le16((u16) adapter->txretrycount); 507 cpu_to_le16((u16) priv->txretrycount);
511 } 508 }
512 509
513 break; 510 break;
@@ -534,7 +531,6 @@ static int lbs_cmd_802_11_radio_control(struct lbs_private *priv,
534 struct cmd_ds_command *cmd, 531 struct cmd_ds_command *cmd,
535 int cmd_action) 532 int cmd_action)
536{ 533{
537 struct lbs_adapter *adapter = priv->adapter;
538 struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio; 534 struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio;
539 535
540 lbs_deb_enter(LBS_DEB_CMD); 536 lbs_deb_enter(LBS_DEB_CMD);
@@ -546,7 +542,7 @@ static int lbs_cmd_802_11_radio_control(struct lbs_private *priv,
546 542
547 pradiocontrol->action = cpu_to_le16(cmd_action); 543 pradiocontrol->action = cpu_to_le16(cmd_action);
548 544
549 switch (adapter->preamble) { 545 switch (priv->preamble) {
550 case CMD_TYPE_SHORT_PREAMBLE: 546 case CMD_TYPE_SHORT_PREAMBLE:
551 pradiocontrol->control = cpu_to_le16(SET_SHORT_PREAMBLE); 547 pradiocontrol->control = cpu_to_le16(SET_SHORT_PREAMBLE);
552 break; 548 break;
@@ -561,7 +557,7 @@ static int lbs_cmd_802_11_radio_control(struct lbs_private *priv,
561 break; 557 break;
562 } 558 }
563 559
564 if (adapter->radioon) 560 if (priv->radioon)
565 pradiocontrol->control |= cpu_to_le16(TURN_ON_RF); 561 pradiocontrol->control |= cpu_to_le16(TURN_ON_RF);
566 else 562 else
567 pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF); 563 pradiocontrol->control &= cpu_to_le16(~TURN_ON_RF);
@@ -640,7 +636,6 @@ static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv,
640{ 636{
641 struct cmd_ds_802_11_rate_adapt_rateset 637 struct cmd_ds_802_11_rate_adapt_rateset
642 *rateadapt = &cmd->params.rateset; 638 *rateadapt = &cmd->params.rateset;
643 struct lbs_adapter *adapter = priv->adapter;
644 639
645 lbs_deb_enter(LBS_DEB_CMD); 640 lbs_deb_enter(LBS_DEB_CMD);
646 cmd->size = 641 cmd->size =
@@ -649,8 +644,8 @@ static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv,
649 cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET); 644 cmd->command = cpu_to_le16(CMD_802_11_RATE_ADAPT_RATESET);
650 645
651 rateadapt->action = cpu_to_le16(cmd_action); 646 rateadapt->action = cpu_to_le16(cmd_action);
652 rateadapt->enablehwauto = cpu_to_le16(adapter->enablehwauto); 647 rateadapt->enablehwauto = cpu_to_le16(priv->enablehwauto);
653 rateadapt->bitmap = cpu_to_le16(adapter->ratebitmap); 648 rateadapt->bitmap = cpu_to_le16(priv->ratebitmap);
654 649
655 lbs_deb_leave(LBS_DEB_CMD); 650 lbs_deb_leave(LBS_DEB_CMD);
656 return 0; 651 return 0;
@@ -661,7 +656,6 @@ static int lbs_cmd_802_11_data_rate(struct lbs_private *priv,
661 u16 cmd_action) 656 u16 cmd_action)
662{ 657{
663 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate; 658 struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate;
664 struct lbs_adapter *adapter = priv->adapter;
665 659
666 lbs_deb_enter(LBS_DEB_CMD); 660 lbs_deb_enter(LBS_DEB_CMD);
667 661
@@ -672,9 +666,9 @@ static int lbs_cmd_802_11_data_rate(struct lbs_private *priv,
672 pdatarate->action = cpu_to_le16(cmd_action); 666 pdatarate->action = cpu_to_le16(cmd_action);
673 667
674 if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) { 668 if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) {
675 pdatarate->rates[0] = lbs_data_rate_to_fw_index(adapter->cur_rate); 669 pdatarate->rates[0] = lbs_data_rate_to_fw_index(priv->cur_rate);
676 lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n", 670 lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n",
677 adapter->cur_rate); 671 priv->cur_rate);
678 } else if (cmd_action == CMD_ACT_SET_TX_AUTO) { 672 } else if (cmd_action == CMD_ACT_SET_TX_AUTO) {
679 lbs_deb_cmd("DATA_RATE: setting auto\n"); 673 lbs_deb_cmd("DATA_RATE: setting auto\n");
680 } 674 }
@@ -688,7 +682,6 @@ static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv,
688 u16 cmd_action) 682 u16 cmd_action)
689{ 683{
690 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr; 684 struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr;
691 struct lbs_adapter *adapter = priv->adapter;
692 685
693 lbs_deb_enter(LBS_DEB_CMD); 686 lbs_deb_enter(LBS_DEB_CMD);
694 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) + 687 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
@@ -698,9 +691,9 @@ static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv,
698 lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs); 691 lbs_deb_cmd("MULTICAST_ADR: setting %d addresses\n", pMCastAdr->nr_of_adrs);
699 pMCastAdr->action = cpu_to_le16(cmd_action); 692 pMCastAdr->action = cpu_to_le16(cmd_action);
700 pMCastAdr->nr_of_adrs = 693 pMCastAdr->nr_of_adrs =
701 cpu_to_le16((u16) adapter->nr_of_multicastmacaddr); 694 cpu_to_le16((u16) priv->nr_of_multicastmacaddr);
702 memcpy(pMCastAdr->maclist, adapter->multicastlist, 695 memcpy(pMCastAdr->maclist, priv->multicastlist,
703 adapter->nr_of_multicastmacaddr * ETH_ALEN); 696 priv->nr_of_multicastmacaddr * ETH_ALEN);
704 697
705 lbs_deb_leave(LBS_DEB_CMD); 698 lbs_deb_leave(LBS_DEB_CMD);
706 return 0; 699 return 0;
@@ -730,7 +723,6 @@ static int lbs_cmd_802_11_rf_channel(struct lbs_private *priv,
730static int lbs_cmd_802_11_rssi(struct lbs_private *priv, 723static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
731 struct cmd_ds_command *cmd) 724 struct cmd_ds_command *cmd)
732{ 725{
733 struct lbs_adapter *adapter = priv->adapter;
734 726
735 lbs_deb_enter(LBS_DEB_CMD); 727 lbs_deb_enter(LBS_DEB_CMD);
736 cmd->command = cpu_to_le16(CMD_802_11_RSSI); 728 cmd->command = cpu_to_le16(CMD_802_11_RSSI);
@@ -738,12 +730,12 @@ static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
738 cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR); 730 cmd->params.rssi.N = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR);
739 731
740 /* reset Beacon SNR/NF/RSSI values */ 732 /* reset Beacon SNR/NF/RSSI values */
741 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = 0; 733 priv->SNR[TYPE_BEACON][TYPE_NOAVG] = 0;
742 adapter->SNR[TYPE_BEACON][TYPE_AVG] = 0; 734 priv->SNR[TYPE_BEACON][TYPE_AVG] = 0;
743 adapter->NF[TYPE_BEACON][TYPE_NOAVG] = 0; 735 priv->NF[TYPE_BEACON][TYPE_NOAVG] = 0;
744 adapter->NF[TYPE_BEACON][TYPE_AVG] = 0; 736 priv->NF[TYPE_BEACON][TYPE_AVG] = 0;
745 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0; 737 priv->RSSI[TYPE_BEACON][TYPE_NOAVG] = 0;
746 adapter->RSSI[TYPE_BEACON][TYPE_AVG] = 0; 738 priv->RSSI[TYPE_BEACON][TYPE_AVG] = 0;
747 739
748 lbs_deb_leave(LBS_DEB_CMD); 740 lbs_deb_leave(LBS_DEB_CMD);
749 return 0; 741 return 0;
@@ -828,7 +820,6 @@ static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
828 struct cmd_ds_command *cmd, 820 struct cmd_ds_command *cmd,
829 u16 cmd_action) 821 u16 cmd_action)
830{ 822{
831 struct lbs_adapter *adapter = priv->adapter;
832 823
833 lbs_deb_enter(LBS_DEB_CMD); 824 lbs_deb_enter(LBS_DEB_CMD);
834 cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS); 825 cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS);
@@ -840,8 +831,8 @@ static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
840 831
841 if (cmd_action == CMD_ACT_SET) { 832 if (cmd_action == CMD_ACT_SET) {
842 memcpy(cmd->params.macadd.macadd, 833 memcpy(cmd->params.macadd.macadd,
843 adapter->current_addr, ETH_ALEN); 834 priv->current_addr, ETH_ALEN);
844 lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", adapter->current_addr, 6); 835 lbs_deb_hex(LBS_DEB_CMD, "SET_CMD: MAC addr", priv->current_addr, 6);
845 } 836 }
846 837
847 lbs_deb_leave(LBS_DEB_CMD); 838 lbs_deb_leave(LBS_DEB_CMD);
@@ -958,7 +949,6 @@ static int lbs_cmd_bcn_ctrl(struct lbs_private * priv,
958{ 949{
959 struct cmd_ds_802_11_beacon_control 950 struct cmd_ds_802_11_beacon_control
960 *bcn_ctrl = &cmd->params.bcn_ctrl; 951 *bcn_ctrl = &cmd->params.bcn_ctrl;
961 struct lbs_adapter *adapter = priv->adapter;
962 952
963 lbs_deb_enter(LBS_DEB_CMD); 953 lbs_deb_enter(LBS_DEB_CMD);
964 cmd->size = 954 cmd->size =
@@ -967,8 +957,8 @@ static int lbs_cmd_bcn_ctrl(struct lbs_private * priv,
967 cmd->command = cpu_to_le16(CMD_802_11_BEACON_CTRL); 957 cmd->command = cpu_to_le16(CMD_802_11_BEACON_CTRL);
968 958
969 bcn_ctrl->action = cpu_to_le16(cmd_action); 959 bcn_ctrl->action = cpu_to_le16(cmd_action);
970 bcn_ctrl->beacon_enable = cpu_to_le16(adapter->beacon_enable); 960 bcn_ctrl->beacon_enable = cpu_to_le16(priv->beacon_enable);
971 bcn_ctrl->beacon_period = cpu_to_le16(adapter->beacon_period); 961 bcn_ctrl->beacon_period = cpu_to_le16(priv->beacon_period);
972 962
973 lbs_deb_leave(LBS_DEB_CMD); 963 lbs_deb_leave(LBS_DEB_CMD);
974 return 0; 964 return 0;
@@ -978,7 +968,7 @@ static int lbs_cmd_bcn_ctrl(struct lbs_private * priv,
978 * Note: NEVER use lbs_queue_cmd() with addtail==0 other than for 968 * Note: NEVER use lbs_queue_cmd() with addtail==0 other than for
979 * the command timer, because it does not account for queued commands. 969 * the command timer, because it does not account for queued commands.
980 */ 970 */
981void lbs_queue_cmd(struct lbs_adapter *adapter, 971void lbs_queue_cmd(struct lbs_private *priv,
982 struct cmd_ctrl_node *cmdnode, 972 struct cmd_ctrl_node *cmdnode,
983 u8 addtail) 973 u8 addtail)
984{ 974{
@@ -1002,19 +992,19 @@ void lbs_queue_cmd(struct lbs_adapter *adapter,
1002 if (le16_to_cpu(cmdptr->command) == CMD_802_11_PS_MODE) { 992 if (le16_to_cpu(cmdptr->command) == CMD_802_11_PS_MODE) {
1003 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode; 993 struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
1004 if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) { 994 if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
1005 if (adapter->psstate != PS_STATE_FULL_POWER) 995 if (priv->psstate != PS_STATE_FULL_POWER)
1006 addtail = 0; 996 addtail = 0;
1007 } 997 }
1008 } 998 }
1009 999
1010 spin_lock_irqsave(&adapter->driver_lock, flags); 1000 spin_lock_irqsave(&priv->driver_lock, flags);
1011 1001
1012 if (addtail) 1002 if (addtail)
1013 list_add_tail(&cmdnode->list, &adapter->cmdpendingq); 1003 list_add_tail(&cmdnode->list, &priv->cmdpendingq);
1014 else 1004 else
1015 list_add(&cmdnode->list, &adapter->cmdpendingq); 1005 list_add(&cmdnode->list, &priv->cmdpendingq);
1016 1006
1017 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1007 spin_unlock_irqrestore(&priv->driver_lock, flags);
1018 1008
1019 lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n", 1009 lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n",
1020 le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command)); 1010 le16_to_cpu(((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command));
@@ -1035,31 +1025,30 @@ static int DownloadcommandToStation(struct lbs_private *priv,
1035{ 1025{
1036 unsigned long flags; 1026 unsigned long flags;
1037 struct cmd_ds_command *cmdptr; 1027 struct cmd_ds_command *cmdptr;
1038 struct lbs_adapter *adapter = priv->adapter;
1039 int ret = -1; 1028 int ret = -1;
1040 u16 cmdsize; 1029 u16 cmdsize;
1041 u16 command; 1030 u16 command;
1042 1031
1043 lbs_deb_enter(LBS_DEB_HOST); 1032 lbs_deb_enter(LBS_DEB_HOST);
1044 1033
1045 if (!adapter || !cmdnode) { 1034 if (!priv || !cmdnode) {
1046 lbs_deb_host("DNLD_CMD: adapter or cmdmode is NULL\n"); 1035 lbs_deb_host("DNLD_CMD: priv or cmdmode is NULL\n");
1047 goto done; 1036 goto done;
1048 } 1037 }
1049 1038
1050 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1039 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1051 1040
1052 spin_lock_irqsave(&adapter->driver_lock, flags); 1041 spin_lock_irqsave(&priv->driver_lock, flags);
1053 if (!cmdptr || !cmdptr->size) { 1042 if (!cmdptr || !cmdptr->size) {
1054 lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n"); 1043 lbs_deb_host("DNLD_CMD: cmdptr is NULL or zero\n");
1055 __lbs_cleanup_and_insert_cmd(priv, cmdnode); 1044 __lbs_cleanup_and_insert_cmd(priv, cmdnode);
1056 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1045 spin_unlock_irqrestore(&priv->driver_lock, flags);
1057 goto done; 1046 goto done;
1058 } 1047 }
1059 1048
1060 adapter->cur_cmd = cmdnode; 1049 priv->cur_cmd = cmdnode;
1061 adapter->cur_cmd_retcode = 0; 1050 priv->cur_cmd_retcode = 0;
1062 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1051 spin_unlock_irqrestore(&priv->driver_lock, flags);
1063 1052
1064 cmdsize = le16_to_cpu(cmdptr->size); 1053 cmdsize = le16_to_cpu(cmdptr->size);
1065 command = le16_to_cpu(cmdptr->command); 1054 command = le16_to_cpu(cmdptr->command);
@@ -1074,11 +1063,11 @@ static int DownloadcommandToStation(struct lbs_private *priv,
1074 1063
1075 if (ret != 0) { 1064 if (ret != 0) {
1076 lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n"); 1065 lbs_deb_host("DNLD_CMD: hw_host_to_card failed\n");
1077 spin_lock_irqsave(&adapter->driver_lock, flags); 1066 spin_lock_irqsave(&priv->driver_lock, flags);
1078 adapter->cur_cmd_retcode = ret; 1067 priv->cur_cmd_retcode = ret;
1079 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 1068 __lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
1080 adapter->cur_cmd = NULL; 1069 priv->cur_cmd = NULL;
1081 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1070 spin_unlock_irqrestore(&priv->driver_lock, flags);
1082 goto done; 1071 goto done;
1083 } 1072 }
1084 1073
@@ -1087,9 +1076,9 @@ static int DownloadcommandToStation(struct lbs_private *priv,
1087 /* Setup the timer after transmit command */ 1076 /* Setup the timer after transmit command */
1088 if (command == CMD_802_11_SCAN || command == CMD_802_11_AUTHENTICATE 1077 if (command == CMD_802_11_SCAN || command == CMD_802_11_AUTHENTICATE
1089 || command == CMD_802_11_ASSOCIATE) 1078 || command == CMD_802_11_ASSOCIATE)
1090 mod_timer(&adapter->command_timer, jiffies + (10*HZ)); 1079 mod_timer(&priv->command_timer, jiffies + (10*HZ));
1091 else 1080 else
1092 mod_timer(&adapter->command_timer, jiffies + (5*HZ)); 1081 mod_timer(&priv->command_timer, jiffies + (5*HZ));
1093 1082
1094 ret = 0; 1083 ret = 0;
1095 1084
@@ -1107,7 +1096,7 @@ static int lbs_cmd_mac_control(struct lbs_private *priv,
1107 1096
1108 cmd->command = cpu_to_le16(CMD_MAC_CONTROL); 1097 cmd->command = cpu_to_le16(CMD_MAC_CONTROL);
1109 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN); 1098 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_control) + S_DS_GEN);
1110 mac->action = cpu_to_le16(priv->adapter->currentpacketfilter); 1099 mac->action = cpu_to_le16(priv->currentpacketfilter);
1111 1100
1112 lbs_deb_cmd("MAC_CONTROL: action 0x%x, size %d\n", 1101 lbs_deb_cmd("MAC_CONTROL: action 0x%x, size %d\n",
1113 le16_to_cpu(mac->action), le16_to_cpu(cmd->size)); 1102 le16_to_cpu(mac->action), le16_to_cpu(cmd->size));
@@ -1118,18 +1107,17 @@ static int lbs_cmd_mac_control(struct lbs_private *priv,
1118 1107
1119/** 1108/**
1120 * This function inserts command node to cmdfreeq 1109 * This function inserts command node to cmdfreeq
1121 * after cleans it. Requires adapter->driver_lock held. 1110 * after cleans it. Requires priv->driver_lock held.
1122 */ 1111 */
1123void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv, 1112void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
1124 struct cmd_ctrl_node *ptempcmd) 1113 struct cmd_ctrl_node *ptempcmd)
1125{ 1114{
1126 struct lbs_adapter *adapter = priv->adapter;
1127 1115
1128 if (!ptempcmd) 1116 if (!ptempcmd)
1129 return; 1117 return;
1130 1118
1131 cleanup_cmdnode(ptempcmd); 1119 cleanup_cmdnode(ptempcmd);
1132 list_add_tail(&ptempcmd->list, &adapter->cmdfreeq); 1120 list_add_tail(&ptempcmd->list, &priv->cmdfreeq);
1133} 1121}
1134 1122
1135static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv, 1123static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
@@ -1137,9 +1125,9 @@ static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
1137{ 1125{
1138 unsigned long flags; 1126 unsigned long flags;
1139 1127
1140 spin_lock_irqsave(&priv->adapter->driver_lock, flags); 1128 spin_lock_irqsave(&priv->driver_lock, flags);
1141 __lbs_cleanup_and_insert_cmd(priv, ptempcmd); 1129 __lbs_cleanup_and_insert_cmd(priv, ptempcmd);
1142 spin_unlock_irqrestore(&priv->adapter->driver_lock, flags); 1130 spin_unlock_irqrestore(&priv->driver_lock, flags);
1143} 1131}
1144 1132
1145int lbs_set_radio_control(struct lbs_private *priv) 1133int lbs_set_radio_control(struct lbs_private *priv)
@@ -1154,7 +1142,7 @@ int lbs_set_radio_control(struct lbs_private *priv)
1154 CMD_OPTION_WAITFORRSP, 0, NULL); 1142 CMD_OPTION_WAITFORRSP, 0, NULL);
1155 1143
1156 lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n", 1144 lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n",
1157 priv->adapter->radioon, priv->adapter->preamble); 1145 priv->radioon, priv->preamble);
1158 1146
1159 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1147 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
1160 return ret; 1148 return ret;
@@ -1191,20 +1179,19 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1191 u16 wait_option, u32 cmd_oid, void *pdata_buf) 1179 u16 wait_option, u32 cmd_oid, void *pdata_buf)
1192{ 1180{
1193 int ret = 0; 1181 int ret = 0;
1194 struct lbs_adapter *adapter = priv->adapter;
1195 struct cmd_ctrl_node *cmdnode; 1182 struct cmd_ctrl_node *cmdnode;
1196 struct cmd_ds_command *cmdptr; 1183 struct cmd_ds_command *cmdptr;
1197 unsigned long flags; 1184 unsigned long flags;
1198 1185
1199 lbs_deb_enter(LBS_DEB_HOST); 1186 lbs_deb_enter(LBS_DEB_HOST);
1200 1187
1201 if (!adapter) { 1188 if (!priv) {
1202 lbs_deb_host("PREP_CMD: adapter is NULL\n"); 1189 lbs_deb_host("PREP_CMD: priv is NULL\n");
1203 ret = -1; 1190 ret = -1;
1204 goto done; 1191 goto done;
1205 } 1192 }
1206 1193
1207 if (adapter->surpriseremoved) { 1194 if (priv->surpriseremoved) {
1208 lbs_deb_host("PREP_CMD: card removed\n"); 1195 lbs_deb_host("PREP_CMD: card removed\n");
1209 ret = -1; 1196 ret = -1;
1210 goto done; 1197 goto done;
@@ -1235,8 +1222,8 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1235 } 1222 }
1236 1223
1237 /* Set sequence number, command and INT option */ 1224 /* Set sequence number, command and INT option */
1238 adapter->seqnum++; 1225 priv->seqnum++;
1239 cmdptr->seqnum = cpu_to_le16(adapter->seqnum); 1226 cmdptr->seqnum = cpu_to_le16(priv->seqnum);
1240 1227
1241 cmdptr->command = cpu_to_le16(cmd_no); 1228 cmdptr->command = cpu_to_le16(cmd_no);
1242 cmdptr->result = 0; 1229 cmdptr->result = 0;
@@ -1482,7 +1469,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1482 1469
1483 cmdnode->cmdwaitqwoken = 0; 1470 cmdnode->cmdwaitqwoken = 0;
1484 1471
1485 lbs_queue_cmd(adapter, cmdnode, 1); 1472 lbs_queue_cmd(priv, cmdnode, 1);
1486 wake_up_interruptible(&priv->waitq); 1473 wake_up_interruptible(&priv->waitq);
1487 1474
1488 if (wait_option & CMD_OPTION_WAITFORRSP) { 1475 if (wait_option & CMD_OPTION_WAITFORRSP) {
@@ -1492,14 +1479,14 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
1492 cmdnode->cmdwaitqwoken); 1479 cmdnode->cmdwaitqwoken);
1493 } 1480 }
1494 1481
1495 spin_lock_irqsave(&adapter->driver_lock, flags); 1482 spin_lock_irqsave(&priv->driver_lock, flags);
1496 if (adapter->cur_cmd_retcode) { 1483 if (priv->cur_cmd_retcode) {
1497 lbs_deb_host("PREP_CMD: command failed with return code %d\n", 1484 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
1498 adapter->cur_cmd_retcode); 1485 priv->cur_cmd_retcode);
1499 adapter->cur_cmd_retcode = 0; 1486 priv->cur_cmd_retcode = 0;
1500 ret = -1; 1487 ret = -1;
1501 } 1488 }
1502 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1489 spin_unlock_irqrestore(&priv->driver_lock, flags);
1503 1490
1504done: 1491done:
1505 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); 1492 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
@@ -1521,7 +1508,6 @@ int lbs_allocate_cmd_buffer(struct lbs_private *priv)
1521 u32 i; 1508 u32 i;
1522 struct cmd_ctrl_node *tempcmd_array; 1509 struct cmd_ctrl_node *tempcmd_array;
1523 u8 *ptempvirtualaddr; 1510 u8 *ptempvirtualaddr;
1524 struct lbs_adapter *adapter = priv->adapter;
1525 1511
1526 lbs_deb_enter(LBS_DEB_HOST); 1512 lbs_deb_enter(LBS_DEB_HOST);
1527 1513
@@ -1533,7 +1519,7 @@ int lbs_allocate_cmd_buffer(struct lbs_private *priv)
1533 ret = -1; 1519 ret = -1;
1534 goto done; 1520 goto done;
1535 } 1521 }
1536 adapter->cmd_array = tempcmd_array; 1522 priv->cmd_array = tempcmd_array;
1537 1523
1538 /* Allocate and initialize command buffers */ 1524 /* Allocate and initialize command buffers */
1539 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; 1525 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
@@ -1571,17 +1557,16 @@ int lbs_free_cmd_buffer(struct lbs_private *priv)
1571 u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */ 1557 u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
1572 unsigned int i; 1558 unsigned int i;
1573 struct cmd_ctrl_node *tempcmd_array; 1559 struct cmd_ctrl_node *tempcmd_array;
1574 struct lbs_adapter *adapter = priv->adapter;
1575 1560
1576 lbs_deb_enter(LBS_DEB_HOST); 1561 lbs_deb_enter(LBS_DEB_HOST);
1577 1562
1578 /* need to check if cmd array is allocated or not */ 1563 /* need to check if cmd array is allocated or not */
1579 if (adapter->cmd_array == NULL) { 1564 if (priv->cmd_array == NULL) {
1580 lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n"); 1565 lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n");
1581 goto done; 1566 goto done;
1582 } 1567 }
1583 1568
1584 tempcmd_array = adapter->cmd_array; 1569 tempcmd_array = priv->cmd_array;
1585 1570
1586 /* Release shared memory buffers */ 1571 /* Release shared memory buffers */
1587 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER; 1572 ulbufsize = MRVDRV_SIZE_OF_CMD_BUFFER;
@@ -1593,9 +1578,9 @@ int lbs_free_cmd_buffer(struct lbs_private *priv)
1593 } 1578 }
1594 1579
1595 /* Release cmd_ctrl_node */ 1580 /* Release cmd_ctrl_node */
1596 if (adapter->cmd_array) { 1581 if (priv->cmd_array) {
1597 kfree(adapter->cmd_array); 1582 kfree(priv->cmd_array);
1598 adapter->cmd_array = NULL; 1583 priv->cmd_array = NULL;
1599 } 1584 }
1600 1585
1601done: 1586done:
@@ -1613,18 +1598,17 @@ done:
1613struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv) 1598struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
1614{ 1599{
1615 struct cmd_ctrl_node *tempnode; 1600 struct cmd_ctrl_node *tempnode;
1616 struct lbs_adapter *adapter = priv->adapter;
1617 unsigned long flags; 1601 unsigned long flags;
1618 1602
1619 lbs_deb_enter(LBS_DEB_HOST); 1603 lbs_deb_enter(LBS_DEB_HOST);
1620 1604
1621 if (!adapter) 1605 if (!priv)
1622 return NULL; 1606 return NULL;
1623 1607
1624 spin_lock_irqsave(&adapter->driver_lock, flags); 1608 spin_lock_irqsave(&priv->driver_lock, flags);
1625 1609
1626 if (!list_empty(&adapter->cmdfreeq)) { 1610 if (!list_empty(&priv->cmdfreeq)) {
1627 tempnode = list_first_entry(&adapter->cmdfreeq, 1611 tempnode = list_first_entry(&priv->cmdfreeq,
1628 struct cmd_ctrl_node, list); 1612 struct cmd_ctrl_node, list);
1629 list_del(&tempnode->list); 1613 list_del(&tempnode->list);
1630 } else { 1614 } else {
@@ -1632,7 +1616,7 @@ struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
1632 tempnode = NULL; 1616 tempnode = NULL;
1633 } 1617 }
1634 1618
1635 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1619 spin_unlock_irqrestore(&priv->driver_lock, flags);
1636 1620
1637 if (tempnode) 1621 if (tempnode)
1638 cleanup_cmdnode(tempnode); 1622 cleanup_cmdnode(tempnode);
@@ -1700,7 +1684,6 @@ void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
1700 */ 1684 */
1701int lbs_execute_next_command(struct lbs_private *priv) 1685int lbs_execute_next_command(struct lbs_private *priv)
1702{ 1686{
1703 struct lbs_adapter *adapter = priv->adapter;
1704 struct cmd_ctrl_node *cmdnode = NULL; 1687 struct cmd_ctrl_node *cmdnode = NULL;
1705 struct cmd_ds_command *cmdptr; 1688 struct cmd_ds_command *cmdptr;
1706 unsigned long flags; 1689 unsigned long flags;
@@ -1711,40 +1694,40 @@ int lbs_execute_next_command(struct lbs_private *priv)
1711 // data packet is received 1694 // data packet is received
1712 lbs_deb_enter(LBS_DEB_THREAD); 1695 lbs_deb_enter(LBS_DEB_THREAD);
1713 1696
1714 spin_lock_irqsave(&adapter->driver_lock, flags); 1697 spin_lock_irqsave(&priv->driver_lock, flags);
1715 1698
1716 if (adapter->cur_cmd) { 1699 if (priv->cur_cmd) {
1717 lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n"); 1700 lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
1718 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1701 spin_unlock_irqrestore(&priv->driver_lock, flags);
1719 ret = -1; 1702 ret = -1;
1720 goto done; 1703 goto done;
1721 } 1704 }
1722 1705
1723 if (!list_empty(&adapter->cmdpendingq)) { 1706 if (!list_empty(&priv->cmdpendingq)) {
1724 cmdnode = list_first_entry(&adapter->cmdpendingq, 1707 cmdnode = list_first_entry(&priv->cmdpendingq,
1725 struct cmd_ctrl_node, list); 1708 struct cmd_ctrl_node, list);
1726 } 1709 }
1727 1710
1728 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1711 spin_unlock_irqrestore(&priv->driver_lock, flags);
1729 1712
1730 if (cmdnode) { 1713 if (cmdnode) {
1731 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1714 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1732 1715
1733 if (is_command_allowed_in_ps(cmdptr->command)) { 1716 if (is_command_allowed_in_ps(cmdptr->command)) {
1734 if ((adapter->psstate == PS_STATE_SLEEP) || 1717 if ((priv->psstate == PS_STATE_SLEEP) ||
1735 (adapter->psstate == PS_STATE_PRE_SLEEP)) { 1718 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1736 lbs_deb_host( 1719 lbs_deb_host(
1737 "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n", 1720 "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n",
1738 le16_to_cpu(cmdptr->command), 1721 le16_to_cpu(cmdptr->command),
1739 adapter->psstate); 1722 priv->psstate);
1740 ret = -1; 1723 ret = -1;
1741 goto done; 1724 goto done;
1742 } 1725 }
1743 lbs_deb_host("EXEC_NEXT_CMD: OK to send command " 1726 lbs_deb_host("EXEC_NEXT_CMD: OK to send command "
1744 "0x%04x in psstate %d\n", 1727 "0x%04x in psstate %d\n",
1745 le16_to_cpu(cmdptr->command), 1728 le16_to_cpu(cmdptr->command),
1746 adapter->psstate); 1729 priv->psstate);
1747 } else if (adapter->psstate != PS_STATE_FULL_POWER) { 1730 } else if (priv->psstate != PS_STATE_FULL_POWER) {
1748 /* 1731 /*
1749 * 1. Non-PS command: 1732 * 1. Non-PS command:
1750 * Queue it. set needtowakeup to TRUE if current state 1733 * Queue it. set needtowakeup to TRUE if current state
@@ -1760,12 +1743,12 @@ int lbs_execute_next_command(struct lbs_private *priv)
1760 cpu_to_le16(CMD_802_11_PS_MODE)) { 1743 cpu_to_le16(CMD_802_11_PS_MODE)) {
1761 /* Prepare to send Exit PS, 1744 /* Prepare to send Exit PS,
1762 * this non PS command will be sent later */ 1745 * this non PS command will be sent later */
1763 if ((adapter->psstate == PS_STATE_SLEEP) 1746 if ((priv->psstate == PS_STATE_SLEEP)
1764 || (adapter->psstate == PS_STATE_PRE_SLEEP) 1747 || (priv->psstate == PS_STATE_PRE_SLEEP)
1765 ) { 1748 ) {
1766 /* w/ new scheme, it will not reach here. 1749 /* w/ new scheme, it will not reach here.
1767 since it is blocked in main_thread. */ 1750 since it is blocked in main_thread. */
1768 adapter->needtowakeup = 1; 1751 priv->needtowakeup = 1;
1769 } else 1752 } else
1770 lbs_ps_wakeup(priv, 0); 1753 lbs_ps_wakeup(priv, 0);
1771 1754
@@ -1793,13 +1776,13 @@ int lbs_execute_next_command(struct lbs_private *priv)
1793 goto done; 1776 goto done;
1794 } 1777 }
1795 1778
1796 if ((adapter->psstate == PS_STATE_SLEEP) || 1779 if ((priv->psstate == PS_STATE_SLEEP) ||
1797 (adapter->psstate == PS_STATE_PRE_SLEEP)) { 1780 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1798 lbs_deb_host( 1781 lbs_deb_host(
1799 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); 1782 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
1800 list_del(&cmdnode->list); 1783 list_del(&cmdnode->list);
1801 lbs_cleanup_and_insert_cmd(priv, cmdnode); 1784 lbs_cleanup_and_insert_cmd(priv, cmdnode);
1802 adapter->needtowakeup = 1; 1785 priv->needtowakeup = 1;
1803 1786
1804 ret = 0; 1787 ret = 0;
1805 goto done; 1788 goto done;
@@ -1818,15 +1801,15 @@ int lbs_execute_next_command(struct lbs_private *priv)
1818 * check if in power save mode, if yes, put the device back 1801 * check if in power save mode, if yes, put the device back
1819 * to PS mode 1802 * to PS mode
1820 */ 1803 */
1821 if ((adapter->psmode != LBS802_11POWERMODECAM) && 1804 if ((priv->psmode != LBS802_11POWERMODECAM) &&
1822 (adapter->psstate == PS_STATE_FULL_POWER) && 1805 (priv->psstate == PS_STATE_FULL_POWER) &&
1823 ((adapter->connect_status == LBS_CONNECTED) || 1806 ((priv->connect_status == LBS_CONNECTED) ||
1824 (adapter->mesh_connect_status == LBS_CONNECTED))) { 1807 (priv->mesh_connect_status == LBS_CONNECTED))) {
1825 if (adapter->secinfo.WPAenabled || 1808 if (priv->secinfo.WPAenabled ||
1826 adapter->secinfo.WPA2enabled) { 1809 priv->secinfo.WPA2enabled) {
1827 /* check for valid WPA group keys */ 1810 /* check for valid WPA group keys */
1828 if (adapter->wpa_mcast_key.len || 1811 if (priv->wpa_mcast_key.len ||
1829 adapter->wpa_unicast_key.len) { 1812 priv->wpa_unicast_key.len) {
1830 lbs_deb_host( 1813 lbs_deb_host(
1831 "EXEC_NEXT_CMD: WPA enabled and GTK_SET" 1814 "EXEC_NEXT_CMD: WPA enabled and GTK_SET"
1832 " go back to PS_SLEEP"); 1815 " go back to PS_SLEEP");
@@ -1874,7 +1857,6 @@ void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
1874static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size) 1857static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
1875{ 1858{
1876 unsigned long flags; 1859 unsigned long flags;
1877 struct lbs_adapter *adapter = priv->adapter;
1878 int ret = 0; 1860 int ret = 0;
1879 1861
1880 lbs_deb_enter(LBS_DEB_HOST); 1862 lbs_deb_enter(LBS_DEB_HOST);
@@ -1887,24 +1869,24 @@ static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
1887 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size); 1869 ret = priv->hw_host_to_card(priv, MVMS_CMD, cmdptr, size);
1888 priv->dnld_sent = DNLD_RES_RECEIVED; 1870 priv->dnld_sent = DNLD_RES_RECEIVED;
1889 1871
1890 spin_lock_irqsave(&adapter->driver_lock, flags); 1872 spin_lock_irqsave(&priv->driver_lock, flags);
1891 if (adapter->intcounter || adapter->currenttxskb) 1873 if (priv->intcounter || priv->currenttxskb)
1892 lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n", 1874 lbs_deb_host("SEND_SLEEPC_CMD: intcounter %d, currenttxskb %p\n",
1893 adapter->intcounter, adapter->currenttxskb); 1875 priv->intcounter, priv->currenttxskb);
1894 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1876 spin_unlock_irqrestore(&priv->driver_lock, flags);
1895 1877
1896 if (ret) { 1878 if (ret) {
1897 lbs_pr_alert( 1879 lbs_pr_alert(
1898 "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n"); 1880 "SEND_SLEEPC_CMD: Host to Card failed for Confirm Sleep\n");
1899 } else { 1881 } else {
1900 spin_lock_irqsave(&adapter->driver_lock, flags); 1882 spin_lock_irqsave(&priv->driver_lock, flags);
1901 if (!adapter->intcounter) { 1883 if (!priv->intcounter) {
1902 adapter->psstate = PS_STATE_SLEEP; 1884 priv->psstate = PS_STATE_SLEEP;
1903 } else { 1885 } else {
1904 lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n", 1886 lbs_deb_host("SEND_SLEEPC_CMD: after sent, intcounter %d\n",
1905 adapter->intcounter); 1887 priv->intcounter);
1906 } 1888 }
1907 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1889 spin_unlock_irqrestore(&priv->driver_lock, flags);
1908 1890
1909 lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n"); 1891 lbs_deb_host("SEND_SLEEPC_CMD: sent confirm sleep\n");
1910 } 1892 }
@@ -1961,7 +1943,6 @@ void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
1961void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) 1943void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
1962{ 1944{
1963 unsigned long flags =0; 1945 unsigned long flags =0;
1964 struct lbs_adapter *adapter = priv->adapter;
1965 u8 allowed = 1; 1946 u8 allowed = 1;
1966 1947
1967 lbs_deb_enter(LBS_DEB_HOST); 1948 lbs_deb_enter(LBS_DEB_HOST);
@@ -1971,20 +1952,20 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
1971 lbs_deb_host("dnld_sent was set"); 1952 lbs_deb_host("dnld_sent was set");
1972 } 1953 }
1973 1954
1974 spin_lock_irqsave(&adapter->driver_lock, flags); 1955 spin_lock_irqsave(&priv->driver_lock, flags);
1975 if (adapter->cur_cmd) { 1956 if (priv->cur_cmd) {
1976 allowed = 0; 1957 allowed = 0;
1977 lbs_deb_host("cur_cmd was set"); 1958 lbs_deb_host("cur_cmd was set");
1978 } 1959 }
1979 if (adapter->intcounter > 0) { 1960 if (priv->intcounter > 0) {
1980 allowed = 0; 1961 allowed = 0;
1981 lbs_deb_host("intcounter %d", adapter->intcounter); 1962 lbs_deb_host("intcounter %d", priv->intcounter);
1982 } 1963 }
1983 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1964 spin_unlock_irqrestore(&priv->driver_lock, flags);
1984 1965
1985 if (allowed) { 1966 if (allowed) {
1986 lbs_deb_host("sending lbs_ps_confirm_sleep\n"); 1967 lbs_deb_host("sending lbs_ps_confirm_sleep\n");
1987 sendconfirmsleep(priv, (u8 *) & adapter->lbs_ps_confirm_sleep, 1968 sendconfirmsleep(priv, (u8 *) & priv->lbs_ps_confirm_sleep,
1988 sizeof(struct PS_CMD_ConfirmSleep)); 1969 sizeof(struct PS_CMD_ConfirmSleep));
1989 } else { 1970 } else {
1990 lbs_deb_host("sleep confirm has been delayed\n"); 1971 lbs_deb_host("sleep confirm has been delayed\n");
@@ -2014,7 +1995,6 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
2014int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, 1995int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size,
2015 int (*callback)(uint16_t, struct cmd_ds_command *, struct lbs_private *)) 1996 int (*callback)(uint16_t, struct cmd_ds_command *, struct lbs_private *))
2016{ 1997{
2017 struct lbs_adapter *adapter = priv->adapter;
2018 struct cmd_ctrl_node *cmdnode; 1998 struct cmd_ctrl_node *cmdnode;
2019 struct cmd_ds_gen *cmdptr; 1999 struct cmd_ds_gen *cmdptr;
2020 unsigned long flags; 2000 unsigned long flags;
@@ -2022,13 +2002,13 @@ int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size,
2022 2002
2023 lbs_deb_enter(LBS_DEB_HOST); 2003 lbs_deb_enter(LBS_DEB_HOST);
2024 2004
2025 if (!adapter) { 2005 if (!priv) {
2026 lbs_deb_host("PREP_CMD: adapter is NULL\n"); 2006 lbs_deb_host("PREP_CMD: priv is NULL\n");
2027 ret = -1; 2007 ret = -1;
2028 goto done; 2008 goto done;
2029 } 2009 }
2030 2010
2031 if (adapter->surpriseremoved) { 2011 if (priv->surpriseremoved) {
2032 lbs_deb_host("PREP_CMD: card removed\n"); 2012 lbs_deb_host("PREP_CMD: card removed\n");
2033 ret = -1; 2013 ret = -1;
2034 goto done; 2014 goto done;
@@ -2050,10 +2030,10 @@ int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size,
2050 cmdnode->callback = callback; 2030 cmdnode->callback = callback;
2051 2031
2052 /* Set sequence number, clean result, move to buffer */ 2032 /* Set sequence number, clean result, move to buffer */
2053 adapter->seqnum++; 2033 priv->seqnum++;
2054 cmdptr->command = cpu_to_le16(command); 2034 cmdptr->command = cpu_to_le16(command);
2055 cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN); 2035 cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN);
2056 cmdptr->seqnum = cpu_to_le16(adapter->seqnum); 2036 cmdptr->seqnum = cpu_to_le16(priv->seqnum);
2057 cmdptr->result = 0; 2037 cmdptr->result = 0;
2058 memcpy(cmdptr->cmdresp, cmd, cmd_size); 2038 memcpy(cmdptr->cmdresp, cmd, cmd_size);
2059 2039
@@ -2063,20 +2043,20 @@ int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size,
2063 * because the caller of lbs_cmd() sets up all of *cmd for us. */ 2043 * because the caller of lbs_cmd() sets up all of *cmd for us. */
2064 2044
2065 cmdnode->cmdwaitqwoken = 0; 2045 cmdnode->cmdwaitqwoken = 0;
2066 lbs_queue_cmd(adapter, cmdnode, 1); 2046 lbs_queue_cmd(priv, cmdnode, 1);
2067 wake_up_interruptible(&priv->waitq); 2047 wake_up_interruptible(&priv->waitq);
2068 2048
2069 might_sleep(); 2049 might_sleep();
2070 wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken); 2050 wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken);
2071 2051
2072 spin_lock_irqsave(&adapter->driver_lock, flags); 2052 spin_lock_irqsave(&priv->driver_lock, flags);
2073 if (adapter->cur_cmd_retcode) { 2053 if (priv->cur_cmd_retcode) {
2074 lbs_deb_host("PREP_CMD: command failed with return code %d\n", 2054 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
2075 adapter->cur_cmd_retcode); 2055 priv->cur_cmd_retcode);
2076 adapter->cur_cmd_retcode = 0; 2056 priv->cur_cmd_retcode = 0;
2077 ret = -1; 2057 ret = -1;
2078 } 2058 }
2079 spin_unlock_irqrestore(&adapter->driver_lock, flags); 2059 spin_unlock_irqrestore(&priv->driver_lock, flags);
2080 2060
2081done: 2061done:
2082 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); 2062 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 44865bf12ba4..ab6e729efacf 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -25,10 +25,9 @@
25 */ 25 */
26void lbs_mac_event_disconnected(struct lbs_private *priv) 26void lbs_mac_event_disconnected(struct lbs_private *priv)
27{ 27{
28 struct lbs_adapter *adapter = priv->adapter;
29 union iwreq_data wrqu; 28 union iwreq_data wrqu;
30 29
31 if (adapter->connect_status != LBS_CONNECTED) 30 if (priv->connect_status != LBS_CONNECTED)
32 return; 31 return;
33 32
34 lbs_deb_enter(LBS_DEB_ASSOC); 33 lbs_deb_enter(LBS_DEB_ASSOC);
@@ -45,31 +44,31 @@ void lbs_mac_event_disconnected(struct lbs_private *priv)
45 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 44 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
46 45
47 /* Free Tx and Rx packets */ 46 /* Free Tx and Rx packets */
48 kfree_skb(priv->adapter->currenttxskb); 47 kfree_skb(priv->currenttxskb);
49 priv->adapter->currenttxskb = NULL; 48 priv->currenttxskb = NULL;
50 49
51 /* report disconnect to upper layer */ 50 /* report disconnect to upper layer */
52 netif_stop_queue(priv->dev); 51 netif_stop_queue(priv->dev);
53 netif_carrier_off(priv->dev); 52 netif_carrier_off(priv->dev);
54 53
55 /* reset SNR/NF/RSSI values */ 54 /* reset SNR/NF/RSSI values */
56 memset(adapter->SNR, 0x00, sizeof(adapter->SNR)); 55 memset(priv->SNR, 0x00, sizeof(priv->SNR));
57 memset(adapter->NF, 0x00, sizeof(adapter->NF)); 56 memset(priv->NF, 0x00, sizeof(priv->NF));
58 memset(adapter->RSSI, 0x00, sizeof(adapter->RSSI)); 57 memset(priv->RSSI, 0x00, sizeof(priv->RSSI));
59 memset(adapter->rawSNR, 0x00, sizeof(adapter->rawSNR)); 58 memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
60 memset(adapter->rawNF, 0x00, sizeof(adapter->rawNF)); 59 memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
61 adapter->nextSNRNF = 0; 60 priv->nextSNRNF = 0;
62 adapter->numSNRNF = 0; 61 priv->numSNRNF = 0;
63 adapter->connect_status = LBS_DISCONNECTED; 62 priv->connect_status = LBS_DISCONNECTED;
64 63
65 /* Clear out associated SSID and BSSID since connection is 64 /* Clear out associated SSID and BSSID since connection is
66 * no longer valid. 65 * no longer valid.
67 */ 66 */
68 memset(&adapter->curbssparams.bssid, 0, ETH_ALEN); 67 memset(&priv->curbssparams.bssid, 0, ETH_ALEN);
69 memset(&adapter->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE); 68 memset(&priv->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE);
70 adapter->curbssparams.ssid_len = 0; 69 priv->curbssparams.ssid_len = 0;
71 70
72 if (adapter->psstate != PS_STATE_FULL_POWER) { 71 if (priv->psstate != PS_STATE_FULL_POWER) {
73 /* make firmware to exit PS mode */ 72 /* make firmware to exit PS mode */
74 lbs_deb_cmd("disconnected, so exit PS mode\n"); 73 lbs_deb_cmd("disconnected, so exit PS mode\n");
75 lbs_ps_wakeup(priv, 0); 74 lbs_ps_wakeup(priv, 0);
@@ -107,7 +106,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
107 u16 type, struct cmd_ds_command *resp) 106 u16 type, struct cmd_ds_command *resp)
108{ 107{
109 int ret = 0; 108 int ret = 0;
110 struct lbs_adapter *adapter = priv->adapter;
111 109
112 lbs_deb_enter(LBS_DEB_CMD); 110 lbs_deb_enter(LBS_DEB_CMD);
113 111
@@ -116,8 +114,8 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
116 { 114 {
117 struct cmd_ds_mac_reg_access *reg = &resp->params.macreg; 115 struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
118 116
119 adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 117 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
120 adapter->offsetvalue.value = le32_to_cpu(reg->value); 118 priv->offsetvalue.value = le32_to_cpu(reg->value);
121 break; 119 break;
122 } 120 }
123 121
@@ -125,8 +123,8 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
125 { 123 {
126 struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg; 124 struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
127 125
128 adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 126 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
129 adapter->offsetvalue.value = reg->value; 127 priv->offsetvalue.value = reg->value;
130 break; 128 break;
131 } 129 }
132 130
@@ -134,8 +132,8 @@ static int lbs_ret_reg_access(struct lbs_private *priv,
134 { 132 {
135 struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg; 133 struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
136 134
137 adapter->offsetvalue.offset = (u32)le16_to_cpu(reg->offset); 135 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
138 adapter->offsetvalue.value = reg->value; 136 priv->offsetvalue.value = reg->value;
139 break; 137 break;
140 } 138 }
141 139
@@ -152,19 +150,18 @@ static int lbs_ret_get_hw_spec(struct lbs_private *priv,
152{ 150{
153 u32 i; 151 u32 i;
154 struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec; 152 struct cmd_ds_get_hw_spec *hwspec = &resp->params.hwspec;
155 struct lbs_adapter *adapter = priv->adapter;
156 int ret = 0; 153 int ret = 0;
157 DECLARE_MAC_BUF(mac); 154 DECLARE_MAC_BUF(mac);
158 155
159 lbs_deb_enter(LBS_DEB_CMD); 156 lbs_deb_enter(LBS_DEB_CMD);
160 157
161 adapter->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo); 158 priv->fwcapinfo = le32_to_cpu(hwspec->fwcapinfo);
162 159
163 memcpy(adapter->fwreleasenumber, hwspec->fwreleasenumber, 4); 160 memcpy(priv->fwreleasenumber, hwspec->fwreleasenumber, 4);
164 161
165 lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n", 162 lbs_deb_cmd("GET_HW_SPEC: firmware release %u.%u.%up%u\n",
166 adapter->fwreleasenumber[2], adapter->fwreleasenumber[1], 163 priv->fwreleasenumber[2], priv->fwreleasenumber[1],
167 adapter->fwreleasenumber[0], adapter->fwreleasenumber[3]); 164 priv->fwreleasenumber[0], priv->fwreleasenumber[3]);
168 lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n", 165 lbs_deb_cmd("GET_HW_SPEC: MAC addr %s\n",
169 print_mac(mac, hwspec->permanentaddr)); 166 print_mac(mac, hwspec->permanentaddr));
170 lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n", 167 lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
@@ -174,29 +171,29 @@ static int lbs_ret_get_hw_spec(struct lbs_private *priv,
174 * only ever be 8-bit, even though the field size is 16-bit. Some firmware 171 * only ever be 8-bit, even though the field size is 16-bit. Some firmware
175 * returns non-zero high 8 bits here. 172 * returns non-zero high 8 bits here.
176 */ 173 */
177 adapter->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF; 174 priv->regioncode = le16_to_cpu(hwspec->regioncode) & 0xFF;
178 175
179 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) { 176 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
180 /* use the region code to search for the index */ 177 /* use the region code to search for the index */
181 if (adapter->regioncode == lbs_region_code_to_index[i]) { 178 if (priv->regioncode == lbs_region_code_to_index[i]) {
182 break; 179 break;
183 } 180 }
184 } 181 }
185 182
186 /* if it's unidentified region code, use the default (USA) */ 183 /* if it's unidentified region code, use the default (USA) */
187 if (i >= MRVDRV_MAX_REGION_CODE) { 184 if (i >= MRVDRV_MAX_REGION_CODE) {
188 adapter->regioncode = 0x10; 185 priv->regioncode = 0x10;
189 lbs_pr_info("unidentified region code; using the default (USA)\n"); 186 lbs_pr_info("unidentified region code; using the default (USA)\n");
190 } 187 }
191 188
192 if (adapter->current_addr[0] == 0xff) 189 if (priv->current_addr[0] == 0xff)
193 memmove(adapter->current_addr, hwspec->permanentaddr, ETH_ALEN); 190 memmove(priv->current_addr, hwspec->permanentaddr, ETH_ALEN);
194 191
195 memcpy(priv->dev->dev_addr, adapter->current_addr, ETH_ALEN); 192 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
196 if (priv->mesh_dev) 193 if (priv->mesh_dev)
197 memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 194 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
198 195
199 if (lbs_set_regiontable(priv, adapter->regioncode, 0)) { 196 if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
200 ret = -1; 197 ret = -1;
201 goto done; 198 goto done;
202 } 199 }
@@ -215,7 +212,6 @@ static int lbs_ret_802_11_sleep_params(struct lbs_private *priv,
215 struct cmd_ds_command *resp) 212 struct cmd_ds_command *resp)
216{ 213{
217 struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; 214 struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params;
218 struct lbs_adapter *adapter = priv->adapter;
219 215
220 lbs_deb_enter(LBS_DEB_CMD); 216 lbs_deb_enter(LBS_DEB_CMD);
221 217
@@ -224,12 +220,12 @@ static int lbs_ret_802_11_sleep_params(struct lbs_private *priv,
224 le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime), 220 le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime),
225 sp->calcontrol, sp->externalsleepclk); 221 sp->calcontrol, sp->externalsleepclk);
226 222
227 adapter->sp.sp_error = le16_to_cpu(sp->error); 223 priv->sp.sp_error = le16_to_cpu(sp->error);
228 adapter->sp.sp_offset = le16_to_cpu(sp->offset); 224 priv->sp.sp_offset = le16_to_cpu(sp->offset);
229 adapter->sp.sp_stabletime = le16_to_cpu(sp->stabletime); 225 priv->sp.sp_stabletime = le16_to_cpu(sp->stabletime);
230 adapter->sp.sp_calcontrol = sp->calcontrol; 226 priv->sp.sp_calcontrol = sp->calcontrol;
231 adapter->sp.sp_extsleepclk = sp->externalsleepclk; 227 priv->sp.sp_extsleepclk = sp->externalsleepclk;
232 adapter->sp.sp_reserved = le16_to_cpu(sp->reserved); 228 priv->sp.sp_reserved = le16_to_cpu(sp->reserved);
233 229
234 lbs_deb_enter(LBS_DEB_CMD); 230 lbs_deb_enter(LBS_DEB_CMD);
235 return 0; 231 return 0;
@@ -239,13 +235,12 @@ static int lbs_ret_802_11_stat(struct lbs_private *priv,
239 struct cmd_ds_command *resp) 235 struct cmd_ds_command *resp)
240{ 236{
241 lbs_deb_enter(LBS_DEB_CMD); 237 lbs_deb_enter(LBS_DEB_CMD);
242/* currently adapter->wlan802_11Stat is unused 238/* currently priv->wlan802_11Stat is unused
243 239
244 struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat; 240 struct cmd_ds_802_11_get_stat *p11Stat = &resp->params.gstat;
245 struct lbs_adapter *adapter = priv->adapter;
246 241
247 // TODO Convert it to Big endian befor copy 242 // TODO Convert it to Big endian befor copy
248 memcpy(&adapter->wlan802_11Stat, 243 memcpy(&priv->wlan802_11Stat,
249 p11Stat, sizeof(struct cmd_ds_802_11_get_stat)); 244 p11Stat, sizeof(struct cmd_ds_802_11_get_stat));
250*/ 245*/
251 lbs_deb_leave(LBS_DEB_CMD); 246 lbs_deb_leave(LBS_DEB_CMD);
@@ -268,22 +263,22 @@ static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
268 if (querytype == CMD_ACT_GET) { 263 if (querytype == CMD_ACT_GET) {
269 switch (oid) { 264 switch (oid) {
270 case FRAGTHRESH_I: 265 case FRAGTHRESH_I:
271 priv->adapter->fragthsd = 266 priv->fragthsd =
272 le16_to_cpu(*((__le16 *)(smib->value))); 267 le16_to_cpu(*((__le16 *)(smib->value)));
273 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n", 268 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
274 priv->adapter->fragthsd); 269 priv->fragthsd);
275 break; 270 break;
276 case RTSTHRESH_I: 271 case RTSTHRESH_I:
277 priv->adapter->rtsthsd = 272 priv->rtsthsd =
278 le16_to_cpu(*((__le16 *)(smib->value))); 273 le16_to_cpu(*((__le16 *)(smib->value)));
279 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n", 274 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
280 priv->adapter->rtsthsd); 275 priv->rtsthsd);
281 break; 276 break;
282 case SHORT_RETRYLIM_I: 277 case SHORT_RETRYLIM_I:
283 priv->adapter->txretrycount = 278 priv->txretrycount =
284 le16_to_cpu(*((__le16 *)(smib->value))); 279 le16_to_cpu(*((__le16 *)(smib->value)));
285 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n", 280 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
286 priv->adapter->rtsthsd); 281 priv->rtsthsd);
287 break; 282 break;
288 default: 283 default:
289 break; 284 break;
@@ -299,7 +294,6 @@ static int lbs_ret_802_11_key_material(struct lbs_private *priv,
299{ 294{
300 struct cmd_ds_802_11_key_material *pkeymaterial = 295 struct cmd_ds_802_11_key_material *pkeymaterial =
301 &resp->params.keymaterial; 296 &resp->params.keymaterial;
302 struct lbs_adapter *adapter = priv->adapter;
303 u16 action = le16_to_cpu(pkeymaterial->action); 297 u16 action = le16_to_cpu(pkeymaterial->action);
304 298
305 lbs_deb_enter(LBS_DEB_CMD); 299 lbs_deb_enter(LBS_DEB_CMD);
@@ -327,9 +321,9 @@ static int lbs_ret_802_11_key_material(struct lbs_private *priv,
327 break; 321 break;
328 322
329 if (key_flags & KEY_INFO_WPA_UNICAST) 323 if (key_flags & KEY_INFO_WPA_UNICAST)
330 pkey = &adapter->wpa_unicast_key; 324 pkey = &priv->wpa_unicast_key;
331 else if (key_flags & KEY_INFO_WPA_MCAST) 325 else if (key_flags & KEY_INFO_WPA_MCAST)
332 pkey = &adapter->wpa_mcast_key; 326 pkey = &priv->wpa_mcast_key;
333 else 327 else
334 break; 328 break;
335 329
@@ -354,11 +348,10 @@ static int lbs_ret_802_11_mac_address(struct lbs_private *priv,
354 struct cmd_ds_command *resp) 348 struct cmd_ds_command *resp)
355{ 349{
356 struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd; 350 struct cmd_ds_802_11_mac_address *macadd = &resp->params.macadd;
357 struct lbs_adapter *adapter = priv->adapter;
358 351
359 lbs_deb_enter(LBS_DEB_CMD); 352 lbs_deb_enter(LBS_DEB_CMD);
360 353
361 memcpy(adapter->current_addr, macadd->macadd, ETH_ALEN); 354 memcpy(priv->current_addr, macadd->macadd, ETH_ALEN);
362 355
363 lbs_deb_enter(LBS_DEB_CMD); 356 lbs_deb_enter(LBS_DEB_CMD);
364 return 0; 357 return 0;
@@ -368,13 +361,12 @@ static int lbs_ret_802_11_rf_tx_power(struct lbs_private *priv,
368 struct cmd_ds_command *resp) 361 struct cmd_ds_command *resp)
369{ 362{
370 struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp; 363 struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp;
371 struct lbs_adapter *adapter = priv->adapter;
372 364
373 lbs_deb_enter(LBS_DEB_CMD); 365 lbs_deb_enter(LBS_DEB_CMD);
374 366
375 adapter->txpowerlevel = le16_to_cpu(rtp->currentlevel); 367 priv->txpowerlevel = le16_to_cpu(rtp->currentlevel);
376 368
377 lbs_deb_cmd("TX power currently %d\n", adapter->txpowerlevel); 369 lbs_deb_cmd("TX power currently %d\n", priv->txpowerlevel);
378 370
379 lbs_deb_leave(LBS_DEB_CMD); 371 lbs_deb_leave(LBS_DEB_CMD);
380 return 0; 372 return 0;
@@ -384,13 +376,12 @@ static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv,
384 struct cmd_ds_command *resp) 376 struct cmd_ds_command *resp)
385{ 377{
386 struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset; 378 struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset;
387 struct lbs_adapter *adapter = priv->adapter;
388 379
389 lbs_deb_enter(LBS_DEB_CMD); 380 lbs_deb_enter(LBS_DEB_CMD);
390 381
391 if (rates->action == CMD_ACT_GET) { 382 if (rates->action == CMD_ACT_GET) {
392 adapter->enablehwauto = le16_to_cpu(rates->enablehwauto); 383 priv->enablehwauto = le16_to_cpu(rates->enablehwauto);
393 adapter->ratebitmap = le16_to_cpu(rates->bitmap); 384 priv->ratebitmap = le16_to_cpu(rates->bitmap);
394 } 385 }
395 386
396 lbs_deb_leave(LBS_DEB_CMD); 387 lbs_deb_leave(LBS_DEB_CMD);
@@ -401,7 +392,6 @@ static int lbs_ret_802_11_data_rate(struct lbs_private *priv,
401 struct cmd_ds_command *resp) 392 struct cmd_ds_command *resp)
402{ 393{
403 struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate; 394 struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate;
404 struct lbs_adapter *adapter = priv->adapter;
405 395
406 lbs_deb_enter(LBS_DEB_CMD); 396 lbs_deb_enter(LBS_DEB_CMD);
407 397
@@ -411,8 +401,8 @@ static int lbs_ret_802_11_data_rate(struct lbs_private *priv,
411 /* FIXME: get actual rates FW can do if this command actually returns 401 /* FIXME: get actual rates FW can do if this command actually returns
412 * all data rates supported. 402 * all data rates supported.
413 */ 403 */
414 adapter->cur_rate = lbs_fw_index_to_data_rate(pdatarate->rates[0]); 404 priv->cur_rate = lbs_fw_index_to_data_rate(pdatarate->rates[0]);
415 lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", adapter->cur_rate); 405 lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", priv->cur_rate);
416 406
417 lbs_deb_leave(LBS_DEB_CMD); 407 lbs_deb_leave(LBS_DEB_CMD);
418 return 0; 408 return 0;
@@ -422,19 +412,18 @@ static int lbs_ret_802_11_rf_channel(struct lbs_private *priv,
422 struct cmd_ds_command *resp) 412 struct cmd_ds_command *resp)
423{ 413{
424 struct cmd_ds_802_11_rf_channel *rfchannel = &resp->params.rfchannel; 414 struct cmd_ds_802_11_rf_channel *rfchannel = &resp->params.rfchannel;
425 struct lbs_adapter *adapter = priv->adapter;
426 u16 action = le16_to_cpu(rfchannel->action); 415 u16 action = le16_to_cpu(rfchannel->action);
427 u16 newchannel = le16_to_cpu(rfchannel->currentchannel); 416 u16 newchannel = le16_to_cpu(rfchannel->currentchannel);
428 417
429 lbs_deb_enter(LBS_DEB_CMD); 418 lbs_deb_enter(LBS_DEB_CMD);
430 419
431 if (action == CMD_OPT_802_11_RF_CHANNEL_GET 420 if (action == CMD_OPT_802_11_RF_CHANNEL_GET
432 && adapter->curbssparams.channel != newchannel) { 421 && priv->curbssparams.channel != newchannel) {
433 lbs_deb_cmd("channel switch from %d to %d\n", 422 lbs_deb_cmd("channel switch from %d to %d\n",
434 adapter->curbssparams.channel, newchannel); 423 priv->curbssparams.channel, newchannel);
435 424
436 /* Update the channel again */ 425 /* Update the channel again */
437 adapter->curbssparams.channel = newchannel; 426 priv->curbssparams.channel = newchannel;
438 } 427 }
439 428
440 lbs_deb_enter(LBS_DEB_CMD); 429 lbs_deb_enter(LBS_DEB_CMD);
@@ -445,28 +434,27 @@ static int lbs_ret_802_11_rssi(struct lbs_private *priv,
445 struct cmd_ds_command *resp) 434 struct cmd_ds_command *resp)
446{ 435{
447 struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp; 436 struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;
448 struct lbs_adapter *adapter = priv->adapter;
449 437
450 lbs_deb_enter(LBS_DEB_CMD); 438 lbs_deb_enter(LBS_DEB_CMD);
451 439
452 /* store the non average value */ 440 /* store the non average value */
453 adapter->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR); 441 priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR);
454 adapter->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor); 442 priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor);
455 443
456 adapter->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR); 444 priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR);
457 adapter->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor); 445 priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor);
458 446
459 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG] = 447 priv->RSSI[TYPE_BEACON][TYPE_NOAVG] =
460 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], 448 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
461 adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 449 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
462 450
463 adapter->RSSI[TYPE_BEACON][TYPE_AVG] = 451 priv->RSSI[TYPE_BEACON][TYPE_AVG] =
464 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE, 452 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
465 adapter->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE); 453 priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
466 454
467 lbs_deb_cmd("RSSI: beacon %d, avg %d\n", 455 lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
468 adapter->RSSI[TYPE_BEACON][TYPE_NOAVG], 456 priv->RSSI[TYPE_BEACON][TYPE_NOAVG],
469 adapter->RSSI[TYPE_BEACON][TYPE_AVG]); 457 priv->RSSI[TYPE_BEACON][TYPE_AVG]);
470 458
471 lbs_deb_leave(LBS_DEB_CMD); 459 lbs_deb_leave(LBS_DEB_CMD);
472 return 0; 460 return 0;
@@ -475,9 +463,8 @@ static int lbs_ret_802_11_rssi(struct lbs_private *priv,
475static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv, 463static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv,
476 struct cmd_ds_command *resp) 464 struct cmd_ds_command *resp)
477{ 465{
478 struct lbs_adapter *adapter = priv->adapter;
479 struct lbs_ioctl_regrdwr *pbuf; 466 struct lbs_ioctl_regrdwr *pbuf;
480 pbuf = (struct lbs_ioctl_regrdwr *) adapter->prdeeprom; 467 pbuf = (struct lbs_ioctl_regrdwr *) priv->prdeeprom;
481 468
482 lbs_deb_enter_args(LBS_DEB_CMD, "len %d", 469 lbs_deb_enter_args(LBS_DEB_CMD, "len %d",
483 le16_to_cpu(resp->params.rdeeprom.bytecount)); 470 le16_to_cpu(resp->params.rdeeprom.bytecount));
@@ -502,12 +489,11 @@ static int lbs_ret_get_log(struct lbs_private *priv,
502 struct cmd_ds_command *resp) 489 struct cmd_ds_command *resp)
503{ 490{
504 struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog; 491 struct cmd_ds_802_11_get_log *logmessage = &resp->params.glog;
505 struct lbs_adapter *adapter = priv->adapter;
506 492
507 lbs_deb_enter(LBS_DEB_CMD); 493 lbs_deb_enter(LBS_DEB_CMD);
508 494
509 /* Stored little-endian */ 495 /* Stored little-endian */
510 memcpy(&adapter->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log)); 496 memcpy(&priv->logmsg, logmessage, sizeof(struct cmd_ds_802_11_get_log));
511 497
512 lbs_deb_leave(LBS_DEB_CMD); 498 lbs_deb_leave(LBS_DEB_CMD);
513 return 0; 499 return 0;
@@ -517,8 +503,7 @@ static int lbs_ret_802_11_enable_rsn(struct lbs_private *priv,
517 struct cmd_ds_command *resp) 503 struct cmd_ds_command *resp)
518{ 504{
519 struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn; 505 struct cmd_ds_802_11_enable_rsn *enable_rsn = &resp->params.enbrsn;
520 struct lbs_adapter *adapter = priv->adapter; 506 u32 * pdata_buf = priv->cur_cmd->pdata_buf;
521 u32 * pdata_buf = adapter->cur_cmd->pdata_buf;
522 507
523 lbs_deb_enter(LBS_DEB_CMD); 508 lbs_deb_enter(LBS_DEB_CMD);
524 509
@@ -536,13 +521,12 @@ static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
536{ 521{
537 struct cmd_ds_802_11_beacon_control *bcn_ctrl = 522 struct cmd_ds_802_11_beacon_control *bcn_ctrl =
538 &resp->params.bcn_ctrl; 523 &resp->params.bcn_ctrl;
539 struct lbs_adapter *adapter = priv->adapter;
540 524
541 lbs_deb_enter(LBS_DEB_CMD); 525 lbs_deb_enter(LBS_DEB_CMD);
542 526
543 if (bcn_ctrl->action == CMD_ACT_GET) { 527 if (bcn_ctrl->action == CMD_ACT_GET) {
544 adapter->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable); 528 priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable);
545 adapter->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period); 529 priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period);
546 } 530 }
547 531
548 lbs_deb_enter(LBS_DEB_CMD); 532 lbs_deb_enter(LBS_DEB_CMD);
@@ -552,11 +536,10 @@ static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
552static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv, 536static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv,
553 struct cmd_ds_command *resp) 537 struct cmd_ds_command *resp)
554{ 538{
555 struct lbs_adapter *adapter = priv->adapter;
556 struct cmd_ds_802_11_subscribe_event *cmd_event = 539 struct cmd_ds_802_11_subscribe_event *cmd_event =
557 &resp->params.subscribe_event; 540 &resp->params.subscribe_event;
558 struct cmd_ds_802_11_subscribe_event *dst_event = 541 struct cmd_ds_802_11_subscribe_event *dst_event =
559 adapter->cur_cmd->pdata_buf; 542 priv->cur_cmd->pdata_buf;
560 543
561 lbs_deb_enter(LBS_DEB_CMD); 544 lbs_deb_enter(LBS_DEB_CMD);
562 545
@@ -575,7 +558,6 @@ static inline int handle_cmd_response(u16 respcmd,
575{ 558{
576 int ret = 0; 559 int ret = 0;
577 unsigned long flags; 560 unsigned long flags;
578 struct lbs_adapter *adapter = priv->adapter;
579 561
580 lbs_deb_enter(LBS_DEB_HOST); 562 lbs_deb_enter(LBS_DEB_HOST);
581 563
@@ -628,10 +610,10 @@ static inline int handle_cmd_response(u16 respcmd,
628 610
629 case CMD_RET(CMD_802_11_SET_AFC): 611 case CMD_RET(CMD_802_11_SET_AFC):
630 case CMD_RET(CMD_802_11_GET_AFC): 612 case CMD_RET(CMD_802_11_GET_AFC):
631 spin_lock_irqsave(&adapter->driver_lock, flags); 613 spin_lock_irqsave(&priv->driver_lock, flags);
632 memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc, 614 memmove(priv->cur_cmd->pdata_buf, &resp->params.afc,
633 sizeof(struct cmd_ds_802_11_afc)); 615 sizeof(struct cmd_ds_802_11_afc));
634 spin_unlock_irqrestore(&adapter->driver_lock, flags); 616 spin_unlock_irqrestore(&priv->driver_lock, flags);
635 617
636 break; 618 break;
637 619
@@ -686,59 +668,59 @@ static inline int handle_cmd_response(u16 respcmd,
686 ret = lbs_ret_802_11_sleep_params(priv, resp); 668 ret = lbs_ret_802_11_sleep_params(priv, resp);
687 break; 669 break;
688 case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT): 670 case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT):
689 spin_lock_irqsave(&adapter->driver_lock, flags); 671 spin_lock_irqsave(&priv->driver_lock, flags);
690 *((u16 *) adapter->cur_cmd->pdata_buf) = 672 *((u16 *) priv->cur_cmd->pdata_buf) =
691 le16_to_cpu(resp->params.inactivity_timeout.timeout); 673 le16_to_cpu(resp->params.inactivity_timeout.timeout);
692 spin_unlock_irqrestore(&adapter->driver_lock, flags); 674 spin_unlock_irqrestore(&priv->driver_lock, flags);
693 break; 675 break;
694 676
695 case CMD_RET(CMD_802_11_TPC_CFG): 677 case CMD_RET(CMD_802_11_TPC_CFG):
696 spin_lock_irqsave(&adapter->driver_lock, flags); 678 spin_lock_irqsave(&priv->driver_lock, flags);
697 memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg, 679 memmove(priv->cur_cmd->pdata_buf, &resp->params.tpccfg,
698 sizeof(struct cmd_ds_802_11_tpc_cfg)); 680 sizeof(struct cmd_ds_802_11_tpc_cfg));
699 spin_unlock_irqrestore(&adapter->driver_lock, flags); 681 spin_unlock_irqrestore(&priv->driver_lock, flags);
700 break; 682 break;
701 case CMD_RET(CMD_802_11_LED_GPIO_CTRL): 683 case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
702 spin_lock_irqsave(&adapter->driver_lock, flags); 684 spin_lock_irqsave(&priv->driver_lock, flags);
703 memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio, 685 memmove(priv->cur_cmd->pdata_buf, &resp->params.ledgpio,
704 sizeof(struct cmd_ds_802_11_led_ctrl)); 686 sizeof(struct cmd_ds_802_11_led_ctrl));
705 spin_unlock_irqrestore(&adapter->driver_lock, flags); 687 spin_unlock_irqrestore(&priv->driver_lock, flags);
706 break; 688 break;
707 case CMD_RET(CMD_802_11_SUBSCRIBE_EVENT): 689 case CMD_RET(CMD_802_11_SUBSCRIBE_EVENT):
708 ret = lbs_ret_802_11_subscribe_event(priv, resp); 690 ret = lbs_ret_802_11_subscribe_event(priv, resp);
709 break; 691 break;
710 692
711 case CMD_RET(CMD_802_11_PWR_CFG): 693 case CMD_RET(CMD_802_11_PWR_CFG):
712 spin_lock_irqsave(&adapter->driver_lock, flags); 694 spin_lock_irqsave(&priv->driver_lock, flags);
713 memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg, 695 memmove(priv->cur_cmd->pdata_buf, &resp->params.pwrcfg,
714 sizeof(struct cmd_ds_802_11_pwr_cfg)); 696 sizeof(struct cmd_ds_802_11_pwr_cfg));
715 spin_unlock_irqrestore(&adapter->driver_lock, flags); 697 spin_unlock_irqrestore(&priv->driver_lock, flags);
716 698
717 break; 699 break;
718 700
719 case CMD_RET(CMD_GET_TSF): 701 case CMD_RET(CMD_GET_TSF):
720 spin_lock_irqsave(&adapter->driver_lock, flags); 702 spin_lock_irqsave(&priv->driver_lock, flags);
721 memcpy(priv->adapter->cur_cmd->pdata_buf, 703 memcpy(priv->cur_cmd->pdata_buf,
722 &resp->params.gettsf.tsfvalue, sizeof(u64)); 704 &resp->params.gettsf.tsfvalue, sizeof(u64));
723 spin_unlock_irqrestore(&adapter->driver_lock, flags); 705 spin_unlock_irqrestore(&priv->driver_lock, flags);
724 break; 706 break;
725 case CMD_RET(CMD_BT_ACCESS): 707 case CMD_RET(CMD_BT_ACCESS):
726 spin_lock_irqsave(&adapter->driver_lock, flags); 708 spin_lock_irqsave(&priv->driver_lock, flags);
727 if (adapter->cur_cmd->pdata_buf) 709 if (priv->cur_cmd->pdata_buf)
728 memcpy(adapter->cur_cmd->pdata_buf, 710 memcpy(priv->cur_cmd->pdata_buf,
729 &resp->params.bt.addr1, 2 * ETH_ALEN); 711 &resp->params.bt.addr1, 2 * ETH_ALEN);
730 spin_unlock_irqrestore(&adapter->driver_lock, flags); 712 spin_unlock_irqrestore(&priv->driver_lock, flags);
731 break; 713 break;
732 case CMD_RET(CMD_FWT_ACCESS): 714 case CMD_RET(CMD_FWT_ACCESS):
733 spin_lock_irqsave(&adapter->driver_lock, flags); 715 spin_lock_irqsave(&priv->driver_lock, flags);
734 if (adapter->cur_cmd->pdata_buf) 716 if (priv->cur_cmd->pdata_buf)
735 memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt, 717 memcpy(priv->cur_cmd->pdata_buf, &resp->params.fwt,
736 sizeof(resp->params.fwt)); 718 sizeof(resp->params.fwt));
737 spin_unlock_irqrestore(&adapter->driver_lock, flags); 719 spin_unlock_irqrestore(&priv->driver_lock, flags);
738 break; 720 break;
739 case CMD_RET(CMD_MESH_ACCESS): 721 case CMD_RET(CMD_MESH_ACCESS):
740 if (adapter->cur_cmd->pdata_buf) 722 if (priv->cur_cmd->pdata_buf)
741 memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh, 723 memcpy(priv->cur_cmd->pdata_buf, &resp->params.mesh,
742 sizeof(resp->params.mesh)); 724 sizeof(resp->params.mesh));
743 break; 725 break;
744 case CMD_RET(CMD_802_11_BEACON_CTRL): 726 case CMD_RET(CMD_802_11_BEACON_CTRL):
@@ -758,7 +740,6 @@ int lbs_process_rx_command(struct lbs_private *priv)
758{ 740{
759 u16 respcmd; 741 u16 respcmd;
760 struct cmd_ds_command *resp; 742 struct cmd_ds_command *resp;
761 struct lbs_adapter *adapter = priv->adapter;
762 int ret = 0; 743 int ret = 0;
763 ulong flags; 744 ulong flags;
764 u16 result; 745 u16 result;
@@ -766,39 +747,39 @@ int lbs_process_rx_command(struct lbs_private *priv)
766 lbs_deb_enter(LBS_DEB_HOST); 747 lbs_deb_enter(LBS_DEB_HOST);
767 748
768 /* Now we got response from FW, cancel the command timer */ 749 /* Now we got response from FW, cancel the command timer */
769 del_timer(&adapter->command_timer); 750 del_timer(&priv->command_timer);
770 751
771 mutex_lock(&adapter->lock); 752 mutex_lock(&priv->lock);
772 spin_lock_irqsave(&adapter->driver_lock, flags); 753 spin_lock_irqsave(&priv->driver_lock, flags);
773 754
774 if (!adapter->cur_cmd) { 755 if (!priv->cur_cmd) {
775 lbs_deb_host("CMD_RESP: cur_cmd is NULL\n"); 756 lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
776 ret = -1; 757 ret = -1;
777 spin_unlock_irqrestore(&adapter->driver_lock, flags); 758 spin_unlock_irqrestore(&priv->driver_lock, flags);
778 goto done; 759 goto done;
779 } 760 }
780 resp = (struct cmd_ds_command *)(adapter->cur_cmd->bufvirtualaddr); 761 resp = (struct cmd_ds_command *)(priv->cur_cmd->bufvirtualaddr);
781 762
782 respcmd = le16_to_cpu(resp->command); 763 respcmd = le16_to_cpu(resp->command);
783 result = le16_to_cpu(resp->result); 764 result = le16_to_cpu(resp->result);
784 765
785 lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n", 766 lbs_deb_host("CMD_RESP: response 0x%04x, size %d, jiffies %lu\n",
786 respcmd, priv->upld_len, jiffies); 767 respcmd, priv->upld_len, jiffies);
787 lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", adapter->cur_cmd->bufvirtualaddr, 768 lbs_deb_hex(LBS_DEB_HOST, "CMD_RESP", priv->cur_cmd->bufvirtualaddr,
788 priv->upld_len); 769 priv->upld_len);
789 770
790 if (!(respcmd & 0x8000)) { 771 if (!(respcmd & 0x8000)) {
791 lbs_deb_host("invalid response!\n"); 772 lbs_deb_host("invalid response!\n");
792 adapter->cur_cmd_retcode = -1; 773 priv->cur_cmd_retcode = -1;
793 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 774 __lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
794 adapter->cur_cmd = NULL; 775 priv->cur_cmd = NULL;
795 spin_unlock_irqrestore(&adapter->driver_lock, flags); 776 spin_unlock_irqrestore(&priv->driver_lock, flags);
796 ret = -1; 777 ret = -1;
797 goto done; 778 goto done;
798 } 779 }
799 780
800 /* Store the response code to cur_cmd_retcode. */ 781 /* Store the response code to cur_cmd_retcode. */
801 adapter->cur_cmd_retcode = result; 782 priv->cur_cmd_retcode = result;
802 783
803 if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) { 784 if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
804 struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode; 785 struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode;
@@ -816,15 +797,15 @@ int lbs_process_rx_command(struct lbs_private *priv)
816 * ad-hoc mode. It takes place in 797 * ad-hoc mode. It takes place in
817 * lbs_execute_next_command(). 798 * lbs_execute_next_command().
818 */ 799 */
819 if (adapter->mode == IW_MODE_ADHOC && 800 if (priv->mode == IW_MODE_ADHOC &&
820 action == CMD_SUBCMD_ENTER_PS) 801 action == CMD_SUBCMD_ENTER_PS)
821 adapter->psmode = LBS802_11POWERMODECAM; 802 priv->psmode = LBS802_11POWERMODECAM;
822 } else if (action == CMD_SUBCMD_ENTER_PS) { 803 } else if (action == CMD_SUBCMD_ENTER_PS) {
823 adapter->needtowakeup = 0; 804 priv->needtowakeup = 0;
824 adapter->psstate = PS_STATE_AWAKE; 805 priv->psstate = PS_STATE_AWAKE;
825 806
826 lbs_deb_host("CMD_RESP: ENTER_PS command response\n"); 807 lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
827 if (adapter->connect_status != LBS_CONNECTED) { 808 if (priv->connect_status != LBS_CONNECTED) {
828 /* 809 /*
829 * When Deauth Event received before Enter_PS command 810 * When Deauth Event received before Enter_PS command
830 * response, We need to wake up the firmware. 811 * response, We need to wake up the firmware.
@@ -832,23 +813,23 @@ int lbs_process_rx_command(struct lbs_private *priv)
832 lbs_deb_host( 813 lbs_deb_host(
833 "disconnected, invoking lbs_ps_wakeup\n"); 814 "disconnected, invoking lbs_ps_wakeup\n");
834 815
835 spin_unlock_irqrestore(&adapter->driver_lock, flags); 816 spin_unlock_irqrestore(&priv->driver_lock, flags);
836 mutex_unlock(&adapter->lock); 817 mutex_unlock(&priv->lock);
837 lbs_ps_wakeup(priv, 0); 818 lbs_ps_wakeup(priv, 0);
838 mutex_lock(&adapter->lock); 819 mutex_lock(&priv->lock);
839 spin_lock_irqsave(&adapter->driver_lock, flags); 820 spin_lock_irqsave(&priv->driver_lock, flags);
840 } 821 }
841 } else if (action == CMD_SUBCMD_EXIT_PS) { 822 } else if (action == CMD_SUBCMD_EXIT_PS) {
842 adapter->needtowakeup = 0; 823 priv->needtowakeup = 0;
843 adapter->psstate = PS_STATE_FULL_POWER; 824 priv->psstate = PS_STATE_FULL_POWER;
844 lbs_deb_host("CMD_RESP: EXIT_PS command response\n"); 825 lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
845 } else { 826 } else {
846 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); 827 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
847 } 828 }
848 829
849 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 830 __lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
850 adapter->cur_cmd = NULL; 831 priv->cur_cmd = NULL;
851 spin_unlock_irqrestore(&adapter->driver_lock, flags); 832 spin_unlock_irqrestore(&priv->driver_lock, flags);
852 833
853 ret = 0; 834 ret = 0;
854 goto done; 835 goto done;
@@ -869,32 +850,32 @@ int lbs_process_rx_command(struct lbs_private *priv)
869 850
870 } 851 }
871 852
872 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 853 __lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
873 adapter->cur_cmd = NULL; 854 priv->cur_cmd = NULL;
874 spin_unlock_irqrestore(&adapter->driver_lock, flags); 855 spin_unlock_irqrestore(&priv->driver_lock, flags);
875 856
876 ret = -1; 857 ret = -1;
877 goto done; 858 goto done;
878 } 859 }
879 860
880 spin_unlock_irqrestore(&adapter->driver_lock, flags); 861 spin_unlock_irqrestore(&priv->driver_lock, flags);
881 862
882 if (adapter->cur_cmd && adapter->cur_cmd->callback) 863 if (priv->cur_cmd && priv->cur_cmd->callback)
883 ret = adapter->cur_cmd->callback(respcmd, resp, priv); 864 ret = priv->cur_cmd->callback(respcmd, resp, priv);
884 else 865 else
885 ret = handle_cmd_response(respcmd, resp, priv); 866 ret = handle_cmd_response(respcmd, resp, priv);
886 867
887 spin_lock_irqsave(&adapter->driver_lock, flags); 868 spin_lock_irqsave(&priv->driver_lock, flags);
888 869
889 if (adapter->cur_cmd) { 870 if (priv->cur_cmd) {
890 /* Clean up and Put current command back to cmdfreeq */ 871 /* Clean up and Put current command back to cmdfreeq */
891 __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); 872 __lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
892 adapter->cur_cmd = NULL; 873 priv->cur_cmd = NULL;
893 } 874 }
894 spin_unlock_irqrestore(&adapter->driver_lock, flags); 875 spin_unlock_irqrestore(&priv->driver_lock, flags);
895 876
896done: 877done:
897 mutex_unlock(&adapter->lock); 878 mutex_unlock(&priv->lock);
898 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret); 879 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
899 return ret; 880 return ret;
900} 881}
@@ -902,14 +883,13 @@ done:
902int lbs_process_event(struct lbs_private *priv) 883int lbs_process_event(struct lbs_private *priv)
903{ 884{
904 int ret = 0; 885 int ret = 0;
905 struct lbs_adapter *adapter = priv->adapter;
906 u32 eventcause; 886 u32 eventcause;
907 887
908 lbs_deb_enter(LBS_DEB_CMD); 888 lbs_deb_enter(LBS_DEB_CMD);
909 889
910 spin_lock_irq(&adapter->driver_lock); 890 spin_lock_irq(&priv->driver_lock);
911 eventcause = adapter->eventcause >> SBI_EVENT_CAUSE_SHIFT; 891 eventcause = priv->eventcause >> SBI_EVENT_CAUSE_SHIFT;
912 spin_unlock_irq(&adapter->driver_lock); 892 spin_unlock_irq(&priv->driver_lock);
913 893
914 lbs_deb_cmd("event cause %d\n", eventcause); 894 lbs_deb_cmd("event cause %d\n", eventcause);
915 895
@@ -937,14 +917,14 @@ int lbs_process_event(struct lbs_private *priv)
937 lbs_deb_cmd("EVENT: sleep\n"); 917 lbs_deb_cmd("EVENT: sleep\n");
938 918
939 /* handle unexpected PS SLEEP event */ 919 /* handle unexpected PS SLEEP event */
940 if (adapter->psstate == PS_STATE_FULL_POWER) { 920 if (priv->psstate == PS_STATE_FULL_POWER) {
941 lbs_deb_cmd( 921 lbs_deb_cmd(
942 "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n"); 922 "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
943 break; 923 break;
944 } 924 }
945 adapter->psstate = PS_STATE_PRE_SLEEP; 925 priv->psstate = PS_STATE_PRE_SLEEP;
946 926
947 lbs_ps_confirm_sleep(priv, (u16) adapter->psmode); 927 lbs_ps_confirm_sleep(priv, (u16) priv->psmode);
948 928
949 break; 929 break;
950 930
@@ -952,19 +932,19 @@ int lbs_process_event(struct lbs_private *priv)
952 lbs_deb_cmd("EVENT: awake\n"); 932 lbs_deb_cmd("EVENT: awake\n");
953 933
954 /* handle unexpected PS AWAKE event */ 934 /* handle unexpected PS AWAKE event */
955 if (adapter->psstate == PS_STATE_FULL_POWER) { 935 if (priv->psstate == PS_STATE_FULL_POWER) {
956 lbs_deb_cmd( 936 lbs_deb_cmd(
957 "EVENT: In FULL POWER mode - ignore PS AWAKE\n"); 937 "EVENT: In FULL POWER mode - ignore PS AWAKE\n");
958 break; 938 break;
959 } 939 }
960 940
961 adapter->psstate = PS_STATE_AWAKE; 941 priv->psstate = PS_STATE_AWAKE;
962 942
963 if (adapter->needtowakeup) { 943 if (priv->needtowakeup) {
964 /* 944 /*
965 * wait for the command processing to finish 945 * wait for the command processing to finish
966 * before resuming sending 946 * before resuming sending
967 * adapter->needtowakeup will be set to FALSE 947 * priv->needtowakeup will be set to FALSE
968 * in lbs_ps_wakeup() 948 * in lbs_ps_wakeup()
969 */ 949 */
970 lbs_deb_cmd("waking up ...\n"); 950 lbs_deb_cmd("waking up ...\n");
@@ -1012,12 +992,12 @@ int lbs_process_event(struct lbs_private *priv)
1012 break; 992 break;
1013 } 993 }
1014 lbs_pr_info("EVENT: MESH_AUTO_STARTED\n"); 994 lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
1015 adapter->mesh_connect_status = LBS_CONNECTED; 995 priv->mesh_connect_status = LBS_CONNECTED;
1016 if (priv->mesh_open == 1) { 996 if (priv->mesh_open == 1) {
1017 netif_wake_queue(priv->mesh_dev); 997 netif_wake_queue(priv->mesh_dev);
1018 netif_carrier_on(priv->mesh_dev); 998 netif_carrier_on(priv->mesh_dev);
1019 } 999 }
1020 adapter->mode = IW_MODE_ADHOC; 1000 priv->mode = IW_MODE_ADHOC;
1021 schedule_work(&priv->sync_channel); 1001 schedule_work(&priv->sync_channel);
1022 break; 1002 break;
1023 1003
@@ -1026,9 +1006,9 @@ int lbs_process_event(struct lbs_private *priv)
1026 break; 1006 break;
1027 } 1007 }
1028 1008
1029 spin_lock_irq(&adapter->driver_lock); 1009 spin_lock_irq(&priv->driver_lock);
1030 adapter->eventcause = 0; 1010 priv->eventcause = 0;
1031 spin_unlock_irq(&adapter->driver_lock); 1011 spin_unlock_irq(&priv->driver_lock);
1032 1012
1033 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1013 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
1034 return ret; 1014 return ret;
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 9a041e5b209c..fe422b28a4f8 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -45,9 +45,9 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
45 ssize_t res; 45 ssize_t res;
46 46
47 pos += snprintf(buf+pos, len-pos, "state = %s\n", 47 pos += snprintf(buf+pos, len-pos, "state = %s\n",
48 szStates[priv->adapter->connect_status]); 48 szStates[priv->connect_status]);
49 pos += snprintf(buf+pos, len-pos, "region_code = %02x\n", 49 pos += snprintf(buf+pos, len-pos, "region_code = %02x\n",
50 (u32) priv->adapter->regioncode); 50 (u32) priv->regioncode);
51 51
52 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 52 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
53 53
@@ -70,8 +70,8 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
70 pos += snprintf(buf+pos, len-pos, 70 pos += snprintf(buf+pos, len-pos,
71 "# | ch | rssi | bssid | cap | Qual | SSID \n"); 71 "# | ch | rssi | bssid | cap | Qual | SSID \n");
72 72
73 mutex_lock(&priv->adapter->lock); 73 mutex_lock(&priv->lock);
74 list_for_each_entry (iter_bss, &priv->adapter->network_list, list) { 74 list_for_each_entry (iter_bss, &priv->network_list, list) {
75 u16 ibss = (iter_bss->capability & WLAN_CAPABILITY_IBSS); 75 u16 ibss = (iter_bss->capability & WLAN_CAPABILITY_IBSS);
76 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY); 76 u16 privacy = (iter_bss->capability & WLAN_CAPABILITY_PRIVACY);
77 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT); 77 u16 spectrum_mgmt = (iter_bss->capability & WLAN_CAPABILITY_SPECTRUM_MGMT);
@@ -90,7 +90,7 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
90 90
91 numscansdone++; 91 numscansdone++;
92 } 92 }
93 mutex_unlock(&priv->adapter->lock); 93 mutex_unlock(&priv->lock);
94 94
95 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 95 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
96 96
@@ -118,12 +118,12 @@ static ssize_t lbs_sleepparams_write(struct file *file,
118 res = -EFAULT; 118 res = -EFAULT;
119 goto out_unlock; 119 goto out_unlock;
120 } 120 }
121 priv->adapter->sp.sp_error = p1; 121 priv->sp.sp_error = p1;
122 priv->adapter->sp.sp_offset = p2; 122 priv->sp.sp_offset = p2;
123 priv->adapter->sp.sp_stabletime = p3; 123 priv->sp.sp_stabletime = p3;
124 priv->adapter->sp.sp_calcontrol = p4; 124 priv->sp.sp_calcontrol = p4;
125 priv->adapter->sp.sp_extsleepclk = p5; 125 priv->sp.sp_extsleepclk = p5;
126 priv->adapter->sp.sp_reserved = p6; 126 priv->sp.sp_reserved = p6;
127 127
128 res = lbs_prepare_and_send_command(priv, 128 res = lbs_prepare_and_send_command(priv,
129 CMD_802_11_SLEEP_PARAMS, 129 CMD_802_11_SLEEP_PARAMS,
@@ -144,7 +144,6 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
144 size_t count, loff_t *ppos) 144 size_t count, loff_t *ppos)
145{ 145{
146 struct lbs_private *priv = file->private_data; 146 struct lbs_private *priv = file->private_data;
147 struct lbs_adapter *adapter = priv->adapter;
148 ssize_t res; 147 ssize_t res;
149 size_t pos = 0; 148 size_t pos = 0;
150 unsigned long addr = get_zeroed_page(GFP_KERNEL); 149 unsigned long addr = get_zeroed_page(GFP_KERNEL);
@@ -159,10 +158,10 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
159 goto out_unlock; 158 goto out_unlock;
160 } 159 }
161 160
162 pos += snprintf(buf, len, "%d %d %d %d %d %d\n", adapter->sp.sp_error, 161 pos += snprintf(buf, len, "%d %d %d %d %d %d\n", priv->sp.sp_error,
163 adapter->sp.sp_offset, adapter->sp.sp_stabletime, 162 priv->sp.sp_offset, priv->sp.sp_stabletime,
164 adapter->sp.sp_calcontrol, adapter->sp.sp_extsleepclk, 163 priv->sp.sp_calcontrol, priv->sp.sp_extsleepclk,
165 adapter->sp.sp_reserved); 164 priv->sp.sp_reserved);
166 165
167 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 166 res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
168 167
@@ -321,11 +320,11 @@ static ssize_t lbs_setuserscan(struct file *file,
321 lbs_parse_type(buf, count, scan_cfg); 320 lbs_parse_type(buf, count, scan_cfg);
322 321
323 lbs_scan_networks(priv, scan_cfg, 1); 322 lbs_scan_networks(priv, scan_cfg, 1);
324 wait_event_interruptible(priv->adapter->cmd_pending, 323 wait_event_interruptible(priv->cmd_pending,
325 priv->adapter->surpriseremoved || 324 priv->surpriseremoved ||
326 (!priv->adapter->cur_cmd && list_empty(&priv->adapter->cmdpendingq))); 325 (!priv->cur_cmd && list_empty(&priv->cmdpendingq)));
327 326
328 if (priv->adapter->surpriseremoved) 327 if (priv->surpriseremoved)
329 goto out_scan_cfg; 328 goto out_scan_cfg;
330 329
331 memset(&wrqu, 0x00, sizeof(union iwreq_data)); 330 memset(&wrqu, 0x00, sizeof(union iwreq_data));
@@ -620,7 +619,6 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
620 size_t count, loff_t *ppos) 619 size_t count, loff_t *ppos)
621{ 620{
622 struct lbs_private *priv = file->private_data; 621 struct lbs_private *priv = file->private_data;
623 struct lbs_adapter *adapter = priv->adapter;
624 struct lbs_offset_value offval; 622 struct lbs_offset_value offval;
625 ssize_t pos = 0; 623 ssize_t pos = 0;
626 int ret; 624 int ret;
@@ -635,7 +633,7 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
635 CMD_OPTION_WAITFORRSP, 0, &offval); 633 CMD_OPTION_WAITFORRSP, 0, &offval);
636 mdelay(10); 634 mdelay(10);
637 pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n", 635 pos += snprintf(buf+pos, len-pos, "MAC[0x%x] = 0x%08x\n",
638 priv->mac_offset, adapter->offsetvalue.value); 636 priv->mac_offset, priv->offsetvalue.value);
639 637
640 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 638 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
641 free_page(addr); 639 free_page(addr);
@@ -703,7 +701,6 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
703 size_t count, loff_t *ppos) 701 size_t count, loff_t *ppos)
704{ 702{
705 struct lbs_private *priv = file->private_data; 703 struct lbs_private *priv = file->private_data;
706 struct lbs_adapter *adapter = priv->adapter;
707 struct lbs_offset_value offval; 704 struct lbs_offset_value offval;
708 ssize_t pos = 0; 705 ssize_t pos = 0;
709 int ret; 706 int ret;
@@ -718,7 +715,7 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
718 CMD_OPTION_WAITFORRSP, 0, &offval); 715 CMD_OPTION_WAITFORRSP, 0, &offval);
719 mdelay(10); 716 mdelay(10);
720 pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n", 717 pos += snprintf(buf+pos, len-pos, "BBP[0x%x] = 0x%08x\n",
721 priv->bbp_offset, adapter->offsetvalue.value); 718 priv->bbp_offset, priv->offsetvalue.value);
722 719
723 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 720 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
724 free_page(addr); 721 free_page(addr);
@@ -787,7 +784,6 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
787 size_t count, loff_t *ppos) 784 size_t count, loff_t *ppos)
788{ 785{
789 struct lbs_private *priv = file->private_data; 786 struct lbs_private *priv = file->private_data;
790 struct lbs_adapter *adapter = priv->adapter;
791 struct lbs_offset_value offval; 787 struct lbs_offset_value offval;
792 ssize_t pos = 0; 788 ssize_t pos = 0;
793 int ret; 789 int ret;
@@ -802,7 +798,7 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
802 CMD_OPTION_WAITFORRSP, 0, &offval); 798 CMD_OPTION_WAITFORRSP, 0, &offval);
803 mdelay(10); 799 mdelay(10);
804 pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n", 800 pos += snprintf(buf+pos, len-pos, "RF[0x%x] = 0x%08x\n",
805 priv->rf_offset, adapter->offsetvalue.value); 801 priv->rf_offset, priv->offsetvalue.value);
806 802
807 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); 803 ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
808 free_page(addr); 804 free_page(addr);
@@ -1009,8 +1005,8 @@ void lbs_debugfs_remove_one(struct lbs_private *priv)
1009 1005
1010#ifdef PROC_DEBUG 1006#ifdef PROC_DEBUG
1011 1007
1012#define item_size(n) (FIELD_SIZEOF(struct lbs_adapter, n)) 1008#define item_size(n) (FIELD_SIZEOF(struct lbs_private, n))
1013#define item_addr(n) (offsetof(struct lbs_adapter, n)) 1009#define item_addr(n) (offsetof(struct lbs_private, n))
1014 1010
1015 1011
1016struct debug_data { 1012struct debug_data {
@@ -1019,7 +1015,7 @@ struct debug_data {
1019 size_t addr; 1015 size_t addr;
1020}; 1016};
1021 1017
1022/* To debug any member of struct lbs_adapter, simply add one line here. 1018/* To debug any member of struct lbs_private, simply add one line here.
1023 */ 1019 */
1024static struct debug_data items[] = { 1020static struct debug_data items[] = {
1025 {"intcounter", item_size(intcounter), item_addr(intcounter)}, 1021 {"intcounter", item_size(intcounter), item_addr(intcounter)},
@@ -1158,7 +1154,7 @@ static void lbs_debug_init(struct lbs_private *priv, struct net_device *dev)
1158 return; 1154 return;
1159 1155
1160 for (i = 0; i < num_of_items; i++) 1156 for (i = 0; i < num_of_items; i++)
1161 items[i].addr += (size_t) priv->adapter; 1157 items[i].addr += (size_t) priv;
1162 1158
1163 priv->debugfs_debug = debugfs_create_file("debug", 0644, 1159 priv->debugfs_debug = debugfs_create_file("debug", 0644,
1164 priv->debugfs_dir, &items[0], 1160 priv->debugfs_dir, &items[0],
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 1a8fdaa7375c..e255b1915742 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -12,7 +12,6 @@
12 12
13/** Function Prototype Declaration */ 13/** Function Prototype Declaration */
14struct lbs_private; 14struct lbs_private;
15struct lbs_adapter;
16struct sk_buff; 15struct sk_buff;
17struct net_device; 16struct net_device;
18struct cmd_ctrl_node; 17struct cmd_ctrl_node;
@@ -32,7 +31,7 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
32 u16 cmd_action, 31 u16 cmd_action,
33 u16 wait_option, u32 cmd_oid, void *pdata_buf); 32 u16 wait_option, u32 cmd_oid, void *pdata_buf);
34 33
35void lbs_queue_cmd(struct lbs_adapter *adapter, 34void lbs_queue_cmd(struct lbs_private *priv,
36 struct cmd_ctrl_node *cmdnode, 35 struct cmd_ctrl_node *cmdnode,
37 u8 addtail); 36 u8 addtail);
38 37
@@ -43,7 +42,7 @@ void lbs_interrupt(struct net_device *);
43int lbs_set_radio_control(struct lbs_private *priv); 42int lbs_set_radio_control(struct lbs_private *priv);
44u32 lbs_fw_index_to_data_rate(u8 index); 43u32 lbs_fw_index_to_data_rate(u8 index);
45u8 lbs_data_rate_to_fw_index(u32 rate); 44u8 lbs_data_rate_to_fw_index(u32 rate);
46void lbs_get_fwversion(struct lbs_adapter *adapter, 45void lbs_get_fwversion(struct lbs_private *priv,
47 char *fwversion, 46 char *fwversion,
48 int maxlen); 47 int maxlen);
49 48
@@ -66,7 +65,7 @@ void lbs_ps_wakeup(struct lbs_private *priv, int wait_option);
66void lbs_tx_runqueue(struct lbs_private *priv); 65void lbs_tx_runqueue(struct lbs_private *priv);
67 66
68struct chan_freq_power *lbs_find_cfp_by_band_and_channel( 67struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
69 struct lbs_adapter *adapter, 68 struct lbs_private *priv,
70 u8 band, 69 u8 band,
71 u16 channel); 70 u16 channel);
72 71
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index eaa45d4bb9d2..21b0d382096b 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -1,7 +1,7 @@
1/** 1/**
2 * This file contains definitions and data structures specific 2 * This file contains definitions and data structures specific
3 * to Marvell 802.11 NIC. It contains the Device Information 3 * to Marvell 802.11 NIC. It contains the Device Information
4 * structure struct lbs_adapter. 4 * structure struct lbs_private..
5 */ 5 */
6#ifndef _LBS_DEV_H_ 6#ifndef _LBS_DEV_H_
7#define _LBS_DEV_H_ 7#define _LBS_DEV_H_
@@ -109,7 +109,6 @@ struct lbs_private {
109 char name[DEV_NAME_LEN]; 109 char name[DEV_NAME_LEN];
110 110
111 void *card; 111 void *card;
112 struct lbs_adapter *adapter;
113 struct net_device *dev; 112 struct net_device *dev;
114 113
115 struct net_device_stats stats; 114 struct net_device_stats stats;
@@ -156,54 +155,10 @@ struct lbs_private {
156 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb); 155 int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
157 int (*hw_get_int_status) (struct lbs_private *priv, u8 *); 156 int (*hw_get_int_status) (struct lbs_private *priv, u8 *);
158 int (*hw_read_event_cause) (struct lbs_private *); 157 int (*hw_read_event_cause) (struct lbs_private *);
159};
160
161/** Association request
162 *
163 * Encapsulates all the options that describe a specific assocation request
164 * or configuration of the wireless card's radio, mode, and security settings.
165 */
166struct assoc_request {
167#define ASSOC_FLAG_SSID 1
168#define ASSOC_FLAG_CHANNEL 2
169#define ASSOC_FLAG_BAND 3
170#define ASSOC_FLAG_MODE 4
171#define ASSOC_FLAG_BSSID 5
172#define ASSOC_FLAG_WEP_KEYS 6
173#define ASSOC_FLAG_WEP_TX_KEYIDX 7
174#define ASSOC_FLAG_WPA_MCAST_KEY 8
175#define ASSOC_FLAG_WPA_UCAST_KEY 9
176#define ASSOC_FLAG_SECINFO 10
177#define ASSOC_FLAG_WPA_IE 11
178 unsigned long flags;
179
180 u8 ssid[IW_ESSID_MAX_SIZE + 1];
181 u8 ssid_len;
182 u8 channel;
183 u8 band;
184 u8 mode;
185 u8 bssid[ETH_ALEN];
186
187 /** WEP keys */
188 struct enc_key wep_keys[4];
189 u16 wep_tx_keyidx;
190
191 /** WPA keys */
192 struct enc_key wpa_mcast_key;
193 struct enc_key wpa_unicast_key;
194
195 struct lbs_802_11_security secinfo;
196 158
197 /** WPA Information Elements*/ 159 /* was struct lbs_adapter from here... */
198 u8 wpa_ie[MAX_WPA_IE_LEN];
199 u8 wpa_ie_len;
200
201 /* BSS to associate with for infrastructure of Ad-Hoc join */
202 struct bss_descriptor bss;
203};
204 160
205/** Wlan adapter data structure*/ 161 /** Wlan adapter data structure*/
206struct lbs_adapter {
207 /** STATUS variables */ 162 /** STATUS variables */
208 u8 fwreleasenumber[4]; 163 u8 fwreleasenumber[4];
209 u32 fwcapinfo; 164 u32 fwcapinfo;
@@ -229,7 +184,7 @@ struct lbs_adapter {
229 struct list_head cmdpendingq; 184 struct list_head cmdpendingq;
230 185
231 wait_queue_head_t cmd_pending; 186 wait_queue_head_t cmd_pending;
232 /* command related variables protected by adapter->driver_lock */ 187 /* command related variables protected by priv->driver_lock */
233 188
234 /** Async and Sync Event variables */ 189 /** Async and Sync Event variables */
235 u32 intcounter; 190 u32 intcounter;
@@ -366,4 +321,48 @@ struct lbs_adapter {
366 u8 fw_ready; 321 u8 fw_ready;
367}; 322};
368 323
324/** Association request
325 *
326 * Encapsulates all the options that describe a specific assocation request
327 * or configuration of the wireless card's radio, mode, and security settings.
328 */
329struct assoc_request {
330#define ASSOC_FLAG_SSID 1
331#define ASSOC_FLAG_CHANNEL 2
332#define ASSOC_FLAG_BAND 3
333#define ASSOC_FLAG_MODE 4
334#define ASSOC_FLAG_BSSID 5
335#define ASSOC_FLAG_WEP_KEYS 6
336#define ASSOC_FLAG_WEP_TX_KEYIDX 7
337#define ASSOC_FLAG_WPA_MCAST_KEY 8
338#define ASSOC_FLAG_WPA_UCAST_KEY 9
339#define ASSOC_FLAG_SECINFO 10
340#define ASSOC_FLAG_WPA_IE 11
341 unsigned long flags;
342
343 u8 ssid[IW_ESSID_MAX_SIZE + 1];
344 u8 ssid_len;
345 u8 channel;
346 u8 band;
347 u8 mode;
348 u8 bssid[ETH_ALEN];
349
350 /** WEP keys */
351 struct enc_key wep_keys[4];
352 u16 wep_tx_keyidx;
353
354 /** WPA keys */
355 struct enc_key wpa_mcast_key;
356 struct enc_key wpa_unicast_key;
357
358 struct lbs_802_11_security secinfo;
359
360 /** WPA Information Elements*/
361 u8 wpa_ie[MAX_WPA_IE_LEN];
362 u8 wpa_ie_len;
363
364 /* BSS to associate with for infrastructure of Ad-Hoc join */
365 struct bss_descriptor bss;
366};
367
369#endif 368#endif
diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
index f32fb00129e7..a54b4f406af2 100644
--- a/drivers/net/wireless/libertas/ethtool.c
+++ b/drivers/net/wireless/libertas/ethtool.c
@@ -25,7 +25,7 @@ static void lbs_ethtool_get_drvinfo(struct net_device *dev,
25 struct lbs_private *priv = (struct lbs_private *) dev->priv; 25 struct lbs_private *priv = (struct lbs_private *) dev->priv;
26 char fwver[32]; 26 char fwver[32];
27 27
28 lbs_get_fwversion(priv->adapter, fwver, sizeof(fwver) - 1); 28 lbs_get_fwversion(priv, fwver, sizeof(fwver) - 1);
29 29
30 strcpy(info->driver, "libertas"); 30 strcpy(info->driver, "libertas");
31 strcpy(info->version, lbs_driver_version); 31 strcpy(info->version, lbs_driver_version);
@@ -46,7 +46,6 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
46 struct ethtool_eeprom *eeprom, u8 * bytes) 46 struct ethtool_eeprom *eeprom, u8 * bytes)
47{ 47{
48 struct lbs_private *priv = (struct lbs_private *) dev->priv; 48 struct lbs_private *priv = (struct lbs_private *) dev->priv;
49 struct lbs_adapter *adapter = priv->adapter;
50 struct lbs_ioctl_regrdwr regctrl; 49 struct lbs_ioctl_regrdwr regctrl;
51 char *ptr; 50 char *ptr;
52 int ret; 51 int ret;
@@ -60,10 +59,10 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
60 59
61// mutex_lock(&priv->mutex); 60// mutex_lock(&priv->mutex);
62 61
63 adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL); 62 priv->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
64 if (!adapter->prdeeprom) 63 if (!priv->prdeeprom)
65 return -ENOMEM; 64 return -ENOMEM;
66 memcpy(adapter->prdeeprom, &regctrl, sizeof(regctrl)); 65 memcpy(priv->prdeeprom, &regctrl, sizeof(regctrl));
67 66
68 /* +14 is for action, offset, and NOB in 67 /* +14 is for action, offset, and NOB in
69 * response */ 68 * response */
@@ -77,14 +76,14 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
77 &regctrl); 76 &regctrl);
78 77
79 if (ret) { 78 if (ret) {
80 if (adapter->prdeeprom) 79 if (priv->prdeeprom)
81 kfree(adapter->prdeeprom); 80 kfree(priv->prdeeprom);
82 goto done; 81 goto done;
83 } 82 }
84 83
85 mdelay(10); 84 mdelay(10);
86 85
87 ptr = (char *)adapter->prdeeprom; 86 ptr = (char *)priv->prdeeprom;
88 87
89 /* skip the command header, but include the "value" u32 variable */ 88 /* skip the command header, but include the "value" u32 variable */
90 ptr = ptr + sizeof(struct lbs_ioctl_regrdwr) - 4; 89 ptr = ptr + sizeof(struct lbs_ioctl_regrdwr) - 4;
@@ -94,8 +93,8 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
94 */ 93 */
95 memcpy(bytes, ptr, eeprom->len); 94 memcpy(bytes, ptr, eeprom->len);
96 95
97 if (adapter->prdeeprom) 96 if (priv->prdeeprom)
98 kfree(adapter->prdeeprom); 97 kfree(priv->prdeeprom);
99// mutex_unlock(&priv->mutex); 98// mutex_unlock(&priv->mutex);
100 99
101 ret = 0; 100 ret = 0;
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 8508260a286b..49a01780dd03 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -255,7 +255,7 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
255 255
256 } else if (int_cause == 0xffff) { 256 } else if (int_cause == 0xffff) {
257 /* Read in junk, the card has probably been removed */ 257 /* Read in junk, the card has probably been removed */
258 card->priv->adapter->surpriseremoved = 1; 258 card->priv->surpriseremoved = 1;
259 259
260 } else { 260 } else {
261 if (int_cause & IF_CS_H_IC_TX_OVER) 261 if (int_cause & IF_CS_H_IC_TX_OVER)
@@ -644,7 +644,6 @@ static int if_cs_host_to_card(struct lbs_private *priv,
644static int if_cs_get_int_status(struct lbs_private *priv, u8 *ireg) 644static int if_cs_get_int_status(struct lbs_private *priv, u8 *ireg)
645{ 645{
646 struct if_cs_card *card = (struct if_cs_card *)priv->card; 646 struct if_cs_card *card = (struct if_cs_card *)priv->card;
647 /* struct lbs_adapter *adapter = priv->adapter; */
648 int ret = 0; 647 int ret = 0;
649 u16 int_cause; 648 u16 int_cause;
650 u8 *cmdbuf; 649 u8 *cmdbuf;
@@ -652,7 +651,7 @@ static int if_cs_get_int_status(struct lbs_private *priv, u8 *ireg)
652 651
653 lbs_deb_enter(LBS_DEB_CS); 652 lbs_deb_enter(LBS_DEB_CS);
654 653
655 if (priv->adapter->surpriseremoved) 654 if (priv->surpriseremoved)
656 goto out; 655 goto out;
657 656
658 int_cause = if_cs_read16(card, IF_CS_C_INT_CAUSE) & IF_CS_C_IC_MASK; 657 int_cause = if_cs_read16(card, IF_CS_C_INT_CAUSE) & IF_CS_C_IC_MASK;
@@ -678,22 +677,22 @@ sbi_get_int_status_exit:
678 677
679 /* Card has a command result for us */ 678 /* Card has a command result for us */
680 if (*ireg & IF_CS_C_S_CMD_UPLD_RDY) { 679 if (*ireg & IF_CS_C_S_CMD_UPLD_RDY) {
681 spin_lock(&priv->adapter->driver_lock); 680 spin_lock(&priv->driver_lock);
682 if (!priv->adapter->cur_cmd) { 681 if (!priv->cur_cmd) {
683 cmdbuf = priv->upld_buf; 682 cmdbuf = priv->upld_buf;
684 priv->adapter->hisregcpy &= ~IF_CS_C_S_RX_UPLD_RDY; 683 priv->hisregcpy &= ~IF_CS_C_S_RX_UPLD_RDY;
685 } else { 684 } else {
686 cmdbuf = priv->adapter->cur_cmd->bufvirtualaddr; 685 cmdbuf = priv->cur_cmd->bufvirtualaddr;
687 } 686 }
688 687
689 ret = if_cs_receive_cmdres(priv, cmdbuf, &priv->upld_len); 688 ret = if_cs_receive_cmdres(priv, cmdbuf, &priv->upld_len);
690 spin_unlock(&priv->adapter->driver_lock); 689 spin_unlock(&priv->driver_lock);
691 if (ret < 0) 690 if (ret < 0)
692 lbs_pr_err("could not receive cmd from card\n"); 691 lbs_pr_err("could not receive cmd from card\n");
693 } 692 }
694 693
695out: 694out:
696 lbs_deb_leave_args(LBS_DEB_CS, "ret %d, ireg 0x%x, hisregcpy 0x%x", ret, *ireg, priv->adapter->hisregcpy); 695 lbs_deb_leave_args(LBS_DEB_CS, "ret %d, ireg 0x%x, hisregcpy 0x%x", ret, *ireg, priv->hisregcpy);
697 return ret; 696 return ret;
698} 697}
699 698
@@ -702,7 +701,7 @@ static int if_cs_read_event_cause(struct lbs_private *priv)
702{ 701{
703 lbs_deb_enter(LBS_DEB_CS); 702 lbs_deb_enter(LBS_DEB_CS);
704 703
705 priv->adapter->eventcause = (if_cs_read16(priv->card, IF_CS_C_STATUS) & IF_CS_C_S_STATUS_MASK) >> 5; 704 priv->eventcause = (if_cs_read16(priv->card, IF_CS_C_STATUS) & IF_CS_C_S_STATUS_MASK) >> 5;
706 if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_HOST_EVENT); 705 if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_HOST_EVENT);
707 706
708 return 0; 707 return 0;
@@ -869,7 +868,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
869 priv->hw_get_int_status = if_cs_get_int_status; 868 priv->hw_get_int_status = if_cs_get_int_status;
870 priv->hw_read_event_cause = if_cs_read_event_cause; 869 priv->hw_read_event_cause = if_cs_read_event_cause;
871 870
872 priv->adapter->fw_ready = 1; 871 priv->fw_ready = 1;
873 872
874 /* Now actually get the IRQ */ 873 /* Now actually get the IRQ */
875 ret = request_irq(p_dev->irq.AssignedIRQ, if_cs_interrupt, 874 ret = request_irq(p_dev->irq.AssignedIRQ, if_cs_interrupt,
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index 181ebf0fc0df..24239609367f 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -134,9 +134,9 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
134 134
135 lbs_deb_enter(LBS_DEB_SDIO); 135 lbs_deb_enter(LBS_DEB_SDIO);
136 136
137 spin_lock_irqsave(&card->priv->adapter->driver_lock, flags); 137 spin_lock_irqsave(&card->priv->driver_lock, flags);
138 138
139 if (!card->priv->adapter->cur_cmd) { 139 if (!card->priv->cur_cmd) {
140 lbs_deb_sdio("discarding spurious response\n"); 140 lbs_deb_sdio("discarding spurious response\n");
141 ret = 0; 141 ret = 0;
142 goto out; 142 goto out;
@@ -149,7 +149,7 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
149 goto out; 149 goto out;
150 } 150 }
151 151
152 memcpy(card->priv->adapter->cur_cmd->bufvirtualaddr, buffer, size); 152 memcpy(card->priv->cur_cmd->bufvirtualaddr, buffer, size);
153 card->priv->upld_len = size; 153 card->priv->upld_len = size;
154 154
155 card->int_cause |= MRVDRV_CMD_UPLD_RDY; 155 card->int_cause |= MRVDRV_CMD_UPLD_RDY;
@@ -159,7 +159,7 @@ static int if_sdio_handle_cmd(struct if_sdio_card *card,
159 ret = 0; 159 ret = 0;
160 160
161out: 161out:
162 spin_unlock_irqrestore(&card->priv->adapter->driver_lock, flags); 162 spin_unlock_irqrestore(&card->priv->driver_lock, flags);
163 163
164 lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret); 164 lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
165 165
@@ -231,14 +231,14 @@ static int if_sdio_handle_event(struct if_sdio_card *card,
231 event <<= SBI_EVENT_CAUSE_SHIFT; 231 event <<= SBI_EVENT_CAUSE_SHIFT;
232 } 232 }
233 233
234 spin_lock_irqsave(&card->priv->adapter->driver_lock, flags); 234 spin_lock_irqsave(&card->priv->driver_lock, flags);
235 235
236 card->event = event; 236 card->event = event;
237 card->int_cause |= MRVDRV_CARDEVENT; 237 card->int_cause |= MRVDRV_CARDEVENT;
238 238
239 lbs_interrupt(card->priv->dev); 239 lbs_interrupt(card->priv->dev);
240 240
241 spin_unlock_irqrestore(&card->priv->adapter->driver_lock, flags); 241 spin_unlock_irqrestore(&card->priv->driver_lock, flags);
242 242
243 ret = 0; 243 ret = 0;
244 244
@@ -800,7 +800,7 @@ static int if_sdio_read_event_cause(struct lbs_private *priv)
800 800
801 card = priv->card; 801 card = priv->card;
802 802
803 priv->adapter->eventcause = card->event; 803 priv->eventcause = card->event;
804 804
805 lbs_deb_leave(LBS_DEB_SDIO); 805 lbs_deb_leave(LBS_DEB_SDIO);
806 806
@@ -962,7 +962,7 @@ static int if_sdio_probe(struct sdio_func *func,
962 priv->hw_get_int_status = if_sdio_get_int_status; 962 priv->hw_get_int_status = if_sdio_get_int_status;
963 priv->hw_read_event_cause = if_sdio_read_event_cause; 963 priv->hw_read_event_cause = if_sdio_read_event_cause;
964 964
965 priv->adapter->fw_ready = 1; 965 priv->fw_ready = 1;
966 966
967 /* 967 /*
968 * Enable interrupts now that everything is set up 968 * Enable interrupts now that everything is set up
@@ -985,7 +985,7 @@ out:
985err_activate_card: 985err_activate_card:
986 flush_scheduled_work(); 986 flush_scheduled_work();
987 free_netdev(priv->dev); 987 free_netdev(priv->dev);
988 kfree(priv->adapter); 988 kfree(priv);
989reclaim: 989reclaim:
990 sdio_claim_host(func); 990 sdio_claim_host(func);
991release_int: 991release_int:
@@ -1015,7 +1015,7 @@ static void if_sdio_remove(struct sdio_func *func)
1015 1015
1016 card = sdio_get_drvdata(func); 1016 card = sdio_get_drvdata(func);
1017 1017
1018 card->priv->adapter->surpriseremoved = 1; 1018 card->priv->surpriseremoved = 1;
1019 1019
1020 lbs_deb_sdio("call remove card\n"); 1020 lbs_deb_sdio("call remove card\n");
1021 lbs_stop_card(card->priv); 1021 lbs_stop_card(card->priv);
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 7c4bd8d982a5..87bed4a1718d 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -229,7 +229,7 @@ static int if_usb_probe(struct usb_interface *intf,
229 /* Delay 200 ms to waiting for the FW ready */ 229 /* Delay 200 ms to waiting for the FW ready */
230 if_usb_submit_rx_urb(cardp); 230 if_usb_submit_rx_urb(cardp);
231 msleep_interruptible(200); 231 msleep_interruptible(200);
232 priv->adapter->fw_ready = 1; 232 priv->fw_ready = 1;
233 233
234 if (lbs_start_card(priv)) 234 if (lbs_start_card(priv))
235 goto err_start_card; 235 goto err_start_card;
@@ -270,9 +270,8 @@ static void if_usb_disconnect(struct usb_interface *intf)
270 cardp->surprise_removed = 1; 270 cardp->surprise_removed = 1;
271 271
272 if (priv) { 272 if (priv) {
273 struct lbs_adapter *adapter = priv->adapter;
274 273
275 adapter->surpriseremoved = 1; 274 priv->surpriseremoved = 1;
276 lbs_stop_card(priv); 275 lbs_stop_card(priv);
277 lbs_remove_mesh(priv); 276 lbs_remove_mesh(priv);
278 lbs_remove_card(priv); 277 lbs_remove_card(priv);
@@ -609,14 +608,14 @@ static inline void process_cmdrequest(int recvlength, u8 *recvbuff,
609 if (!in_interrupt()) 608 if (!in_interrupt())
610 BUG(); 609 BUG();
611 610
612 spin_lock(&priv->adapter->driver_lock); 611 spin_lock(&priv->driver_lock);
613 /* take care of cur_cmd = NULL case by reading the 612 /* take care of cur_cmd = NULL case by reading the
614 * data to clear the interrupt */ 613 * data to clear the interrupt */
615 if (!priv->adapter->cur_cmd) { 614 if (!priv->cur_cmd) {
616 cmdbuf = priv->upld_buf; 615 cmdbuf = priv->upld_buf;
617 priv->adapter->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; 616 priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY;
618 } else 617 } else
619 cmdbuf = priv->adapter->cur_cmd->bufvirtualaddr; 618 cmdbuf = priv->cur_cmd->bufvirtualaddr;
620 619
621 cardp->usb_int_cause |= MRVDRV_CMD_UPLD_RDY; 620 cardp->usb_int_cause |= MRVDRV_CMD_UPLD_RDY;
622 priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); 621 priv->upld_len = (recvlength - MESSAGE_HEADER_LEN);
@@ -625,7 +624,7 @@ static inline void process_cmdrequest(int recvlength, u8 *recvbuff,
625 624
626 kfree_skb(skb); 625 kfree_skb(skb);
627 lbs_interrupt(priv->dev); 626 lbs_interrupt(priv->dev);
628 spin_unlock(&priv->adapter->driver_lock); 627 spin_unlock(&priv->driver_lock);
629 628
630 lbs_deb_usbd(&cardp->udev->dev, 629 lbs_deb_usbd(&cardp->udev->dev,
631 "Wake up main thread to handle cmd response\n"); 630 "Wake up main thread to handle cmd response\n");
@@ -685,20 +684,20 @@ static void if_usb_receive(struct urb *urb)
685 684
686 case CMD_TYPE_INDICATION: 685 case CMD_TYPE_INDICATION:
687 /* Event cause handling */ 686 /* Event cause handling */
688 spin_lock(&priv->adapter->driver_lock); 687 spin_lock(&priv->driver_lock);
689 cardp->usb_event_cause = le32_to_cpu(*(__le32 *) (recvbuff + MESSAGE_HEADER_LEN)); 688 cardp->usb_event_cause = le32_to_cpu(*(__le32 *) (recvbuff + MESSAGE_HEADER_LEN));
690 lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n", 689 lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n",
691 cardp->usb_event_cause); 690 cardp->usb_event_cause);
692 if (cardp->usb_event_cause & 0xffff0000) { 691 if (cardp->usb_event_cause & 0xffff0000) {
693 lbs_send_tx_feedback(priv); 692 lbs_send_tx_feedback(priv);
694 spin_unlock(&priv->adapter->driver_lock); 693 spin_unlock(&priv->driver_lock);
695 break; 694 break;
696 } 695 }
697 cardp->usb_event_cause <<= 3; 696 cardp->usb_event_cause <<= 3;
698 cardp->usb_int_cause |= MRVDRV_CARDEVENT; 697 cardp->usb_int_cause |= MRVDRV_CARDEVENT;
699 kfree_skb(skb); 698 kfree_skb(skb);
700 lbs_interrupt(priv->dev); 699 lbs_interrupt(priv->dev);
701 spin_unlock(&priv->adapter->driver_lock); 700 spin_unlock(&priv->driver_lock);
702 goto rx_exit; 701 goto rx_exit;
703 default: 702 default:
704 lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n", 703 lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n",
@@ -750,7 +749,7 @@ static int if_usb_host_to_card(struct lbs_private *priv,
750 nb + MESSAGE_HEADER_LEN); 749 nb + MESSAGE_HEADER_LEN);
751} 750}
752 751
753/* called with adapter->driver_lock held */ 752/* called with priv->driver_lock held */
754static int if_usb_get_int_status(struct lbs_private *priv, u8 *ireg) 753static int if_usb_get_int_status(struct lbs_private *priv, u8 *ireg)
755{ 754{
756 struct usb_card_rec *cardp = priv->card; 755 struct usb_card_rec *cardp = priv->card;
@@ -767,7 +766,7 @@ static int if_usb_read_event_cause(struct lbs_private *priv)
767{ 766{
768 struct usb_card_rec *cardp = priv->card; 767 struct usb_card_rec *cardp = priv->card;
769 768
770 priv->adapter->eventcause = cardp->usb_event_cause; 769 priv->eventcause = cardp->usb_event_cause;
771 /* Re-submit rx urb here to avoid event lost issue */ 770 /* Re-submit rx urb here to avoid event lost issue */
772 if_usb_submit_rx_urb(cardp); 771 if_usb_submit_rx_urb(cardp);
773 return 0; 772 return 0;
@@ -942,7 +941,7 @@ static int if_usb_suspend(struct usb_interface *intf, pm_message_t message)
942 941
943 lbs_deb_enter(LBS_DEB_USB); 942 lbs_deb_enter(LBS_DEB_USB);
944 943
945 if (priv->adapter->psstate != PS_STATE_FULL_POWER) 944 if (priv->psstate != PS_STATE_FULL_POWER)
946 return -1; 945 return -1;
947 946
948 if (priv->mesh_dev && !priv->mesh_autostart_enabled) { 947 if (priv->mesh_dev && !priv->mesh_autostart_enabled) {
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c
index 1550e6afb053..14425d9a198a 100644
--- a/drivers/net/wireless/libertas/join.c
+++ b/drivers/net/wireless/libertas/join.c
@@ -30,13 +30,13 @@
30 * NOTE: Setting the MSB of the basic rates need to be taken 30 * NOTE: Setting the MSB of the basic rates need to be taken
31 * care, either before or after calling this function 31 * care, either before or after calling this function
32 * 32 *
33 * @param adapter A pointer to struct lbs_adapter structure 33 * @param priv A pointer to struct lbs_private structure
34 * @param rate1 the buffer which keeps input and output 34 * @param rate1 the buffer which keeps input and output
35 * @param rate1_size the size of rate1 buffer; new size of buffer on return 35 * @param rate1_size the size of rate1 buffer; new size of buffer on return
36 * 36 *
37 * @return 0 or -1 37 * @return 0 or -1
38 */ 38 */
39static int get_common_rates(struct lbs_adapter *adapter, 39static int get_common_rates(struct lbs_private *priv,
40 u8 *rates, 40 u8 *rates,
41 u16 *rates_size) 41 u16 *rates_size)
42{ 42{
@@ -57,15 +57,15 @@ static int get_common_rates(struct lbs_adapter *adapter,
57 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size); 57 lbs_deb_hex(LBS_DEB_JOIN, "AP rates ", rates, *rates_size);
58 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates); 58 lbs_deb_hex(LBS_DEB_JOIN, "card rates ", card_rates, num_card_rates);
59 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); 59 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size);
60 lbs_deb_join("TX data rate 0x%02x\n", adapter->cur_rate); 60 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate);
61 61
62 if (!adapter->auto_rate) { 62 if (!priv->auto_rate) {
63 for (i = 0; i < tmp_size; i++) { 63 for (i = 0; i < tmp_size; i++) {
64 if (tmp[i] == adapter->cur_rate) 64 if (tmp[i] == priv->cur_rate)
65 goto done; 65 goto done;
66 } 66 }
67 lbs_pr_alert("Previously set fixed data rate %#x isn't " 67 lbs_pr_alert("Previously set fixed data rate %#x isn't "
68 "compatible with the network.\n", adapter->cur_rate); 68 "compatible with the network.\n", priv->cur_rate);
69 ret = -1; 69 ret = -1;
70 goto done; 70 goto done;
71 } 71 }
@@ -125,7 +125,6 @@ void lbs_unset_basic_rate_flags(u8 *rates, size_t len)
125 */ 125 */
126int lbs_associate(struct lbs_private *priv, struct assoc_request *assoc_req) 126int lbs_associate(struct lbs_private *priv, struct assoc_request *assoc_req)
127{ 127{
128 struct lbs_adapter *adapter = priv->adapter;
129 int ret; 128 int ret;
130 129
131 lbs_deb_enter(LBS_DEB_ASSOC); 130 lbs_deb_enter(LBS_DEB_ASSOC);
@@ -138,11 +137,11 @@ int lbs_associate(struct lbs_private *priv, struct assoc_request *assoc_req)
138 goto done; 137 goto done;
139 138
140 /* set preamble to firmware */ 139 /* set preamble to firmware */
141 if ( (adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 140 if ( (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
142 && (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) 141 && (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
143 adapter->preamble = CMD_TYPE_SHORT_PREAMBLE; 142 priv->preamble = CMD_TYPE_SHORT_PREAMBLE;
144 else 143 else
145 adapter->preamble = CMD_TYPE_LONG_PREAMBLE; 144 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
146 145
147 lbs_set_radio_control(priv); 146 lbs_set_radio_control(priv);
148 147
@@ -164,17 +163,16 @@ done:
164int lbs_start_adhoc_network(struct lbs_private *priv, 163int lbs_start_adhoc_network(struct lbs_private *priv,
165 struct assoc_request *assoc_req) 164 struct assoc_request *assoc_req)
166{ 165{
167 struct lbs_adapter *adapter = priv->adapter;
168 int ret = 0; 166 int ret = 0;
169 167
170 adapter->adhoccreate = 1; 168 priv->adhoccreate = 1;
171 169
172 if (adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) { 170 if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) {
173 lbs_deb_join("AdhocStart: Short preamble\n"); 171 lbs_deb_join("AdhocStart: Short preamble\n");
174 adapter->preamble = CMD_TYPE_SHORT_PREAMBLE; 172 priv->preamble = CMD_TYPE_SHORT_PREAMBLE;
175 } else { 173 } else {
176 lbs_deb_join("AdhocStart: Long preamble\n"); 174 lbs_deb_join("AdhocStart: Long preamble\n");
177 adapter->preamble = CMD_TYPE_LONG_PREAMBLE; 175 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
178 } 176 }
179 177
180 lbs_set_radio_control(priv); 178 lbs_set_radio_control(priv);
@@ -200,26 +198,25 @@ int lbs_start_adhoc_network(struct lbs_private *priv,
200int lbs_join_adhoc_network(struct lbs_private *priv, 198int lbs_join_adhoc_network(struct lbs_private *priv,
201 struct assoc_request *assoc_req) 199 struct assoc_request *assoc_req)
202{ 200{
203 struct lbs_adapter *adapter = priv->adapter;
204 struct bss_descriptor * bss = &assoc_req->bss; 201 struct bss_descriptor * bss = &assoc_req->bss;
205 int ret = 0; 202 int ret = 0;
206 203
207 lbs_deb_join("%s: Current SSID '%s', ssid length %u\n", 204 lbs_deb_join("%s: Current SSID '%s', ssid length %u\n",
208 __func__, 205 __func__,
209 escape_essid(adapter->curbssparams.ssid, 206 escape_essid(priv->curbssparams.ssid,
210 adapter->curbssparams.ssid_len), 207 priv->curbssparams.ssid_len),
211 adapter->curbssparams.ssid_len); 208 priv->curbssparams.ssid_len);
212 lbs_deb_join("%s: requested ssid '%s', ssid length %u\n", 209 lbs_deb_join("%s: requested ssid '%s', ssid length %u\n",
213 __func__, escape_essid(bss->ssid, bss->ssid_len), 210 __func__, escape_essid(bss->ssid, bss->ssid_len),
214 bss->ssid_len); 211 bss->ssid_len);
215 212
216 /* check if the requested SSID is already joined */ 213 /* check if the requested SSID is already joined */
217 if ( adapter->curbssparams.ssid_len 214 if ( priv->curbssparams.ssid_len
218 && !lbs_ssid_cmp(adapter->curbssparams.ssid, 215 && !lbs_ssid_cmp(priv->curbssparams.ssid,
219 adapter->curbssparams.ssid_len, 216 priv->curbssparams.ssid_len,
220 bss->ssid, bss->ssid_len) 217 bss->ssid, bss->ssid_len)
221 && (adapter->mode == IW_MODE_ADHOC) 218 && (priv->mode == IW_MODE_ADHOC)
222 && (adapter->connect_status == LBS_CONNECTED)) { 219 && (priv->connect_status == LBS_CONNECTED)) {
223 union iwreq_data wrqu; 220 union iwreq_data wrqu;
224 221
225 lbs_deb_join("ADHOC_J_CMD: New ad-hoc SSID is the same as " 222 lbs_deb_join("ADHOC_J_CMD: New ad-hoc SSID is the same as "
@@ -229,7 +226,7 @@ int lbs_join_adhoc_network(struct lbs_private *priv,
229 * request really was successful, even if just a null-op. 226 * request really was successful, even if just a null-op.
230 */ 227 */
231 memset(&wrqu, 0, sizeof(wrqu)); 228 memset(&wrqu, 0, sizeof(wrqu));
232 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, 229 memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid,
233 ETH_ALEN); 230 ETH_ALEN);
234 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 231 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
235 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 232 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
@@ -239,12 +236,12 @@ int lbs_join_adhoc_network(struct lbs_private *priv,
239 /* Use shortpreamble only when both creator and card supports 236 /* Use shortpreamble only when both creator and card supports
240 short preamble */ 237 short preamble */
241 if ( !(bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) 238 if ( !(bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
242 || !(adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) { 239 || !(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
243 lbs_deb_join("AdhocJoin: Long preamble\n"); 240 lbs_deb_join("AdhocJoin: Long preamble\n");
244 adapter->preamble = CMD_TYPE_LONG_PREAMBLE; 241 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
245 } else { 242 } else {
246 lbs_deb_join("AdhocJoin: Short preamble\n"); 243 lbs_deb_join("AdhocJoin: Short preamble\n");
247 adapter->preamble = CMD_TYPE_SHORT_PREAMBLE; 244 priv->preamble = CMD_TYPE_SHORT_PREAMBLE;
248 } 245 }
249 246
250 lbs_set_radio_control(priv); 247 lbs_set_radio_control(priv);
@@ -252,7 +249,7 @@ int lbs_join_adhoc_network(struct lbs_private *priv,
252 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel); 249 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel);
253 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band); 250 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band);
254 251
255 adapter->adhoccreate = 0; 252 priv->adhoccreate = 0;
256 253
257 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_JOIN, 254 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_JOIN,
258 0, CMD_OPTION_WAITFORRSP, 255 0, CMD_OPTION_WAITFORRSP,
@@ -293,7 +290,6 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
293 struct cmd_ds_command *cmd, 290 struct cmd_ds_command *cmd,
294 void *pdata_buf) 291 void *pdata_buf)
295{ 292{
296 struct lbs_adapter *adapter = priv->adapter;
297 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth; 293 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth;
298 int ret = -1; 294 int ret = -1;
299 u8 *bssid = pdata_buf; 295 u8 *bssid = pdata_buf;
@@ -306,7 +302,7 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
306 + S_DS_GEN); 302 + S_DS_GEN);
307 303
308 /* translate auth mode to 802.11 defined wire value */ 304 /* translate auth mode to 802.11 defined wire value */
309 switch (adapter->secinfo.auth_mode) { 305 switch (priv->secinfo.auth_mode) {
310 case IW_AUTH_ALG_OPEN_SYSTEM: 306 case IW_AUTH_ALG_OPEN_SYSTEM:
311 pauthenticate->authtype = 0x00; 307 pauthenticate->authtype = 0x00;
312 break; 308 break;
@@ -318,7 +314,7 @@ int lbs_cmd_80211_authenticate(struct lbs_private *priv,
318 break; 314 break;
319 default: 315 default:
320 lbs_deb_join("AUTH_CMD: invalid auth alg 0x%X\n", 316 lbs_deb_join("AUTH_CMD: invalid auth alg 0x%X\n",
321 adapter->secinfo.auth_mode); 317 priv->secinfo.auth_mode);
322 goto out; 318 goto out;
323 } 319 }
324 320
@@ -336,7 +332,6 @@ out:
336int lbs_cmd_80211_deauthenticate(struct lbs_private *priv, 332int lbs_cmd_80211_deauthenticate(struct lbs_private *priv,
337 struct cmd_ds_command *cmd) 333 struct cmd_ds_command *cmd)
338{ 334{
339 struct lbs_adapter *adapter = priv->adapter;
340 struct cmd_ds_802_11_deauthenticate *dauth = &cmd->params.deauth; 335 struct cmd_ds_802_11_deauthenticate *dauth = &cmd->params.deauth;
341 336
342 lbs_deb_enter(LBS_DEB_JOIN); 337 lbs_deb_enter(LBS_DEB_JOIN);
@@ -346,7 +341,7 @@ int lbs_cmd_80211_deauthenticate(struct lbs_private *priv,
346 S_DS_GEN); 341 S_DS_GEN);
347 342
348 /* set AP MAC address */ 343 /* set AP MAC address */
349 memmove(dauth->macaddr, adapter->curbssparams.bssid, ETH_ALEN); 344 memmove(dauth->macaddr, priv->curbssparams.bssid, ETH_ALEN);
350 345
351 /* Reason code 3 = Station is leaving */ 346 /* Reason code 3 = Station is leaving */
352#define REASON_CODE_STA_LEAVING 3 347#define REASON_CODE_STA_LEAVING 3
@@ -359,7 +354,6 @@ int lbs_cmd_80211_deauthenticate(struct lbs_private *priv,
359int lbs_cmd_80211_associate(struct lbs_private *priv, 354int lbs_cmd_80211_associate(struct lbs_private *priv,
360 struct cmd_ds_command *cmd, void *pdata_buf) 355 struct cmd_ds_command *cmd, void *pdata_buf)
361{ 356{
362 struct lbs_adapter *adapter = priv->adapter;
363 struct cmd_ds_802_11_associate *passo = &cmd->params.associate; 357 struct cmd_ds_802_11_associate *passo = &cmd->params.associate;
364 int ret = 0; 358 int ret = 0;
365 struct assoc_request * assoc_req = pdata_buf; 359 struct assoc_request * assoc_req = pdata_buf;
@@ -376,7 +370,7 @@ int lbs_cmd_80211_associate(struct lbs_private *priv,
376 370
377 pos = (u8 *) passo; 371 pos = (u8 *) passo;
378 372
379 if (!adapter) { 373 if (!priv) {
380 ret = -1; 374 ret = -1;
381 goto done; 375 goto done;
382 } 376 }
@@ -420,7 +414,7 @@ int lbs_cmd_80211_associate(struct lbs_private *priv,
420 rates->header.type = cpu_to_le16(TLV_TYPE_RATES); 414 rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
421 memcpy(&rates->rates, &bss->rates, MAX_RATES); 415 memcpy(&rates->rates, &bss->rates, MAX_RATES);
422 tmplen = MAX_RATES; 416 tmplen = MAX_RATES;
423 if (get_common_rates(adapter, rates->rates, &tmplen)) { 417 if (get_common_rates(priv, rates->rates, &tmplen)) {
424 ret = -1; 418 ret = -1;
425 goto done; 419 goto done;
426 } 420 }
@@ -429,8 +423,8 @@ int lbs_cmd_80211_associate(struct lbs_private *priv,
429 lbs_deb_assoc("ASSOC_CMD: num rates %u\n", tmplen); 423 lbs_deb_assoc("ASSOC_CMD: num rates %u\n", tmplen);
430 424
431 /* Copy the infra. association rates into Current BSS state structure */ 425 /* Copy the infra. association rates into Current BSS state structure */
432 memset(&adapter->curbssparams.rates, 0, sizeof(adapter->curbssparams.rates)); 426 memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates));
433 memcpy(&adapter->curbssparams.rates, &rates->rates, tmplen); 427 memcpy(&priv->curbssparams.rates, &rates->rates, tmplen);
434 428
435 /* Set MSB on basic rates as the firmware requires, but _after_ 429 /* Set MSB on basic rates as the firmware requires, but _after_
436 * copying to current bss rates. 430 * copying to current bss rates.
@@ -450,7 +444,7 @@ int lbs_cmd_80211_associate(struct lbs_private *priv,
450 } 444 }
451 445
452 /* update curbssparams */ 446 /* update curbssparams */
453 adapter->curbssparams.channel = bss->phyparamset.dsparamset.currentchan; 447 priv->curbssparams.channel = bss->phyparamset.dsparamset.currentchan;
454 448
455 if (lbs_parse_dnld_countryinfo_11d(priv, bss)) { 449 if (lbs_parse_dnld_countryinfo_11d(priv, bss)) {
456 ret = -1; 450 ret = -1;
@@ -474,7 +468,6 @@ done:
474int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv, 468int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
475 struct cmd_ds_command *cmd, void *pdata_buf) 469 struct cmd_ds_command *cmd, void *pdata_buf)
476{ 470{
477 struct lbs_adapter *adapter = priv->adapter;
478 struct cmd_ds_802_11_ad_hoc_start *adhs = &cmd->params.ads; 471 struct cmd_ds_802_11_ad_hoc_start *adhs = &cmd->params.ads;
479 int ret = 0; 472 int ret = 0;
480 int cmdappendsize = 0; 473 int cmdappendsize = 0;
@@ -484,7 +477,7 @@ int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
484 477
485 lbs_deb_enter(LBS_DEB_JOIN); 478 lbs_deb_enter(LBS_DEB_JOIN);
486 479
487 if (!adapter) { 480 if (!priv) {
488 ret = -1; 481 ret = -1;
489 goto done; 482 goto done;
490 } 483 }
@@ -494,7 +487,7 @@ int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
494 /* 487 /*
495 * Fill in the parameters for 2 data structures: 488 * Fill in the parameters for 2 data structures:
496 * 1. cmd_ds_802_11_ad_hoc_start command 489 * 1. cmd_ds_802_11_ad_hoc_start command
497 * 2. adapter->scantable[i] 490 * 2. priv->scantable[i]
498 * 491 *
499 * Driver will fill up SSID, bsstype,IBSS param, Physical Param, 492 * Driver will fill up SSID, bsstype,IBSS param, Physical Param,
500 * probe delay, and cap info. 493 * probe delay, and cap info.
@@ -512,10 +505,10 @@ int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
512 505
513 /* set the BSS type */ 506 /* set the BSS type */
514 adhs->bsstype = CMD_BSS_TYPE_IBSS; 507 adhs->bsstype = CMD_BSS_TYPE_IBSS;
515 adapter->mode = IW_MODE_ADHOC; 508 priv->mode = IW_MODE_ADHOC;
516 if (adapter->beacon_period == 0) 509 if (priv->beacon_period == 0)
517 adapter->beacon_period = MRVDRV_BEACON_INTERVAL; 510 priv->beacon_period = MRVDRV_BEACON_INTERVAL;
518 adhs->beaconperiod = cpu_to_le16(adapter->beacon_period); 511 adhs->beaconperiod = cpu_to_le16(priv->beacon_period);
519 512
520 /* set Physical param set */ 513 /* set Physical param set */
521#define DS_PARA_IE_ID 3 514#define DS_PARA_IE_ID 3
@@ -557,8 +550,8 @@ int lbs_cmd_80211_ad_hoc_start(struct lbs_private *priv,
557 memcpy(adhs->rates, lbs_bg_rates, ratesize); 550 memcpy(adhs->rates, lbs_bg_rates, ratesize);
558 551
559 /* Copy the ad-hoc creating rates into Current BSS state structure */ 552 /* Copy the ad-hoc creating rates into Current BSS state structure */
560 memset(&adapter->curbssparams.rates, 0, sizeof(adapter->curbssparams.rates)); 553 memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates));
561 memcpy(&adapter->curbssparams.rates, &adhs->rates, ratesize); 554 memcpy(&priv->curbssparams.rates, &adhs->rates, ratesize);
562 555
563 /* Set MSB on basic rates as the firmware requires, but _after_ 556 /* Set MSB on basic rates as the firmware requires, but _after_
564 * copying to current bss rates. 557 * copying to current bss rates.
@@ -597,7 +590,6 @@ int lbs_cmd_80211_ad_hoc_stop(struct lbs_private *priv,
597int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv, 590int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv,
598 struct cmd_ds_command *cmd, void *pdata_buf) 591 struct cmd_ds_command *cmd, void *pdata_buf)
599{ 592{
600 struct lbs_adapter *adapter = priv->adapter;
601 struct cmd_ds_802_11_ad_hoc_join *join_cmd = &cmd->params.adj; 593 struct cmd_ds_802_11_ad_hoc_join *join_cmd = &cmd->params.adj;
602 struct assoc_request * assoc_req = pdata_buf; 594 struct assoc_request * assoc_req = pdata_buf;
603 struct bss_descriptor *bss = &assoc_req->bss; 595 struct bss_descriptor *bss = &assoc_req->bss;
@@ -638,21 +630,21 @@ int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv,
638 /* probedelay */ 630 /* probedelay */
639 join_cmd->probedelay = cpu_to_le16(CMD_SCAN_PROBE_DELAY_TIME); 631 join_cmd->probedelay = cpu_to_le16(CMD_SCAN_PROBE_DELAY_TIME);
640 632
641 adapter->curbssparams.channel = bss->channel; 633 priv->curbssparams.channel = bss->channel;
642 634
643 /* Copy Data rates from the rates recorded in scan response */ 635 /* Copy Data rates from the rates recorded in scan response */
644 memset(join_cmd->bss.rates, 0, sizeof(join_cmd->bss.rates)); 636 memset(join_cmd->bss.rates, 0, sizeof(join_cmd->bss.rates));
645 ratesize = min_t(u16, sizeof(join_cmd->bss.rates), MAX_RATES); 637 ratesize = min_t(u16, sizeof(join_cmd->bss.rates), MAX_RATES);
646 memcpy(join_cmd->bss.rates, bss->rates, ratesize); 638 memcpy(join_cmd->bss.rates, bss->rates, ratesize);
647 if (get_common_rates(adapter, join_cmd->bss.rates, &ratesize)) { 639 if (get_common_rates(priv, join_cmd->bss.rates, &ratesize)) {
648 lbs_deb_join("ADHOC_J_CMD: get_common_rates returns error.\n"); 640 lbs_deb_join("ADHOC_J_CMD: get_common_rates returns error.\n");
649 ret = -1; 641 ret = -1;
650 goto done; 642 goto done;
651 } 643 }
652 644
653 /* Copy the ad-hoc creating rates into Current BSS state structure */ 645 /* Copy the ad-hoc creating rates into Current BSS state structure */
654 memset(&adapter->curbssparams.rates, 0, sizeof(adapter->curbssparams.rates)); 646 memset(&priv->curbssparams.rates, 0, sizeof(priv->curbssparams.rates));
655 memcpy(&adapter->curbssparams.rates, join_cmd->bss.rates, ratesize); 647 memcpy(&priv->curbssparams.rates, join_cmd->bss.rates, ratesize);
656 648
657 /* Set MSB on basic rates as the firmware requires, but _after_ 649 /* Set MSB on basic rates as the firmware requires, but _after_
658 * copying to current bss rates. 650 * copying to current bss rates.
@@ -668,7 +660,7 @@ int lbs_cmd_80211_ad_hoc_join(struct lbs_private *priv,
668 join_cmd->bss.capability = cpu_to_le16(tmp); 660 join_cmd->bss.capability = cpu_to_le16(tmp);
669 } 661 }
670 662
671 if (adapter->psmode == LBS802_11POWERMODEMAX_PSP) { 663 if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
672 /* wake up first */ 664 /* wake up first */
673 __le32 Localpsmode; 665 __le32 Localpsmode;
674 666
@@ -700,7 +692,6 @@ done:
700int lbs_ret_80211_associate(struct lbs_private *priv, 692int lbs_ret_80211_associate(struct lbs_private *priv,
701 struct cmd_ds_command *resp) 693 struct cmd_ds_command *resp)
702{ 694{
703 struct lbs_adapter *adapter = priv->adapter;
704 int ret = 0; 695 int ret = 0;
705 union iwreq_data wrqu; 696 union iwreq_data wrqu;
706 struct ieeetypes_assocrsp *passocrsp; 697 struct ieeetypes_assocrsp *passocrsp;
@@ -709,12 +700,12 @@ int lbs_ret_80211_associate(struct lbs_private *priv,
709 700
710 lbs_deb_enter(LBS_DEB_ASSOC); 701 lbs_deb_enter(LBS_DEB_ASSOC);
711 702
712 if (!adapter->in_progress_assoc_req) { 703 if (!priv->in_progress_assoc_req) {
713 lbs_deb_assoc("ASSOC_RESP: no in-progress assoc request\n"); 704 lbs_deb_assoc("ASSOC_RESP: no in-progress assoc request\n");
714 ret = -1; 705 ret = -1;
715 goto done; 706 goto done;
716 } 707 }
717 bss = &adapter->in_progress_assoc_req->bss; 708 bss = &priv->in_progress_assoc_req->bss;
718 709
719 passocrsp = (struct ieeetypes_assocrsp *) & resp->params; 710 passocrsp = (struct ieeetypes_assocrsp *) & resp->params;
720 711
@@ -771,29 +762,29 @@ int lbs_ret_80211_associate(struct lbs_private *priv,
771 le16_to_cpu(resp->size) - S_DS_GEN); 762 le16_to_cpu(resp->size) - S_DS_GEN);
772 763
773 /* Send a Media Connected event, according to the Spec */ 764 /* Send a Media Connected event, according to the Spec */
774 adapter->connect_status = LBS_CONNECTED; 765 priv->connect_status = LBS_CONNECTED;
775 766
776 /* Update current SSID and BSSID */ 767 /* Update current SSID and BSSID */
777 memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); 768 memcpy(&priv->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE);
778 adapter->curbssparams.ssid_len = bss->ssid_len; 769 priv->curbssparams.ssid_len = bss->ssid_len;
779 memcpy(adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); 770 memcpy(priv->curbssparams.bssid, bss->bssid, ETH_ALEN);
780 771
781 lbs_deb_assoc("ASSOC_RESP: currentpacketfilter is 0x%x\n", 772 lbs_deb_assoc("ASSOC_RESP: currentpacketfilter is 0x%x\n",
782 adapter->currentpacketfilter); 773 priv->currentpacketfilter);
783 774
784 adapter->SNR[TYPE_RXPD][TYPE_AVG] = 0; 775 priv->SNR[TYPE_RXPD][TYPE_AVG] = 0;
785 adapter->NF[TYPE_RXPD][TYPE_AVG] = 0; 776 priv->NF[TYPE_RXPD][TYPE_AVG] = 0;
786 777
787 memset(adapter->rawSNR, 0x00, sizeof(adapter->rawSNR)); 778 memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
788 memset(adapter->rawNF, 0x00, sizeof(adapter->rawNF)); 779 memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
789 adapter->nextSNRNF = 0; 780 priv->nextSNRNF = 0;
790 adapter->numSNRNF = 0; 781 priv->numSNRNF = 0;
791 782
792 netif_carrier_on(priv->dev); 783 netif_carrier_on(priv->dev);
793 netif_wake_queue(priv->dev); 784 netif_wake_queue(priv->dev);
794 785
795 786
796 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN); 787 memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid, ETH_ALEN);
797 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 788 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
798 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 789 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
799 790
@@ -816,7 +807,6 @@ int lbs_ret_80211_disassociate(struct lbs_private *priv,
816int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv, 807int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv,
817 struct cmd_ds_command *resp) 808 struct cmd_ds_command *resp)
818{ 809{
819 struct lbs_adapter *adapter = priv->adapter;
820 int ret = 0; 810 int ret = 0;
821 u16 command = le16_to_cpu(resp->command); 811 u16 command = le16_to_cpu(resp->command);
822 u16 result = le16_to_cpu(resp->result); 812 u16 result = le16_to_cpu(resp->result);
@@ -833,19 +823,19 @@ int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv,
833 lbs_deb_join("ADHOC_RESP: command = %x\n", command); 823 lbs_deb_join("ADHOC_RESP: command = %x\n", command);
834 lbs_deb_join("ADHOC_RESP: result = %x\n", result); 824 lbs_deb_join("ADHOC_RESP: result = %x\n", result);
835 825
836 if (!adapter->in_progress_assoc_req) { 826 if (!priv->in_progress_assoc_req) {
837 lbs_deb_join("ADHOC_RESP: no in-progress association request\n"); 827 lbs_deb_join("ADHOC_RESP: no in-progress association request\n");
838 ret = -1; 828 ret = -1;
839 goto done; 829 goto done;
840 } 830 }
841 bss = &adapter->in_progress_assoc_req->bss; 831 bss = &priv->in_progress_assoc_req->bss;
842 832
843 /* 833 /*
844 * Join result code 0 --> SUCCESS 834 * Join result code 0 --> SUCCESS
845 */ 835 */
846 if (result) { 836 if (result) {
847 lbs_deb_join("ADHOC_RESP: failed\n"); 837 lbs_deb_join("ADHOC_RESP: failed\n");
848 if (adapter->connect_status == LBS_CONNECTED) { 838 if (priv->connect_status == LBS_CONNECTED) {
849 lbs_mac_event_disconnected(priv); 839 lbs_mac_event_disconnected(priv);
850 } 840 }
851 ret = -1; 841 ret = -1;
@@ -860,7 +850,7 @@ int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv,
860 escape_essid(bss->ssid, bss->ssid_len)); 850 escape_essid(bss->ssid, bss->ssid_len));
861 851
862 /* Send a Media Connected event, according to the Spec */ 852 /* Send a Media Connected event, according to the Spec */
863 adapter->connect_status = LBS_CONNECTED; 853 priv->connect_status = LBS_CONNECTED;
864 854
865 if (command == CMD_RET(CMD_802_11_AD_HOC_START)) { 855 if (command == CMD_RET(CMD_802_11_AD_HOC_START)) {
866 /* Update the created network descriptor with the new BSSID */ 856 /* Update the created network descriptor with the new BSSID */
@@ -868,22 +858,22 @@ int lbs_ret_80211_ad_hoc_start(struct lbs_private *priv,
868 } 858 }
869 859
870 /* Set the BSSID from the joined/started descriptor */ 860 /* Set the BSSID from the joined/started descriptor */
871 memcpy(&adapter->curbssparams.bssid, bss->bssid, ETH_ALEN); 861 memcpy(&priv->curbssparams.bssid, bss->bssid, ETH_ALEN);
872 862
873 /* Set the new SSID to current SSID */ 863 /* Set the new SSID to current SSID */
874 memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE); 864 memcpy(&priv->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE);
875 adapter->curbssparams.ssid_len = bss->ssid_len; 865 priv->curbssparams.ssid_len = bss->ssid_len;
876 866
877 netif_carrier_on(priv->dev); 867 netif_carrier_on(priv->dev);
878 netif_wake_queue(priv->dev); 868 netif_wake_queue(priv->dev);
879 869
880 memset(&wrqu, 0, sizeof(wrqu)); 870 memset(&wrqu, 0, sizeof(wrqu));
881 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN); 871 memcpy(wrqu.ap_addr.sa_data, priv->curbssparams.bssid, ETH_ALEN);
882 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 872 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
883 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 873 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
884 874
885 lbs_deb_join("ADHOC_RESP: - Joined/Started Ad Hoc\n"); 875 lbs_deb_join("ADHOC_RESP: - Joined/Started Ad Hoc\n");
886 lbs_deb_join("ADHOC_RESP: channel = %d\n", adapter->curbssparams.channel); 876 lbs_deb_join("ADHOC_RESP: channel = %d\n", priv->curbssparams.channel);
887 lbs_deb_join("ADHOC_RESP: BSSID = %s\n", 877 lbs_deb_join("ADHOC_RESP: BSSID = %s\n",
888 print_mac(mac, padhocresult->bssid)); 878 print_mac(mac, padhocresult->bssid));
889 879
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 7155f4818167..243cdea419c2 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -257,8 +257,7 @@ static ssize_t lbs_rtap_get(struct device *dev,
257 struct device_attribute *attr, char * buf) 257 struct device_attribute *attr, char * buf)
258{ 258{
259 struct lbs_private *priv = to_net_dev(dev)->priv; 259 struct lbs_private *priv = to_net_dev(dev)->priv;
260 struct lbs_adapter *adapter = priv->adapter; 260 return snprintf(buf, 5, "0x%X\n", priv->monitormode);
261 return snprintf(buf, 5, "0x%X\n", adapter->monitormode);
262} 261}
263 262
264/** 263/**
@@ -269,31 +268,30 @@ static ssize_t lbs_rtap_set(struct device *dev,
269{ 268{
270 int monitor_mode; 269 int monitor_mode;
271 struct lbs_private *priv = to_net_dev(dev)->priv; 270 struct lbs_private *priv = to_net_dev(dev)->priv;
272 struct lbs_adapter *adapter = priv->adapter;
273 271
274 sscanf(buf, "%x", &monitor_mode); 272 sscanf(buf, "%x", &monitor_mode);
275 if (monitor_mode != LBS_MONITOR_OFF) { 273 if (monitor_mode != LBS_MONITOR_OFF) {
276 if(adapter->monitormode == monitor_mode) 274 if(priv->monitormode == monitor_mode)
277 return strlen(buf); 275 return strlen(buf);
278 if (adapter->monitormode == LBS_MONITOR_OFF) { 276 if (priv->monitormode == LBS_MONITOR_OFF) {
279 if (adapter->mode == IW_MODE_INFRA) 277 if (priv->mode == IW_MODE_INFRA)
280 lbs_send_deauthentication(priv); 278 lbs_send_deauthentication(priv);
281 else if (adapter->mode == IW_MODE_ADHOC) 279 else if (priv->mode == IW_MODE_ADHOC)
282 lbs_stop_adhoc_network(priv); 280 lbs_stop_adhoc_network(priv);
283 lbs_add_rtap(priv); 281 lbs_add_rtap(priv);
284 } 282 }
285 adapter->monitormode = monitor_mode; 283 priv->monitormode = monitor_mode;
286 } 284 }
287 285
288 else { 286 else {
289 if (adapter->monitormode == LBS_MONITOR_OFF) 287 if (priv->monitormode == LBS_MONITOR_OFF)
290 return strlen(buf); 288 return strlen(buf);
291 adapter->monitormode = LBS_MONITOR_OFF; 289 priv->monitormode = LBS_MONITOR_OFF;
292 lbs_remove_rtap(priv); 290 lbs_remove_rtap(priv);
293 291
294 if (adapter->currenttxskb) { 292 if (priv->currenttxskb) {
295 dev_kfree_skb_any(adapter->currenttxskb); 293 dev_kfree_skb_any(priv->currenttxskb);
296 adapter->currenttxskb = NULL; 294 priv->currenttxskb = NULL;
297 } 295 }
298 296
299 /* Wake queues, command thread, etc. */ 297 /* Wake queues, command thread, etc. */
@@ -302,7 +300,7 @@ static ssize_t lbs_rtap_set(struct device *dev,
302 300
303 lbs_prepare_and_send_command(priv, 301 lbs_prepare_and_send_command(priv,
304 CMD_802_11_MONITOR_MODE, CMD_ACT_SET, 302 CMD_802_11_MONITOR_MODE, CMD_ACT_SET,
305 CMD_OPTION_WAITFORRSP, 0, &adapter->monitormode); 303 CMD_OPTION_WAITFORRSP, 0, &priv->monitormode);
306 return strlen(buf); 304 return strlen(buf);
307} 305}
308 306
@@ -382,14 +380,13 @@ static struct attribute_group lbs_mesh_attr_group = {
382static int pre_open_check(struct net_device *dev) 380static int pre_open_check(struct net_device *dev)
383{ 381{
384 struct lbs_private *priv = (struct lbs_private *) dev->priv; 382 struct lbs_private *priv = (struct lbs_private *) dev->priv;
385 struct lbs_adapter *adapter = priv->adapter;
386 int i = 0; 383 int i = 0;
387 384
388 while (!adapter->fw_ready && i < 20) { 385 while (!priv->fw_ready && i < 20) {
389 i++; 386 i++;
390 msleep_interruptible(100); 387 msleep_interruptible(100);
391 } 388 }
392 if (!adapter->fw_ready) { 389 if (!priv->fw_ready) {
393 lbs_pr_err("firmware not ready\n"); 390 lbs_pr_err("firmware not ready\n");
394 return -1; 391 return -1;
395 } 392 }
@@ -406,19 +403,18 @@ static int pre_open_check(struct net_device *dev)
406static int lbs_dev_open(struct net_device *dev) 403static int lbs_dev_open(struct net_device *dev)
407{ 404{
408 struct lbs_private *priv = (struct lbs_private *) dev->priv; 405 struct lbs_private *priv = (struct lbs_private *) dev->priv;
409 struct lbs_adapter *adapter = priv->adapter;
410 406
411 lbs_deb_enter(LBS_DEB_NET); 407 lbs_deb_enter(LBS_DEB_NET);
412 408
413 priv->open = 1; 409 priv->open = 1;
414 410
415 if (adapter->connect_status == LBS_CONNECTED) 411 if (priv->connect_status == LBS_CONNECTED)
416 netif_carrier_on(priv->dev); 412 netif_carrier_on(priv->dev);
417 else 413 else
418 netif_carrier_off(priv->dev); 414 netif_carrier_off(priv->dev);
419 415
420 if (priv->mesh_dev) { 416 if (priv->mesh_dev) {
421 if (adapter->mesh_connect_status == LBS_CONNECTED) 417 if (priv->mesh_connect_status == LBS_CONNECTED)
422 netif_carrier_on(priv->mesh_dev); 418 netif_carrier_on(priv->mesh_dev);
423 else 419 else
424 netif_carrier_off(priv->mesh_dev); 420 netif_carrier_off(priv->mesh_dev);
@@ -442,7 +438,7 @@ static int lbs_mesh_open(struct net_device *dev)
442 priv->mesh_open = 1 ; 438 priv->mesh_open = 1 ;
443 netif_wake_queue(priv->mesh_dev); 439 netif_wake_queue(priv->mesh_dev);
444 440
445 priv->adapter->mesh_connect_status = LBS_CONNECTED; 441 priv->mesh_connect_status = LBS_CONNECTED;
446 442
447 netif_carrier_on(priv->mesh_dev); 443 netif_carrier_on(priv->mesh_dev);
448 netif_wake_queue(priv->mesh_dev); 444 netif_wake_queue(priv->mesh_dev);
@@ -534,7 +530,7 @@ static int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
534 priv->stats.tx_dropped++; 530 priv->stats.tx_dropped++;
535 goto done; 531 goto done;
536 } 532 }
537 if (priv->adapter->currenttxskb) { 533 if (priv->currenttxskb) {
538 lbs_pr_err("%s while TX skb pending\n", __func__); 534 lbs_pr_err("%s while TX skb pending\n", __func__);
539 priv->stats.tx_dropped++; 535 priv->stats.tx_dropped++;
540 goto done; 536 goto done;
@@ -562,7 +558,7 @@ static int lbs_mesh_pre_start_xmit(struct sk_buff *skb,
562 int ret; 558 int ret;
563 559
564 lbs_deb_enter(LBS_DEB_MESH); 560 lbs_deb_enter(LBS_DEB_MESH);
565 if (priv->adapter->monitormode != LBS_MONITOR_OFF) { 561 if (priv->monitormode != LBS_MONITOR_OFF) {
566 netif_stop_queue(dev); 562 netif_stop_queue(dev);
567 return -EOPNOTSUPP; 563 return -EOPNOTSUPP;
568 } 564 }
@@ -585,7 +581,7 @@ static int lbs_pre_start_xmit(struct sk_buff *skb, struct net_device *dev)
585 581
586 lbs_deb_enter(LBS_DEB_TX); 582 lbs_deb_enter(LBS_DEB_TX);
587 583
588 if (priv->adapter->monitormode != LBS_MONITOR_OFF) { 584 if (priv->monitormode != LBS_MONITOR_OFF) {
589 netif_stop_queue(dev); 585 netif_stop_queue(dev);
590 return -EOPNOTSUPP; 586 return -EOPNOTSUPP;
591 } 587 }
@@ -608,20 +604,20 @@ static void lbs_tx_timeout(struct net_device *dev)
608 priv->dnld_sent = DNLD_RES_RECEIVED; 604 priv->dnld_sent = DNLD_RES_RECEIVED;
609 dev->trans_start = jiffies; 605 dev->trans_start = jiffies;
610 606
611 if (priv->adapter->currenttxskb) { 607 if (priv->currenttxskb) {
612 if (priv->adapter->monitormode != LBS_MONITOR_OFF) { 608 if (priv->monitormode != LBS_MONITOR_OFF) {
613 /* If we are here, we have not received feedback from 609 /* If we are here, we have not received feedback from
614 the previous packet. Assume TX_FAIL and move on. */ 610 the previous packet. Assume TX_FAIL and move on. */
615 priv->adapter->eventcause = 0x01000000; 611 priv->eventcause = 0x01000000;
616 lbs_send_tx_feedback(priv); 612 lbs_send_tx_feedback(priv);
617 } else 613 } else
618 wake_up_interruptible(&priv->waitq); 614 wake_up_interruptible(&priv->waitq);
619 } else if (dev == priv->dev) { 615 } else if (dev == priv->dev) {
620 if (priv->adapter->connect_status == LBS_CONNECTED) 616 if (priv->connect_status == LBS_CONNECTED)
621 netif_wake_queue(priv->dev); 617 netif_wake_queue(priv->dev);
622 618
623 } else if (dev == priv->mesh_dev) { 619 } else if (dev == priv->mesh_dev) {
624 if (priv->adapter->mesh_connect_status == LBS_CONNECTED) 620 if (priv->mesh_connect_status == LBS_CONNECTED)
625 netif_wake_queue(priv->mesh_dev); 621 netif_wake_queue(priv->mesh_dev);
626 } 622 }
627 623
@@ -630,23 +626,22 @@ static void lbs_tx_timeout(struct net_device *dev)
630 626
631void lbs_host_to_card_done(struct lbs_private *priv) 627void lbs_host_to_card_done(struct lbs_private *priv)
632{ 628{
633 struct lbs_adapter *adapter = priv->adapter;
634 629
635 priv->dnld_sent = DNLD_RES_RECEIVED; 630 priv->dnld_sent = DNLD_RES_RECEIVED;
636 631
637 /* Wake main thread if commands are pending */ 632 /* Wake main thread if commands are pending */
638 if (!adapter->cur_cmd) 633 if (!priv->cur_cmd)
639 wake_up_interruptible(&priv->waitq); 634 wake_up_interruptible(&priv->waitq);
640 635
641 /* Don't wake netif queues if we're in monitor mode and 636 /* Don't wake netif queues if we're in monitor mode and
642 a TX packet is already pending. */ 637 a TX packet is already pending. */
643 if (priv->adapter->currenttxskb) 638 if (priv->currenttxskb)
644 return; 639 return;
645 640
646 if (priv->dev && adapter->connect_status == LBS_CONNECTED) 641 if (priv->dev && priv->connect_status == LBS_CONNECTED)
647 netif_wake_queue(priv->dev); 642 netif_wake_queue(priv->dev);
648 643
649 if (priv->mesh_dev && adapter->mesh_connect_status == LBS_CONNECTED) 644 if (priv->mesh_dev && priv->mesh_connect_status == LBS_CONNECTED)
650 netif_wake_queue(priv->mesh_dev); 645 netif_wake_queue(priv->mesh_dev);
651} 646}
652EXPORT_SYMBOL_GPL(lbs_host_to_card_done); 647EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
@@ -668,7 +663,6 @@ static int lbs_set_mac_address(struct net_device *dev, void *addr)
668{ 663{
669 int ret = 0; 664 int ret = 0;
670 struct lbs_private *priv = (struct lbs_private *) dev->priv; 665 struct lbs_private *priv = (struct lbs_private *) dev->priv;
671 struct lbs_adapter *adapter = priv->adapter;
672 struct sockaddr *phwaddr = addr; 666 struct sockaddr *phwaddr = addr;
673 667
674 lbs_deb_enter(LBS_DEB_NET); 668 lbs_deb_enter(LBS_DEB_NET);
@@ -676,13 +670,13 @@ static int lbs_set_mac_address(struct net_device *dev, void *addr)
676 /* In case it was called from the mesh device */ 670 /* In case it was called from the mesh device */
677 dev = priv->dev ; 671 dev = priv->dev ;
678 672
679 memset(adapter->current_addr, 0, ETH_ALEN); 673 memset(priv->current_addr, 0, ETH_ALEN);
680 674
681 /* dev->dev_addr is 8 bytes */ 675 /* dev->dev_addr is 8 bytes */
682 lbs_deb_hex(LBS_DEB_NET, "dev->dev_addr", dev->dev_addr, ETH_ALEN); 676 lbs_deb_hex(LBS_DEB_NET, "dev->dev_addr", dev->dev_addr, ETH_ALEN);
683 677
684 lbs_deb_hex(LBS_DEB_NET, "addr", phwaddr->sa_data, ETH_ALEN); 678 lbs_deb_hex(LBS_DEB_NET, "addr", phwaddr->sa_data, ETH_ALEN);
685 memcpy(adapter->current_addr, phwaddr->sa_data, ETH_ALEN); 679 memcpy(priv->current_addr, phwaddr->sa_data, ETH_ALEN);
686 680
687 ret = lbs_prepare_and_send_command(priv, CMD_802_11_MAC_ADDRESS, 681 ret = lbs_prepare_and_send_command(priv, CMD_802_11_MAC_ADDRESS,
688 CMD_ACT_SET, 682 CMD_ACT_SET,
@@ -694,24 +688,24 @@ static int lbs_set_mac_address(struct net_device *dev, void *addr)
694 goto done; 688 goto done;
695 } 689 }
696 690
697 lbs_deb_hex(LBS_DEB_NET, "adapter->macaddr", adapter->current_addr, ETH_ALEN); 691 lbs_deb_hex(LBS_DEB_NET, "priv->macaddr", priv->current_addr, ETH_ALEN);
698 memcpy(dev->dev_addr, adapter->current_addr, ETH_ALEN); 692 memcpy(dev->dev_addr, priv->current_addr, ETH_ALEN);
699 if (priv->mesh_dev) 693 if (priv->mesh_dev)
700 memcpy(priv->mesh_dev->dev_addr, adapter->current_addr, ETH_ALEN); 694 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
701 695
702done: 696done:
703 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret); 697 lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
704 return ret; 698 return ret;
705} 699}
706 700
707static int lbs_copy_multicast_address(struct lbs_adapter *adapter, 701static int lbs_copy_multicast_address(struct lbs_private *priv,
708 struct net_device *dev) 702 struct net_device *dev)
709{ 703{
710 int i = 0; 704 int i = 0;
711 struct dev_mc_list *mcptr = dev->mc_list; 705 struct dev_mc_list *mcptr = dev->mc_list;
712 706
713 for (i = 0; i < dev->mc_count; i++) { 707 for (i = 0; i < dev->mc_count; i++) {
714 memcpy(&adapter->multicastlist[i], mcptr->dmi_addr, ETH_ALEN); 708 memcpy(&priv->multicastlist[i], mcptr->dmi_addr, ETH_ALEN);
715 mcptr = mcptr->next; 709 mcptr = mcptr->next;
716 } 710 }
717 711
@@ -722,50 +716,49 @@ static int lbs_copy_multicast_address(struct lbs_adapter *adapter,
722static void lbs_set_multicast_list(struct net_device *dev) 716static void lbs_set_multicast_list(struct net_device *dev)
723{ 717{
724 struct lbs_private *priv = dev->priv; 718 struct lbs_private *priv = dev->priv;
725 struct lbs_adapter *adapter = priv->adapter;
726 int oldpacketfilter; 719 int oldpacketfilter;
727 DECLARE_MAC_BUF(mac); 720 DECLARE_MAC_BUF(mac);
728 721
729 lbs_deb_enter(LBS_DEB_NET); 722 lbs_deb_enter(LBS_DEB_NET);
730 723
731 oldpacketfilter = adapter->currentpacketfilter; 724 oldpacketfilter = priv->currentpacketfilter;
732 725
733 if (dev->flags & IFF_PROMISC) { 726 if (dev->flags & IFF_PROMISC) {
734 lbs_deb_net("enable promiscuous mode\n"); 727 lbs_deb_net("enable promiscuous mode\n");
735 adapter->currentpacketfilter |= 728 priv->currentpacketfilter |=
736 CMD_ACT_MAC_PROMISCUOUS_ENABLE; 729 CMD_ACT_MAC_PROMISCUOUS_ENABLE;
737 adapter->currentpacketfilter &= 730 priv->currentpacketfilter &=
738 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE | 731 ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE |
739 CMD_ACT_MAC_MULTICAST_ENABLE); 732 CMD_ACT_MAC_MULTICAST_ENABLE);
740 } else { 733 } else {
741 /* Multicast */ 734 /* Multicast */
742 adapter->currentpacketfilter &= 735 priv->currentpacketfilter &=
743 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE; 736 ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
744 737
745 if (dev->flags & IFF_ALLMULTI || dev->mc_count > 738 if (dev->flags & IFF_ALLMULTI || dev->mc_count >
746 MRVDRV_MAX_MULTICAST_LIST_SIZE) { 739 MRVDRV_MAX_MULTICAST_LIST_SIZE) {
747 lbs_deb_net( "enabling all multicast\n"); 740 lbs_deb_net( "enabling all multicast\n");
748 adapter->currentpacketfilter |= 741 priv->currentpacketfilter |=
749 CMD_ACT_MAC_ALL_MULTICAST_ENABLE; 742 CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
750 adapter->currentpacketfilter &= 743 priv->currentpacketfilter &=
751 ~CMD_ACT_MAC_MULTICAST_ENABLE; 744 ~CMD_ACT_MAC_MULTICAST_ENABLE;
752 } else { 745 } else {
753 adapter->currentpacketfilter &= 746 priv->currentpacketfilter &=
754 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE; 747 ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
755 748
756 if (!dev->mc_count) { 749 if (!dev->mc_count) {
757 lbs_deb_net("no multicast addresses, " 750 lbs_deb_net("no multicast addresses, "
758 "disabling multicast\n"); 751 "disabling multicast\n");
759 adapter->currentpacketfilter &= 752 priv->currentpacketfilter &=
760 ~CMD_ACT_MAC_MULTICAST_ENABLE; 753 ~CMD_ACT_MAC_MULTICAST_ENABLE;
761 } else { 754 } else {
762 int i; 755 int i;
763 756
764 adapter->currentpacketfilter |= 757 priv->currentpacketfilter |=
765 CMD_ACT_MAC_MULTICAST_ENABLE; 758 CMD_ACT_MAC_MULTICAST_ENABLE;
766 759
767 adapter->nr_of_multicastmacaddr = 760 priv->nr_of_multicastmacaddr =
768 lbs_copy_multicast_address(adapter, dev); 761 lbs_copy_multicast_address(priv, dev);
769 762
770 lbs_deb_net("multicast addresses: %d\n", 763 lbs_deb_net("multicast addresses: %d\n",
771 dev->mc_count); 764 dev->mc_count);
@@ -773,7 +766,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
773 for (i = 0; i < dev->mc_count; i++) { 766 for (i = 0; i < dev->mc_count; i++) {
774 lbs_deb_net("Multicast address %d:%s\n", 767 lbs_deb_net("Multicast address %d:%s\n",
775 i, print_mac(mac, 768 i, print_mac(mac,
776 adapter->multicastlist[i])); 769 priv->multicastlist[i]));
777 } 770 }
778 /* send multicast addresses to firmware */ 771 /* send multicast addresses to firmware */
779 lbs_prepare_and_send_command(priv, 772 lbs_prepare_and_send_command(priv,
@@ -784,7 +777,7 @@ static void lbs_set_multicast_list(struct net_device *dev)
784 } 777 }
785 } 778 }
786 779
787 if (adapter->currentpacketfilter != oldpacketfilter) { 780 if (priv->currentpacketfilter != oldpacketfilter) {
788 lbs_set_mac_packet_filter(priv); 781 lbs_set_mac_packet_filter(priv);
789 } 782 }
790 783
@@ -803,7 +796,6 @@ static int lbs_thread(void *data)
803{ 796{
804 struct net_device *dev = data; 797 struct net_device *dev = data;
805 struct lbs_private *priv = dev->priv; 798 struct lbs_private *priv = dev->priv;
806 struct lbs_adapter *adapter = priv->adapter;
807 wait_queue_t wait; 799 wait_queue_t wait;
808 u8 ireg = 0; 800 u8 ireg = 0;
809 801
@@ -815,99 +807,99 @@ static int lbs_thread(void *data)
815 807
816 for (;;) { 808 for (;;) {
817 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n", 809 lbs_deb_thread( "main-thread 111: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
818 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent); 810 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
819 811
820 add_wait_queue(&priv->waitq, &wait); 812 add_wait_queue(&priv->waitq, &wait);
821 set_current_state(TASK_INTERRUPTIBLE); 813 set_current_state(TASK_INTERRUPTIBLE);
822 spin_lock_irq(&adapter->driver_lock); 814 spin_lock_irq(&priv->driver_lock);
823 815
824 if ((adapter->psstate == PS_STATE_SLEEP) || 816 if ((priv->psstate == PS_STATE_SLEEP) ||
825 (!adapter->intcounter && (priv->dnld_sent || adapter->cur_cmd || list_empty(&adapter->cmdpendingq)))) { 817 (!priv->intcounter && (priv->dnld_sent || priv->cur_cmd || list_empty(&priv->cmdpendingq)))) {
826 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n", 818 lbs_deb_thread("main-thread sleeping... Conn=%d IntC=%d PS_mode=%d PS_State=%d\n",
827 adapter->connect_status, adapter->intcounter, 819 priv->connect_status, priv->intcounter,
828 adapter->psmode, adapter->psstate); 820 priv->psmode, priv->psstate);
829 spin_unlock_irq(&adapter->driver_lock); 821 spin_unlock_irq(&priv->driver_lock);
830 schedule(); 822 schedule();
831 } else 823 } else
832 spin_unlock_irq(&adapter->driver_lock); 824 spin_unlock_irq(&priv->driver_lock);
833 825
834 lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n", 826 lbs_deb_thread("main-thread 222 (waking up): intcounter=%d currenttxskb=%p dnld_sent=%d\n",
835 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent); 827 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
836 828
837 set_current_state(TASK_RUNNING); 829 set_current_state(TASK_RUNNING);
838 remove_wait_queue(&priv->waitq, &wait); 830 remove_wait_queue(&priv->waitq, &wait);
839 try_to_freeze(); 831 try_to_freeze();
840 832
841 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n", 833 lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
842 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent); 834 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
843 835
844 if (kthread_should_stop() || adapter->surpriseremoved) { 836 if (kthread_should_stop() || priv->surpriseremoved) {
845 lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n", 837 lbs_deb_thread("main-thread: break from main thread: surpriseremoved=0x%x\n",
846 adapter->surpriseremoved); 838 priv->surpriseremoved);
847 break; 839 break;
848 } 840 }
849 841
850 842
851 spin_lock_irq(&adapter->driver_lock); 843 spin_lock_irq(&priv->driver_lock);
852 844
853 if (adapter->intcounter) { 845 if (priv->intcounter) {
854 u8 int_status; 846 u8 int_status;
855 847
856 adapter->intcounter = 0; 848 priv->intcounter = 0;
857 int_status = priv->hw_get_int_status(priv, &ireg); 849 int_status = priv->hw_get_int_status(priv, &ireg);
858 850
859 if (int_status) { 851 if (int_status) {
860 lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n"); 852 lbs_deb_thread("main-thread: reading HOST_INT_STATUS_REG failed\n");
861 spin_unlock_irq(&adapter->driver_lock); 853 spin_unlock_irq(&priv->driver_lock);
862 continue; 854 continue;
863 } 855 }
864 adapter->hisregcpy |= ireg; 856 priv->hisregcpy |= ireg;
865 } 857 }
866 858
867 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n", 859 lbs_deb_thread("main-thread 444: intcounter=%d currenttxskb=%p dnld_sent=%d\n",
868 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent); 860 priv->intcounter, priv->currenttxskb, priv->dnld_sent);
869 861
870 /* command response? */ 862 /* command response? */
871 if (adapter->hisregcpy & MRVDRV_CMD_UPLD_RDY) { 863 if (priv->hisregcpy & MRVDRV_CMD_UPLD_RDY) {
872 lbs_deb_thread("main-thread: cmd response ready\n"); 864 lbs_deb_thread("main-thread: cmd response ready\n");
873 865
874 adapter->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; 866 priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY;
875 spin_unlock_irq(&adapter->driver_lock); 867 spin_unlock_irq(&priv->driver_lock);
876 lbs_process_rx_command(priv); 868 lbs_process_rx_command(priv);
877 spin_lock_irq(&adapter->driver_lock); 869 spin_lock_irq(&priv->driver_lock);
878 } 870 }
879 871
880 /* Any Card Event */ 872 /* Any Card Event */
881 if (adapter->hisregcpy & MRVDRV_CARDEVENT) { 873 if (priv->hisregcpy & MRVDRV_CARDEVENT) {
882 lbs_deb_thread("main-thread: Card Event Activity\n"); 874 lbs_deb_thread("main-thread: Card Event Activity\n");
883 875
884 adapter->hisregcpy &= ~MRVDRV_CARDEVENT; 876 priv->hisregcpy &= ~MRVDRV_CARDEVENT;
885 877
886 if (priv->hw_read_event_cause(priv)) { 878 if (priv->hw_read_event_cause(priv)) {
887 lbs_pr_alert("main-thread: hw_read_event_cause failed\n"); 879 lbs_pr_alert("main-thread: hw_read_event_cause failed\n");
888 spin_unlock_irq(&adapter->driver_lock); 880 spin_unlock_irq(&priv->driver_lock);
889 continue; 881 continue;
890 } 882 }
891 spin_unlock_irq(&adapter->driver_lock); 883 spin_unlock_irq(&priv->driver_lock);
892 lbs_process_event(priv); 884 lbs_process_event(priv);
893 } else 885 } else
894 spin_unlock_irq(&adapter->driver_lock); 886 spin_unlock_irq(&priv->driver_lock);
895 887
896 /* Check if we need to confirm Sleep Request received previously */ 888 /* Check if we need to confirm Sleep Request received previously */
897 if (adapter->psstate == PS_STATE_PRE_SLEEP && 889 if (priv->psstate == PS_STATE_PRE_SLEEP &&
898 !priv->dnld_sent && !adapter->cur_cmd) { 890 !priv->dnld_sent && !priv->cur_cmd) {
899 if (adapter->connect_status == LBS_CONNECTED) { 891 if (priv->connect_status == LBS_CONNECTED) {
900 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n", 892 lbs_deb_thread("main_thread: PRE_SLEEP--intcounter=%d currenttxskb=%p dnld_sent=%d cur_cmd=%p, confirm now\n",
901 adapter->intcounter, adapter->currenttxskb, priv->dnld_sent, adapter->cur_cmd); 893 priv->intcounter, priv->currenttxskb, priv->dnld_sent, priv->cur_cmd);
902 894
903 lbs_ps_confirm_sleep(priv, (u16) adapter->psmode); 895 lbs_ps_confirm_sleep(priv, (u16) priv->psmode);
904 } else { 896 } else {
905 /* workaround for firmware sending 897 /* workaround for firmware sending
906 * deauth/linkloss event immediately 898 * deauth/linkloss event immediately
907 * after sleep request; remove this 899 * after sleep request; remove this
908 * after firmware fixes it 900 * after firmware fixes it
909 */ 901 */
910 adapter->psstate = PS_STATE_AWAKE; 902 priv->psstate = PS_STATE_AWAKE;
911 lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n"); 903 lbs_pr_alert("main-thread: ignore PS_SleepConfirm in non-connected state\n");
912 } 904 }
913 } 905 }
@@ -915,25 +907,25 @@ static int lbs_thread(void *data)
915 /* The PS state is changed during processing of Sleep Request 907 /* The PS state is changed during processing of Sleep Request
916 * event above 908 * event above
917 */ 909 */
918 if ((priv->adapter->psstate == PS_STATE_SLEEP) || 910 if ((priv->psstate == PS_STATE_SLEEP) ||
919 (priv->adapter->psstate == PS_STATE_PRE_SLEEP)) 911 (priv->psstate == PS_STATE_PRE_SLEEP))
920 continue; 912 continue;
921 913
922 /* Execute the next command */ 914 /* Execute the next command */
923 if (!priv->dnld_sent && !priv->adapter->cur_cmd) 915 if (!priv->dnld_sent && !priv->cur_cmd)
924 lbs_execute_next_command(priv); 916 lbs_execute_next_command(priv);
925 917
926 /* Wake-up command waiters which can't sleep in 918 /* Wake-up command waiters which can't sleep in
927 * lbs_prepare_and_send_command 919 * lbs_prepare_and_send_command
928 */ 920 */
929 if (!list_empty(&adapter->cmdpendingq)) 921 if (!list_empty(&priv->cmdpendingq))
930 wake_up_all(&adapter->cmd_pending); 922 wake_up_all(&priv->cmd_pending);
931 923
932 lbs_tx_runqueue(priv); 924 lbs_tx_runqueue(priv);
933 } 925 }
934 926
935 del_timer(&adapter->command_timer); 927 del_timer(&priv->command_timer);
936 wake_up_all(&adapter->cmd_pending); 928 wake_up_all(&priv->cmd_pending);
937 929
938 lbs_deb_leave(LBS_DEB_THREAD); 930 lbs_deb_leave(LBS_DEB_THREAD);
939 return 0; 931 return 0;
@@ -950,7 +942,6 @@ static int lbs_thread(void *data)
950static int lbs_setup_firmware(struct lbs_private *priv) 942static int lbs_setup_firmware(struct lbs_private *priv)
951{ 943{
952 int ret = -1; 944 int ret = -1;
953 struct lbs_adapter *adapter = priv->adapter;
954 struct cmd_ds_mesh_access mesh_access; 945 struct cmd_ds_mesh_access mesh_access;
955 946
956 lbs_deb_enter(LBS_DEB_FW); 947 lbs_deb_enter(LBS_DEB_FW);
@@ -958,7 +949,7 @@ static int lbs_setup_firmware(struct lbs_private *priv)
958 /* 949 /*
959 * Read MAC address from HW 950 * Read MAC address from HW
960 */ 951 */
961 memset(adapter->current_addr, 0xff, ETH_ALEN); 952 memset(priv->current_addr, 0xff, ETH_ALEN);
962 953
963 ret = lbs_prepare_and_send_command(priv, CMD_GET_HW_SPEC, 954 ret = lbs_prepare_and_send_command(priv, CMD_GET_HW_SPEC,
964 0, CMD_OPTION_WAITFORRSP, 0, NULL); 955 0, CMD_OPTION_WAITFORRSP, 0, NULL);
@@ -1008,12 +999,11 @@ done:
1008static void command_timer_fn(unsigned long data) 999static void command_timer_fn(unsigned long data)
1009{ 1000{
1010 struct lbs_private *priv = (struct lbs_private *)data; 1001 struct lbs_private *priv = (struct lbs_private *)data;
1011 struct lbs_adapter *adapter = priv->adapter;
1012 struct cmd_ctrl_node *ptempnode; 1002 struct cmd_ctrl_node *ptempnode;
1013 struct cmd_ds_command *cmd; 1003 struct cmd_ds_command *cmd;
1014 unsigned long flags; 1004 unsigned long flags;
1015 1005
1016 ptempnode = adapter->cur_cmd; 1006 ptempnode = priv->cur_cmd;
1017 if (ptempnode == NULL) { 1007 if (ptempnode == NULL) {
1018 lbs_deb_fw("ptempnode empty\n"); 1008 lbs_deb_fw("ptempnode empty\n");
1019 return; 1009 return;
@@ -1027,15 +1017,15 @@ static void command_timer_fn(unsigned long data)
1027 1017
1028 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command); 1018 lbs_deb_fw("command_timer_fn fired, cmd %x\n", cmd->command);
1029 1019
1030 if (!adapter->fw_ready) 1020 if (!priv->fw_ready)
1031 return; 1021 return;
1032 1022
1033 spin_lock_irqsave(&adapter->driver_lock, flags); 1023 spin_lock_irqsave(&priv->driver_lock, flags);
1034 adapter->cur_cmd = NULL; 1024 priv->cur_cmd = NULL;
1035 spin_unlock_irqrestore(&adapter->driver_lock, flags); 1025 spin_unlock_irqrestore(&priv->driver_lock, flags);
1036 1026
1037 lbs_deb_fw("re-sending same command because of timeout\n"); 1027 lbs_deb_fw("re-sending same command because of timeout\n");
1038 lbs_queue_cmd(adapter, ptempnode, 0); 1028 lbs_queue_cmd(priv, ptempnode, 0);
1039 1029
1040 wake_up_interruptible(&priv->waitq); 1030 wake_up_interruptible(&priv->waitq);
1041 1031
@@ -1044,63 +1034,62 @@ static void command_timer_fn(unsigned long data)
1044 1034
1045static int lbs_init_adapter(struct lbs_private *priv) 1035static int lbs_init_adapter(struct lbs_private *priv)
1046{ 1036{
1047 struct lbs_adapter *adapter = priv->adapter;
1048 size_t bufsize; 1037 size_t bufsize;
1049 int i, ret = 0; 1038 int i, ret = 0;
1050 1039
1051 /* Allocate buffer to store the BSSID list */ 1040 /* Allocate buffer to store the BSSID list */
1052 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor); 1041 bufsize = MAX_NETWORK_COUNT * sizeof(struct bss_descriptor);
1053 adapter->networks = kzalloc(bufsize, GFP_KERNEL); 1042 priv->networks = kzalloc(bufsize, GFP_KERNEL);
1054 if (!adapter->networks) { 1043 if (!priv->networks) {
1055 lbs_pr_err("Out of memory allocating beacons\n"); 1044 lbs_pr_err("Out of memory allocating beacons\n");
1056 ret = -1; 1045 ret = -1;
1057 goto out; 1046 goto out;
1058 } 1047 }
1059 1048
1060 /* Initialize scan result lists */ 1049 /* Initialize scan result lists */
1061 INIT_LIST_HEAD(&adapter->network_free_list); 1050 INIT_LIST_HEAD(&priv->network_free_list);
1062 INIT_LIST_HEAD(&adapter->network_list); 1051 INIT_LIST_HEAD(&priv->network_list);
1063 for (i = 0; i < MAX_NETWORK_COUNT; i++) { 1052 for (i = 0; i < MAX_NETWORK_COUNT; i++) {
1064 list_add_tail(&adapter->networks[i].list, 1053 list_add_tail(&priv->networks[i].list,
1065 &adapter->network_free_list); 1054 &priv->network_free_list);
1066 } 1055 }
1067 1056
1068 adapter->lbs_ps_confirm_sleep.seqnum = cpu_to_le16(++adapter->seqnum); 1057 priv->lbs_ps_confirm_sleep.seqnum = cpu_to_le16(++priv->seqnum);
1069 adapter->lbs_ps_confirm_sleep.command = 1058 priv->lbs_ps_confirm_sleep.command =
1070 cpu_to_le16(CMD_802_11_PS_MODE); 1059 cpu_to_le16(CMD_802_11_PS_MODE);
1071 adapter->lbs_ps_confirm_sleep.size = 1060 priv->lbs_ps_confirm_sleep.size =
1072 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep)); 1061 cpu_to_le16(sizeof(struct PS_CMD_ConfirmSleep));
1073 adapter->lbs_ps_confirm_sleep.action = 1062 priv->lbs_ps_confirm_sleep.action =
1074 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED); 1063 cpu_to_le16(CMD_SUBCMD_SLEEP_CONFIRMED);
1075 1064
1076 memset(adapter->current_addr, 0xff, ETH_ALEN); 1065 memset(priv->current_addr, 0xff, ETH_ALEN);
1077 1066
1078 adapter->connect_status = LBS_DISCONNECTED; 1067 priv->connect_status = LBS_DISCONNECTED;
1079 adapter->mesh_connect_status = LBS_DISCONNECTED; 1068 priv->mesh_connect_status = LBS_DISCONNECTED;
1080 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM; 1069 priv->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1081 adapter->mode = IW_MODE_INFRA; 1070 priv->mode = IW_MODE_INFRA;
1082 adapter->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; 1071 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
1083 adapter->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; 1072 priv->currentpacketfilter = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
1084 adapter->radioon = RADIO_ON; 1073 priv->radioon = RADIO_ON;
1085 adapter->auto_rate = 1; 1074 priv->auto_rate = 1;
1086 adapter->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; 1075 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
1087 adapter->psmode = LBS802_11POWERMODECAM; 1076 priv->psmode = LBS802_11POWERMODECAM;
1088 adapter->psstate = PS_STATE_FULL_POWER; 1077 priv->psstate = PS_STATE_FULL_POWER;
1089 1078
1090 mutex_init(&adapter->lock); 1079 mutex_init(&priv->lock);
1091 1080
1092 memset(&adapter->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*)); 1081 memset(&priv->tx_queue_ps, 0, NR_TX_QUEUE*sizeof(struct sk_buff*));
1093 adapter->tx_queue_idx = 0; 1082 priv->tx_queue_idx = 0;
1094 spin_lock_init(&adapter->txqueue_lock); 1083 spin_lock_init(&priv->txqueue_lock);
1095 1084
1096 setup_timer(&adapter->command_timer, command_timer_fn, 1085 setup_timer(&priv->command_timer, command_timer_fn,
1097 (unsigned long)priv); 1086 (unsigned long)priv);
1098 1087
1099 INIT_LIST_HEAD(&adapter->cmdfreeq); 1088 INIT_LIST_HEAD(&priv->cmdfreeq);
1100 INIT_LIST_HEAD(&adapter->cmdpendingq); 1089 INIT_LIST_HEAD(&priv->cmdpendingq);
1101 1090
1102 spin_lock_init(&adapter->driver_lock); 1091 spin_lock_init(&priv->driver_lock);
1103 init_waitqueue_head(&adapter->cmd_pending); 1092 init_waitqueue_head(&priv->cmd_pending);
1104 1093
1105 /* Allocate the command buffers */ 1094 /* Allocate the command buffers */
1106 if (lbs_allocate_cmd_buffer(priv)) { 1095 if (lbs_allocate_cmd_buffer(priv)) {
@@ -1114,27 +1103,15 @@ out:
1114 1103
1115static void lbs_free_adapter(struct lbs_private *priv) 1104static void lbs_free_adapter(struct lbs_private *priv)
1116{ 1105{
1117 struct lbs_adapter *adapter = priv->adapter;
1118
1119 if (!adapter) {
1120 lbs_deb_fw("why double free adapter?\n");
1121 return;
1122 }
1123
1124 lbs_deb_fw("free command buffer\n"); 1106 lbs_deb_fw("free command buffer\n");
1125 lbs_free_cmd_buffer(priv); 1107 lbs_free_cmd_buffer(priv);
1126 1108
1127 lbs_deb_fw("free command_timer\n"); 1109 lbs_deb_fw("free command_timer\n");
1128 del_timer(&adapter->command_timer); 1110 del_timer(&priv->command_timer);
1129 1111
1130 lbs_deb_fw("free scan results table\n"); 1112 lbs_deb_fw("free scan results table\n");
1131 kfree(adapter->networks); 1113 kfree(priv->networks);
1132 adapter->networks = NULL; 1114 priv->networks = NULL;
1133
1134 /* Free the adapter object itself */
1135 lbs_deb_fw("free adapter\n");
1136 kfree(adapter);
1137 priv->adapter = NULL;
1138} 1115}
1139 1116
1140/** 1117/**
@@ -1159,13 +1136,6 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1159 } 1136 }
1160 priv = dev->priv; 1137 priv = dev->priv;
1161 1138
1162 /* allocate buffer for struct lbs_adapter */
1163 priv->adapter = kzalloc(sizeof(struct lbs_adapter), GFP_KERNEL);
1164 if (!priv->adapter) {
1165 lbs_pr_err("allocate buffer for struct lbs_adapter failed\n");
1166 goto err_kzalloc;
1167 }
1168
1169 if (lbs_init_adapter(priv)) { 1139 if (lbs_init_adapter(priv)) {
1170 lbs_pr_err("failed to initialize adapter structure.\n"); 1140 lbs_pr_err("failed to initialize adapter structure.\n");
1171 goto err_init_adapter; 1141 goto err_init_adapter;
@@ -1212,8 +1182,6 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1212 1182
1213err_init_adapter: 1183err_init_adapter:
1214 lbs_free_adapter(priv); 1184 lbs_free_adapter(priv);
1215
1216err_kzalloc:
1217 free_netdev(dev); 1185 free_netdev(dev);
1218 priv = NULL; 1186 priv = NULL;
1219 1187
@@ -1226,7 +1194,6 @@ EXPORT_SYMBOL_GPL(lbs_add_card);
1226 1194
1227int lbs_remove_card(struct lbs_private *priv) 1195int lbs_remove_card(struct lbs_private *priv)
1228{ 1196{
1229 struct lbs_adapter *adapter = priv->adapter;
1230 struct net_device *dev = priv->dev; 1197 struct net_device *dev = priv->dev;
1231 union iwreq_data wrqu; 1198 union iwreq_data wrqu;
1232 1199
@@ -1241,8 +1208,8 @@ int lbs_remove_card(struct lbs_private *priv)
1241 cancel_delayed_work(&priv->assoc_work); 1208 cancel_delayed_work(&priv->assoc_work);
1242 destroy_workqueue(priv->work_thread); 1209 destroy_workqueue(priv->work_thread);
1243 1210
1244 if (adapter->psmode == LBS802_11POWERMODEMAX_PSP) { 1211 if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
1245 adapter->psmode = LBS802_11POWERMODECAM; 1212 priv->psmode = LBS802_11POWERMODECAM;
1246 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); 1213 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
1247 } 1214 }
1248 1215
@@ -1251,7 +1218,7 @@ int lbs_remove_card(struct lbs_private *priv)
1251 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 1218 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
1252 1219
1253 /* Stop the thread servicing the interrupts */ 1220 /* Stop the thread servicing the interrupts */
1254 adapter->surpriseremoved = 1; 1221 priv->surpriseremoved = 1;
1255 kthread_stop(priv->main_thread); 1222 kthread_stop(priv->main_thread);
1256 1223
1257 lbs_free_adapter(priv); 1224 lbs_free_adapter(priv);
@@ -1315,12 +1282,12 @@ int lbs_stop_card(struct lbs_private *priv)
1315 lbs_debugfs_remove_one(priv); 1282 lbs_debugfs_remove_one(priv);
1316 1283
1317 /* Flush pending command nodes */ 1284 /* Flush pending command nodes */
1318 spin_lock_irqsave(&priv->adapter->driver_lock, flags); 1285 spin_lock_irqsave(&priv->driver_lock, flags);
1319 list_for_each_entry(cmdnode, &priv->adapter->cmdpendingq, list) { 1286 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
1320 cmdnode->cmdwaitqwoken = 1; 1287 cmdnode->cmdwaitqwoken = 1;
1321 wake_up_interruptible(&cmdnode->cmdwait_q); 1288 wake_up_interruptible(&cmdnode->cmdwait_q);
1322 } 1289 }
1323 spin_unlock_irqrestore(&priv->adapter->driver_lock, flags); 1290 spin_unlock_irqrestore(&priv->driver_lock, flags);
1324 1291
1325 unregister_netdev(dev); 1292 unregister_netdev(dev);
1326 1293
@@ -1452,7 +1419,6 @@ struct chan_freq_power *lbs_get_region_cfp_table(u8 region, u8 band, int *cfp_no
1452 1419
1453int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band) 1420int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
1454{ 1421{
1455 struct lbs_adapter *adapter = priv->adapter;
1456 int ret = 0; 1422 int ret = 0;
1457 int i = 0; 1423 int i = 0;
1458 1424
@@ -1461,22 +1427,22 @@ int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band)
1461 1427
1462 lbs_deb_enter(LBS_DEB_MAIN); 1428 lbs_deb_enter(LBS_DEB_MAIN);
1463 1429
1464 memset(adapter->region_channel, 0, sizeof(adapter->region_channel)); 1430 memset(priv->region_channel, 0, sizeof(priv->region_channel));
1465 1431
1466 { 1432 {
1467 cfp = lbs_get_region_cfp_table(region, band, &cfp_no); 1433 cfp = lbs_get_region_cfp_table(region, band, &cfp_no);
1468 if (cfp != NULL) { 1434 if (cfp != NULL) {
1469 adapter->region_channel[i].nrcfp = cfp_no; 1435 priv->region_channel[i].nrcfp = cfp_no;
1470 adapter->region_channel[i].CFP = cfp; 1436 priv->region_channel[i].CFP = cfp;
1471 } else { 1437 } else {
1472 lbs_deb_main("wrong region code %#x in band B/G\n", 1438 lbs_deb_main("wrong region code %#x in band B/G\n",
1473 region); 1439 region);
1474 ret = -1; 1440 ret = -1;
1475 goto out; 1441 goto out;
1476 } 1442 }
1477 adapter->region_channel[i].valid = 1; 1443 priv->region_channel[i].valid = 1;
1478 adapter->region_channel[i].region = region; 1444 priv->region_channel[i].region = region;
1479 adapter->region_channel[i].band = band; 1445 priv->region_channel[i].band = band;
1480 i++; 1446 i++;
1481 } 1447 }
1482out: 1448out:
@@ -1499,12 +1465,12 @@ void lbs_interrupt(struct net_device *dev)
1499 lbs_deb_enter(LBS_DEB_THREAD); 1465 lbs_deb_enter(LBS_DEB_THREAD);
1500 1466
1501 lbs_deb_thread("lbs_interrupt: intcounter=%d\n", 1467 lbs_deb_thread("lbs_interrupt: intcounter=%d\n",
1502 priv->adapter->intcounter); 1468 priv->intcounter);
1503 1469
1504 priv->adapter->intcounter++; 1470 priv->intcounter++;
1505 1471
1506 if (priv->adapter->psstate == PS_STATE_SLEEP) { 1472 if (priv->psstate == PS_STATE_SLEEP) {
1507 priv->adapter->psstate = PS_STATE_AWAKE; 1473 priv->psstate = PS_STATE_AWAKE;
1508 netif_wake_queue(dev); 1474 netif_wake_queue(dev);
1509 if (priv->mesh_dev) 1475 if (priv->mesh_dev)
1510 netif_wake_queue(priv->mesh_dev); 1476 netif_wake_queue(priv->mesh_dev);
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index a252a8f74bec..58e831108120 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -48,12 +48,11 @@ static u8 lbs_getavgsnr(struct lbs_private *priv)
48{ 48{
49 u8 i; 49 u8 i;
50 u16 temp = 0; 50 u16 temp = 0;
51 struct lbs_adapter *adapter = priv->adapter; 51 if (priv->numSNRNF == 0)
52 if (adapter->numSNRNF == 0)
53 return 0; 52 return 0;
54 for (i = 0; i < adapter->numSNRNF; i++) 53 for (i = 0; i < priv->numSNRNF; i++)
55 temp += adapter->rawSNR[i]; 54 temp += priv->rawSNR[i];
56 return (u8) (temp / adapter->numSNRNF); 55 return (u8) (temp / priv->numSNRNF);
57 56
58} 57}
59 58
@@ -67,12 +66,11 @@ static u8 lbs_getavgnf(struct lbs_private *priv)
67{ 66{
68 u8 i; 67 u8 i;
69 u16 temp = 0; 68 u16 temp = 0;
70 struct lbs_adapter *adapter = priv->adapter; 69 if (priv->numSNRNF == 0)
71 if (adapter->numSNRNF == 0)
72 return 0; 70 return 0;
73 for (i = 0; i < adapter->numSNRNF; i++) 71 for (i = 0; i < priv->numSNRNF; i++)
74 temp += adapter->rawNF[i]; 72 temp += priv->rawNF[i];
75 return (u8) (temp / adapter->numSNRNF); 73 return (u8) (temp / priv->numSNRNF);
76 74
77} 75}
78 76
@@ -85,14 +83,13 @@ static u8 lbs_getavgnf(struct lbs_private *priv)
85 */ 83 */
86static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd) 84static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd)
87{ 85{
88 struct lbs_adapter *adapter = priv->adapter; 86 if (priv->numSNRNF < DEFAULT_DATA_AVG_FACTOR)
89 if (adapter->numSNRNF < DEFAULT_DATA_AVG_FACTOR) 87 priv->numSNRNF++;
90 adapter->numSNRNF++; 88 priv->rawSNR[priv->nextSNRNF] = p_rx_pd->snr;
91 adapter->rawSNR[adapter->nextSNRNF] = p_rx_pd->snr; 89 priv->rawNF[priv->nextSNRNF] = p_rx_pd->nf;
92 adapter->rawNF[adapter->nextSNRNF] = p_rx_pd->nf; 90 priv->nextSNRNF++;
93 adapter->nextSNRNF++; 91 if (priv->nextSNRNF >= DEFAULT_DATA_AVG_FACTOR)
94 if (adapter->nextSNRNF >= DEFAULT_DATA_AVG_FACTOR) 92 priv->nextSNRNF = 0;
95 adapter->nextSNRNF = 0;
96 return; 93 return;
97} 94}
98 95
@@ -105,32 +102,31 @@ static void lbs_save_rawSNRNF(struct lbs_private *priv, struct rxpd *p_rx_pd)
105 */ 102 */
106static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd) 103static void lbs_compute_rssi(struct lbs_private *priv, struct rxpd *p_rx_pd)
107{ 104{
108 struct lbs_adapter *adapter = priv->adapter;
109 105
110 lbs_deb_enter(LBS_DEB_RX); 106 lbs_deb_enter(LBS_DEB_RX);
111 107
112 lbs_deb_rx("rxpd: SNR %d, NF %d\n", p_rx_pd->snr, p_rx_pd->nf); 108 lbs_deb_rx("rxpd: SNR %d, NF %d\n", p_rx_pd->snr, p_rx_pd->nf);
113 lbs_deb_rx("before computing SNR: SNR-avg = %d, NF-avg = %d\n", 109 lbs_deb_rx("before computing SNR: SNR-avg = %d, NF-avg = %d\n",
114 adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 110 priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
115 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 111 priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
116 112
117 adapter->SNR[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->snr; 113 priv->SNR[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->snr;
118 adapter->NF[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->nf; 114 priv->NF[TYPE_RXPD][TYPE_NOAVG] = p_rx_pd->nf;
119 lbs_save_rawSNRNF(priv, p_rx_pd); 115 lbs_save_rawSNRNF(priv, p_rx_pd);
120 116
121 adapter->SNR[TYPE_RXPD][TYPE_AVG] = lbs_getavgsnr(priv) * AVG_SCALE; 117 priv->SNR[TYPE_RXPD][TYPE_AVG] = lbs_getavgsnr(priv) * AVG_SCALE;
122 adapter->NF[TYPE_RXPD][TYPE_AVG] = lbs_getavgnf(priv) * AVG_SCALE; 118 priv->NF[TYPE_RXPD][TYPE_AVG] = lbs_getavgnf(priv) * AVG_SCALE;
123 lbs_deb_rx("after computing SNR: SNR-avg = %d, NF-avg = %d\n", 119 lbs_deb_rx("after computing SNR: SNR-avg = %d, NF-avg = %d\n",
124 adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 120 priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
125 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 121 priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
126 122
127 adapter->RSSI[TYPE_RXPD][TYPE_NOAVG] = 123 priv->RSSI[TYPE_RXPD][TYPE_NOAVG] =
128 CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG], 124 CAL_RSSI(priv->SNR[TYPE_RXPD][TYPE_NOAVG],
129 adapter->NF[TYPE_RXPD][TYPE_NOAVG]); 125 priv->NF[TYPE_RXPD][TYPE_NOAVG]);
130 126
131 adapter->RSSI[TYPE_RXPD][TYPE_AVG] = 127 priv->RSSI[TYPE_RXPD][TYPE_AVG] =
132 CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE, 128 CAL_RSSI(priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
133 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE); 129 priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
134 130
135 lbs_deb_leave(LBS_DEB_RX); 131 lbs_deb_leave(LBS_DEB_RX);
136} 132}
@@ -139,7 +135,7 @@ void lbs_upload_rx_packet(struct lbs_private *priv, struct sk_buff *skb)
139{ 135{
140 lbs_deb_rx("skb->data %p\n", skb->data); 136 lbs_deb_rx("skb->data %p\n", skb->data);
141 137
142 if (priv->adapter->monitormode != LBS_MONITOR_OFF) { 138 if (priv->monitormode != LBS_MONITOR_OFF) {
143 skb->protocol = eth_type_trans(skb, priv->rtap_net_dev); 139 skb->protocol = eth_type_trans(skb, priv->rtap_net_dev);
144 } else { 140 } else {
145 if (priv->mesh_dev && IS_MESH_FRAME(skb)) 141 if (priv->mesh_dev && IS_MESH_FRAME(skb))
@@ -161,7 +157,6 @@ void lbs_upload_rx_packet(struct lbs_private *priv, struct sk_buff *skb)
161 */ 157 */
162int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb) 158int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
163{ 159{
164 struct lbs_adapter *adapter = priv->adapter;
165 int ret = 0; 160 int ret = 0;
166 161
167 struct rxpackethdr *p_rx_pkt; 162 struct rxpackethdr *p_rx_pkt;
@@ -174,7 +169,7 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
174 169
175 lbs_deb_enter(LBS_DEB_RX); 170 lbs_deb_enter(LBS_DEB_RX);
176 171
177 if (priv->adapter->monitormode != LBS_MONITOR_OFF) 172 if (priv->monitormode != LBS_MONITOR_OFF)
178 return process_rxed_802_11_packet(priv, skb); 173 return process_rxed_802_11_packet(priv, skb);
179 174
180 p_rx_pkt = (struct rxpackethdr *) skb->data; 175 p_rx_pkt = (struct rxpackethdr *) skb->data;
@@ -258,8 +253,8 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
258 /* Take the data rate from the rxpd structure 253 /* Take the data rate from the rxpd structure
259 * only if the rate is auto 254 * only if the rate is auto
260 */ 255 */
261 if (adapter->auto_rate) 256 if (priv->auto_rate)
262 adapter->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate); 257 priv->cur_rate = lbs_fw_index_to_data_rate(p_rx_pd->rx_rate);
263 258
264 lbs_compute_rssi(priv, p_rx_pd); 259 lbs_compute_rssi(priv, p_rx_pd);
265 260
@@ -327,7 +322,6 @@ static u8 convert_mv_rate_to_radiotap(u8 rate)
327static int process_rxed_802_11_packet(struct lbs_private *priv, 322static int process_rxed_802_11_packet(struct lbs_private *priv,
328 struct sk_buff *skb) 323 struct sk_buff *skb)
329{ 324{
330 struct lbs_adapter *adapter = priv->adapter;
331 int ret = 0; 325 int ret = 0;
332 326
333 struct rx80211packethdr *p_rx_pkt; 327 struct rx80211packethdr *p_rx_pkt;
@@ -361,7 +355,7 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
361 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 355 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
362 356
363 /* create the exported radio header */ 357 /* create the exported radio header */
364 if (priv->adapter->monitormode == LBS_MONITOR_OFF) { 358 if (priv->monitormode == LBS_MONITOR_OFF) {
365 /* no radio header */ 359 /* no radio header */
366 /* chop the rxpd */ 360 /* chop the rxpd */
367 skb_pull(skb, sizeof(struct rxpd)); 361 skb_pull(skb, sizeof(struct rxpd));
@@ -410,8 +404,8 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
410 /* Take the data rate from the rxpd structure 404 /* Take the data rate from the rxpd structure
411 * only if the rate is auto 405 * only if the rate is auto
412 */ 406 */
413 if (adapter->auto_rate) 407 if (priv->auto_rate)
414 adapter->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate); 408 priv->cur_rate = lbs_fw_index_to_data_rate(prxpd->rx_rate);
415 409
416 lbs_compute_rssi(priv, prxpd); 410 lbs_compute_rssi(priv, prxpd);
417 411
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 }
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h
index 9b62e2b01f68..319f70dde350 100644
--- a/drivers/net/wireless/libertas/scan.h
+++ b/drivers/net/wireless/libertas/scan.h
@@ -10,8 +10,6 @@
10#include <net/ieee80211.h> 10#include <net/ieee80211.h>
11#include "hostcmd.h" 11#include "hostcmd.h"
12 12
13struct lbs_adapter;
14
15/** 13/**
16 * @brief Maximum number of channels that can be sent in a setuserscan ioctl 14 * @brief Maximum number of channels that can be sent in a setuserscan ioctl
17 * 15 *
@@ -168,11 +166,11 @@ struct bss_descriptor {
168 166
169int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len); 167int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len);
170 168
171struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter, 169struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv,
172 u8 *ssid, u8 ssid_len, u8 *bssid, u8 mode, 170 u8 *ssid, u8 ssid_len, u8 *bssid, u8 mode,
173 int channel); 171 int channel);
174 172
175struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter, 173struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv,
176 u8 *bssid, u8 mode); 174 u8 *bssid, u8 mode);
177 175
178int lbs_find_best_network_ssid(struct lbs_private *priv, u8 *out_ssid, 176int lbs_find_best_network_ssid(struct lbs_private *priv, u8 *out_ssid,
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index 131ef3fe0337..4cb39d33003c 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -64,11 +64,11 @@ static int SendSinglePacket(struct lbs_private *priv, struct sk_buff *skb)
64 u8 *p802x_hdr; 64 u8 *p802x_hdr;
65 struct tx_radiotap_hdr *pradiotap_hdr; 65 struct tx_radiotap_hdr *pradiotap_hdr;
66 u32 new_rate; 66 u32 new_rate;
67 u8 *ptr = priv->adapter->tmptxbuf; 67 u8 *ptr = priv->tmptxbuf;
68 68
69 lbs_deb_enter(LBS_DEB_TX); 69 lbs_deb_enter(LBS_DEB_TX);
70 70
71 if (priv->adapter->surpriseremoved) 71 if (priv->surpriseremoved)
72 return -1; 72 return -1;
73 73
74 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { 74 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) {
@@ -86,7 +86,7 @@ static int SendSinglePacket(struct lbs_private *priv, struct sk_buff *skb)
86 plocaltxpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd)); 86 plocaltxpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
87 87
88 p802x_hdr = skb->data; 88 p802x_hdr = skb->data;
89 if (priv->adapter->monitormode != LBS_MONITOR_OFF) { 89 if (priv->monitormode != LBS_MONITOR_OFF) {
90 90
91 /* locate radiotap header */ 91 /* locate radiotap header */
92 pradiotap_hdr = (struct tx_radiotap_hdr *)skb->data; 92 pradiotap_hdr = (struct tx_radiotap_hdr *)skb->data;
@@ -106,7 +106,7 @@ static int SendSinglePacket(struct lbs_private *priv, struct sk_buff *skb)
106 106
107 } 107 }
108 /* copy destination address from 802.3 or 802.11 header */ 108 /* copy destination address from 802.3 or 802.11 header */
109 if (priv->adapter->monitormode != LBS_MONITOR_OFF) 109 if (priv->monitormode != LBS_MONITOR_OFF)
110 memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr + 4, ETH_ALEN); 110 memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr + 4, ETH_ALEN);
111 else 111 else
112 memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr, ETH_ALEN); 112 memcpy(plocaltxpd->tx_dest_addr_high, p802x_hdr, ETH_ALEN);
@@ -124,7 +124,7 @@ static int SendSinglePacket(struct lbs_private *priv, struct sk_buff *skb)
124 lbs_deb_hex(LBS_DEB_TX, "Tx Data", (u8 *) p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length)); 124 lbs_deb_hex(LBS_DEB_TX, "Tx Data", (u8 *) p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length));
125 memcpy(ptr, p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length)); 125 memcpy(ptr, p802x_hdr, le16_to_cpu(plocaltxpd->tx_packet_length));
126 ret = priv->hw_host_to_card(priv, MVMS_DAT, 126 ret = priv->hw_host_to_card(priv, MVMS_DAT,
127 priv->adapter->tmptxbuf, 127 priv->tmptxbuf,
128 le16_to_cpu(plocaltxpd->tx_packet_length) + 128 le16_to_cpu(plocaltxpd->tx_packet_length) +
129 sizeof(struct txpd)); 129 sizeof(struct txpd));
130 130
@@ -144,7 +144,7 @@ done:
144 priv->stats.tx_errors++; 144 priv->stats.tx_errors++;
145 } 145 }
146 146
147 if (!ret && priv->adapter->monitormode != LBS_MONITOR_OFF) { 147 if (!ret && priv->monitormode != LBS_MONITOR_OFF) {
148 /* Keep the skb to echo it back once Tx feedback is 148 /* Keep the skb to echo it back once Tx feedback is
149 received from FW */ 149 received from FW */
150 skb_orphan(skb); 150 skb_orphan(skb);
@@ -154,7 +154,7 @@ done:
154 netif_stop_queue(priv->mesh_dev); 154 netif_stop_queue(priv->mesh_dev);
155 155
156 /* Keep the skb around for when we get feedback */ 156 /* Keep the skb around for when we get feedback */
157 priv->adapter->currenttxskb = skb; 157 priv->currenttxskb = skb;
158 } else { 158 } else {
159 dev_kfree_skb_any(skb); 159 dev_kfree_skb_any(skb);
160 } 160 }
@@ -166,29 +166,27 @@ done:
166 166
167void lbs_tx_runqueue(struct lbs_private *priv) 167void lbs_tx_runqueue(struct lbs_private *priv)
168{ 168{
169 struct lbs_adapter *adapter = priv->adapter;
170 int i; 169 int i;
171 170
172 spin_lock(&adapter->txqueue_lock); 171 spin_lock(&priv->txqueue_lock);
173 for (i = 0; i < adapter->tx_queue_idx; i++) { 172 for (i = 0; i < priv->tx_queue_idx; i++) {
174 struct sk_buff *skb = adapter->tx_queue_ps[i]; 173 struct sk_buff *skb = priv->tx_queue_ps[i];
175 spin_unlock(&adapter->txqueue_lock); 174 spin_unlock(&priv->txqueue_lock);
176 SendSinglePacket(priv, skb); 175 SendSinglePacket(priv, skb);
177 spin_lock(&adapter->txqueue_lock); 176 spin_lock(&priv->txqueue_lock);
178 } 177 }
179 adapter->tx_queue_idx = 0; 178 priv->tx_queue_idx = 0;
180 spin_unlock(&adapter->txqueue_lock); 179 spin_unlock(&priv->txqueue_lock);
181} 180}
182 181
183static void lbs_tx_queue(struct lbs_private *priv, struct sk_buff *skb) 182static void lbs_tx_queue(struct lbs_private *priv, struct sk_buff *skb)
184{ 183{
185 struct lbs_adapter *adapter = priv->adapter;
186 184
187 spin_lock(&adapter->txqueue_lock); 185 spin_lock(&priv->txqueue_lock);
188 186
189 WARN_ON(priv->adapter->tx_queue_idx >= NR_TX_QUEUE); 187 WARN_ON(priv->tx_queue_idx >= NR_TX_QUEUE);
190 adapter->tx_queue_ps[adapter->tx_queue_idx++] = skb; 188 priv->tx_queue_ps[priv->tx_queue_idx++] = skb;
191 if (adapter->tx_queue_idx == NR_TX_QUEUE) { 189 if (priv->tx_queue_idx == NR_TX_QUEUE) {
192 netif_stop_queue(priv->dev); 190 netif_stop_queue(priv->dev);
193 if (priv->mesh_dev) 191 if (priv->mesh_dev)
194 netif_stop_queue(priv->mesh_dev); 192 netif_stop_queue(priv->mesh_dev);
@@ -198,7 +196,7 @@ static void lbs_tx_queue(struct lbs_private *priv, struct sk_buff *skb)
198 netif_start_queue(priv->mesh_dev); 196 netif_start_queue(priv->mesh_dev);
199 } 197 }
200 198
201 spin_unlock(&adapter->txqueue_lock); 199 spin_unlock(&priv->txqueue_lock);
202} 200}
203 201
204/** 202/**
@@ -221,8 +219,8 @@ int lbs_process_tx(struct lbs_private *priv, struct sk_buff *skb)
221 goto done; 219 goto done;
222 } 220 }
223 221
224 if ((priv->adapter->psstate == PS_STATE_SLEEP) || 222 if ((priv->psstate == PS_STATE_SLEEP) ||
225 (priv->adapter->psstate == PS_STATE_PRE_SLEEP)) { 223 (priv->psstate == PS_STATE_PRE_SLEEP)) {
226 lbs_tx_queue(priv, skb); 224 lbs_tx_queue(priv, skb);
227 return ret; 225 return ret;
228 } 226 }
@@ -244,17 +242,16 @@ done:
244 */ 242 */
245void lbs_send_tx_feedback(struct lbs_private *priv) 243void lbs_send_tx_feedback(struct lbs_private *priv)
246{ 244{
247 struct lbs_adapter *adapter = priv->adapter;
248 struct tx_radiotap_hdr *radiotap_hdr; 245 struct tx_radiotap_hdr *radiotap_hdr;
249 u32 status = adapter->eventcause; 246 u32 status = priv->eventcause;
250 int txfail; 247 int txfail;
251 int try_count; 248 int try_count;
252 249
253 if (adapter->monitormode == LBS_MONITOR_OFF || 250 if (priv->monitormode == LBS_MONITOR_OFF ||
254 adapter->currenttxskb == NULL) 251 priv->currenttxskb == NULL)
255 return; 252 return;
256 253
257 radiotap_hdr = (struct tx_radiotap_hdr *)adapter->currenttxskb->data; 254 radiotap_hdr = (struct tx_radiotap_hdr *)priv->currenttxskb->data;
258 255
259 txfail = (status >> 24); 256 txfail = (status >> 24);
260 257
@@ -267,14 +264,14 @@ void lbs_send_tx_feedback(struct lbs_private *priv)
267#endif 264#endif
268 try_count = (status >> 16) & 0xff; 265 try_count = (status >> 16) & 0xff;
269 radiotap_hdr->data_retries = (try_count) ? 266 radiotap_hdr->data_retries = (try_count) ?
270 (1 + adapter->txretrycount - try_count) : 0; 267 (1 + priv->txretrycount - try_count) : 0;
271 lbs_upload_rx_packet(priv, adapter->currenttxskb); 268 lbs_upload_rx_packet(priv, priv->currenttxskb);
272 adapter->currenttxskb = NULL; 269 priv->currenttxskb = NULL;
273 270
274 if (adapter->connect_status == LBS_CONNECTED) 271 if (priv->connect_status == LBS_CONNECTED)
275 netif_wake_queue(priv->dev); 272 netif_wake_queue(priv->dev);
276 273
277 if (priv->mesh_dev && (adapter->mesh_connect_status == LBS_CONNECTED)) 274 if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED))
278 netif_wake_queue(priv->mesh_dev); 275 netif_wake_queue(priv->mesh_dev);
279} 276}
280EXPORT_SYMBOL_GPL(lbs_send_tx_feedback); 277EXPORT_SYMBOL_GPL(lbs_send_tx_feedback);
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 1af140bbbcb1..1e0b2245db56 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -23,7 +23,7 @@
23 23
24static inline void lbs_postpone_association_work(struct lbs_private *priv) 24static inline void lbs_postpone_association_work(struct lbs_private *priv)
25{ 25{
26 if (priv->adapter->surpriseremoved) 26 if (priv->surpriseremoved)
27 return; 27 return;
28 cancel_delayed_work(&priv->assoc_work); 28 cancel_delayed_work(&priv->assoc_work);
29 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2); 29 queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
@@ -32,21 +32,21 @@ static inline void lbs_postpone_association_work(struct lbs_private *priv)
32static inline void lbs_cancel_association_work(struct lbs_private *priv) 32static inline void lbs_cancel_association_work(struct lbs_private *priv)
33{ 33{
34 cancel_delayed_work(&priv->assoc_work); 34 cancel_delayed_work(&priv->assoc_work);
35 kfree(priv->adapter->pending_assoc_req); 35 kfree(priv->pending_assoc_req);
36 priv->adapter->pending_assoc_req = NULL; 36 priv->pending_assoc_req = NULL;
37} 37}
38 38
39 39
40/** 40/**
41 * @brief Find the channel frequency power info with specific channel 41 * @brief Find the channel frequency power info with specific channel
42 * 42 *
43 * @param adapter A pointer to struct lbs_adapter structure 43 * @param priv A pointer to struct lbs_private structure
44 * @param band it can be BAND_A, BAND_G or BAND_B 44 * @param band it can be BAND_A, BAND_G or BAND_B
45 * @param channel the channel for looking 45 * @param channel the channel for looking
46 * @return A pointer to struct chan_freq_power structure or NULL if not find. 46 * @return A pointer to struct chan_freq_power structure or NULL if not find.
47 */ 47 */
48struct chan_freq_power *lbs_find_cfp_by_band_and_channel( 48struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
49 struct lbs_adapter *adapter, 49 struct lbs_private *priv,
50 u8 band, 50 u8 band,
51 u16 channel) 51 u16 channel)
52{ 52{
@@ -54,11 +54,11 @@ struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
54 struct region_channel *rc; 54 struct region_channel *rc;
55 int i, j; 55 int i, j;
56 56
57 for (j = 0; !cfp && (j < ARRAY_SIZE(adapter->region_channel)); j++) { 57 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
58 rc = &adapter->region_channel[j]; 58 rc = &priv->region_channel[j];
59 59
60 if (adapter->enable11d) 60 if (priv->enable11d)
61 rc = &adapter->universal_channel[j]; 61 rc = &priv->universal_channel[j];
62 if (!rc->valid || !rc->CFP) 62 if (!rc->valid || !rc->CFP)
63 continue; 63 continue;
64 if (rc->band != band) 64 if (rc->band != band)
@@ -81,13 +81,13 @@ struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
81/** 81/**
82 * @brief Find the channel frequency power info with specific frequency 82 * @brief Find the channel frequency power info with specific frequency
83 * 83 *
84 * @param adapter A pointer to struct lbs_adapter structure 84 * @param priv A pointer to struct lbs_private structure
85 * @param band it can be BAND_A, BAND_G or BAND_B 85 * @param band it can be BAND_A, BAND_G or BAND_B
86 * @param freq the frequency for looking 86 * @param freq the frequency for looking
87 * @return A pointer to struct chan_freq_power structure or NULL if not find. 87 * @return A pointer to struct chan_freq_power structure or NULL if not find.
88 */ 88 */
89static struct chan_freq_power *find_cfp_by_band_and_freq( 89static struct chan_freq_power *find_cfp_by_band_and_freq(
90 struct lbs_adapter *adapter, 90 struct lbs_private *priv,
91 u8 band, 91 u8 band,
92 u32 freq) 92 u32 freq)
93{ 93{
@@ -95,11 +95,11 @@ static struct chan_freq_power *find_cfp_by_band_and_freq(
95 struct region_channel *rc; 95 struct region_channel *rc;
96 int i, j; 96 int i, j;
97 97
98 for (j = 0; !cfp && (j < ARRAY_SIZE(adapter->region_channel)); j++) { 98 for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
99 rc = &adapter->region_channel[j]; 99 rc = &priv->region_channel[j];
100 100
101 if (adapter->enable11d) 101 if (priv->enable11d)
102 rc = &adapter->universal_channel[j]; 102 rc = &priv->universal_channel[j];
103 if (!rc->valid || !rc->CFP) 103 if (!rc->valid || !rc->CFP)
104 continue; 104 continue;
105 if (rc->band != band) 105 if (rc->band != band)
@@ -130,13 +130,12 @@ static struct chan_freq_power *find_cfp_by_band_and_freq(
130static int lbs_radio_ioctl(struct lbs_private *priv, u8 option) 130static int lbs_radio_ioctl(struct lbs_private *priv, u8 option)
131{ 131{
132 int ret = 0; 132 int ret = 0;
133 struct lbs_adapter *adapter = priv->adapter;
134 133
135 lbs_deb_enter(LBS_DEB_WEXT); 134 lbs_deb_enter(LBS_DEB_WEXT);
136 135
137 if (adapter->radioon != option) { 136 if (priv->radioon != option) {
138 lbs_deb_wext("switching radio %s\n", option ? "on" : "off"); 137 lbs_deb_wext("switching radio %s\n", option ? "on" : "off");
139 adapter->radioon = option; 138 priv->radioon = option;
140 139
141 ret = lbs_prepare_and_send_command(priv, 140 ret = lbs_prepare_and_send_command(priv,
142 CMD_802_11_RADIO_CONTROL, 141 CMD_802_11_RADIO_CONTROL,
@@ -151,18 +150,18 @@ static int lbs_radio_ioctl(struct lbs_private *priv, u8 option)
151/** 150/**
152 * @brief Copy active data rates based on adapter mode and status 151 * @brief Copy active data rates based on adapter mode and status
153 * 152 *
154 * @param adapter A pointer to struct lbs_adapter structure 153 * @param priv A pointer to struct lbs_private structure
155 * @param rate The buf to return the active rates 154 * @param rate The buf to return the active rates
156 */ 155 */
157static void copy_active_data_rates(struct lbs_adapter *adapter, u8 *rates) 156static void copy_active_data_rates(struct lbs_private *priv, u8 *rates)
158{ 157{
159 lbs_deb_enter(LBS_DEB_WEXT); 158 lbs_deb_enter(LBS_DEB_WEXT);
160 159
161 if ((adapter->connect_status != LBS_CONNECTED) && 160 if ((priv->connect_status != LBS_CONNECTED) &&
162 (adapter->mesh_connect_status != LBS_CONNECTED)) 161 (priv->mesh_connect_status != LBS_CONNECTED))
163 memcpy(rates, lbs_bg_rates, MAX_RATES); 162 memcpy(rates, lbs_bg_rates, MAX_RATES);
164 else 163 else
165 memcpy(rates, adapter->curbssparams.rates, MAX_RATES); 164 memcpy(rates, priv->curbssparams.rates, MAX_RATES);
166 165
167 lbs_deb_leave(LBS_DEB_WEXT); 166 lbs_deb_leave(LBS_DEB_WEXT);
168} 167}
@@ -184,18 +183,17 @@ static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
184 struct iw_freq *fwrq, char *extra) 183 struct iw_freq *fwrq, char *extra)
185{ 184{
186 struct lbs_private *priv = dev->priv; 185 struct lbs_private *priv = dev->priv;
187 struct lbs_adapter *adapter = priv->adapter;
188 struct chan_freq_power *cfp; 186 struct chan_freq_power *cfp;
189 187
190 lbs_deb_enter(LBS_DEB_WEXT); 188 lbs_deb_enter(LBS_DEB_WEXT);
191 189
192 cfp = lbs_find_cfp_by_band_and_channel(adapter, 0, 190 cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
193 adapter->curbssparams.channel); 191 priv->curbssparams.channel);
194 192
195 if (!cfp) { 193 if (!cfp) {
196 if (adapter->curbssparams.channel) 194 if (priv->curbssparams.channel)
197 lbs_deb_wext("invalid channel %d\n", 195 lbs_deb_wext("invalid channel %d\n",
198 adapter->curbssparams.channel); 196 priv->curbssparams.channel);
199 return -EINVAL; 197 return -EINVAL;
200 } 198 }
201 199
@@ -211,12 +209,11 @@ static int lbs_get_wap(struct net_device *dev, struct iw_request_info *info,
211 struct sockaddr *awrq, char *extra) 209 struct sockaddr *awrq, char *extra)
212{ 210{
213 struct lbs_private *priv = dev->priv; 211 struct lbs_private *priv = dev->priv;
214 struct lbs_adapter *adapter = priv->adapter;
215 212
216 lbs_deb_enter(LBS_DEB_WEXT); 213 lbs_deb_enter(LBS_DEB_WEXT);
217 214
218 if (adapter->connect_status == LBS_CONNECTED) { 215 if (priv->connect_status == LBS_CONNECTED) {
219 memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN); 216 memcpy(awrq->sa_data, priv->curbssparams.bssid, ETH_ALEN);
220 } else { 217 } else {
221 memset(awrq->sa_data, 0, ETH_ALEN); 218 memset(awrq->sa_data, 0, ETH_ALEN);
222 } 219 }
@@ -230,7 +227,6 @@ static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
230 struct iw_point *dwrq, char *extra) 227 struct iw_point *dwrq, char *extra)
231{ 228{
232 struct lbs_private *priv = dev->priv; 229 struct lbs_private *priv = dev->priv;
233 struct lbs_adapter *adapter = priv->adapter;
234 230
235 lbs_deb_enter(LBS_DEB_WEXT); 231 lbs_deb_enter(LBS_DEB_WEXT);
236 232
@@ -242,10 +238,10 @@ static int lbs_set_nick(struct net_device *dev, struct iw_request_info *info,
242 return -E2BIG; 238 return -E2BIG;
243 } 239 }
244 240
245 mutex_lock(&adapter->lock); 241 mutex_lock(&priv->lock);
246 memset(adapter->nodename, 0, sizeof(adapter->nodename)); 242 memset(priv->nodename, 0, sizeof(priv->nodename));
247 memcpy(adapter->nodename, extra, dwrq->length); 243 memcpy(priv->nodename, extra, dwrq->length);
248 mutex_unlock(&adapter->lock); 244 mutex_unlock(&priv->lock);
249 245
250 lbs_deb_leave(LBS_DEB_WEXT); 246 lbs_deb_leave(LBS_DEB_WEXT);
251 return 0; 247 return 0;
@@ -255,12 +251,11 @@ static int lbs_get_nick(struct net_device *dev, struct iw_request_info *info,
255 struct iw_point *dwrq, char *extra) 251 struct iw_point *dwrq, char *extra)
256{ 252{
257 struct lbs_private *priv = dev->priv; 253 struct lbs_private *priv = dev->priv;
258 struct lbs_adapter *adapter = priv->adapter;
259 254
260 lbs_deb_enter(LBS_DEB_WEXT); 255 lbs_deb_enter(LBS_DEB_WEXT);
261 256
262 dwrq->length = strlen(adapter->nodename); 257 dwrq->length = strlen(priv->nodename);
263 memcpy(extra, adapter->nodename, dwrq->length); 258 memcpy(extra, priv->nodename, dwrq->length);
264 extra[dwrq->length] = '\0'; 259 extra[dwrq->length] = '\0';
265 260
266 dwrq->flags = 1; /* active */ 261 dwrq->flags = 1; /* active */
@@ -273,13 +268,12 @@ static int mesh_get_nick(struct net_device *dev, struct iw_request_info *info,
273 struct iw_point *dwrq, char *extra) 268 struct iw_point *dwrq, char *extra)
274{ 269{
275 struct lbs_private *priv = dev->priv; 270 struct lbs_private *priv = dev->priv;
276 struct lbs_adapter *adapter = priv->adapter;
277 271
278 lbs_deb_enter(LBS_DEB_WEXT); 272 lbs_deb_enter(LBS_DEB_WEXT);
279 273
280 /* Use nickname to indicate that mesh is on */ 274 /* Use nickname to indicate that mesh is on */
281 275
282 if (adapter->mesh_connect_status == LBS_CONNECTED) { 276 if (priv->mesh_connect_status == LBS_CONNECTED) {
283 strncpy(extra, "Mesh", 12); 277 strncpy(extra, "Mesh", 12);
284 extra[12] = '\0'; 278 extra[12] = '\0';
285 dwrq->length = strlen(extra); 279 dwrq->length = strlen(extra);
@@ -299,17 +293,16 @@ static int lbs_set_rts(struct net_device *dev, struct iw_request_info *info,
299{ 293{
300 int ret = 0; 294 int ret = 0;
301 struct lbs_private *priv = dev->priv; 295 struct lbs_private *priv = dev->priv;
302 struct lbs_adapter *adapter = priv->adapter;
303 u32 rthr = vwrq->value; 296 u32 rthr = vwrq->value;
304 297
305 lbs_deb_enter(LBS_DEB_WEXT); 298 lbs_deb_enter(LBS_DEB_WEXT);
306 299
307 if (vwrq->disabled) { 300 if (vwrq->disabled) {
308 adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE; 301 priv->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
309 } else { 302 } else {
310 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE) 303 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
311 return -EINVAL; 304 return -EINVAL;
312 adapter->rtsthsd = rthr; 305 priv->rtsthsd = rthr;
313 } 306 }
314 307
315 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 308 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
@@ -325,18 +318,17 @@ static int lbs_get_rts(struct net_device *dev, struct iw_request_info *info,
325{ 318{
326 int ret = 0; 319 int ret = 0;
327 struct lbs_private *priv = dev->priv; 320 struct lbs_private *priv = dev->priv;
328 struct lbs_adapter *adapter = priv->adapter;
329 321
330 lbs_deb_enter(LBS_DEB_WEXT); 322 lbs_deb_enter(LBS_DEB_WEXT);
331 323
332 adapter->rtsthsd = 0; 324 priv->rtsthsd = 0;
333 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 325 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
334 CMD_ACT_GET, CMD_OPTION_WAITFORRSP, 326 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
335 OID_802_11_RTS_THRESHOLD, NULL); 327 OID_802_11_RTS_THRESHOLD, NULL);
336 if (ret) 328 if (ret)
337 goto out; 329 goto out;
338 330
339 vwrq->value = adapter->rtsthsd; 331 vwrq->value = priv->rtsthsd;
340 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE) 332 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE)
341 || (vwrq->value > MRVDRV_RTS_MAX_VALUE)); 333 || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
342 vwrq->fixed = 1; 334 vwrq->fixed = 1;
@@ -352,17 +344,16 @@ static int lbs_set_frag(struct net_device *dev, struct iw_request_info *info,
352 int ret = 0; 344 int ret = 0;
353 u32 fthr = vwrq->value; 345 u32 fthr = vwrq->value;
354 struct lbs_private *priv = dev->priv; 346 struct lbs_private *priv = dev->priv;
355 struct lbs_adapter *adapter = priv->adapter;
356 347
357 lbs_deb_enter(LBS_DEB_WEXT); 348 lbs_deb_enter(LBS_DEB_WEXT);
358 349
359 if (vwrq->disabled) { 350 if (vwrq->disabled) {
360 adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE; 351 priv->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
361 } else { 352 } else {
362 if (fthr < MRVDRV_FRAG_MIN_VALUE 353 if (fthr < MRVDRV_FRAG_MIN_VALUE
363 || fthr > MRVDRV_FRAG_MAX_VALUE) 354 || fthr > MRVDRV_FRAG_MAX_VALUE)
364 return -EINVAL; 355 return -EINVAL;
365 adapter->fragthsd = fthr; 356 priv->fragthsd = fthr;
366 } 357 }
367 358
368 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 359 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
@@ -378,11 +369,10 @@ static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
378{ 369{
379 int ret = 0; 370 int ret = 0;
380 struct lbs_private *priv = dev->priv; 371 struct lbs_private *priv = dev->priv;
381 struct lbs_adapter *adapter = priv->adapter;
382 372
383 lbs_deb_enter(LBS_DEB_WEXT); 373 lbs_deb_enter(LBS_DEB_WEXT);
384 374
385 adapter->fragthsd = 0; 375 priv->fragthsd = 0;
386 ret = lbs_prepare_and_send_command(priv, 376 ret = lbs_prepare_and_send_command(priv,
387 CMD_802_11_SNMP_MIB, 377 CMD_802_11_SNMP_MIB,
388 CMD_ACT_GET, CMD_OPTION_WAITFORRSP, 378 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
@@ -390,7 +380,7 @@ static int lbs_get_frag(struct net_device *dev, struct iw_request_info *info,
390 if (ret) 380 if (ret)
391 goto out; 381 goto out;
392 382
393 vwrq->value = adapter->fragthsd; 383 vwrq->value = priv->fragthsd;
394 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE) 384 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE)
395 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE)); 385 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE));
396 vwrq->fixed = 1; 386 vwrq->fixed = 1;
@@ -404,11 +394,10 @@ static int lbs_get_mode(struct net_device *dev,
404 struct iw_request_info *info, u32 * uwrq, char *extra) 394 struct iw_request_info *info, u32 * uwrq, char *extra)
405{ 395{
406 struct lbs_private *priv = dev->priv; 396 struct lbs_private *priv = dev->priv;
407 struct lbs_adapter *adapter = priv->adapter;
408 397
409 lbs_deb_enter(LBS_DEB_WEXT); 398 lbs_deb_enter(LBS_DEB_WEXT);
410 399
411 *uwrq = adapter->mode; 400 *uwrq = priv->mode;
412 401
413 lbs_deb_leave(LBS_DEB_WEXT); 402 lbs_deb_leave(LBS_DEB_WEXT);
414 return 0; 403 return 0;
@@ -432,7 +421,6 @@ static int lbs_get_txpow(struct net_device *dev,
432{ 421{
433 int ret = 0; 422 int ret = 0;
434 struct lbs_private *priv = dev->priv; 423 struct lbs_private *priv = dev->priv;
435 struct lbs_adapter *adapter = priv->adapter;
436 424
437 lbs_deb_enter(LBS_DEB_WEXT); 425 lbs_deb_enter(LBS_DEB_WEXT);
438 426
@@ -444,10 +432,10 @@ static int lbs_get_txpow(struct net_device *dev,
444 if (ret) 432 if (ret)
445 goto out; 433 goto out;
446 434
447 lbs_deb_wext("tx power level %d dbm\n", adapter->txpowerlevel); 435 lbs_deb_wext("tx power level %d dbm\n", priv->txpowerlevel);
448 vwrq->value = adapter->txpowerlevel; 436 vwrq->value = priv->txpowerlevel;
449 vwrq->fixed = 1; 437 vwrq->fixed = 1;
450 if (adapter->radioon) { 438 if (priv->radioon) {
451 vwrq->disabled = 0; 439 vwrq->disabled = 0;
452 vwrq->flags = IW_TXPOW_DBM; 440 vwrq->flags = IW_TXPOW_DBM;
453 } else { 441 } else {
@@ -464,7 +452,6 @@ static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
464{ 452{
465 int ret = 0; 453 int ret = 0;
466 struct lbs_private *priv = dev->priv; 454 struct lbs_private *priv = dev->priv;
467 struct lbs_adapter *adapter = priv->adapter;
468 455
469 lbs_deb_enter(LBS_DEB_WEXT); 456 lbs_deb_enter(LBS_DEB_WEXT);
470 457
@@ -477,7 +464,7 @@ static int lbs_set_retry(struct net_device *dev, struct iw_request_info *info,
477 return -EINVAL; 464 return -EINVAL;
478 465
479 /* Adding 1 to convert retry count to try count */ 466 /* Adding 1 to convert retry count to try count */
480 adapter->txretrycount = vwrq->value + 1; 467 priv->txretrycount = vwrq->value + 1;
481 468
482 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB, 469 ret = lbs_prepare_and_send_command(priv, CMD_802_11_SNMP_MIB,
483 CMD_ACT_SET, 470 CMD_ACT_SET,
@@ -499,12 +486,11 @@ static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
499 struct iw_param *vwrq, char *extra) 486 struct iw_param *vwrq, char *extra)
500{ 487{
501 struct lbs_private *priv = dev->priv; 488 struct lbs_private *priv = dev->priv;
502 struct lbs_adapter *adapter = priv->adapter;
503 int ret = 0; 489 int ret = 0;
504 490
505 lbs_deb_enter(LBS_DEB_WEXT); 491 lbs_deb_enter(LBS_DEB_WEXT);
506 492
507 adapter->txretrycount = 0; 493 priv->txretrycount = 0;
508 ret = lbs_prepare_and_send_command(priv, 494 ret = lbs_prepare_and_send_command(priv,
509 CMD_802_11_SNMP_MIB, 495 CMD_802_11_SNMP_MIB,
510 CMD_ACT_GET, CMD_OPTION_WAITFORRSP, 496 CMD_ACT_GET, CMD_OPTION_WAITFORRSP,
@@ -516,7 +502,7 @@ static int lbs_get_retry(struct net_device *dev, struct iw_request_info *info,
516 if (!vwrq->flags) { 502 if (!vwrq->flags) {
517 vwrq->flags = IW_RETRY_LIMIT; 503 vwrq->flags = IW_RETRY_LIMIT;
518 /* Subtract 1 to convert try count to retry count */ 504 /* Subtract 1 to convert try count to retry count */
519 vwrq->value = adapter->txretrycount - 1; 505 vwrq->value = priv->txretrycount - 1;
520 } 506 }
521 507
522out: 508out:
@@ -568,7 +554,6 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
568{ 554{
569 int i, j; 555 int i, j;
570 struct lbs_private *priv = dev->priv; 556 struct lbs_private *priv = dev->priv;
571 struct lbs_adapter *adapter = priv->adapter;
572 struct iw_range *range = (struct iw_range *)extra; 557 struct iw_range *range = (struct iw_range *)extra;
573 struct chan_freq_power *cfp; 558 struct chan_freq_power *cfp;
574 u8 rates[MAX_RATES + 1]; 559 u8 rates[MAX_RATES + 1];
@@ -584,7 +569,7 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
584 range->max_nwid = 0; 569 range->max_nwid = 0;
585 570
586 memset(rates, 0, sizeof(rates)); 571 memset(rates, 0, sizeof(rates));
587 copy_active_data_rates(adapter, rates); 572 copy_active_data_rates(priv, rates);
588 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES); 573 range->num_bitrates = strnlen(rates, IW_MAX_BITRATES);
589 for (i = 0; i < range->num_bitrates; i++) 574 for (i = 0; i < range->num_bitrates; i++)
590 range->bitrate[i] = rates[i] * 500000; 575 range->bitrate[i] = rates[i] * 500000;
@@ -593,14 +578,14 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
593 range->num_bitrates); 578 range->num_bitrates);
594 579
595 range->num_frequency = 0; 580 range->num_frequency = 0;
596 if (priv->adapter->enable11d && 581 if (priv->enable11d &&
597 (adapter->connect_status == LBS_CONNECTED || 582 (priv->connect_status == LBS_CONNECTED ||
598 adapter->mesh_connect_status == LBS_CONNECTED)) { 583 priv->mesh_connect_status == LBS_CONNECTED)) {
599 u8 chan_no; 584 u8 chan_no;
600 u8 band; 585 u8 band;
601 586
602 struct parsed_region_chan_11d *parsed_region_chan = 587 struct parsed_region_chan_11d *parsed_region_chan =
603 &adapter->parsed_region_chan; 588 &priv->parsed_region_chan;
604 589
605 if (parsed_region_chan == NULL) { 590 if (parsed_region_chan == NULL) {
606 lbs_deb_wext("11d: parsed_region_chan is NULL\n"); 591 lbs_deb_wext("11d: parsed_region_chan is NULL\n");
@@ -624,12 +609,12 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
624 } 609 }
625 if (!flag) { 610 if (!flag) {
626 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES) 611 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
627 && (j < ARRAY_SIZE(adapter->region_channel)); j++) { 612 && (j < ARRAY_SIZE(priv->region_channel)); j++) {
628 cfp = adapter->region_channel[j].CFP; 613 cfp = priv->region_channel[j].CFP;
629 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES) 614 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
630 && adapter->region_channel[j].valid 615 && priv->region_channel[j].valid
631 && cfp 616 && cfp
632 && (i < adapter->region_channel[j].nrcfp); i++) { 617 && (i < priv->region_channel[j].nrcfp); i++) {
633 range->freq[range->num_frequency].i = 618 range->freq[range->num_frequency].i =
634 (long)cfp->channel; 619 (long)cfp->channel;
635 range->freq[range->num_frequency].m = 620 range->freq[range->num_frequency].m =
@@ -729,7 +714,7 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
729 IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); 714 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
730 range->event_capa[1] = IW_EVENT_CAPA_K_1; 715 range->event_capa[1] = IW_EVENT_CAPA_K_1;
731 716
732 if (adapter->fwcapinfo & FW_CAPINFO_WPA) { 717 if (priv->fwcapinfo & FW_CAPINFO_WPA) {
733 range->enc_capa = IW_ENC_CAPA_WPA 718 range->enc_capa = IW_ENC_CAPA_WPA
734 | IW_ENC_CAPA_WPA2 719 | IW_ENC_CAPA_WPA2
735 | IW_ENC_CAPA_CIPHER_TKIP 720 | IW_ENC_CAPA_CIPHER_TKIP
@@ -745,7 +730,6 @@ static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
745 struct iw_param *vwrq, char *extra) 730 struct iw_param *vwrq, char *extra)
746{ 731{
747 struct lbs_private *priv = dev->priv; 732 struct lbs_private *priv = dev->priv;
748 struct lbs_adapter *adapter = priv->adapter;
749 733
750 lbs_deb_enter(LBS_DEB_WEXT); 734 lbs_deb_enter(LBS_DEB_WEXT);
751 735
@@ -754,8 +738,8 @@ static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
754 */ 738 */
755 739
756 if (vwrq->disabled) { 740 if (vwrq->disabled) {
757 adapter->psmode = LBS802_11POWERMODECAM; 741 priv->psmode = LBS802_11POWERMODECAM;
758 if (adapter->psstate != PS_STATE_FULL_POWER) { 742 if (priv->psstate != PS_STATE_FULL_POWER) {
759 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP); 743 lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
760 } 744 }
761 745
@@ -771,13 +755,13 @@ static int lbs_set_power(struct net_device *dev, struct iw_request_info *info,
771 return -EINVAL; 755 return -EINVAL;
772 } 756 }
773 757
774 if (adapter->psmode != LBS802_11POWERMODECAM) { 758 if (priv->psmode != LBS802_11POWERMODECAM) {
775 return 0; 759 return 0;
776 } 760 }
777 761
778 adapter->psmode = LBS802_11POWERMODEMAX_PSP; 762 priv->psmode = LBS802_11POWERMODEMAX_PSP;
779 763
780 if (adapter->connect_status == LBS_CONNECTED) { 764 if (priv->connect_status == LBS_CONNECTED) {
781 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP); 765 lbs_ps_sleep(priv, CMD_OPTION_WAITFORRSP);
782 } 766 }
783 767
@@ -789,15 +773,14 @@ static int lbs_get_power(struct net_device *dev, struct iw_request_info *info,
789 struct iw_param *vwrq, char *extra) 773 struct iw_param *vwrq, char *extra)
790{ 774{
791 struct lbs_private *priv = dev->priv; 775 struct lbs_private *priv = dev->priv;
792 struct lbs_adapter *adapter = priv->adapter;
793 int mode; 776 int mode;
794 777
795 lbs_deb_enter(LBS_DEB_WEXT); 778 lbs_deb_enter(LBS_DEB_WEXT);
796 779
797 mode = adapter->psmode; 780 mode = priv->psmode;
798 781
799 if ((vwrq->disabled = (mode == LBS802_11POWERMODECAM)) 782 if ((vwrq->disabled = (mode == LBS802_11POWERMODECAM))
800 || adapter->connect_status == LBS_DISCONNECTED) 783 || priv->connect_status == LBS_DISCONNECTED)
801 { 784 {
802 goto out; 785 goto out;
803 } 786 }
@@ -820,7 +803,6 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
820 PERFECT = 100 803 PERFECT = 100
821 }; 804 };
822 struct lbs_private *priv = dev->priv; 805 struct lbs_private *priv = dev->priv;
823 struct lbs_adapter *adapter = priv->adapter;
824 u32 rssi_qual; 806 u32 rssi_qual;
825 u32 tx_qual; 807 u32 tx_qual;
826 u32 quality = 0; 808 u32 quality = 0;
@@ -830,23 +812,23 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
830 812
831 lbs_deb_enter(LBS_DEB_WEXT); 813 lbs_deb_enter(LBS_DEB_WEXT);
832 814
833 priv->wstats.status = adapter->mode; 815 priv->wstats.status = priv->mode;
834 816
835 /* If we're not associated, all quality values are meaningless */ 817 /* If we're not associated, all quality values are meaningless */
836 if ((adapter->connect_status != LBS_CONNECTED) && 818 if ((priv->connect_status != LBS_CONNECTED) &&
837 (adapter->mesh_connect_status != LBS_CONNECTED)) 819 (priv->mesh_connect_status != LBS_CONNECTED))
838 goto out; 820 goto out;
839 821
840 /* Quality by RSSI */ 822 /* Quality by RSSI */
841 priv->wstats.qual.level = 823 priv->wstats.qual.level =
842 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG], 824 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
843 adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 825 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
844 826
845 if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { 827 if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
846 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; 828 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
847 } else { 829 } else {
848 priv->wstats.qual.noise = 830 priv->wstats.qual.noise =
849 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 831 CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]);
850 } 832 }
851 833
852 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level); 834 lbs_deb_wext("signal level %#x\n", priv->wstats.qual.level);
@@ -870,7 +852,7 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
870 /* Quality by TX errors */ 852 /* Quality by TX errors */
871 priv->wstats.discard.retries = priv->stats.tx_errors; 853 priv->wstats.discard.retries = priv->stats.tx_errors;
872 854
873 tx_retries = le32_to_cpu(adapter->logmsg.retry); 855 tx_retries = le32_to_cpu(priv->logmsg.retry);
874 856
875 if (tx_retries > 75) 857 if (tx_retries > 75)
876 tx_qual = (90 - tx_retries) * POOR / 15; 858 tx_qual = (90 - tx_retries) * POOR / 15;
@@ -886,10 +868,10 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
886 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD; 868 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
887 quality = min(quality, tx_qual); 869 quality = min(quality, tx_qual);
888 870
889 priv->wstats.discard.code = le32_to_cpu(adapter->logmsg.wepundecryptable); 871 priv->wstats.discard.code = le32_to_cpu(priv->logmsg.wepundecryptable);
890 priv->wstats.discard.fragment = le32_to_cpu(adapter->logmsg.rxfrag); 872 priv->wstats.discard.fragment = le32_to_cpu(priv->logmsg.rxfrag);
891 priv->wstats.discard.retries = tx_retries; 873 priv->wstats.discard.retries = tx_retries;
892 priv->wstats.discard.misc = le32_to_cpu(adapter->logmsg.ackfailure); 874 priv->wstats.discard.misc = le32_to_cpu(priv->logmsg.ackfailure);
893 875
894 /* Calculate quality */ 876 /* Calculate quality */
895 priv->wstats.qual.qual = min_t(u8, quality, 100); 877 priv->wstats.qual.qual = min_t(u8, quality, 100);
@@ -924,14 +906,13 @@ static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
924{ 906{
925 int ret = -EINVAL; 907 int ret = -EINVAL;
926 struct lbs_private *priv = dev->priv; 908 struct lbs_private *priv = dev->priv;
927 struct lbs_adapter *adapter = priv->adapter;
928 struct chan_freq_power *cfp; 909 struct chan_freq_power *cfp;
929 struct assoc_request * assoc_req; 910 struct assoc_request * assoc_req;
930 911
931 lbs_deb_enter(LBS_DEB_WEXT); 912 lbs_deb_enter(LBS_DEB_WEXT);
932 913
933 mutex_lock(&adapter->lock); 914 mutex_lock(&priv->lock);
934 assoc_req = lbs_get_association_request(adapter); 915 assoc_req = lbs_get_association_request(priv);
935 if (!assoc_req) { 916 if (!assoc_req) {
936 ret = -ENOMEM; 917 ret = -ENOMEM;
937 goto out; 918 goto out;
@@ -941,7 +922,7 @@ static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
941 if (fwrq->e == 1) { 922 if (fwrq->e == 1) {
942 long f = fwrq->m / 100000; 923 long f = fwrq->m / 100000;
943 924
944 cfp = find_cfp_by_band_and_freq(adapter, 0, f); 925 cfp = find_cfp_by_band_and_freq(priv, 0, f);
945 if (!cfp) { 926 if (!cfp) {
946 lbs_deb_wext("invalid freq %ld\n", f); 927 lbs_deb_wext("invalid freq %ld\n", f);
947 goto out; 928 goto out;
@@ -956,7 +937,7 @@ static int lbs_set_freq(struct net_device *dev, struct iw_request_info *info,
956 goto out; 937 goto out;
957 } 938 }
958 939
959 cfp = lbs_find_cfp_by_band_and_channel(adapter, 0, fwrq->m); 940 cfp = lbs_find_cfp_by_band_and_channel(priv, 0, fwrq->m);
960 if (!cfp) { 941 if (!cfp) {
961 goto out; 942 goto out;
962 } 943 }
@@ -971,7 +952,7 @@ out:
971 } else { 952 } else {
972 lbs_cancel_association_work(priv); 953 lbs_cancel_association_work(priv);
973 } 954 }
974 mutex_unlock(&adapter->lock); 955 mutex_unlock(&priv->lock);
975 956
976 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 957 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
977 return ret; 958 return ret;
@@ -981,7 +962,6 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
981 struct iw_param *vwrq, char *extra) 962 struct iw_param *vwrq, char *extra)
982{ 963{
983 struct lbs_private *priv = dev->priv; 964 struct lbs_private *priv = dev->priv;
984 struct lbs_adapter *adapter = priv->adapter;
985 u32 new_rate; 965 u32 new_rate;
986 u16 action; 966 u16 action;
987 int ret = -EINVAL; 967 int ret = -EINVAL;
@@ -993,14 +973,14 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
993 /* Auto rate? */ 973 /* Auto rate? */
994 if (vwrq->value == -1) { 974 if (vwrq->value == -1) {
995 action = CMD_ACT_SET_TX_AUTO; 975 action = CMD_ACT_SET_TX_AUTO;
996 adapter->auto_rate = 1; 976 priv->auto_rate = 1;
997 adapter->cur_rate = 0; 977 priv->cur_rate = 0;
998 } else { 978 } else {
999 if (vwrq->value % 100000) 979 if (vwrq->value % 100000)
1000 goto out; 980 goto out;
1001 981
1002 memset(rates, 0, sizeof(rates)); 982 memset(rates, 0, sizeof(rates));
1003 copy_active_data_rates(adapter, rates); 983 copy_active_data_rates(priv, rates);
1004 new_rate = vwrq->value / 500000; 984 new_rate = vwrq->value / 500000;
1005 if (!memchr(rates, new_rate, sizeof(rates))) { 985 if (!memchr(rates, new_rate, sizeof(rates))) {
1006 lbs_pr_alert("fixed data rate 0x%X out of range\n", 986 lbs_pr_alert("fixed data rate 0x%X out of range\n",
@@ -1008,9 +988,9 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info,
1008 goto out; 988 goto out;
1009 } 989 }
1010 990
1011 adapter->cur_rate = new_rate; 991 priv->cur_rate = new_rate;
1012 action = CMD_ACT_SET_TX_FIX_RATE; 992 action = CMD_ACT_SET_TX_FIX_RATE;
1013 adapter->auto_rate = 0; 993 priv->auto_rate = 0;
1014 } 994 }
1015 995
1016 ret = lbs_prepare_and_send_command(priv, CMD_802_11_DATA_RATE, 996 ret = lbs_prepare_and_send_command(priv, CMD_802_11_DATA_RATE,
@@ -1025,14 +1005,13 @@ static int lbs_get_rate(struct net_device *dev, struct iw_request_info *info,
1025 struct iw_param *vwrq, char *extra) 1005 struct iw_param *vwrq, char *extra)
1026{ 1006{
1027 struct lbs_private *priv = dev->priv; 1007 struct lbs_private *priv = dev->priv;
1028 struct lbs_adapter *adapter = priv->adapter;
1029 1008
1030 lbs_deb_enter(LBS_DEB_WEXT); 1009 lbs_deb_enter(LBS_DEB_WEXT);
1031 1010
1032 if (adapter->connect_status == LBS_CONNECTED) { 1011 if (priv->connect_status == LBS_CONNECTED) {
1033 vwrq->value = adapter->cur_rate * 500000; 1012 vwrq->value = priv->cur_rate * 500000;
1034 1013
1035 if (adapter->auto_rate) 1014 if (priv->auto_rate)
1036 vwrq->fixed = 0; 1015 vwrq->fixed = 0;
1037 else 1016 else
1038 vwrq->fixed = 1; 1017 vwrq->fixed = 1;
@@ -1051,7 +1030,6 @@ static int lbs_set_mode(struct net_device *dev,
1051{ 1030{
1052 int ret = 0; 1031 int ret = 0;
1053 struct lbs_private *priv = dev->priv; 1032 struct lbs_private *priv = dev->priv;
1054 struct lbs_adapter *adapter = priv->adapter;
1055 struct assoc_request * assoc_req; 1033 struct assoc_request * assoc_req;
1056 1034
1057 lbs_deb_enter(LBS_DEB_WEXT); 1035 lbs_deb_enter(LBS_DEB_WEXT);
@@ -1064,8 +1042,8 @@ static int lbs_set_mode(struct net_device *dev,
1064 goto out; 1042 goto out;
1065 } 1043 }
1066 1044
1067 mutex_lock(&adapter->lock); 1045 mutex_lock(&priv->lock);
1068 assoc_req = lbs_get_association_request(adapter); 1046 assoc_req = lbs_get_association_request(priv);
1069 if (!assoc_req) { 1047 if (!assoc_req) {
1070 ret = -ENOMEM; 1048 ret = -ENOMEM;
1071 lbs_cancel_association_work(priv); 1049 lbs_cancel_association_work(priv);
@@ -1075,7 +1053,7 @@ static int lbs_set_mode(struct net_device *dev,
1075 lbs_postpone_association_work(priv); 1053 lbs_postpone_association_work(priv);
1076 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq); 1054 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
1077 } 1055 }
1078 mutex_unlock(&adapter->lock); 1056 mutex_unlock(&priv->lock);
1079 1057
1080out: 1058out:
1081 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1059 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -1097,18 +1075,17 @@ static int lbs_get_encode(struct net_device *dev,
1097 struct iw_point *dwrq, u8 * extra) 1075 struct iw_point *dwrq, u8 * extra)
1098{ 1076{
1099 struct lbs_private *priv = dev->priv; 1077 struct lbs_private *priv = dev->priv;
1100 struct lbs_adapter *adapter = priv->adapter;
1101 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1078 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1102 1079
1103 lbs_deb_enter(LBS_DEB_WEXT); 1080 lbs_deb_enter(LBS_DEB_WEXT);
1104 1081
1105 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n", 1082 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
1106 dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx); 1083 dwrq->flags, index, dwrq->length, priv->wep_tx_keyidx);
1107 1084
1108 dwrq->flags = 0; 1085 dwrq->flags = 0;
1109 1086
1110 /* Authentication method */ 1087 /* Authentication method */
1111 switch (adapter->secinfo.auth_mode) { 1088 switch (priv->secinfo.auth_mode) {
1112 case IW_AUTH_ALG_OPEN_SYSTEM: 1089 case IW_AUTH_ALG_OPEN_SYSTEM:
1113 dwrq->flags = IW_ENCODE_OPEN; 1090 dwrq->flags = IW_ENCODE_OPEN;
1114 break; 1091 break;
@@ -1124,22 +1101,22 @@ static int lbs_get_encode(struct net_device *dev,
1124 1101
1125 memset(extra, 0, 16); 1102 memset(extra, 0, 16);
1126 1103
1127 mutex_lock(&adapter->lock); 1104 mutex_lock(&priv->lock);
1128 1105
1129 /* Default to returning current transmit key */ 1106 /* Default to returning current transmit key */
1130 if (index < 0) 1107 if (index < 0)
1131 index = adapter->wep_tx_keyidx; 1108 index = priv->wep_tx_keyidx;
1132 1109
1133 if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) { 1110 if ((priv->wep_keys[index].len) && priv->secinfo.wep_enabled) {
1134 memcpy(extra, adapter->wep_keys[index].key, 1111 memcpy(extra, priv->wep_keys[index].key,
1135 adapter->wep_keys[index].len); 1112 priv->wep_keys[index].len);
1136 dwrq->length = adapter->wep_keys[index].len; 1113 dwrq->length = priv->wep_keys[index].len;
1137 1114
1138 dwrq->flags |= (index + 1); 1115 dwrq->flags |= (index + 1);
1139 /* Return WEP enabled */ 1116 /* Return WEP enabled */
1140 dwrq->flags &= ~IW_ENCODE_DISABLED; 1117 dwrq->flags &= ~IW_ENCODE_DISABLED;
1141 } else if ((adapter->secinfo.WPAenabled) 1118 } else if ((priv->secinfo.WPAenabled)
1142 || (adapter->secinfo.WPA2enabled)) { 1119 || (priv->secinfo.WPA2enabled)) {
1143 /* return WPA enabled */ 1120 /* return WPA enabled */
1144 dwrq->flags &= ~IW_ENCODE_DISABLED; 1121 dwrq->flags &= ~IW_ENCODE_DISABLED;
1145 dwrq->flags |= IW_ENCODE_NOKEY; 1122 dwrq->flags |= IW_ENCODE_NOKEY;
@@ -1147,7 +1124,7 @@ static int lbs_get_encode(struct net_device *dev,
1147 dwrq->flags |= IW_ENCODE_DISABLED; 1124 dwrq->flags |= IW_ENCODE_DISABLED;
1148 } 1125 }
1149 1126
1150 mutex_unlock(&adapter->lock); 1127 mutex_unlock(&priv->lock);
1151 1128
1152 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n", 1129 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
1153 extra[0], extra[1], extra[2], 1130 extra[0], extra[1], extra[2],
@@ -1293,14 +1270,13 @@ static int lbs_set_encode(struct net_device *dev,
1293{ 1270{
1294 int ret = 0; 1271 int ret = 0;
1295 struct lbs_private *priv = dev->priv; 1272 struct lbs_private *priv = dev->priv;
1296 struct lbs_adapter *adapter = priv->adapter;
1297 struct assoc_request * assoc_req; 1273 struct assoc_request * assoc_req;
1298 u16 is_default = 0, index = 0, set_tx_key = 0; 1274 u16 is_default = 0, index = 0, set_tx_key = 0;
1299 1275
1300 lbs_deb_enter(LBS_DEB_WEXT); 1276 lbs_deb_enter(LBS_DEB_WEXT);
1301 1277
1302 mutex_lock(&adapter->lock); 1278 mutex_lock(&priv->lock);
1303 assoc_req = lbs_get_association_request(adapter); 1279 assoc_req = lbs_get_association_request(priv);
1304 if (!assoc_req) { 1280 if (!assoc_req) {
1305 ret = -ENOMEM; 1281 ret = -ENOMEM;
1306 goto out; 1282 goto out;
@@ -1348,7 +1324,7 @@ out:
1348 } else { 1324 } else {
1349 lbs_cancel_association_work(priv); 1325 lbs_cancel_association_work(priv);
1350 } 1326 }
1351 mutex_unlock(&adapter->lock); 1327 mutex_unlock(&priv->lock);
1352 1328
1353 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1329 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1354 return ret; 1330 return ret;
@@ -1370,7 +1346,6 @@ static int lbs_get_encodeext(struct net_device *dev,
1370{ 1346{
1371 int ret = -EINVAL; 1347 int ret = -EINVAL;
1372 struct lbs_private *priv = dev->priv; 1348 struct lbs_private *priv = dev->priv;
1373 struct lbs_adapter *adapter = priv->adapter;
1374 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1349 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1375 int index, max_key_len; 1350 int index, max_key_len;
1376 1351
@@ -1386,46 +1361,46 @@ static int lbs_get_encodeext(struct net_device *dev,
1386 goto out; 1361 goto out;
1387 index--; 1362 index--;
1388 } else { 1363 } else {
1389 index = adapter->wep_tx_keyidx; 1364 index = priv->wep_tx_keyidx;
1390 } 1365 }
1391 1366
1392 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) && 1367 if (!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) &&
1393 ext->alg != IW_ENCODE_ALG_WEP) { 1368 ext->alg != IW_ENCODE_ALG_WEP) {
1394 if (index != 0 || adapter->mode != IW_MODE_INFRA) 1369 if (index != 0 || priv->mode != IW_MODE_INFRA)
1395 goto out; 1370 goto out;
1396 } 1371 }
1397 1372
1398 dwrq->flags = index + 1; 1373 dwrq->flags = index + 1;
1399 memset(ext, 0, sizeof(*ext)); 1374 memset(ext, 0, sizeof(*ext));
1400 1375
1401 if ( !adapter->secinfo.wep_enabled 1376 if ( !priv->secinfo.wep_enabled
1402 && !adapter->secinfo.WPAenabled 1377 && !priv->secinfo.WPAenabled
1403 && !adapter->secinfo.WPA2enabled) { 1378 && !priv->secinfo.WPA2enabled) {
1404 ext->alg = IW_ENCODE_ALG_NONE; 1379 ext->alg = IW_ENCODE_ALG_NONE;
1405 ext->key_len = 0; 1380 ext->key_len = 0;
1406 dwrq->flags |= IW_ENCODE_DISABLED; 1381 dwrq->flags |= IW_ENCODE_DISABLED;
1407 } else { 1382 } else {
1408 u8 *key = NULL; 1383 u8 *key = NULL;
1409 1384
1410 if ( adapter->secinfo.wep_enabled 1385 if ( priv->secinfo.wep_enabled
1411 && !adapter->secinfo.WPAenabled 1386 && !priv->secinfo.WPAenabled
1412 && !adapter->secinfo.WPA2enabled) { 1387 && !priv->secinfo.WPA2enabled) {
1413 /* WEP */ 1388 /* WEP */
1414 ext->alg = IW_ENCODE_ALG_WEP; 1389 ext->alg = IW_ENCODE_ALG_WEP;
1415 ext->key_len = adapter->wep_keys[index].len; 1390 ext->key_len = priv->wep_keys[index].len;
1416 key = &adapter->wep_keys[index].key[0]; 1391 key = &priv->wep_keys[index].key[0];
1417 } else if ( !adapter->secinfo.wep_enabled 1392 } else if ( !priv->secinfo.wep_enabled
1418 && (adapter->secinfo.WPAenabled || 1393 && (priv->secinfo.WPAenabled ||
1419 adapter->secinfo.WPA2enabled)) { 1394 priv->secinfo.WPA2enabled)) {
1420 /* WPA */ 1395 /* WPA */
1421 struct enc_key * pkey = NULL; 1396 struct enc_key * pkey = NULL;
1422 1397
1423 if ( adapter->wpa_mcast_key.len 1398 if ( priv->wpa_mcast_key.len
1424 && (adapter->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED)) 1399 && (priv->wpa_mcast_key.flags & KEY_INFO_WPA_ENABLED))
1425 pkey = &adapter->wpa_mcast_key; 1400 pkey = &priv->wpa_mcast_key;
1426 else if ( adapter->wpa_unicast_key.len 1401 else if ( priv->wpa_unicast_key.len
1427 && (adapter->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED)) 1402 && (priv->wpa_unicast_key.flags & KEY_INFO_WPA_ENABLED))
1428 pkey = &adapter->wpa_unicast_key; 1403 pkey = &priv->wpa_unicast_key;
1429 1404
1430 if (pkey) { 1405 if (pkey) {
1431 if (pkey->type == KEY_TYPE_ID_AES) { 1406 if (pkey->type == KEY_TYPE_ID_AES) {
@@ -1477,15 +1452,14 @@ static int lbs_set_encodeext(struct net_device *dev,
1477{ 1452{
1478 int ret = 0; 1453 int ret = 0;
1479 struct lbs_private *priv = dev->priv; 1454 struct lbs_private *priv = dev->priv;
1480 struct lbs_adapter *adapter = priv->adapter;
1481 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1455 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1482 int alg = ext->alg; 1456 int alg = ext->alg;
1483 struct assoc_request * assoc_req; 1457 struct assoc_request * assoc_req;
1484 1458
1485 lbs_deb_enter(LBS_DEB_WEXT); 1459 lbs_deb_enter(LBS_DEB_WEXT);
1486 1460
1487 mutex_lock(&adapter->lock); 1461 mutex_lock(&priv->lock);
1488 assoc_req = lbs_get_association_request(adapter); 1462 assoc_req = lbs_get_association_request(priv);
1489 if (!assoc_req) { 1463 if (!assoc_req) {
1490 ret = -ENOMEM; 1464 ret = -ENOMEM;
1491 goto out; 1465 goto out;
@@ -1589,7 +1563,7 @@ out:
1589 } else { 1563 } else {
1590 lbs_cancel_association_work(priv); 1564 lbs_cancel_association_work(priv);
1591 } 1565 }
1592 mutex_unlock(&adapter->lock); 1566 mutex_unlock(&priv->lock);
1593 1567
1594 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1568 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1595 return ret; 1569 return ret;
@@ -1602,14 +1576,13 @@ static int lbs_set_genie(struct net_device *dev,
1602 char *extra) 1576 char *extra)
1603{ 1577{
1604 struct lbs_private *priv = dev->priv; 1578 struct lbs_private *priv = dev->priv;
1605 struct lbs_adapter *adapter = priv->adapter;
1606 int ret = 0; 1579 int ret = 0;
1607 struct assoc_request * assoc_req; 1580 struct assoc_request * assoc_req;
1608 1581
1609 lbs_deb_enter(LBS_DEB_WEXT); 1582 lbs_deb_enter(LBS_DEB_WEXT);
1610 1583
1611 mutex_lock(&adapter->lock); 1584 mutex_lock(&priv->lock);
1612 assoc_req = lbs_get_association_request(adapter); 1585 assoc_req = lbs_get_association_request(priv);
1613 if (!assoc_req) { 1586 if (!assoc_req) {
1614 ret = -ENOMEM; 1587 ret = -ENOMEM;
1615 goto out; 1588 goto out;
@@ -1625,7 +1598,7 @@ static int lbs_set_genie(struct net_device *dev,
1625 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length); 1598 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
1626 assoc_req->wpa_ie_len = dwrq->length; 1599 assoc_req->wpa_ie_len = dwrq->length;
1627 } else { 1600 } else {
1628 memset(&assoc_req->wpa_ie[0], 0, sizeof(adapter->wpa_ie)); 1601 memset(&assoc_req->wpa_ie[0], 0, sizeof(priv->wpa_ie));
1629 assoc_req->wpa_ie_len = 0; 1602 assoc_req->wpa_ie_len = 0;
1630 } 1603 }
1631 1604
@@ -1636,7 +1609,7 @@ out:
1636 } else { 1609 } else {
1637 lbs_cancel_association_work(priv); 1610 lbs_cancel_association_work(priv);
1638 } 1611 }
1639 mutex_unlock(&adapter->lock); 1612 mutex_unlock(&priv->lock);
1640 1613
1641 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1614 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1642 return ret; 1615 return ret;
@@ -1649,22 +1622,21 @@ static int lbs_get_genie(struct net_device *dev,
1649{ 1622{
1650 int ret = 0; 1623 int ret = 0;
1651 struct lbs_private *priv = dev->priv; 1624 struct lbs_private *priv = dev->priv;
1652 struct lbs_adapter *adapter = priv->adapter;
1653 1625
1654 lbs_deb_enter(LBS_DEB_WEXT); 1626 lbs_deb_enter(LBS_DEB_WEXT);
1655 1627
1656 if (adapter->wpa_ie_len == 0) { 1628 if (priv->wpa_ie_len == 0) {
1657 dwrq->length = 0; 1629 dwrq->length = 0;
1658 goto out; 1630 goto out;
1659 } 1631 }
1660 1632
1661 if (dwrq->length < adapter->wpa_ie_len) { 1633 if (dwrq->length < priv->wpa_ie_len) {
1662 ret = -E2BIG; 1634 ret = -E2BIG;
1663 goto out; 1635 goto out;
1664 } 1636 }
1665 1637
1666 dwrq->length = adapter->wpa_ie_len; 1638 dwrq->length = priv->wpa_ie_len;
1667 memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len); 1639 memcpy(extra, &priv->wpa_ie[0], priv->wpa_ie_len);
1668 1640
1669out: 1641out:
1670 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1642 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -1678,15 +1650,14 @@ static int lbs_set_auth(struct net_device *dev,
1678 char *extra) 1650 char *extra)
1679{ 1651{
1680 struct lbs_private *priv = dev->priv; 1652 struct lbs_private *priv = dev->priv;
1681 struct lbs_adapter *adapter = priv->adapter;
1682 struct assoc_request * assoc_req; 1653 struct assoc_request * assoc_req;
1683 int ret = 0; 1654 int ret = 0;
1684 int updated = 0; 1655 int updated = 0;
1685 1656
1686 lbs_deb_enter(LBS_DEB_WEXT); 1657 lbs_deb_enter(LBS_DEB_WEXT);
1687 1658
1688 mutex_lock(&adapter->lock); 1659 mutex_lock(&priv->lock);
1689 assoc_req = lbs_get_association_request(adapter); 1660 assoc_req = lbs_get_association_request(priv);
1690 if (!assoc_req) { 1661 if (!assoc_req) {
1691 ret = -ENOMEM; 1662 ret = -ENOMEM;
1692 goto out; 1663 goto out;
@@ -1765,7 +1736,7 @@ out:
1765 } else if (ret != -EOPNOTSUPP) { 1736 } else if (ret != -EOPNOTSUPP) {
1766 lbs_cancel_association_work(priv); 1737 lbs_cancel_association_work(priv);
1767 } 1738 }
1768 mutex_unlock(&adapter->lock); 1739 mutex_unlock(&priv->lock);
1769 1740
1770 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1741 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1771 return ret; 1742 return ret;
@@ -1778,27 +1749,26 @@ static int lbs_get_auth(struct net_device *dev,
1778{ 1749{
1779 int ret = 0; 1750 int ret = 0;
1780 struct lbs_private *priv = dev->priv; 1751 struct lbs_private *priv = dev->priv;
1781 struct lbs_adapter *adapter = priv->adapter;
1782 1752
1783 lbs_deb_enter(LBS_DEB_WEXT); 1753 lbs_deb_enter(LBS_DEB_WEXT);
1784 1754
1785 switch (dwrq->flags & IW_AUTH_INDEX) { 1755 switch (dwrq->flags & IW_AUTH_INDEX) {
1786 case IW_AUTH_WPA_VERSION: 1756 case IW_AUTH_WPA_VERSION:
1787 dwrq->value = 0; 1757 dwrq->value = 0;
1788 if (adapter->secinfo.WPAenabled) 1758 if (priv->secinfo.WPAenabled)
1789 dwrq->value |= IW_AUTH_WPA_VERSION_WPA; 1759 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
1790 if (adapter->secinfo.WPA2enabled) 1760 if (priv->secinfo.WPA2enabled)
1791 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2; 1761 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
1792 if (!dwrq->value) 1762 if (!dwrq->value)
1793 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED; 1763 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
1794 break; 1764 break;
1795 1765
1796 case IW_AUTH_80211_AUTH_ALG: 1766 case IW_AUTH_80211_AUTH_ALG:
1797 dwrq->value = adapter->secinfo.auth_mode; 1767 dwrq->value = priv->secinfo.auth_mode;
1798 break; 1768 break;
1799 1769
1800 case IW_AUTH_WPA_ENABLED: 1770 case IW_AUTH_WPA_ENABLED:
1801 if (adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled) 1771 if (priv->secinfo.WPAenabled && priv->secinfo.WPA2enabled)
1802 dwrq->value = 1; 1772 dwrq->value = 1;
1803 break; 1773 break;
1804 1774
@@ -1816,7 +1786,6 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1816{ 1786{
1817 int ret = 0; 1787 int ret = 0;
1818 struct lbs_private *priv = dev->priv; 1788 struct lbs_private *priv = dev->priv;
1819 struct lbs_adapter *adapter = priv->adapter;
1820 1789
1821 u16 dbm; 1790 u16 dbm;
1822 1791
@@ -1827,7 +1796,7 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1827 return 0; 1796 return 0;
1828 } 1797 }
1829 1798
1830 adapter->preamble = CMD_TYPE_AUTO_PREAMBLE; 1799 priv->preamble = CMD_TYPE_AUTO_PREAMBLE;
1831 1800
1832 lbs_radio_ioctl(priv, RADIO_ON); 1801 lbs_radio_ioctl(priv, RADIO_ON);
1833 1802
@@ -1858,7 +1827,6 @@ static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
1858 struct iw_point *dwrq, char *extra) 1827 struct iw_point *dwrq, char *extra)
1859{ 1828{
1860 struct lbs_private *priv = dev->priv; 1829 struct lbs_private *priv = dev->priv;
1861 struct lbs_adapter *adapter = priv->adapter;
1862 1830
1863 lbs_deb_enter(LBS_DEB_WEXT); 1831 lbs_deb_enter(LBS_DEB_WEXT);
1864 1832
@@ -1870,19 +1838,19 @@ static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
1870 /* 1838 /*
1871 * Get the current SSID 1839 * Get the current SSID
1872 */ 1840 */
1873 if (adapter->connect_status == LBS_CONNECTED) { 1841 if (priv->connect_status == LBS_CONNECTED) {
1874 memcpy(extra, adapter->curbssparams.ssid, 1842 memcpy(extra, priv->curbssparams.ssid,
1875 adapter->curbssparams.ssid_len); 1843 priv->curbssparams.ssid_len);
1876 extra[adapter->curbssparams.ssid_len] = '\0'; 1844 extra[priv->curbssparams.ssid_len] = '\0';
1877 } else { 1845 } else {
1878 memset(extra, 0, 32); 1846 memset(extra, 0, 32);
1879 extra[adapter->curbssparams.ssid_len] = '\0'; 1847 extra[priv->curbssparams.ssid_len] = '\0';
1880 } 1848 }
1881 /* 1849 /*
1882 * If none, we may want to get the one that was set 1850 * If none, we may want to get the one that was set
1883 */ 1851 */
1884 1852
1885 dwrq->length = adapter->curbssparams.ssid_len; 1853 dwrq->length = priv->curbssparams.ssid_len;
1886 1854
1887 dwrq->flags = 1; /* active */ 1855 dwrq->flags = 1; /* active */
1888 1856
@@ -1894,7 +1862,6 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
1894 struct iw_point *dwrq, char *extra) 1862 struct iw_point *dwrq, char *extra)
1895{ 1863{
1896 struct lbs_private *priv = dev->priv; 1864 struct lbs_private *priv = dev->priv;
1897 struct lbs_adapter *adapter = priv->adapter;
1898 int ret = 0; 1865 int ret = 0;
1899 u8 ssid[IW_ESSID_MAX_SIZE]; 1866 u8 ssid[IW_ESSID_MAX_SIZE];
1900 u8 ssid_len = 0; 1867 u8 ssid_len = 0;
@@ -1927,10 +1894,10 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
1927 } 1894 }
1928 1895
1929out: 1896out:
1930 mutex_lock(&adapter->lock); 1897 mutex_lock(&priv->lock);
1931 if (ret == 0) { 1898 if (ret == 0) {
1932 /* Get or create the current association request */ 1899 /* Get or create the current association request */
1933 assoc_req = lbs_get_association_request(adapter); 1900 assoc_req = lbs_get_association_request(priv);
1934 if (!assoc_req) { 1901 if (!assoc_req) {
1935 ret = -ENOMEM; 1902 ret = -ENOMEM;
1936 } else { 1903 } else {
@@ -1947,7 +1914,7 @@ out:
1947 lbs_cancel_association_work(priv); 1914 lbs_cancel_association_work(priv);
1948 } 1915 }
1949 1916
1950 mutex_unlock(&adapter->lock); 1917 mutex_unlock(&priv->lock);
1951 1918
1952 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1919 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1953 return ret; 1920 return ret;
@@ -1966,7 +1933,6 @@ static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
1966 struct sockaddr *awrq, char *extra) 1933 struct sockaddr *awrq, char *extra)
1967{ 1934{
1968 struct lbs_private *priv = dev->priv; 1935 struct lbs_private *priv = dev->priv;
1969 struct lbs_adapter *adapter = priv->adapter;
1970 struct assoc_request * assoc_req; 1936 struct assoc_request * assoc_req;
1971 int ret = 0; 1937 int ret = 0;
1972 DECLARE_MAC_BUF(mac); 1938 DECLARE_MAC_BUF(mac);
@@ -1978,10 +1944,10 @@ static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
1978 1944
1979 lbs_deb_wext("ASSOC: WAP: sa_data %s\n", print_mac(mac, awrq->sa_data)); 1945 lbs_deb_wext("ASSOC: WAP: sa_data %s\n", print_mac(mac, awrq->sa_data));
1980 1946
1981 mutex_lock(&adapter->lock); 1947 mutex_lock(&priv->lock);
1982 1948
1983 /* Get or create the current association request */ 1949 /* Get or create the current association request */
1984 assoc_req = lbs_get_association_request(adapter); 1950 assoc_req = lbs_get_association_request(priv);
1985 if (!assoc_req) { 1951 if (!assoc_req) {
1986 lbs_cancel_association_work(priv); 1952 lbs_cancel_association_work(priv);
1987 ret = -ENOMEM; 1953 ret = -ENOMEM;
@@ -1992,30 +1958,30 @@ static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
1992 lbs_postpone_association_work(priv); 1958 lbs_postpone_association_work(priv);
1993 } 1959 }
1994 1960
1995 mutex_unlock(&adapter->lock); 1961 mutex_unlock(&priv->lock);
1996 1962
1997 return ret; 1963 return ret;
1998} 1964}
1999 1965
2000void lbs_get_fwversion(struct lbs_adapter *adapter, char *fwversion, int maxlen) 1966void lbs_get_fwversion(struct lbs_private *priv, char *fwversion, int maxlen)
2001{ 1967{
2002 char fwver[32]; 1968 char fwver[32];
2003 1969
2004 mutex_lock(&adapter->lock); 1970 mutex_lock(&priv->lock);
2005 1971
2006 if (adapter->fwreleasenumber[3] == 0) 1972 if (priv->fwreleasenumber[3] == 0)
2007 sprintf(fwver, "%u.%u.%u", 1973 sprintf(fwver, "%u.%u.%u",
2008 adapter->fwreleasenumber[2], 1974 priv->fwreleasenumber[2],
2009 adapter->fwreleasenumber[1], 1975 priv->fwreleasenumber[1],
2010 adapter->fwreleasenumber[0]); 1976 priv->fwreleasenumber[0]);
2011 else 1977 else
2012 sprintf(fwver, "%u.%u.%u.p%u", 1978 sprintf(fwver, "%u.%u.%u.p%u",
2013 adapter->fwreleasenumber[2], 1979 priv->fwreleasenumber[2],
2014 adapter->fwreleasenumber[1], 1980 priv->fwreleasenumber[1],
2015 adapter->fwreleasenumber[0], 1981 priv->fwreleasenumber[0],
2016 adapter->fwreleasenumber[3]); 1982 priv->fwreleasenumber[3]);
2017 1983
2018 mutex_unlock(&adapter->lock); 1984 mutex_unlock(&priv->lock);
2019 snprintf(fwversion, maxlen, fwver); 1985 snprintf(fwversion, maxlen, fwver);
2020} 1986}
2021 1987