aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmd.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-08 15:04:36 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:19 -0500
commitaa21c004f80bdf943736c62dccf0c0398d7824f3 (patch)
tree6815328775d3b5ec46bb342c4c256cde0f223863 /drivers/net/wireless/libertas/cmd.c
parentf86a93e1b2d05a7a38a48c91f8fb8fc7e8f1c734 (diff)
libertas: kill struct lbs_adapter
There seems to be no reason for a separate structure; move it all into struct lbs_private. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r--drivers/net/wireless/libertas/cmd.c278
1 files changed, 129 insertions, 149 deletions
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);