aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r--drivers/net/wireless/mwifiex/11n.c13
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.c2
-rw-r--r--drivers/net/wireless/mwifiex/README2
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c113
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c179
-rw-r--r--drivers/net/wireless/mwifiex/debugfs.c4
-rw-r--r--drivers/net/wireless/mwifiex/decl.h24
-rw-r--r--drivers/net/wireless/mwifiex/init.c3
-rw-r--r--drivers/net/wireless/mwifiex/join.c90
-rw-r--r--drivers/net/wireless/mwifiex/main.c71
-rw-r--r--drivers/net/wireless/mwifiex/main.h123
-rw-r--r--drivers/net/wireless/mwifiex/scan.c126
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c11
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c60
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmdresp.c29
-rw-r--r--drivers/net/wireless/mwifiex/sta_event.c25
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c1008
-rw-r--r--drivers/net/wireless/mwifiex/sta_tx.c2
-rw-r--r--drivers/net/wireless/mwifiex/util.c51
19 files changed, 502 insertions, 1434 deletions
diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
index 73a6e62f5680..edf4c274fa9b 100644
--- a/drivers/net/wireless/mwifiex/11n.c
+++ b/drivers/net/wireless/mwifiex/11n.c
@@ -541,9 +541,8 @@ mwifiex_cfg_tx_buf(struct mwifiex_private *priv,
541 else if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_8K) 541 else if (priv->adapter->curr_tx_buf_size <= MWIFIEX_TX_DATA_BUF_SIZE_8K)
542 curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_8K; 542 curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_8K;
543 if (curr_tx_buf_size != tx_buf) 543 if (curr_tx_buf_size != tx_buf)
544 mwifiex_prepare_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF, 544 mwifiex_send_cmd_async(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF,
545 HostCmd_ACT_GEN_SET, 0, 545 HostCmd_ACT_GEN_SET, 0, &tx_buf);
546 NULL, &tx_buf);
547 546
548 return; 547 return;
549} 548}
@@ -694,8 +693,8 @@ int mwifiex_send_addba(struct mwifiex_private *priv, int tid, u8 *peer_mac)
694 memcpy(&add_ba_req.peer_mac_addr, peer_mac, ETH_ALEN); 693 memcpy(&add_ba_req.peer_mac_addr, peer_mac, ETH_ALEN);
695 694
696 /* We don't wait for the response of this command */ 695 /* We don't wait for the response of this command */
697 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_11N_ADDBA_REQ, 696 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_ADDBA_REQ,
698 0, 0, NULL, &add_ba_req); 697 0, 0, &add_ba_req);
699 698
700 return ret; 699 return ret;
701} 700}
@@ -722,8 +721,8 @@ int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
722 memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN); 721 memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN);
723 722
724 /* We don't wait for the response of this command */ 723 /* We don't wait for the response of this command */
725 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_11N_DELBA, 724 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_DELBA,
726 HostCmd_ACT_GEN_SET, 0, NULL, &delba); 725 HostCmd_ACT_GEN_SET, 0, &delba);
727 726
728 return ret; 727 return ret;
729} 728}
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c
index 8e94e620e6f4..ef46d0a8a6d0 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c
@@ -609,7 +609,7 @@ void mwifiex_11n_ba_stream_timeout(struct mwifiex_private *priv,
609 delba.del_ba_param_set |= cpu_to_le16( 609 delba.del_ba_param_set |= cpu_to_le16(
610 (u16) event->origninator << DELBA_INITIATOR_POS); 610 (u16) event->origninator << DELBA_INITIATOR_POS);
611 delba.reason_code = cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT); 611 delba.reason_code = cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT);
612 mwifiex_prepare_cmd(priv, HostCmd_CMD_11N_DELBA, 0, 0, NULL, &delba); 612 mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_DELBA, 0, 0, &delba);
613 613
614 return; 614 return;
615} 615}
diff --git a/drivers/net/wireless/mwifiex/README b/drivers/net/wireless/mwifiex/README
index 338377f7093b..b55badef4660 100644
--- a/drivers/net/wireless/mwifiex/README
+++ b/drivers/net/wireless/mwifiex/README
@@ -157,7 +157,7 @@ info
157 mp_wr_bitmap = <SDIO multi-port write bitmap> 157 mp_wr_bitmap = <SDIO multi-port write bitmap>
158 cmd_resp_received = <0/1, no cmd response to process/response received and yet to process> 158 cmd_resp_received = <0/1, no cmd response to process/response received and yet to process>
159 event_received = <0/1, no event to process/event received and yet to process> 159 event_received = <0/1, no event to process/event received and yet to process>
160 ioctl_pending = <number of ioctl pending> 160 cmd_pending = <number of cmd pending>
161 tx_pending = <number of Tx packet pending> 161 tx_pending = <number of Tx packet pending>
162 rx_pending = <number of Rx packet pending> 162 rx_pending = <number of Rx packet pending>
163 163
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index ec0895f4e8d3..a1ff490da836 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -139,8 +139,16 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy,
139{ 139{
140 int ret = 0; 140 int ret = 0;
141 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 141 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
142 struct mwifiex_power_cfg power_cfg;
142 143
143 ret = mwifiex_set_tx_power(priv, type, dbm); 144 if (type == NL80211_TX_POWER_FIXED) {
145 power_cfg.is_power_auto = 0;
146 power_cfg.power_level = dbm;
147 } else {
148 power_cfg.is_power_auto = 1;
149 }
150
151 ret = mwifiex_set_tx_power(priv, &power_cfg);
144 152
145 return ret; 153 return ret;
146} 154}
@@ -157,13 +165,15 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
157{ 165{
158 int ret = 0; 166 int ret = 0;
159 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); 167 struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
168 u32 ps_mode;
160 169
161 if (timeout) 170 if (timeout)
162 wiphy_dbg(wiphy, 171 wiphy_dbg(wiphy,
163 "info: ignoring the timeout value" 172 "info: ignoring the timeout value"
164 " for IEEE power save\n"); 173 " for IEEE power save\n");
165 174
166 ret = mwifiex_drv_set_power(priv, enabled); 175 ps_mode = enabled;
176 ret = mwifiex_drv_set_power(priv, &ps_mode);
167 177
168 return ret; 178 return ret;
169} 179}
@@ -291,8 +301,8 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy)
291 301
292 domain_info->no_of_triplet = no_of_triplet; 302 domain_info->no_of_triplet = no_of_triplet;
293 /* Send cmd to FW to set domain info */ 303 /* Send cmd to FW to set domain info */
294 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11D_DOMAIN_INFO, 304 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
295 HostCmd_ACT_GEN_SET, 0, NULL, NULL); 305 HostCmd_ACT_GEN_SET, 0, NULL);
296 if (ret) 306 if (ret)
297 wiphy_err(wiphy, "11D: setting domain info in FW\n"); 307 wiphy_err(wiphy, "11D: setting domain info in FW\n");
298 308
@@ -347,7 +357,6 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
347{ 357{
348 struct mwifiex_chan_freq_power cfp; 358 struct mwifiex_chan_freq_power cfp;
349 int ret = 0; 359 int ret = 0;
350 int status = 0;
351 struct mwifiex_ds_band_cfg band_cfg; 360 struct mwifiex_ds_band_cfg band_cfg;
352 u32 config_bands = 0; 361 u32 config_bands = 0;
353 struct wiphy *wiphy = priv->wdev->wiphy; 362 struct wiphy *wiphy = priv->wdev->wiphy;
@@ -370,10 +379,9 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
370 band_cfg.sec_chan_offset = 379 band_cfg.sec_chan_offset =
371 mwifiex_cfg80211_channel_type_to_mwifiex_channels 380 mwifiex_cfg80211_channel_type_to_mwifiex_channels
372 (channel_type); 381 (channel_type);
373 status = mwifiex_radio_ioctl_band_cfg(priv, HostCmd_ACT_GEN_SET, 382 ret = mwifiex_set_radio_band_cfg(priv, &band_cfg);
374 &band_cfg);
375 383
376 if (status) 384 if (ret)
377 return -EFAULT; 385 return -EFAULT;
378 mwifiex_send_domain_info_cmd_fw(wiphy); 386 mwifiex_send_domain_info_cmd_fw(wiphy);
379 } 387 }
@@ -389,8 +397,8 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
389 /* Convert frequency to channel */ 397 /* Convert frequency to channel */
390 cfp.channel = ieee80211_frequency_to_channel(chan->center_freq); 398 cfp.channel = ieee80211_frequency_to_channel(chan->center_freq);
391 399
392 status = mwifiex_bss_ioctl_channel(priv, HostCmd_ACT_GEN_SET, &cfp); 400 ret = mwifiex_bss_set_channel(priv, &cfp);
393 if (status) 401 if (ret)
394 return -EFAULT; 402 return -EFAULT;
395 403
396 ret = mwifiex_drv_change_adhoc_chan(priv, cfp.channel); 404 ret = mwifiex_drv_change_adhoc_chan(priv, cfp.channel);
@@ -422,66 +430,45 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
422/* 430/*
423 * This function sets the fragmentation threshold. 431 * This function sets the fragmentation threshold.
424 * 432 *
425 * This function creates an IOCTL request, populates it accordingly 433 * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE
426 * and issues an IOCTL.
427 *
428 * The fragmentation threshold value must lies between MWIFIEX_FRAG_MIN_VALUE
429 * and MWIFIEX_FRAG_MAX_VALUE. 434 * and MWIFIEX_FRAG_MAX_VALUE.
430 */ 435 */
431static int 436static int
432mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr) 437mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr)
433{ 438{
434 int ret = 0; 439 int ret = 0;
435 int status = 0;
436 struct mwifiex_wait_queue *wait = NULL;
437 u8 wait_option = MWIFIEX_IOCTL_WAIT;
438 440
439 if (frag_thr < MWIFIEX_FRAG_MIN_VALUE 441 if (frag_thr < MWIFIEX_FRAG_MIN_VALUE
440 || frag_thr > MWIFIEX_FRAG_MAX_VALUE) 442 || frag_thr > MWIFIEX_FRAG_MAX_VALUE)
441 return -EINVAL; 443 return -EINVAL;
442 444
443 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option); 445 /* Send request to firmware */
444 if (!wait) 446 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
445 return -ENOMEM; 447 HostCmd_ACT_GEN_SET, FRAG_THRESH_I,
448 &frag_thr);
446 449
447 status = mwifiex_snmp_mib_ioctl(priv, wait, FRAG_THRESH_I,
448 HostCmd_ACT_GEN_SET, &frag_thr);
449
450 if (mwifiex_request_ioctl(priv, wait, status, wait_option))
451 ret = -EFAULT;
452
453 kfree(wait);
454 return ret; 450 return ret;
455} 451}
456 452
457/* 453/*
458 * This function sets the RTS threshold. 454 * This function sets the RTS threshold.
459 * 455
460 * This function creates an IOCTL request, populates it accordingly 456 * The rts value must lie between MWIFIEX_RTS_MIN_VALUE
461 * and issues an IOCTL. 457 * and MWIFIEX_RTS_MAX_VALUE.
462 */ 458 */
463static int 459static int
464mwifiex_set_rts(struct mwifiex_private *priv, u32 rts_thr) 460mwifiex_set_rts(struct mwifiex_private *priv, u32 rts_thr)
465{ 461{
466 int ret = 0; 462 int ret = 0;
467 struct mwifiex_wait_queue *wait = NULL;
468 int status = 0;
469 u8 wait_option = MWIFIEX_IOCTL_WAIT;
470 463
471 if (rts_thr < MWIFIEX_RTS_MIN_VALUE || rts_thr > MWIFIEX_RTS_MAX_VALUE) 464 if (rts_thr < MWIFIEX_RTS_MIN_VALUE || rts_thr > MWIFIEX_RTS_MAX_VALUE)
472 rts_thr = MWIFIEX_RTS_MAX_VALUE; 465 rts_thr = MWIFIEX_RTS_MAX_VALUE;
473 466
474 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option); 467 /* Send request to firmware */
475 if (!wait) 468 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
476 return -ENOMEM; 469 HostCmd_ACT_GEN_SET, RTS_THRESH_I,
477 470 &rts_thr);
478 status = mwifiex_snmp_mib_ioctl(priv, wait, RTS_THRESH_I,
479 HostCmd_ACT_GEN_SET, &rts_thr);
480
481 if (mwifiex_request_ioctl(priv, wait, status, wait_option))
482 ret = -EFAULT;
483 471
484 kfree(wait);
485 return ret; 472 return ret;
486} 473}
487 474
@@ -518,7 +505,6 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
518{ 505{
519 int ret = 0; 506 int ret = 0;
520 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 507 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
521 struct mwifiex_wait_queue *wait = NULL;
522 508
523 if (priv->bss_mode == type) { 509 if (priv->bss_mode == type) {
524 wiphy_warn(wiphy, "already set to required type\n"); 510 wiphy_warn(wiphy, "already set to required type\n");
@@ -545,24 +531,13 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
545 return -EINVAL; 531 return -EINVAL;
546 } 532 }
547 533
548 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT); 534 mwifiex_deauthenticate(priv, NULL);
549 if (!wait)
550 return -ENOMEM;
551
552 mwifiex_deauthenticate(priv, wait, NULL);
553 535
554 priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM; 536 priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM;
555 537
556 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_SET_BSS_MODE, 538 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_SET_BSS_MODE,
557 HostCmd_ACT_GEN_SET, 0, wait, NULL); 539 HostCmd_ACT_GEN_SET, 0, NULL);
558 if (!ret)
559 ret = -EINPROGRESS;
560 540
561 ret = mwifiex_request_ioctl(priv, wait, ret, MWIFIEX_IOCTL_WAIT);
562 if (ret)
563 ret = -EFAULT;
564
565 kfree(wait);
566 return ret; 541 return ret;
567} 542}
568 543
@@ -592,7 +567,7 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
592 567
593 /* Get signal information from the firmware */ 568 /* Get signal information from the firmware */
594 memset(&signal, 0, sizeof(struct mwifiex_ds_get_signal)); 569 memset(&signal, 0, sizeof(struct mwifiex_ds_get_signal));
595 if (mwifiex_get_signal_info(priv, MWIFIEX_IOCTL_WAIT, &signal)) { 570 if (mwifiex_get_signal_info(priv, &signal)) {
596 dev_err(priv->adapter->dev, "getting signal information\n"); 571 dev_err(priv->adapter->dev, "getting signal information\n");
597 ret = -EFAULT; 572 ret = -EFAULT;
598 } 573 }
@@ -750,7 +725,7 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev,
750 return -EBUSY; 725 return -EBUSY;
751 726
752 priv->disconnect = 1; 727 priv->disconnect = 1;
753 if (mwifiex_disconnect(priv, MWIFIEX_IOCTL_WAIT, NULL)) 728 if (mwifiex_deauthenticate(priv, NULL))
754 return -EFAULT; 729 return -EFAULT;
755 730
756 wiphy_dbg(wiphy, "info: successfully disconnected from %pM:" 731 wiphy_dbg(wiphy, "info: successfully disconnected from %pM:"
@@ -838,8 +813,8 @@ static int mwifiex_inform_bss_from_scan_result(struct mwifiex_private *priv,
838 u8 element_id, element_len; 813 u8 element_id, element_len;
839 814
840 memset(&scan_resp, 0, sizeof(scan_resp)); 815 memset(&scan_resp, 0, sizeof(scan_resp));
841 if (mwifiex_get_scan_table(priv, MWIFIEX_IOCTL_WAIT, &scan_resp)) 816 scan_resp.scan_table = (u8 *) priv->adapter->scan_table;
842 return -EFAULT; 817 scan_resp.num_in_scan_table = priv->adapter->num_in_scan_table;
843 818
844#define MAX_IE_BUF 2048 819#define MAX_IE_BUF 2048
845 ie_buf = kzalloc(MAX_IE_BUF, GFP_KERNEL); 820 ie_buf = kzalloc(MAX_IE_BUF, GFP_KERNEL);
@@ -986,7 +961,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
986 } 961 }
987 962
988 /* disconnect before try to associate */ 963 /* disconnect before try to associate */
989 mwifiex_disconnect(priv, MWIFIEX_IOCTL_WAIT, NULL); 964 mwifiex_deauthenticate(priv, NULL);
990 965
991 if (channel) 966 if (channel)
992 ret = mwifiex_set_rf_channel(priv, channel, 967 ret = mwifiex_set_rf_channel(priv, channel,
@@ -1046,7 +1021,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1046 } 1021 }
1047done: 1022done:
1048 /* Do specific SSID scanning */ 1023 /* Do specific SSID scanning */
1049 if (mwifiex_request_scan(priv, MWIFIEX_IOCTL_WAIT, &req_ssid)) { 1024 if (mwifiex_request_scan(priv, &req_ssid)) {
1050 dev_err(priv->adapter->dev, "scan error\n"); 1025 dev_err(priv->adapter->dev, "scan error\n");
1051 return -EFAULT; 1026 return -EFAULT;
1052 } 1027 }
@@ -1055,8 +1030,7 @@ done:
1055 memcpy(&ssid_bssid.ssid, &req_ssid, sizeof(struct mwifiex_802_11_ssid)); 1030 memcpy(&ssid_bssid.ssid, &req_ssid, sizeof(struct mwifiex_802_11_ssid));
1056 1031
1057 if (mode != NL80211_IFTYPE_ADHOC) { 1032 if (mode != NL80211_IFTYPE_ADHOC) {
1058 if (mwifiex_find_best_bss(priv, MWIFIEX_IOCTL_WAIT, 1033 if (mwifiex_find_best_bss(priv, &ssid_bssid))
1059 &ssid_bssid))
1060 return -EFAULT; 1034 return -EFAULT;
1061 /* Inform the BSS information to kernel, otherwise 1035 /* Inform the BSS information to kernel, otherwise
1062 * kernel will give a panic after successful assoc */ 1036 * kernel will give a panic after successful assoc */
@@ -1072,7 +1046,10 @@ done:
1072 /* Connect to BSS by ESSID */ 1046 /* Connect to BSS by ESSID */
1073 memset(&ssid_bssid.bssid, 0, ETH_ALEN); 1047 memset(&ssid_bssid.bssid, 0, ETH_ALEN);
1074 1048
1075 if (mwifiex_bss_start(priv, MWIFIEX_IOCTL_WAIT, &ssid_bssid)) 1049 if (!netif_queue_stopped(priv->netdev))
1050 netif_stop_queue(priv->netdev);
1051
1052 if (mwifiex_bss_start(priv, &ssid_bssid))
1076 return -EFAULT; 1053 return -EFAULT;
1077 1054
1078 if (mode == NL80211_IFTYPE_ADHOC) { 1055 if (mode == NL80211_IFTYPE_ADHOC) {
@@ -1176,7 +1153,7 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
1176 1153
1177 wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", 1154 wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n",
1178 priv->cfg_bssid); 1155 priv->cfg_bssid);
1179 if (mwifiex_disconnect(priv, MWIFIEX_IOCTL_WAIT, NULL)) 1156 if (mwifiex_deauthenticate(priv, NULL))
1180 return -EFAULT; 1157 return -EFAULT;
1181 1158
1182 queue_work(priv->workqueue, &priv->cfg_workqueue); 1159 queue_work(priv->workqueue, &priv->cfg_workqueue);
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 8676480ead94..bb6fecd77619 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -36,11 +36,12 @@
36static void 36static void
37mwifiex_init_cmd_node(struct mwifiex_private *priv, 37mwifiex_init_cmd_node(struct mwifiex_private *priv,
38 struct cmd_ctrl_node *cmd_node, 38 struct cmd_ctrl_node *cmd_node,
39 u32 cmd_oid, void *wait_queue, void *data_buf) 39 u32 cmd_oid, void *data_buf)
40{ 40{
41 cmd_node->priv = priv; 41 cmd_node->priv = priv;
42 cmd_node->cmd_oid = cmd_oid; 42 cmd_node->cmd_oid = cmd_oid;
43 cmd_node->wq_buf = wait_queue; 43 cmd_node->wait_q_enabled = priv->adapter->cmd_wait_q_required;
44 priv->adapter->cmd_wait_q_required = false;
44 cmd_node->data_buf = data_buf; 45 cmd_node->data_buf = data_buf;
45 cmd_node->cmd_skb = cmd_node->skb; 46 cmd_node->cmd_skb = cmd_node->skb;
46} 47}
@@ -86,8 +87,8 @@ mwifiex_clean_cmd_node(struct mwifiex_adapter *adapter,
86{ 87{
87 cmd_node->cmd_oid = 0; 88 cmd_node->cmd_oid = 0;
88 cmd_node->cmd_flag = 0; 89 cmd_node->cmd_flag = 0;
89 cmd_node->wq_buf = NULL;
90 cmd_node->data_buf = NULL; 90 cmd_node->data_buf = NULL;
91 cmd_node->wait_q_enabled = false;
91 92
92 if (cmd_node->resp_skb) { 93 if (cmd_node->resp_skb) {
93 mwifiex_recv_complete(adapter, cmd_node->resp_skb, 0); 94 mwifiex_recv_complete(adapter, cmd_node->resp_skb, 0);
@@ -98,30 +99,6 @@ mwifiex_clean_cmd_node(struct mwifiex_adapter *adapter,
98} 99}
99 100
100/* 101/*
101 * This function returns a command node from the pending queue which
102 * matches the given IOCTL request.
103 */
104static struct cmd_ctrl_node *
105mwifiex_get_pending_ioctl_cmd(struct mwifiex_adapter *adapter,
106 struct mwifiex_wait_queue *wait_queue)
107{
108 unsigned long flags;
109 struct cmd_ctrl_node *cmd_node;
110
111 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
112 list_for_each_entry(cmd_node, &adapter->cmd_pending_q, list) {
113 if (cmd_node->wq_buf == wait_queue) {
114 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
115 flags);
116 return cmd_node;
117 }
118 }
119 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
120
121 return NULL;
122}
123
124/*
125 * This function sends a host command to the firmware. 102 * This function sends a host command to the firmware.
126 * 103 *
127 * The function copies the host command into the driver command 104 * The function copies the host command into the driver command
@@ -155,7 +132,6 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
155 struct mwifiex_adapter *adapter = priv->adapter; 132 struct mwifiex_adapter *adapter = priv->adapter;
156 int ret = 0; 133 int ret = 0;
157 struct host_cmd_ds_command *host_cmd; 134 struct host_cmd_ds_command *host_cmd;
158 struct mwifiex_wait_queue *wait_queue = NULL;
159 uint16_t cmd_code; 135 uint16_t cmd_code;
160 uint16_t cmd_size; 136 uint16_t cmd_size;
161 struct timeval tstamp; 137 struct timeval tstamp;
@@ -165,15 +141,13 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
165 return -1; 141 return -1;
166 142
167 host_cmd = (struct host_cmd_ds_command *) (cmd_node->cmd_skb->data); 143 host_cmd = (struct host_cmd_ds_command *) (cmd_node->cmd_skb->data);
168 if (cmd_node->wq_buf)
169 wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf;
170 144
171 /* Sanity test */ 145 /* Sanity test */
172 if (host_cmd == NULL || host_cmd->size == 0) { 146 if (host_cmd == NULL || host_cmd->size == 0) {
173 dev_err(adapter->dev, "DNLD_CMD: host_cmd is null" 147 dev_err(adapter->dev, "DNLD_CMD: host_cmd is null"
174 " or cmd size is 0, not sending\n"); 148 " or cmd size is 0, not sending\n");
175 if (wait_queue) 149 if (cmd_node->wait_q_enabled)
176 wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL; 150 adapter->cmd_wait_q.status = -1;
177 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 151 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
178 return -1; 152 return -1;
179 } 153 }
@@ -210,8 +184,8 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
210 184
211 if (ret == -1) { 185 if (ret == -1) {
212 dev_err(adapter->dev, "DNLD_CMD: host to card failed\n"); 186 dev_err(adapter->dev, "DNLD_CMD: host to card failed\n");
213 if (wait_queue) 187 if (cmd_node->wait_q_enabled)
214 wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL; 188 adapter->cmd_wait_q.status = -1;
215 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 189 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
216 190
217 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 191 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
@@ -437,7 +411,31 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
437} 411}
438 412
439/* 413/*
440 * This function prepares a command before sending it to the firmware. 414 * This function is used to send synchronous command to the firmware.
415 *
416 * it allocates a wait queue for the command and wait for the command
417 * response.
418 */
419int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
420 u16 cmd_action, u32 cmd_oid, void *data_buf)
421{
422 int ret = 0;
423 struct mwifiex_adapter *adapter = priv->adapter;
424
425 adapter->cmd_wait_q_required = true;
426 adapter->cmd_wait_q.condition = false;
427
428 ret = mwifiex_send_cmd_async(priv, cmd_no, cmd_action, cmd_oid,
429 data_buf);
430 if (!ret)
431 ret = mwifiex_wait_queue_complete(adapter);
432
433 return ret;
434}
435
436
437/*
438 * This function prepares a command and asynchronously send it to the firmware.
441 * 439 *
442 * Preparation includes - 440 * Preparation includes -
443 * - Sanity tests to make sure the card is still present or the FW 441 * - Sanity tests to make sure the card is still present or the FW
@@ -447,9 +445,8 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
447 * - Fill up the non-default parameters and buffer pointers 445 * - Fill up the non-default parameters and buffer pointers
448 * - Add the command to pending queue 446 * - Add the command to pending queue
449 */ 447 */
450int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, 448int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
451 u16 cmd_action, u32 cmd_oid, 449 u16 cmd_action, u32 cmd_oid, void *data_buf)
452 void *wait_queue, void *data_buf)
453{ 450{
454 int ret = 0; 451 int ret = 0;
455 struct mwifiex_adapter *adapter = priv->adapter; 452 struct mwifiex_adapter *adapter = priv->adapter;
@@ -487,7 +484,7 @@ int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
487 } 484 }
488 485
489 /* Initialize the command node */ 486 /* Initialize the command node */
490 mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, wait_queue, data_buf); 487 mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, data_buf);
491 488
492 if (!cmd_node->cmd_skb) { 489 if (!cmd_node->cmd_skb) {
493 dev_err(adapter->dev, "PREP_CMD: no free cmd buf\n"); 490 dev_err(adapter->dev, "PREP_CMD: no free cmd buf\n");
@@ -537,18 +534,13 @@ void
537mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 534mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
538 struct cmd_ctrl_node *cmd_node) 535 struct cmd_ctrl_node *cmd_node)
539{ 536{
540 struct mwifiex_wait_queue *wait_queue = NULL;
541 unsigned long flags; 537 unsigned long flags;
542 538
543 if (cmd_node == NULL) 539 if (cmd_node == NULL)
544 return; 540 return;
545 if (cmd_node->wq_buf) { 541
546 wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf; 542 if (cmd_node->wait_q_enabled)
547 if (wait_queue->status != MWIFIEX_ERROR_NO_ERROR) 543 mwifiex_complete_cmd(adapter);
548 mwifiex_ioctl_complete(adapter, wait_queue, -1);
549 else
550 mwifiex_ioctl_complete(adapter, wait_queue, 0);
551 }
552 /* Clean the node */ 544 /* Clean the node */
553 mwifiex_clean_cmd_node(adapter, cmd_node); 545 mwifiex_clean_cmd_node(adapter, cmd_node);
554 546
@@ -694,7 +686,6 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
694 uint16_t orig_cmdresp_no; 686 uint16_t orig_cmdresp_no;
695 uint16_t cmdresp_no; 687 uint16_t cmdresp_no;
696 uint16_t cmdresp_result; 688 uint16_t cmdresp_result;
697 struct mwifiex_wait_queue *wait_queue = NULL;
698 struct timeval tstamp; 689 struct timeval tstamp;
699 unsigned long flags; 690 unsigned long flags;
700 691
@@ -708,10 +699,6 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
708 return -1; 699 return -1;
709 } 700 }
710 701
711 if (adapter->curr_cmd->wq_buf)
712 wait_queue = (struct mwifiex_wait_queue *)
713 adapter->curr_cmd->wq_buf;
714
715 adapter->num_cmd_timeout = 0; 702 adapter->num_cmd_timeout = 0;
716 703
717 resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data; 704 resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data;
@@ -766,8 +753,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
766 753
767 if (!(orig_cmdresp_no & HostCmd_RET_BIT)) { 754 if (!(orig_cmdresp_no & HostCmd_RET_BIT)) {
768 dev_err(adapter->dev, "CMD_RESP: invalid cmd resp\n"); 755 dev_err(adapter->dev, "CMD_RESP: invalid cmd resp\n");
769 if (wait_queue) 756 if (adapter->curr_cmd->wait_q_enabled)
770 wait_queue->status = MWIFIEX_ERROR_FW_CMDRESP; 757 adapter->cmd_wait_q.status = -1;
771 758
772 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 759 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
773 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 760 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
@@ -783,8 +770,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
783 ret = mwifiex_ret_802_11_hs_cfg(priv, resp); 770 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
784 } else { 771 } else {
785 /* handle response */ 772 /* handle response */
786 ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp, 773 ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp);
787 wait_queue);
788 } 774 }
789 775
790 /* Check init command response */ 776 /* Check init command response */
@@ -799,10 +785,10 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
799 } 785 }
800 786
801 if (adapter->curr_cmd) { 787 if (adapter->curr_cmd) {
802 if (wait_queue && (!ret)) 788 if (adapter->curr_cmd->wait_q_enabled && (!ret))
803 wait_queue->status = MWIFIEX_ERROR_NO_ERROR; 789 adapter->cmd_wait_q.status = 0;
804 else if (wait_queue && (ret == -1)) 790 else if (adapter->curr_cmd->wait_q_enabled && (ret == -1))
805 wait_queue->status = MWIFIEX_ERROR_CMD_RESP_FAIL; 791 adapter->cmd_wait_q.status = -1;
806 792
807 /* Clean up and put current command back to cmd_free_q */ 793 /* Clean up and put current command back to cmd_free_q */
808 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 794 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
@@ -826,7 +812,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
826 struct mwifiex_adapter *adapter = 812 struct mwifiex_adapter *adapter =
827 (struct mwifiex_adapter *) function_context; 813 (struct mwifiex_adapter *) function_context;
828 struct cmd_ctrl_node *cmd_node = NULL; 814 struct cmd_ctrl_node *cmd_node = NULL;
829 struct mwifiex_wait_queue *wait_queue = NULL;
830 struct timeval tstamp; 815 struct timeval tstamp;
831 816
832 adapter->num_cmd_timeout++; 817 adapter->num_cmd_timeout++;
@@ -836,10 +821,8 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
836 return; 821 return;
837 } 822 }
838 cmd_node = adapter->curr_cmd; 823 cmd_node = adapter->curr_cmd;
839 if (cmd_node->wq_buf) { 824 if (cmd_node->wait_q_enabled)
840 wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf; 825 adapter->cmd_wait_q.status = -ETIMEDOUT;
841 wait_queue->status = MWIFIEX_ERROR_CMD_TIMEOUT;
842 }
843 826
844 if (cmd_node) { 827 if (cmd_node) {
845 adapter->dbg.timeout_cmd_id = 828 adapter->dbg.timeout_cmd_id =
@@ -903,18 +886,15 @@ void
903mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter) 886mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
904{ 887{
905 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 888 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
906 struct mwifiex_wait_queue *wait_queue = NULL;
907 unsigned long flags; 889 unsigned long flags;
908 890
909 /* Cancel current cmd */ 891 /* Cancel current cmd */
910 if ((adapter->curr_cmd) && (adapter->curr_cmd->wq_buf)) { 892 if ((adapter->curr_cmd) && (adapter->curr_cmd->wait_q_enabled)) {
911 wait_queue =
912 (struct mwifiex_wait_queue *) adapter->curr_cmd->wq_buf;
913 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 893 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
914 adapter->curr_cmd->wq_buf = NULL; 894 adapter->curr_cmd->wait_q_enabled = false;
915 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); 895 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
916 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 896 adapter->cmd_wait_q.status = -1;
917 mwifiex_ioctl_complete(adapter, wait_queue, -1); 897 mwifiex_complete_cmd(adapter);
918 } 898 }
919 /* Cancel all pending command */ 899 /* Cancel all pending command */
920 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); 900 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
@@ -923,12 +903,10 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
923 list_del(&cmd_node->list); 903 list_del(&cmd_node->list);
924 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); 904 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
925 905
926 if (cmd_node->wq_buf) { 906 if (cmd_node->wait_q_enabled) {
927 wait_queue = 907 adapter->cmd_wait_q.status = -1;
928 (struct mwifiex_wait_queue *) cmd_node->wq_buf; 908 mwifiex_complete_cmd(adapter);
929 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 909 cmd_node->wait_q_enabled = false;
930 mwifiex_ioctl_complete(adapter, wait_queue, -1);
931 cmd_node->wq_buf = NULL;
932 } 910 }
933 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 911 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
934 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); 912 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
@@ -942,7 +920,7 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
942 list_del(&cmd_node->list); 920 list_del(&cmd_node->list);
943 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 921 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
944 922
945 cmd_node->wq_buf = NULL; 923 cmd_node->wait_q_enabled = false;
946 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 924 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
947 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 925 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
948 } 926 }
@@ -964,8 +942,7 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
964 * are cancelled. 942 * are cancelled.
965 */ 943 */
966void 944void
967mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter, 945mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
968 struct mwifiex_wait_queue *wait_queue)
969{ 946{
970 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 947 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
971 unsigned long cmd_flags; 948 unsigned long cmd_flags;
@@ -974,45 +951,33 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
974 uint16_t cancel_scan_cmd = false; 951 uint16_t cancel_scan_cmd = false;
975 952
976 if ((adapter->curr_cmd) && 953 if ((adapter->curr_cmd) &&
977 (adapter->curr_cmd->wq_buf == wait_queue)) { 954 (adapter->curr_cmd->wait_q_enabled)) {
978 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags); 955 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
979 cmd_node = adapter->curr_cmd; 956 cmd_node = adapter->curr_cmd;
980 cmd_node->wq_buf = NULL; 957 cmd_node->wait_q_enabled = false;
981 cmd_node->cmd_flag |= CMD_F_CANCELED; 958 cmd_node->cmd_flag |= CMD_F_CANCELED;
982 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
983 }
984
985 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
986 while (1) {
987 cmd_node = mwifiex_get_pending_ioctl_cmd(adapter, wait_queue);
988 if (!cmd_node)
989 break;
990
991 spin_lock_irqsave(&adapter->cmd_pending_q_lock, 959 spin_lock_irqsave(&adapter->cmd_pending_q_lock,
992 cmd_pending_q_flags); 960 cmd_pending_q_flags);
993 list_del(&cmd_node->list); 961 list_del(&cmd_node->list);
994 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, 962 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
995 cmd_pending_q_flags); 963 cmd_pending_q_flags);
996
997 cmd_node->wq_buf = NULL;
998 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 964 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
965 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
999 } 966 }
1000 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 967
1001 /* Cancel all pending scan command */ 968 /* Cancel all pending scan command */
1002 spin_lock_irqsave(&adapter->scan_pending_q_lock, 969 spin_lock_irqsave(&adapter->scan_pending_q_lock,
1003 scan_pending_q_flags); 970 scan_pending_q_flags);
1004 list_for_each_entry_safe(cmd_node, tmp_node, 971 list_for_each_entry_safe(cmd_node, tmp_node,
1005 &adapter->scan_pending_q, list) { 972 &adapter->scan_pending_q, list) {
1006 if (cmd_node->wq_buf == wait_queue) { 973 list_del(&cmd_node->list);
1007 list_del(&cmd_node->list); 974 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1008 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 975 scan_pending_q_flags);
1009 scan_pending_q_flags); 976 cmd_node->wait_q_enabled = false;
1010 cmd_node->wq_buf = NULL; 977 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
1011 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 978 spin_lock_irqsave(&adapter->scan_pending_q_lock,
1012 spin_lock_irqsave(&adapter->scan_pending_q_lock, 979 scan_pending_q_flags);
1013 scan_pending_q_flags); 980 cancel_scan_cmd = true;
1014 cancel_scan_cmd = true;
1015 }
1016 } 981 }
1017 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 982 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1018 scan_pending_q_flags); 983 scan_pending_q_flags);
@@ -1022,8 +987,8 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
1022 adapter->scan_processing = false; 987 adapter->scan_processing = false;
1023 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 988 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
1024 } 989 }
1025 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 990 adapter->cmd_wait_q.status = -1;
1026 mwifiex_ioctl_complete(adapter, wait_queue, -1); 991 mwifiex_complete_cmd(adapter);
1027 992
1028 return; 993 return;
1029} 994}
diff --git a/drivers/net/wireless/mwifiex/debugfs.c b/drivers/net/wireless/mwifiex/debugfs.c
index 63b09692f27d..77d7c777ea66 100644
--- a/drivers/net/wireless/mwifiex/debugfs.c
+++ b/drivers/net/wireless/mwifiex/debugfs.c
@@ -129,8 +129,8 @@ static struct mwifiex_debug_data items[] = {
129 item_addr(event_received), 1}, 129 item_addr(event_received), 1},
130 130
131 /* variables defined in struct mwifiex_adapter */ 131 /* variables defined in struct mwifiex_adapter */
132 {"ioctl_pending", adapter_item_size(ioctl_pending), 132 {"cmd_pending", adapter_item_size(cmd_pending),
133 adapter_item_addr(ioctl_pending), 1}, 133 adapter_item_addr(cmd_pending), 1},
134 {"tx_pending", adapter_item_size(tx_pending), 134 {"tx_pending", adapter_item_size(tx_pending),
135 adapter_item_addr(tx_pending), 1}, 135 adapter_item_addr(tx_pending), 1},
136 {"rx_pending", adapter_item_size(rx_pending), 136 {"rx_pending", adapter_item_size(rx_pending),
diff --git a/drivers/net/wireless/mwifiex/decl.h b/drivers/net/wireless/mwifiex/decl.h
index c3c15f9e757e..8364b62c3298 100644
--- a/drivers/net/wireless/mwifiex/decl.h
+++ b/drivers/net/wireless/mwifiex/decl.h
@@ -61,23 +61,6 @@
61 61
62#define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0) 62#define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0)
63 63
64enum mwifiex_error_code {
65 MWIFIEX_ERROR_NO_ERROR = 0,
66 MWIFIEX_ERROR_FW_NOT_READY = 0x00000001,
67 MWIFIEX_ERROR_FW_BUSY,
68 MWIFIEX_ERROR_FW_CMDRESP,
69 MWIFIEX_ERROR_PKT_SIZE_INVALID = 0x80000001,
70 MWIFIEX_ERROR_PKT_TIMEOUT,
71 MWIFIEX_ERROR_CMD_INVALID,
72 MWIFIEX_ERROR_CMD_TIMEOUT,
73 MWIFIEX_ERROR_CMD_DNLD_FAIL,
74 MWIFIEX_ERROR_CMD_CANCEL,
75 MWIFIEX_ERROR_CMD_RESP_FAIL,
76 MWIFIEX_ERROR_ASSOC_FAIL,
77 MWIFIEX_ERROR_EVENT_UNKNOWN,
78 MWIFIEX_ERROR_INVALID_PARAMETER,
79};
80
81enum mwifiex_bss_type { 64enum mwifiex_bss_type {
82 MWIFIEX_BSS_TYPE_STA = 0, 65 MWIFIEX_BSS_TYPE_STA = 0,
83 MWIFIEX_BSS_TYPE_UAP = 1, 66 MWIFIEX_BSS_TYPE_UAP = 1,
@@ -112,12 +95,9 @@ struct mwifiex_802_11_ssid {
112}; 95};
113 96
114struct mwifiex_wait_queue { 97struct mwifiex_wait_queue {
115 u32 bss_index; 98 wait_queue_head_t wait;
116 wait_queue_head_t *wait; 99 u16 condition;
117 u16 *condition;
118 u32 start_time;
119 int status; 100 int status;
120 u32 enabled;
121}; 101};
122 102
123struct mwifiex_rxinfo { 103struct mwifiex_rxinfo {
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c
index 8189862da1f9..26931d5f950f 100644
--- a/drivers/net/wireless/mwifiex/init.c
+++ b/drivers/net/wireless/mwifiex/init.c
@@ -35,7 +35,6 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv)
35{ 35{
36 struct mwifiex_adapter *adapter = priv->adapter; 36 struct mwifiex_adapter *adapter = priv->adapter;
37 struct mwifiex_bss_prio_node *bss_prio; 37 struct mwifiex_bss_prio_node *bss_prio;
38 int status = 0;
39 unsigned long flags; 38 unsigned long flags;
40 39
41 bss_prio = kzalloc(sizeof(struct mwifiex_bss_prio_node), GFP_KERNEL); 40 bss_prio = kzalloc(sizeof(struct mwifiex_bss_prio_node), GFP_KERNEL);
@@ -59,7 +58,7 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv)
59 spin_unlock_irqrestore(&adapter->bss_prio_tbl[priv->bss_priority] 58 spin_unlock_irqrestore(&adapter->bss_prio_tbl[priv->bss_priority]
60 .bss_prio_lock, flags); 59 .bss_prio_lock, flags);
61 60
62 return status; 61 return 0;
63} 62}
64 63
65/* 64/*
diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
index 7a9e0b5962ed..60d25c690c07 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -590,11 +590,10 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
590 * an association success (0) or failure (non-zero). 590 * an association success (0) or failure (non-zero).
591 */ 591 */
592int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, 592int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
593 struct host_cmd_ds_command *resp, void *wq_buf) 593 struct host_cmd_ds_command *resp)
594{ 594{
595 struct mwifiex_adapter *adapter = priv->adapter;
595 int ret = 0; 596 int ret = 0;
596 struct mwifiex_wait_queue *wait_queue =
597 (struct mwifiex_wait_queue *) wq_buf;
598 struct ieee_types_assoc_rsp *assoc_rsp; 597 struct ieee_types_assoc_rsp *assoc_rsp;
599 struct mwifiex_bssdescriptor *bss_desc; 598 struct mwifiex_bssdescriptor *bss_desc;
600 u8 enable_data = true; 599 u8 enable_data = true;
@@ -718,16 +717,11 @@ int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
718 717
719done: 718done:
720 /* Need to indicate IOCTL complete */ 719 /* Need to indicate IOCTL complete */
721 if (wait_queue) { 720 if (adapter->curr_cmd->wait_q_enabled) {
722 if (ret) { 721 if (ret)
723 if (assoc_rsp->status_code) 722 adapter->cmd_wait_q.status = -1;
724 wait_queue->status = 723 else
725 le16_to_cpu(assoc_rsp->status_code); 724 adapter->cmd_wait_q.status = 0;
726 else
727 wait_queue->status = MWIFIEX_ERROR_ASSOC_FAIL;
728 } else {
729 wait_queue->status = MWIFIEX_ERROR_NO_ERROR;
730 }
731 } 725 }
732 726
733 return ret; 727 return ret;
@@ -885,9 +879,9 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
885 mwifiex_get_active_data_rates(priv, adhoc_start->DataRate); 879 mwifiex_get_active_data_rates(priv, adhoc_start->DataRate);
886 if ((adapter->adhoc_start_band & BAND_G) && 880 if ((adapter->adhoc_start_band & BAND_G) &&
887 (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { 881 (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) {
888 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, 882 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
889 HostCmd_ACT_GEN_SET, 883 HostCmd_ACT_GEN_SET, 0,
890 0, NULL, &priv->curr_pkt_filter); 884 &priv->curr_pkt_filter);
891 885
892 if (ret) { 886 if (ret) {
893 dev_err(adapter->dev, 887 dev_err(adapter->dev,
@@ -1066,9 +1060,9 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1066 priv-> 1060 priv->
1067 curr_pkt_filter | HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON; 1061 curr_pkt_filter | HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON;
1068 1062
1069 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, 1063 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
1070 HostCmd_ACT_GEN_SET, 0, NULL, 1064 HostCmd_ACT_GEN_SET, 0,
1071 &curr_pkt_filter); 1065 &curr_pkt_filter);
1072 if (ret) { 1066 if (ret) {
1073 dev_err(priv->adapter->dev, 1067 dev_err(priv->adapter->dev,
1074 "ADHOC_J_CMD: G Protection config failed\n"); 1068 "ADHOC_J_CMD: G Protection config failed\n");
@@ -1192,11 +1186,10 @@ mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1192 * saves the beacon buffer. 1186 * saves the beacon buffer.
1193 */ 1187 */
1194int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, 1188int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1195 struct host_cmd_ds_command *resp, void *wq_buf) 1189 struct host_cmd_ds_command *resp)
1196{ 1190{
1197 int ret = 0; 1191 int ret = 0;
1198 struct mwifiex_wait_queue *wait_queue = 1192 struct mwifiex_adapter *adapter = priv->adapter;
1199 (struct mwifiex_wait_queue *) wq_buf;
1200 struct host_cmd_ds_802_11_ad_hoc_result *adhoc_result; 1193 struct host_cmd_ds_802_11_ad_hoc_result *adhoc_result;
1201 struct mwifiex_bssdescriptor *bss_desc; 1194 struct mwifiex_bssdescriptor *bss_desc;
1202 u16 command = le16_to_cpu(resp->command); 1195 u16 command = le16_to_cpu(resp->command);
@@ -1264,11 +1257,11 @@ int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1264 1257
1265done: 1258done:
1266 /* Need to indicate IOCTL complete */ 1259 /* Need to indicate IOCTL complete */
1267 if (wait_queue) { 1260 if (adapter->curr_cmd->wait_q_enabled) {
1268 if (ret) 1261 if (ret)
1269 wait_queue->status = MWIFIEX_ERROR_ASSOC_FAIL; 1262 adapter->cmd_wait_q.status = -1;
1270 else 1263 else
1271 wait_queue->status = MWIFIEX_ERROR_NO_ERROR; 1264 adapter->cmd_wait_q.status = 0;
1272 1265
1273 } 1266 }
1274 1267
@@ -1283,7 +1276,7 @@ done:
1283 * command to firmware. 1276 * command to firmware.
1284 */ 1277 */
1285int mwifiex_associate(struct mwifiex_private *priv, 1278int mwifiex_associate(struct mwifiex_private *priv,
1286 void *wait_queue, struct mwifiex_bssdescriptor *bss_desc) 1279 struct mwifiex_bssdescriptor *bss_desc)
1287{ 1280{
1288 int ret = 0; 1281 int ret = 0;
1289 u8 current_bssid[ETH_ALEN]; 1282 u8 current_bssid[ETH_ALEN];
@@ -1301,9 +1294,8 @@ int mwifiex_associate(struct mwifiex_private *priv,
1301 retrieval */ 1294 retrieval */
1302 priv->assoc_rsp_size = 0; 1295 priv->assoc_rsp_size = 0;
1303 1296
1304 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_ASSOCIATE, 1297 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_ASSOCIATE,
1305 HostCmd_ACT_GEN_SET, 0, wait_queue, 1298 HostCmd_ACT_GEN_SET, 0, bss_desc);
1306 bss_desc);
1307 1299
1308 return ret; 1300 return ret;
1309} 1301}
@@ -1315,7 +1307,7 @@ int mwifiex_associate(struct mwifiex_private *priv,
1315 */ 1307 */
1316int 1308int
1317mwifiex_adhoc_start(struct mwifiex_private *priv, 1309mwifiex_adhoc_start(struct mwifiex_private *priv,
1318 void *wait_queue, struct mwifiex_802_11_ssid *adhoc_ssid) 1310 struct mwifiex_802_11_ssid *adhoc_ssid)
1319{ 1311{
1320 int ret = 0; 1312 int ret = 0;
1321 1313
@@ -1326,9 +1318,8 @@ mwifiex_adhoc_start(struct mwifiex_private *priv,
1326 dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %d\n", 1318 dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %d\n",
1327 priv->curr_bss_params.band); 1319 priv->curr_bss_params.band);
1328 1320
1329 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_AD_HOC_START, 1321 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_START,
1330 HostCmd_ACT_GEN_SET, 0, wait_queue, 1322 HostCmd_ACT_GEN_SET, 0, adhoc_ssid);
1331 adhoc_ssid);
1332 1323
1333 return ret; 1324 return ret;
1334} 1325}
@@ -1340,7 +1331,7 @@ mwifiex_adhoc_start(struct mwifiex_private *priv,
1340 * if already not connected to the requested SSID. 1331 * if already not connected to the requested SSID.
1341 */ 1332 */
1342int mwifiex_adhoc_join(struct mwifiex_private *priv, 1333int mwifiex_adhoc_join(struct mwifiex_private *priv,
1343 void *wait_queue, struct mwifiex_bssdescriptor *bss_desc) 1334 struct mwifiex_bssdescriptor *bss_desc)
1344{ 1335{
1345 int ret = 0; 1336 int ret = 0;
1346 1337
@@ -1369,9 +1360,8 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv,
1369 dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %c\n", 1360 dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %c\n",
1370 priv->curr_bss_params.band); 1361 priv->curr_bss_params.band);
1371 1362
1372 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_AD_HOC_JOIN, 1363 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_JOIN,
1373 HostCmd_ACT_GEN_SET, 0, wait_queue, 1364 HostCmd_ACT_GEN_SET, 0, bss_desc);
1374 bss_desc);
1375 1365
1376 return ret; 1366 return ret;
1377} 1367}
@@ -1380,9 +1370,7 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv,
1380 * This function deauthenticates/disconnects from infra network by sending 1370 * This function deauthenticates/disconnects from infra network by sending
1381 * deauthentication request. 1371 * deauthentication request.
1382 */ 1372 */
1383static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, 1373static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac)
1384 struct mwifiex_wait_queue *wait,
1385 u8 *mac)
1386{ 1374{
1387 u8 mac_address[ETH_ALEN]; 1375 u8 mac_address[ETH_ALEN];
1388 int ret = 0; 1376 int ret = 0;
@@ -1400,11 +1388,8 @@ static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv,
1400 bss_descriptor.mac_address, ETH_ALEN); 1388 bss_descriptor.mac_address, ETH_ALEN);
1401 } 1389 }
1402 1390
1403 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE, 1391 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
1404 HostCmd_ACT_GEN_SET, 0, wait, &mac_address); 1392 HostCmd_ACT_GEN_SET, 0, &mac_address);
1405
1406 if (!ret && wait)
1407 ret = -EINPROGRESS;
1408 1393
1409 return ret; 1394 return ret;
1410} 1395}
@@ -1415,26 +1400,23 @@ static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv,
1415 * In case of infra made, it sends deauthentication request, and 1400 * In case of infra made, it sends deauthentication request, and
1416 * in case of ad-hoc mode, a stop network request is sent to the firmware. 1401 * in case of ad-hoc mode, a stop network request is sent to the firmware.
1417 */ 1402 */
1418int mwifiex_deauthenticate(struct mwifiex_private *priv, 1403int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac)
1419 struct mwifiex_wait_queue *wait, u8 *mac)
1420{ 1404{
1421 int ret = 0; 1405 int ret = 0;
1422 1406
1423 if (priv->media_connected) { 1407 if (priv->media_connected) {
1424 if (priv->bss_mode == NL80211_IFTYPE_STATION) { 1408 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
1425 ret = mwifiex_deauthenticate_infra(priv, wait, mac); 1409 ret = mwifiex_deauthenticate_infra(priv, mac);
1426 } else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { 1410 } else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1427 ret = mwifiex_prepare_cmd(priv, 1411 ret = mwifiex_send_cmd_sync(priv,
1428 HostCmd_CMD_802_11_AD_HOC_STOP, 1412 HostCmd_CMD_802_11_AD_HOC_STOP,
1429 HostCmd_ACT_GEN_SET, 0, wait, NULL); 1413 HostCmd_ACT_GEN_SET, 0, NULL);
1430
1431 if (!ret && wait)
1432 ret = -EINPROGRESS;
1433 } 1414 }
1434 } 1415 }
1435 1416
1436 return ret; 1417 return ret;
1437} 1418}
1419EXPORT_SYMBOL_GPL(mwifiex_deauthenticate);
1438 1420
1439/* 1421/*
1440 * This function converts band to radio type used in channel TLV. 1422 * This function converts band to radio type used in channel TLV.
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index ed89ca41a902..df665db8c433 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -597,16 +597,23 @@ mwifiex_set_mac_address(struct net_device *dev, void *addr)
597{ 597{
598 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 598 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
599 struct sockaddr *hw_addr = (struct sockaddr *) addr; 599 struct sockaddr *hw_addr = (struct sockaddr *) addr;
600 int ret = 0;
600 601
601 memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN); 602 memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN);
602 603
603 if (mwifiex_request_set_mac_address(priv)) { 604 /* Send request to firmware */
604 dev_err(priv->adapter->dev, "set MAC address failed\n"); 605 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
605 return -EFAULT; 606 HostCmd_ACT_GEN_SET, 0, NULL);
606 } 607
608 if (!ret)
609 memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
610 else
611 dev_err(priv->adapter->dev, "set mac address failed: ret=%d"
612 "\n", ret);
613
607 memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); 614 memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
608 615
609 return 0; 616 return ret;
610} 617}
611 618
612/* 619/*
@@ -615,7 +622,20 @@ mwifiex_set_mac_address(struct net_device *dev, void *addr)
615static void mwifiex_set_multicast_list(struct net_device *dev) 622static void mwifiex_set_multicast_list(struct net_device *dev)
616{ 623{
617 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 624 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
618 mwifiex_request_set_multicast_list(priv, dev); 625 struct mwifiex_multicast_list mcast_list;
626
627 if (dev->flags & IFF_PROMISC) {
628 mcast_list.mode = MWIFIEX_PROMISC_MODE;
629 } else if (dev->flags & IFF_ALLMULTI ||
630 netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
631 mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
632 } else {
633 mcast_list.mode = MWIFIEX_MULTICAST_MODE;
634 if (netdev_mc_count(dev))
635 mcast_list.num_multicast_addr =
636 mwifiex_copy_mcast_addr(&mcast_list, dev);
637 }
638 mwifiex_request_set_multicast_list(priv, &mcast_list);
619} 639}
620 640
621/* 641/*
@@ -677,9 +697,6 @@ mwifiex_init_priv_params(struct mwifiex_private *priv, struct net_device *dev)
677{ 697{
678 dev->netdev_ops = &mwifiex_netdev_ops; 698 dev->netdev_ops = &mwifiex_netdev_ops;
679 /* Initialize private structure */ 699 /* Initialize private structure */
680 init_waitqueue_head(&priv->ioctl_wait_q);
681 init_waitqueue_head(&priv->cmd_wait_q);
682 init_waitqueue_head(&priv->w_stats_wait_q);
683 priv->current_key_index = 0; 700 priv->current_key_index = 0;
684 priv->media_connected = false; 701 priv->media_connected = false;
685 memset(&priv->nick_name, 0, sizeof(priv->nick_name)); 702 memset(&priv->nick_name, 0, sizeof(priv->nick_name));
@@ -808,32 +825,6 @@ mwifiex_remove_interface(struct mwifiex_adapter *adapter, u8 bss_index)
808} 825}
809 826
810/* 827/*
811 * Sends IOCTL request to shutdown firmware.
812 *
813 * This function allocates the IOCTL request buffer, fills it
814 * with requisite parameters and calls the IOCTL handler.
815 */
816int mwifiex_shutdown_fw(struct mwifiex_private *priv, u8 wait_option)
817{
818 struct mwifiex_wait_queue *wait = NULL;
819 int status = 0;
820
821 /* Allocate an IOCTL request buffer */
822 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
823 if (!wait)
824 return -ENOMEM;
825
826 status = mwifiex_misc_ioctl_init_shutdown(priv->adapter, wait,
827 MWIFIEX_FUNC_SHUTDOWN);
828
829 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
830
831 kfree(wait);
832 return status;
833}
834EXPORT_SYMBOL_GPL(mwifiex_shutdown_fw);
835
836/*
837 * This function check if command is pending. 828 * This function check if command is pending.
838 */ 829 */
839int is_command_pending(struct mwifiex_adapter *adapter) 830int is_command_pending(struct mwifiex_adapter *adapter)
@@ -927,6 +918,10 @@ mwifiex_add_card(void *card, struct semaphore *sem,
927 adapter->is_suspended = false; 918 adapter->is_suspended = false;
928 adapter->hs_activated = false; 919 adapter->hs_activated = false;
929 init_waitqueue_head(&adapter->hs_activate_wait_q); 920 init_waitqueue_head(&adapter->hs_activate_wait_q);
921 adapter->cmd_wait_q_required = false;
922 init_waitqueue_head(&adapter->cmd_wait_q.wait);
923 adapter->cmd_wait_q.condition = false;
924 adapter->cmd_wait_q.status = 0;
930 925
931 /* Create workqueue */ 926 /* Create workqueue */
932 adapter->workqueue = create_workqueue("MWIFIEX_WORK_QUEUE"); 927 adapter->workqueue = create_workqueue("MWIFIEX_WORK_QUEUE");
@@ -1038,12 +1033,12 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
1038 dev_dbg(adapter->dev, "cmd: mwifiex_shutdown_drv done\n"); 1033 dev_dbg(adapter->dev, "cmd: mwifiex_shutdown_drv done\n");
1039 if (atomic_read(&adapter->rx_pending) || 1034 if (atomic_read(&adapter->rx_pending) ||
1040 atomic_read(&adapter->tx_pending) || 1035 atomic_read(&adapter->tx_pending) ||
1041 atomic_read(&adapter->ioctl_pending)) { 1036 atomic_read(&adapter->cmd_pending)) {
1042 dev_err(adapter->dev, "rx_pending=%d, tx_pending=%d, " 1037 dev_err(adapter->dev, "rx_pending=%d, tx_pending=%d, "
1043 "ioctl_pending=%d\n", 1038 "cmd_pending=%d\n",
1044 atomic_read(&adapter->rx_pending), 1039 atomic_read(&adapter->rx_pending),
1045 atomic_read(&adapter->tx_pending), 1040 atomic_read(&adapter->tx_pending),
1046 atomic_read(&adapter->ioctl_pending)); 1041 atomic_read(&adapter->cmd_pending));
1047 } 1042 }
1048 1043
1049 /* Remove interface */ 1044 /* Remove interface */
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 43ff149de9db..7ead15e1967e 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -42,11 +42,8 @@ extern const char driver_version[];
42extern struct mwifiex_adapter *g_adapter; 42extern struct mwifiex_adapter *g_adapter;
43 43
44enum { 44enum {
45 MWIFIEX_NO_WAIT, 45 MWIFIEX_ASYNC_CMD,
46 MWIFIEX_IOCTL_WAIT, 46 MWIFIEX_SYNC_CMD
47 MWIFIEX_CMD_WAIT,
48 MWIFIEX_PROC_WAIT,
49 MWIFIEX_WSTATS_WAIT
50}; 47};
51 48
52#define DRV_MODE_STA 0x1 49#define DRV_MODE_STA 0x1
@@ -468,10 +465,6 @@ struct mwifiex_private {
468 u32 curr_bcn_size; 465 u32 curr_bcn_size;
469 /* spin lock for beacon buffer */ 466 /* spin lock for beacon buffer */
470 spinlock_t curr_bcn_buf_lock; 467 spinlock_t curr_bcn_buf_lock;
471 u16 ioctl_wait_q_woken;
472 wait_queue_head_t ioctl_wait_q;
473 u16 cmd_wait_q_woken;
474 wait_queue_head_t cmd_wait_q;
475 struct wireless_dev *wdev; 468 struct wireless_dev *wdev;
476 struct mwifiex_chan_freq_power cfp; 469 struct mwifiex_chan_freq_power cfp;
477 char version_str[128]; 470 char version_str[128];
@@ -480,8 +473,6 @@ struct mwifiex_private {
480#endif 473#endif
481 u8 nick_name[16]; 474 u8 nick_name[16];
482 struct iw_statistics w_stats; 475 struct iw_statistics w_stats;
483 u16 w_stats_wait_q_woken;
484 wait_queue_head_t w_stats_wait_q;
485 u16 current_key_index; 476 u16 current_key_index;
486 struct semaphore async_sem; 477 struct semaphore async_sem;
487 u8 scan_pending_on_block; 478 u8 scan_pending_on_block;
@@ -552,7 +543,7 @@ struct cmd_ctrl_node {
552 struct sk_buff *cmd_skb; 543 struct sk_buff *cmd_skb;
553 struct sk_buff *resp_skb; 544 struct sk_buff *resp_skb;
554 void *data_buf; 545 void *data_buf;
555 void *wq_buf; 546 u32 wait_q_enabled;
556 struct sk_buff *skb; 547 struct sk_buff *skb;
557}; 548};
558 549
@@ -590,7 +581,7 @@ struct mwifiex_adapter {
590 struct mwifiex_if_ops if_ops; 581 struct mwifiex_if_ops if_ops;
591 atomic_t rx_pending; 582 atomic_t rx_pending;
592 atomic_t tx_pending; 583 atomic_t tx_pending;
593 atomic_t ioctl_pending; 584 atomic_t cmd_pending;
594 struct workqueue_struct *workqueue; 585 struct workqueue_struct *workqueue;
595 struct work_struct main_work; 586 struct work_struct main_work;
596 struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM]; 587 struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
@@ -684,6 +675,8 @@ struct mwifiex_adapter {
684 struct mwifiex_dbg dbg; 675 struct mwifiex_dbg dbg;
685 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE]; 676 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
686 u32 arp_filter_size; 677 u32 arp_filter_size;
678 u16 cmd_wait_q_required;
679 struct mwifiex_wait_queue cmd_wait_q;
687}; 680};
688 681
689int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); 682int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
@@ -707,29 +700,23 @@ int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
707 700
708int mwifiex_process_event(struct mwifiex_adapter *adapter); 701int mwifiex_process_event(struct mwifiex_adapter *adapter);
709 702
710int mwifiex_ioctl_complete(struct mwifiex_adapter *adapter, 703int mwifiex_complete_cmd(struct mwifiex_adapter *adapter);
711 struct mwifiex_wait_queue *ioctl_wq,
712 int status);
713 704
714int mwifiex_prepare_cmd(struct mwifiex_private *priv, 705int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
715 uint16_t cmd_no, 706 u16 cmd_action, u32 cmd_oid, void *data_buf);
716 u16 cmd_action, 707
717 u32 cmd_oid, 708int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
718 void *wait_queue, void *data_buf); 709 u16 cmd_action, u32 cmd_oid, void *data_buf);
719 710
720void mwifiex_cmd_timeout_func(unsigned long function_context); 711void mwifiex_cmd_timeout_func(unsigned long function_context);
721 712
722int mwifiex_misc_ioctl_init_shutdown(struct mwifiex_adapter *adapter,
723 struct mwifiex_wait_queue *wait_queue,
724 u32 func_init_shutdown);
725int mwifiex_get_debug_info(struct mwifiex_private *, 713int mwifiex_get_debug_info(struct mwifiex_private *,
726 struct mwifiex_debug_info *); 714 struct mwifiex_debug_info *);
727 715
728int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter); 716int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
729int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter); 717int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
730void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter); 718void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
731void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter, 719void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
732 struct mwifiex_wait_queue *ioctl_wq);
733 720
734void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 721void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
735 struct cmd_ctrl_node *cmd_node); 722 struct cmd_ctrl_node *cmd_node);
@@ -772,24 +759,21 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
772 u16 cmd_action, u32 cmd_oid, 759 u16 cmd_action, u32 cmd_oid,
773 void *data_buf, void *cmd_buf); 760 void *data_buf, void *cmd_buf);
774int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no, 761int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
775 void *cmd_buf, void *ioctl); 762 void *cmd_buf);
776int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *, 763int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
777 struct sk_buff *skb); 764 struct sk_buff *skb);
778int mwifiex_process_sta_event(struct mwifiex_private *); 765int mwifiex_process_sta_event(struct mwifiex_private *);
779void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb); 766void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
780int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta); 767int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
781int mwifiex_scan_networks(struct mwifiex_private *priv, void *wait_queue, 768int mwifiex_scan_networks(struct mwifiex_private *priv,
782 u16 action, 769 const struct mwifiex_user_scan_cfg *user_scan_in);
783 const struct mwifiex_user_scan_cfg
784 *user_scan_in, struct mwifiex_scan_resp *);
785int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv, 770int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv,
786 struct host_cmd_ds_command *cmd, 771 struct host_cmd_ds_command *cmd,
787 void *data_buf); 772 void *data_buf);
788void mwifiex_queue_scan_cmd(struct mwifiex_private *priv, 773void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
789 struct cmd_ctrl_node *cmd_node); 774 struct cmd_ctrl_node *cmd_node);
790int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, 775int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
791 struct host_cmd_ds_command *resp, 776 struct host_cmd_ds_command *resp);
792 void *wait_queue);
793s32 mwifiex_find_ssid_in_list(struct mwifiex_private *priv, 777s32 mwifiex_find_ssid_in_list(struct mwifiex_private *priv,
794 struct mwifiex_802_11_ssid *ssid, u8 *bssid, 778 struct mwifiex_802_11_ssid *ssid, u8 *bssid,
795 u32 mode); 779 u32 mode);
@@ -799,23 +783,20 @@ int mwifiex_find_best_network(struct mwifiex_private *priv,
799 struct mwifiex_ssid_bssid *req_ssid_bssid); 783 struct mwifiex_ssid_bssid *req_ssid_bssid);
800s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1, 784s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
801 struct mwifiex_802_11_ssid *ssid2); 785 struct mwifiex_802_11_ssid *ssid2);
802int mwifiex_associate(struct mwifiex_private *priv, void *wait_queue, 786int mwifiex_associate(struct mwifiex_private *priv,
803 struct mwifiex_bssdescriptor *bss_desc); 787 struct mwifiex_bssdescriptor *bss_desc);
804int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, 788int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
805 struct host_cmd_ds_command 789 struct host_cmd_ds_command
806 *cmd, void *data_buf); 790 *cmd, void *data_buf);
807int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, 791int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
808 struct host_cmd_ds_command *resp, 792 struct host_cmd_ds_command *resp);
809 void *wait_queue);
810void mwifiex_reset_connect_state(struct mwifiex_private *priv); 793void mwifiex_reset_connect_state(struct mwifiex_private *priv);
811void mwifiex_2040_coex_event(struct mwifiex_private *priv); 794void mwifiex_2040_coex_event(struct mwifiex_private *priv);
812u8 mwifiex_band_to_radio_type(u8 band); 795u8 mwifiex_band_to_radio_type(u8 band);
813int mwifiex_deauthenticate(struct mwifiex_private *priv, 796int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
814 struct mwifiex_wait_queue *wait_queue, 797int mwifiex_adhoc_start(struct mwifiex_private *priv,
815 u8 *mac);
816int mwifiex_adhoc_start(struct mwifiex_private *priv, void *wait_queue,
817 struct mwifiex_802_11_ssid *adhoc_ssid); 798 struct mwifiex_802_11_ssid *adhoc_ssid);
818int mwifiex_adhoc_join(struct mwifiex_private *priv, void *wait_queue, 799int mwifiex_adhoc_join(struct mwifiex_private *priv,
819 struct mwifiex_bssdescriptor *bss_desc); 800 struct mwifiex_bssdescriptor *bss_desc);
820int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, 801int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
821 struct host_cmd_ds_command *cmd, 802 struct host_cmd_ds_command *cmd,
@@ -824,8 +805,7 @@ int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
824 struct host_cmd_ds_command *cmd, 805 struct host_cmd_ds_command *cmd,
825 void *data_buf); 806 void *data_buf);
826int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, 807int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
827 struct host_cmd_ds_command *resp, 808 struct host_cmd_ds_command *resp);
828 void *wait_queue);
829int mwifiex_cmd_802_11_bg_scan_query(struct mwifiex_private *priv, 809int mwifiex_cmd_802_11_bg_scan_query(struct mwifiex_private *priv,
830 struct host_cmd_ds_command *cmd, 810 struct host_cmd_ds_command *cmd,
831 void *data_buf); 811 void *data_buf);
@@ -943,52 +923,34 @@ mwifiex_netdev_get_priv(struct net_device *dev)
943 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev)); 923 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
944} 924}
945 925
946struct mwifiex_wait_queue *mwifiex_alloc_fill_wait_queue(
947 struct mwifiex_private *,
948 u8 wait_option);
949struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter 926struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter
950 *adapter, u8 bss_index); 927 *adapter, u8 bss_index);
951int mwifiex_shutdown_fw(struct mwifiex_private *, u8); 928int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
952 929 u32 func_init_shutdown);
953int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *); 930int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *);
954int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *); 931int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
955 932
956void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version, 933void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
957 int maxlen); 934 int maxlen);
958int mwifiex_request_set_mac_address(struct mwifiex_private *priv); 935int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
959void mwifiex_request_set_multicast_list(struct mwifiex_private *priv, 936 struct mwifiex_multicast_list *mcast_list);
960 struct net_device *dev); 937int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
961int mwifiex_request_ioctl(struct mwifiex_private *priv, 938 struct net_device *dev);
962 struct mwifiex_wait_queue *req, 939int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter);
963 int, u8 wait_option);
964int mwifiex_disconnect(struct mwifiex_private *, u8, u8 *);
965int mwifiex_bss_start(struct mwifiex_private *priv, 940int mwifiex_bss_start(struct mwifiex_private *priv,
966 u8 wait_option,
967 struct mwifiex_ssid_bssid *ssid_bssid); 941 struct mwifiex_ssid_bssid *ssid_bssid);
968int mwifiex_set_hs_params(struct mwifiex_private *priv, 942int mwifiex_set_hs_params(struct mwifiex_private *priv,
969 u16 action, u8 wait_option, 943 u16 action, int cmd_type,
970 struct mwifiex_ds_hs_cfg *hscfg); 944 struct mwifiex_ds_hs_cfg *hscfg);
971int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option); 945int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
972int mwifiex_enable_hs(struct mwifiex_adapter *adapter); 946int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
973void mwifiex_process_ioctl_resp(struct mwifiex_private *priv,
974 struct mwifiex_wait_queue *req);
975u32 mwifiex_get_mode(struct mwifiex_private *priv, u8 wait_option);
976int mwifiex_get_signal_info(struct mwifiex_private *priv, 947int mwifiex_get_signal_info(struct mwifiex_private *priv,
977 u8 wait_option,
978 struct mwifiex_ds_get_signal *signal); 948 struct mwifiex_ds_get_signal *signal);
979int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, 949int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
980 struct mwifiex_rate_cfg *rate); 950 struct mwifiex_rate_cfg *rate);
981int mwifiex_get_channel_list(struct mwifiex_private *priv, 951int mwifiex_find_best_bss(struct mwifiex_private *priv,
982 u8 wait_option,
983 struct mwifiex_chan_list *chanlist);
984int mwifiex_get_scan_table(struct mwifiex_private *priv,
985 u8 wait_option,
986 struct mwifiex_scan_resp *scanresp);
987int mwifiex_enable_wep_key(struct mwifiex_private *priv, u8 wait_option);
988int mwifiex_find_best_bss(struct mwifiex_private *priv, u8 wait_option,
989 struct mwifiex_ssid_bssid *ssid_bssid); 952 struct mwifiex_ssid_bssid *ssid_bssid);
990int mwifiex_request_scan(struct mwifiex_private *priv, 953int mwifiex_request_scan(struct mwifiex_private *priv,
991 u8 wait_option,
992 struct mwifiex_802_11_ssid *req_ssid); 954 struct mwifiex_802_11_ssid *req_ssid);
993int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, 955int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
994 struct mwifiex_user_scan_cfg *scan_req); 956 struct mwifiex_user_scan_cfg *scan_req);
@@ -1024,27 +986,22 @@ int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1024 986
1025int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index); 987int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1026 988
1027int mwifiex_drv_set_power(struct mwifiex_private *priv, bool power_on); 989int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1028 990
1029int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, 991int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1030 char *version, int max_len); 992 char *version, int max_len);
1031 993
1032int mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm); 994int mwifiex_set_tx_power(struct mwifiex_private *priv,
995 struct mwifiex_power_cfg *power_cfg);
1033 996
1034int mwifiex_main_process(struct mwifiex_adapter *); 997int mwifiex_main_process(struct mwifiex_adapter *);
1035 998
1036int mwifiex_bss_ioctl_channel(struct mwifiex_private *, 999int mwifiex_bss_set_channel(struct mwifiex_private *,
1037 u16 action, 1000 struct mwifiex_chan_freq_power *cfp);
1038 struct mwifiex_chan_freq_power *cfp);
1039int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *, 1001int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *,
1040 struct mwifiex_wait_queue *,
1041 struct mwifiex_ssid_bssid *); 1002 struct mwifiex_ssid_bssid *);
1042int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *, 1003int mwifiex_set_radio_band_cfg(struct mwifiex_private *,
1043 u16 action, 1004 struct mwifiex_ds_band_cfg *);
1044 struct mwifiex_ds_band_cfg *);
1045int mwifiex_snmp_mib_ioctl(struct mwifiex_private *,
1046 struct mwifiex_wait_queue *,
1047 u32 cmd_oid, u16 action, u32 *value);
1048int mwifiex_get_bss_info(struct mwifiex_private *, 1005int mwifiex_get_bss_info(struct mwifiex_private *,
1049 struct mwifiex_bss_info *); 1006 struct mwifiex_bss_info *);
1050 1007
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 6bb52d0e6cfa..12fe021536d1 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -178,9 +178,8 @@ mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
178 * with requisite parameters and calls the IOCTL handler. 178 * with requisite parameters and calls the IOCTL handler.
179 */ 179 */
180int mwifiex_find_best_bss(struct mwifiex_private *priv, 180int mwifiex_find_best_bss(struct mwifiex_private *priv,
181 u8 wait_option, struct mwifiex_ssid_bssid *ssid_bssid) 181 struct mwifiex_ssid_bssid *ssid_bssid)
182{ 182{
183 struct mwifiex_wait_queue *wait = NULL;
184 struct mwifiex_ssid_bssid tmp_ssid_bssid; 183 struct mwifiex_ssid_bssid tmp_ssid_bssid;
185 int ret = 0; 184 int ret = 0;
186 u8 *mac = NULL; 185 u8 *mac = NULL;
@@ -188,14 +187,9 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
188 if (!ssid_bssid) 187 if (!ssid_bssid)
189 return -1; 188 return -1;
190 189
191 /* Allocate wait request buffer */
192 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
193 if (!wait)
194 return -ENOMEM;
195
196 memcpy(&tmp_ssid_bssid, ssid_bssid, 190 memcpy(&tmp_ssid_bssid, ssid_bssid,
197 sizeof(struct mwifiex_ssid_bssid)); 191 sizeof(struct mwifiex_ssid_bssid));
198 ret = mwifiex_bss_ioctl_find_bss(priv, wait, &tmp_ssid_bssid); 192 ret = mwifiex_bss_ioctl_find_bss(priv, &tmp_ssid_bssid);
199 193
200 if (!ret) { 194 if (!ret) {
201 memcpy(ssid_bssid, &tmp_ssid_bssid, 195 memcpy(ssid_bssid, &tmp_ssid_bssid,
@@ -205,7 +199,6 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
205 " %pM\n", ssid_bssid->ssid.ssid, mac); 199 " %pM\n", ssid_bssid->ssid.ssid, mac);
206 } 200 }
207 201
208 kfree(wait);
209 return ret; 202 return ret;
210} 203}
211 204
@@ -221,22 +214,14 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
221int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, 214int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
222 struct mwifiex_user_scan_cfg *scan_req) 215 struct mwifiex_user_scan_cfg *scan_req)
223{ 216{
224 struct mwifiex_wait_queue *wait = NULL;
225 int status = 0; 217 int status = 0;
226 u8 wait_option = MWIFIEX_IOCTL_WAIT;
227
228 /* Allocate an IOCTL request buffer */
229 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
230 if (!wait)
231 return -ENOMEM;
232 218
233 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET, 219 priv->adapter->cmd_wait_q.condition = false;
234 scan_req, NULL);
235 220
236 status = mwifiex_request_ioctl(priv, wait, status, wait_option); 221 status = mwifiex_scan_networks(priv, scan_req);
222 if (!status)
223 status = mwifiex_wait_queue_complete(priv->adapter);
237 224
238 if (wait && (status != -EINPROGRESS))
239 kfree(wait);
240 return status; 225 return status;
241} 226}
242 227
@@ -674,7 +659,7 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
674 * along with the other TLVs, to the firmware. 659 * along with the other TLVs, to the firmware.
675 */ 660 */
676static int 661static int
677mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf, 662mwifiex_scan_channel_list(struct mwifiex_private *priv,
678 u32 max_chan_per_scan, u8 filtered_scan, 663 u32 max_chan_per_scan, u8 filtered_scan,
679 struct mwifiex_scan_cmd_config *scan_cfg_out, 664 struct mwifiex_scan_cmd_config *scan_cfg_out,
680 struct mwifiex_ie_types_chan_list_param_set 665 struct mwifiex_ie_types_chan_list_param_set
@@ -808,9 +793,9 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf,
808 793
809 /* Send the scan command to the firmware with the specified 794 /* Send the scan command to the firmware with the specified
810 cfg */ 795 cfg */
811 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SCAN, 796 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SCAN,
812 HostCmd_ACT_GEN_SET, 797 HostCmd_ACT_GEN_SET, 0,
813 0, wait_buf, scan_cfg_out); 798 scan_cfg_out);
814 if (ret) 799 if (ret)
815 break; 800 break;
816 } 801 }
@@ -2271,9 +2256,7 @@ mwifiex_scan_delete_ssid_table_entry(struct mwifiex_private *priv,
2271 * update the internal driver scan table. 2256 * update the internal driver scan table.
2272 */ 2257 */
2273int mwifiex_scan_networks(struct mwifiex_private *priv, 2258int mwifiex_scan_networks(struct mwifiex_private *priv,
2274 void *wait_buf, u16 action, 2259 const struct mwifiex_user_scan_cfg *user_scan_in)
2275 const struct mwifiex_user_scan_cfg *user_scan_in,
2276 struct mwifiex_scan_resp *scan_resp)
2277{ 2260{
2278 int ret = 0; 2261 int ret = 0;
2279 struct mwifiex_adapter *adapter = priv->adapter; 2262 struct mwifiex_adapter *adapter = priv->adapter;
@@ -2288,18 +2271,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2288 u8 max_chan_per_scan; 2271 u8 max_chan_per_scan;
2289 unsigned long flags; 2272 unsigned long flags;
2290 2273
2291 if (action == HostCmd_ACT_GEN_GET) { 2274 if (adapter->scan_processing) {
2292 if (scan_resp) {
2293 scan_resp->scan_table = (u8 *) adapter->scan_table;
2294 scan_resp->num_in_scan_table =
2295 adapter->num_in_scan_table;
2296 } else {
2297 ret = -1;
2298 }
2299 return ret;
2300 }
2301
2302 if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
2303 dev_dbg(adapter->dev, "cmd: Scan already in process...\n"); 2275 dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
2304 return ret; 2276 return ret;
2305 } 2277 }
@@ -2308,7 +2280,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2308 adapter->scan_processing = true; 2280 adapter->scan_processing = true;
2309 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); 2281 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
2310 2282
2311 if (priv->scan_block && action == HostCmd_ACT_GEN_SET) { 2283 if (priv->scan_block) {
2312 dev_dbg(adapter->dev, 2284 dev_dbg(adapter->dev,
2313 "cmd: Scan is blocked during association...\n"); 2285 "cmd: Scan is blocked during association...\n");
2314 return ret; 2286 return ret;
@@ -2348,9 +2320,9 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2348 adapter->bcn_buf_end = adapter->bcn_buf; 2320 adapter->bcn_buf_end = adapter->bcn_buf;
2349 } 2321 }
2350 2322
2351 ret = mwifiex_scan_channel_list(priv, wait_buf, max_chan_per_scan, 2323 ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan,
2352 filtered_scan, &scan_cfg_out->config, 2324 &scan_cfg_out->config, chan_list_out,
2353 chan_list_out, scan_chan_list); 2325 scan_chan_list);
2354 2326
2355 /* Get scan command from scan_pending_q and put to cmd_pending_q */ 2327 /* Get scan command from scan_pending_q and put to cmd_pending_q */
2356 if (!ret) { 2328 if (!ret) {
@@ -2367,7 +2339,6 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2367 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 2339 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
2368 flags); 2340 flags);
2369 } 2341 }
2370 ret = -EINPROGRESS;
2371 } else { 2342 } else {
2372 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 2343 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
2373 adapter->scan_processing = true; 2344 adapter->scan_processing = true;
@@ -2437,11 +2408,10 @@ int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv,
2437 * .-------------------------------------------------------------. 2408 * .-------------------------------------------------------------.
2438 */ 2409 */
2439int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, 2410int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2440 struct host_cmd_ds_command *resp, void *wq_buf) 2411 struct host_cmd_ds_command *resp)
2441{ 2412{
2442 int ret = 0; 2413 int ret = 0;
2443 struct mwifiex_adapter *adapter = priv->adapter; 2414 struct mwifiex_adapter *adapter = priv->adapter;
2444 struct mwifiex_wait_queue *wait_queue = NULL;
2445 struct cmd_ctrl_node *cmd_node = NULL; 2415 struct cmd_ctrl_node *cmd_node = NULL;
2446 struct host_cmd_ds_802_11_scan_rsp *scan_rsp = NULL; 2416 struct host_cmd_ds_802_11_scan_rsp *scan_rsp = NULL;
2447 struct mwifiex_bssdescriptor *bss_new_entry = NULL; 2417 struct mwifiex_bssdescriptor *bss_new_entry = NULL;
@@ -2653,13 +2623,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2653 mwifiex_process_scan_results(priv); 2623 mwifiex_process_scan_results(priv);
2654 2624
2655 /* Need to indicate IOCTL complete */ 2625 /* Need to indicate IOCTL complete */
2656 wait_queue = (struct mwifiex_wait_queue *) wq_buf; 2626 if (adapter->curr_cmd->wait_q_enabled) {
2657 if (wait_queue) { 2627 adapter->cmd_wait_q.status = 0;
2658 wait_queue->status = MWIFIEX_ERROR_NO_ERROR; 2628 mwifiex_complete_cmd(adapter);
2659
2660 /* Indicate ioctl complete */
2661 mwifiex_ioctl_complete(adapter,
2662 (struct mwifiex_wait_queue *) wait_queue, 0);
2663 } 2629 }
2664 if (priv->report_scan_result) 2630 if (priv->report_scan_result)
2665 priv->report_scan_result = false; 2631 priv->report_scan_result = false;
@@ -2853,6 +2819,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
2853 struct mwifiex_adapter *adapter = priv->adapter; 2819 struct mwifiex_adapter *adapter = priv->adapter;
2854 unsigned long flags; 2820 unsigned long flags;
2855 2821
2822 cmd_node->wait_q_enabled = true;
2856 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 2823 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
2857 list_add_tail(&cmd_node->list, &adapter->scan_pending_q); 2824 list_add_tail(&cmd_node->list, &adapter->scan_pending_q);
2858 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 2825 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
@@ -2899,9 +2866,7 @@ int mwifiex_find_best_network(struct mwifiex_private *priv,
2899 * firmware, filtered on a specific SSID. 2866 * firmware, filtered on a specific SSID.
2900 */ 2867 */
2901static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv, 2868static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2902 void *wait_buf, u16 action, 2869 struct mwifiex_802_11_ssid *req_ssid)
2903 struct mwifiex_802_11_ssid *req_ssid,
2904 struct mwifiex_scan_resp *scan_resp)
2905{ 2870{
2906 struct mwifiex_adapter *adapter = priv->adapter; 2871 struct mwifiex_adapter *adapter = priv->adapter;
2907 int ret = 0; 2872 int ret = 0;
@@ -2910,24 +2875,12 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2910 if (!req_ssid) 2875 if (!req_ssid)
2911 return -1; 2876 return -1;
2912 2877
2913 if (action == HostCmd_ACT_GEN_GET) { 2878 if (adapter->scan_processing) {
2914 if (scan_resp) {
2915 scan_resp->scan_table =
2916 (u8 *) &priv->curr_bss_params.bss_descriptor;
2917 scan_resp->num_in_scan_table =
2918 adapter->num_in_scan_table;
2919 } else {
2920 ret = -1;
2921 }
2922 return ret;
2923 }
2924
2925 if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
2926 dev_dbg(adapter->dev, "cmd: Scan already in process...\n"); 2879 dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
2927 return ret; 2880 return ret;
2928 } 2881 }
2929 2882
2930 if (priv->scan_block && action == HostCmd_ACT_GEN_SET) { 2883 if (priv->scan_block) {
2931 dev_dbg(adapter->dev, 2884 dev_dbg(adapter->dev,
2932 "cmd: Scan is blocked during association...\n"); 2885 "cmd: Scan is blocked during association...\n");
2933 return ret; 2886 return ret;
@@ -2945,7 +2898,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2945 req_ssid->ssid_len); 2898 req_ssid->ssid_len);
2946 scan_cfg->keep_previous_scan = true; 2899 scan_cfg->keep_previous_scan = true;
2947 2900
2948 ret = mwifiex_scan_networks(priv, wait_buf, action, scan_cfg, NULL); 2901 ret = mwifiex_scan_networks(priv, scan_cfg);
2949 2902
2950 kfree(scan_cfg); 2903 kfree(scan_cfg);
2951 return ret; 2904 return ret;
@@ -2960,12 +2913,10 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2960 * Scan command can be issued for both normal scan and specific SSID 2913 * Scan command can be issued for both normal scan and specific SSID
2961 * scan, depending upon whether an SSID is provided or not. 2914 * scan, depending upon whether an SSID is provided or not.
2962 */ 2915 */
2963int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option, 2916int mwifiex_request_scan(struct mwifiex_private *priv,
2964 struct mwifiex_802_11_ssid *req_ssid) 2917 struct mwifiex_802_11_ssid *req_ssid)
2965{ 2918{
2966 int ret = 0; 2919 int ret = 0;
2967 struct mwifiex_wait_queue *wait = NULL;
2968 int status = 0;
2969 2920
2970 if (down_interruptible(&priv->async_sem)) { 2921 if (down_interruptible(&priv->async_sem)) {
2971 dev_err(priv->adapter->dev, "%s: acquire semaphore\n", 2922 dev_err(priv->adapter->dev, "%s: acquire semaphore\n",
@@ -2974,32 +2925,23 @@ int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option,
2974 } 2925 }
2975 priv->scan_pending_on_block = true; 2926 priv->scan_pending_on_block = true;
2976 2927
2977 /* Allocate wait request buffer */ 2928 priv->adapter->cmd_wait_q.condition = false;
2978 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2979 if (!wait) {
2980 ret = -1;
2981 goto done;
2982 }
2983 2929
2984 if (req_ssid && req_ssid->ssid_len != 0) 2930 if (req_ssid && req_ssid->ssid_len != 0)
2985 /* Specific SSID scan */ 2931 /* Specific SSID scan */
2986 status = mwifiex_scan_specific_ssid(priv, wait, 2932 ret = mwifiex_scan_specific_ssid(priv, req_ssid);
2987 HostCmd_ACT_GEN_SET,
2988 req_ssid, NULL);
2989 else 2933 else
2990 /* Normal scan */ 2934 /* Normal scan */
2991 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET, 2935 ret = mwifiex_scan_networks(priv, NULL);
2992 NULL, NULL); 2936
2993 status = mwifiex_request_ioctl(priv, wait, status, wait_option); 2937 if (!ret)
2994 if (status == -1) 2938 ret = mwifiex_wait_queue_complete(priv->adapter);
2995 ret = -1; 2939
2996done:
2997 if ((wait) && (status != -EINPROGRESS))
2998 kfree(wait);
2999 if (ret == -1) { 2940 if (ret == -1) {
3000 priv->scan_pending_on_block = false; 2941 priv->scan_pending_on_block = false;
3001 up(&priv->async_sem); 2942 up(&priv->async_sem);
3002 } 2943 }
2944
3003 return ret; 2945 return ret;
3004} 2946}
3005 2947
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index f21e5cd19839..f207756cbb79 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -208,7 +208,7 @@ static int mwifiex_sdio_resume(struct device *dev)
208 208
209 /* Disable Host Sleep */ 209 /* Disable Host Sleep */
210 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), 210 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
211 MWIFIEX_NO_WAIT); 211 MWIFIEX_ASYNC_CMD);
212 212
213 return 0; 213 return 0;
214} 214}
@@ -1745,13 +1745,12 @@ mwifiex_sdio_cleanup_module(void)
1745 for (i = 0; i < adapter->priv_num; i++) 1745 for (i = 0; i < adapter->priv_num; i++)
1746 if ((GET_BSS_ROLE(adapter->priv[i]) == MWIFIEX_BSS_ROLE_STA) && 1746 if ((GET_BSS_ROLE(adapter->priv[i]) == MWIFIEX_BSS_ROLE_STA) &&
1747 adapter->priv[i]->media_connected) 1747 adapter->priv[i]->media_connected)
1748 mwifiex_disconnect(adapter->priv[i], MWIFIEX_CMD_WAIT, 1748 mwifiex_deauthenticate(adapter->priv[i], NULL);
1749 NULL);
1750 1749
1751 if (!adapter->surprise_removed) 1750 if (!adapter->surprise_removed)
1752 mwifiex_shutdown_fw(mwifiex_get_priv 1751 mwifiex_init_shutdown_fw(mwifiex_get_priv(adapter,
1753 (adapter, MWIFIEX_BSS_ROLE_ANY), 1752 MWIFIEX_BSS_ROLE_ANY),
1754 MWIFIEX_CMD_WAIT); 1753 MWIFIEX_FUNC_SHUTDOWN);
1755 1754
1756exit: 1755exit:
1757 up(&add_remove_card_sem); 1756 up(&add_remove_card_sem);
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 19de6524d428..dec496369b95 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -1135,65 +1135,66 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1135 1135
1136 if (first_sta) { 1136 if (first_sta) {
1137 1137
1138 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_FUNC_INIT, 1138 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_FUNC_INIT,
1139 HostCmd_ACT_GEN_SET, 0, NULL, NULL); 1139 HostCmd_ACT_GEN_SET, 0, NULL);
1140 if (ret) 1140 if (ret)
1141 return -1; 1141 return -1;
1142 /* Read MAC address from HW */ 1142 /* Read MAC address from HW */
1143 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_GET_HW_SPEC, 1143 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_GET_HW_SPEC,
1144 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 1144 HostCmd_ACT_GEN_GET, 0, NULL);
1145 if (ret) 1145 if (ret)
1146 return -1; 1146 return -1;
1147 1147
1148 /* Reconfigure tx buf size */ 1148 /* Reconfigure tx buf size */
1149 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_RECONFIGURE_TX_BUFF, 1149 ret = mwifiex_send_cmd_async(priv,
1150 HostCmd_ACT_GEN_SET, 0, NULL, 1150 HostCmd_CMD_RECONFIGURE_TX_BUFF,
1151 &priv->adapter->tx_buf_size); 1151 HostCmd_ACT_GEN_SET, 0,
1152 &priv->adapter->tx_buf_size);
1152 if (ret) 1153 if (ret)
1153 return -1; 1154 return -1;
1154 1155
1155 /* Enable IEEE PS by default */ 1156 /* Enable IEEE PS by default */
1156 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; 1157 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1157 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, 1158 ret = mwifiex_send_cmd_async(priv,
1158 EN_AUTO_PS, BITMAP_STA_PS, NULL, 1159 HostCmd_CMD_802_11_PS_MODE_ENH,
1159 NULL); 1160 EN_AUTO_PS, BITMAP_STA_PS, NULL);
1160 if (ret) 1161 if (ret)
1161 return -1; 1162 return -1;
1162 } 1163 }
1163 1164
1164 /* get tx rate */ 1165 /* get tx rate */
1165 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TX_RATE_CFG, 1166 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TX_RATE_CFG,
1166 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 1167 HostCmd_ACT_GEN_GET, 0, NULL);
1167 if (ret) 1168 if (ret)
1168 return -1; 1169 return -1;
1169 priv->data_rate = 0; 1170 priv->data_rate = 0;
1170 1171
1171 /* get tx power */ 1172 /* get tx power */
1172 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TXPWR_CFG, 1173 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TXPWR_CFG,
1173 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 1174 HostCmd_ACT_GEN_GET, 0, NULL);
1174 if (ret) 1175 if (ret)
1175 return -1; 1176 return -1;
1176 1177
1177 /* set ibss coalescing_status */ 1178 /* set ibss coalescing_status */
1178 ret = mwifiex_prepare_cmd(priv, 1179 ret = mwifiex_send_cmd_async(priv,
1179 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, 1180 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1180 HostCmd_ACT_GEN_SET, 0, NULL, &enable); 1181 HostCmd_ACT_GEN_SET, 0, &enable);
1181 if (ret) 1182 if (ret)
1182 return -1; 1183 return -1;
1183 1184
1184 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl)); 1185 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
1185 amsdu_aggr_ctrl.enable = true; 1186 amsdu_aggr_ctrl.enable = true;
1186 /* Send request to firmware */ 1187 /* Send request to firmware */
1187 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, 1188 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
1188 HostCmd_ACT_GEN_SET, 0, NULL, 1189 HostCmd_ACT_GEN_SET, 0,
1189 (void *) &amsdu_aggr_ctrl); 1190 (void *) &amsdu_aggr_ctrl);
1190 if (ret) 1191 if (ret)
1191 return -1; 1192 return -1;
1192 /* MAC Control must be the last command in init_fw */ 1193 /* MAC Control must be the last command in init_fw */
1193 /* set MAC Control */ 1194 /* set MAC Control */
1194 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, 1195 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
1195 HostCmd_ACT_GEN_SET, 0, NULL, 1196 HostCmd_ACT_GEN_SET, 0,
1196 &priv->curr_pkt_filter); 1197 &priv->curr_pkt_filter);
1197 if (ret) 1198 if (ret)
1198 return -1; 1199 return -1;
1199 1200
@@ -1201,19 +1202,18 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1201 /* Enable auto deep sleep */ 1202 /* Enable auto deep sleep */
1202 auto_ds.auto_ds = DEEP_SLEEP_ON; 1203 auto_ds.auto_ds = DEEP_SLEEP_ON;
1203 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; 1204 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
1204 ret = mwifiex_prepare_cmd(priv, 1205 ret = mwifiex_send_cmd_async(priv,
1205 HostCmd_CMD_802_11_PS_MODE_ENH, 1206 HostCmd_CMD_802_11_PS_MODE_ENH,
1206 EN_AUTO_PS, BITMAP_AUTO_DS, NULL, 1207 EN_AUTO_PS, BITMAP_AUTO_DS,
1207 &auto_ds); 1208 &auto_ds);
1208 if (ret) 1209 if (ret)
1209 return -1; 1210 return -1;
1210 } 1211 }
1211 1212
1212 /* Send cmd to FW to enable/disable 11D function */ 1213 /* Send cmd to FW to enable/disable 11D function */
1213 state_11d = ENABLE_11D; 1214 state_11d = ENABLE_11D;
1214 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB, 1215 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB,
1215 HostCmd_ACT_GEN_SET, DOT11D_I, 1216 HostCmd_ACT_GEN_SET, DOT11D_I, &state_11d);
1216 NULL, &state_11d);
1217 if (ret) 1217 if (ret)
1218 dev_err(priv->adapter->dev, "11D: failed to enable 11D\n"); 1218 dev_err(priv->adapter->dev, "11D: failed to enable 11D\n");
1219 1219
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index 648df690f5d1..8743c116bee5 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -41,8 +41,7 @@
41 */ 41 */
42static void 42static void
43mwifiex_process_cmdresp_error(struct mwifiex_private *priv, 43mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
44 struct host_cmd_ds_command *resp, 44 struct host_cmd_ds_command *resp)
45 struct mwifiex_wait_queue *wq_buf)
46{ 45{
47 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 46 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
48 struct mwifiex_adapter *adapter = priv->adapter; 47 struct mwifiex_adapter *adapter = priv->adapter;
@@ -51,8 +50,9 @@ mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
51 50
52 dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n", 51 dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n",
53 resp->command, resp->result); 52 resp->command, resp->result);
54 if (wq_buf) 53
55 wq_buf->status = MWIFIEX_ERROR_FW_CMDRESP; 54 if (adapter->curr_cmd->wait_q_enabled)
55 adapter->cmd_wait_q.status = -1;
56 56
57 switch (le16_to_cpu(resp->command)) { 57 switch (le16_to_cpu(resp->command)) {
58 case HostCmd_CMD_802_11_PS_MODE_ENH: 58 case HostCmd_CMD_802_11_PS_MODE_ENH:
@@ -328,9 +328,9 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
328 if (priv->is_data_rate_auto) 328 if (priv->is_data_rate_auto)
329 priv->data_rate = 0; 329 priv->data_rate = 0;
330 else 330 else
331 ret = mwifiex_prepare_cmd(priv, 331 ret = mwifiex_send_cmd_async(priv,
332 HostCmd_CMD_802_11_TX_RATE_QUERY, 332 HostCmd_CMD_802_11_TX_RATE_QUERY,
333 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 333 HostCmd_ACT_GEN_GET, 0, NULL);
334 334
335 if (data_buf) { 335 if (data_buf) {
336 ds_rate = (struct mwifiex_rate_cfg *) data_buf; 336 ds_rate = (struct mwifiex_rate_cfg *) data_buf;
@@ -833,19 +833,17 @@ static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
833 * response handlers based on the command ID. 833 * response handlers based on the command ID.
834 */ 834 */
835int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, 835int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv,
836 u16 cmdresp_no, void *cmd_buf, void *wq_buf) 836 u16 cmdresp_no, void *cmd_buf)
837{ 837{
838 int ret = 0; 838 int ret = 0;
839 struct mwifiex_adapter *adapter = priv->adapter; 839 struct mwifiex_adapter *adapter = priv->adapter;
840 struct host_cmd_ds_command *resp = 840 struct host_cmd_ds_command *resp =
841 (struct host_cmd_ds_command *) cmd_buf; 841 (struct host_cmd_ds_command *) cmd_buf;
842 struct mwifiex_wait_queue *wait_queue =
843 (struct mwifiex_wait_queue *) wq_buf;
844 void *data_buf = adapter->curr_cmd->data_buf; 842 void *data_buf = adapter->curr_cmd->data_buf;
845 843
846 /* If the command is not successful, cleanup and return failure */ 844 /* If the command is not successful, cleanup and return failure */
847 if (resp->result != HostCmd_RESULT_OK) { 845 if (resp->result != HostCmd_RESULT_OK) {
848 mwifiex_process_cmdresp_error(priv, resp, wait_queue); 846 mwifiex_process_cmdresp_error(priv, resp);
849 return -1; 847 return -1;
850 } 848 }
851 /* Command successful, handle response */ 849 /* Command successful, handle response */
@@ -865,12 +863,11 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv,
865 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf); 863 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf);
866 break; 864 break;
867 case HostCmd_CMD_802_11_SCAN: 865 case HostCmd_CMD_802_11_SCAN:
868 ret = mwifiex_ret_802_11_scan(priv, resp, wait_queue); 866 ret = mwifiex_ret_802_11_scan(priv, resp);
869 wait_queue = NULL; 867 adapter->curr_cmd->wait_q_enabled = false;
870 adapter->curr_cmd->wq_buf = NULL;
871 break; 868 break;
872 case HostCmd_CMD_802_11_BG_SCAN_QUERY: 869 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
873 ret = mwifiex_ret_802_11_scan(priv, resp, wait_queue); 870 ret = mwifiex_ret_802_11_scan(priv, resp);
874 dev_dbg(adapter->dev, 871 dev_dbg(adapter->dev,
875 "info: CMD_RESP: BG_SCAN result is ready!\n"); 872 "info: CMD_RESP: BG_SCAN result is ready!\n");
876 break; 873 break;
@@ -884,14 +881,14 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv,
884 ret = mwifiex_ret_802_11_hs_cfg(priv, resp); 881 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
885 break; 882 break;
886 case HostCmd_CMD_802_11_ASSOCIATE: 883 case HostCmd_CMD_802_11_ASSOCIATE:
887 ret = mwifiex_ret_802_11_associate(priv, resp, wait_queue); 884 ret = mwifiex_ret_802_11_associate(priv, resp);
888 break; 885 break;
889 case HostCmd_CMD_802_11_DEAUTHENTICATE: 886 case HostCmd_CMD_802_11_DEAUTHENTICATE:
890 ret = mwifiex_ret_802_11_deauthenticate(priv, resp); 887 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
891 break; 888 break;
892 case HostCmd_CMD_802_11_AD_HOC_START: 889 case HostCmd_CMD_802_11_AD_HOC_START:
893 case HostCmd_CMD_802_11_AD_HOC_JOIN: 890 case HostCmd_CMD_802_11_AD_HOC_JOIN:
894 ret = mwifiex_ret_802_11_ad_hoc(priv, resp, wait_queue); 891 ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
895 break; 892 break;
896 case HostCmd_CMD_802_11_AD_HOC_STOP: 893 case HostCmd_CMD_802_11_AD_HOC_STOP:
897 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp); 894 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c
index 936d7c175e75..fc265cab0907 100644
--- a/drivers/net/wireless/mwifiex/sta_event.c
+++ b/drivers/net/wireless/mwifiex/sta_event.c
@@ -271,8 +271,9 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
271 271
272 case EVENT_HS_ACT_REQ: 272 case EVENT_HS_ACT_REQ:
273 dev_dbg(adapter->dev, "event: HS_ACT_REQ\n"); 273 dev_dbg(adapter->dev, "event: HS_ACT_REQ\n");
274 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH, 274 ret = mwifiex_send_cmd_async(priv,
275 0, 0, NULL, NULL); 275 HostCmd_CMD_802_11_HS_CFG_ENH,
276 0, 0, NULL);
276 break; 277 break;
277 278
278 case EVENT_MIC_ERR_UNICAST: 279 case EVENT_MIC_ERR_UNICAST:
@@ -303,9 +304,9 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
303 sizeof(struct mwifiex_bssdescriptor) * IW_MAX_AP); 304 sizeof(struct mwifiex_bssdescriptor) * IW_MAX_AP);
304 adapter->num_in_scan_table = 0; 305 adapter->num_in_scan_table = 0;
305 adapter->bcn_buf_end = adapter->bcn_buf; 306 adapter->bcn_buf_end = adapter->bcn_buf;
306 ret = mwifiex_prepare_cmd(priv, 307 ret = mwifiex_send_cmd_async(priv,
307 HostCmd_CMD_802_11_BG_SCAN_QUERY, 308 HostCmd_CMD_802_11_BG_SCAN_QUERY,
308 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 309 HostCmd_ACT_GEN_GET, 0, NULL);
309 break; 310 break;
310 311
311 case EVENT_PORT_RELEASE: 312 case EVENT_PORT_RELEASE:
@@ -314,8 +315,8 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
314 315
315 case EVENT_WMM_STATUS_CHANGE: 316 case EVENT_WMM_STATUS_CHANGE:
316 dev_dbg(adapter->dev, "event: WMM status changed\n"); 317 dev_dbg(adapter->dev, "event: WMM status changed\n");
317 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_WMM_GET_STATUS, 318 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_WMM_GET_STATUS,
318 0, 0, NULL, NULL); 319 0, 0, NULL);
319 break; 320 break;
320 321
321 case EVENT_RSSI_LOW: 322 case EVENT_RSSI_LOW:
@@ -353,15 +354,15 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
353 break; 354 break;
354 case EVENT_IBSS_COALESCED: 355 case EVENT_IBSS_COALESCED:
355 dev_dbg(adapter->dev, "event: IBSS_COALESCED\n"); 356 dev_dbg(adapter->dev, "event: IBSS_COALESCED\n");
356 ret = mwifiex_prepare_cmd(priv, 357 ret = mwifiex_send_cmd_async(priv,
357 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, 358 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
358 HostCmd_ACT_GEN_GET, 0, NULL, NULL); 359 HostCmd_ACT_GEN_GET, 0, NULL);
359 break; 360 break;
360 case EVENT_ADDBA: 361 case EVENT_ADDBA:
361 dev_dbg(adapter->dev, "event: ADDBA Request\n"); 362 dev_dbg(adapter->dev, "event: ADDBA Request\n");
362 mwifiex_prepare_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP, 363 mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_ADDBA_RSP,
363 HostCmd_ACT_GEN_SET, 0, NULL, 364 HostCmd_ACT_GEN_SET, 0,
364 adapter->event_body); 365 adapter->event_body);
365 break; 366 break;
366 case EVENT_DELBA: 367 case EVENT_DELBA:
367 dev_dbg(adapter->dev, "event: DELBA Request\n"); 368 dev_dbg(adapter->dev, "event: DELBA Request\n");
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 2fcdbc224e08..5f2ce9459d26 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -33,9 +33,8 @@
33 * size, and the calling function must ensure enough memory is 33 * size, and the calling function must ensure enough memory is
34 * available. 34 * available.
35 */ 35 */
36static int 36int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
37mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist, 37 struct net_device *dev)
38 struct net_device *dev)
39{ 38{
40 int i = 0; 39 int i = 0;
41 struct netdev_hw_addr *ha; 40 struct netdev_hw_addr *ha;
@@ -47,216 +46,51 @@ mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
47} 46}
48 47
49/* 48/*
50 * Allocate and fills a wait queue with proper parameters.
51 *
52 * This function needs to be called before an IOCTL request can be made.
53 * It can handle the following wait options:
54 * MWIFIEX_NO_WAIT - Waiting is disabled
55 * MWIFIEX_IOCTL_WAIT - Waiting is done on IOCTL wait queue
56 * MWIFIEX_CMD_WAIT - Waiting is done on command wait queue
57 * MWIFIEX_WSTATS_WAIT - Waiting is done on stats wait queue
58 */
59struct mwifiex_wait_queue *
60mwifiex_alloc_fill_wait_queue(struct mwifiex_private *priv,
61 u8 wait_option)
62{
63 struct mwifiex_wait_queue *wait = NULL;
64
65 wait = (struct mwifiex_wait_queue *)
66 kzalloc(sizeof(struct mwifiex_wait_queue), GFP_ATOMIC);
67 if (!wait) {
68 dev_err(priv->adapter->dev, "%s: fail to alloc buffer\n",
69 __func__);
70 return wait;
71 }
72
73 wait->bss_index = priv->bss_index;
74
75 switch (wait_option) {
76 case MWIFIEX_NO_WAIT:
77 wait->enabled = 0;
78 break;
79 case MWIFIEX_IOCTL_WAIT:
80 priv->ioctl_wait_q_woken = false;
81 wait->start_time = jiffies;
82 wait->wait = &priv->ioctl_wait_q;
83 wait->condition = &priv->ioctl_wait_q_woken;
84 wait->enabled = 1;
85 break;
86 case MWIFIEX_CMD_WAIT:
87 priv->cmd_wait_q_woken = false;
88 wait->start_time = jiffies;
89 wait->wait = &priv->cmd_wait_q;
90 wait->condition = &priv->cmd_wait_q_woken;
91 wait->enabled = 1;
92 break;
93 case MWIFIEX_WSTATS_WAIT:
94 priv->w_stats_wait_q_woken = false;
95 wait->start_time = jiffies;
96 wait->wait = &priv->w_stats_wait_q;
97 wait->condition = &priv->w_stats_wait_q_woken;
98 wait->enabled = 1;
99 break;
100 }
101
102 return wait;
103}
104
105/*
106 * Wait queue completion handler. 49 * Wait queue completion handler.
107 * 50 *
108 * This function waits on a particular wait queue. 51 * This function waits on a cmd wait queue. It also cancels the pending
109 * For NO_WAIT option, it returns immediately. It also cancels the 52 * request after waking up, in case of errors.
110 * pending IOCTL request after waking up, in case of errors.
111 */ 53 */
112static void 54int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
113mwifiex_wait_ioctl_complete(struct mwifiex_private *priv,
114 struct mwifiex_wait_queue *wait,
115 u8 wait_option)
116{ 55{
117 bool cancel_flag = false; 56 bool cancel_flag = false;
57 int status = adapter->cmd_wait_q.status;
118 58
119 switch (wait_option) { 59 dev_dbg(adapter->dev, "cmd pending\n");
120 case MWIFIEX_NO_WAIT: 60 atomic_inc(&adapter->cmd_pending);
121 break;
122 case MWIFIEX_IOCTL_WAIT:
123 wait_event_interruptible(priv->ioctl_wait_q,
124 priv->ioctl_wait_q_woken);
125 if (!priv->ioctl_wait_q_woken)
126 cancel_flag = true;
127 break;
128 case MWIFIEX_CMD_WAIT:
129 wait_event_interruptible(priv->cmd_wait_q,
130 priv->cmd_wait_q_woken);
131 if (!priv->cmd_wait_q_woken)
132 cancel_flag = true;
133 break;
134 case MWIFIEX_WSTATS_WAIT:
135 wait_event_interruptible(priv->w_stats_wait_q,
136 priv->w_stats_wait_q_woken);
137 if (!priv->w_stats_wait_q_woken)
138 cancel_flag = true;
139 break;
140 }
141 if (cancel_flag) {
142 mwifiex_cancel_pending_ioctl(priv->adapter, wait);
143 dev_dbg(priv->adapter->dev, "cmd: IOCTL cancel: wait=%p, wait_option=%d\n",
144 wait, wait_option);
145 }
146 61
147 return; 62 /* Status pending, wake up main process */
148} 63 queue_work(adapter->workqueue, &adapter->main_work);
149 64
150/* 65 /* Wait for completion */
151 * The function waits for the request to complete and issues the 66 wait_event_interruptible(adapter->cmd_wait_q.wait,
152 * completion handler, if required. 67 adapter->cmd_wait_q.condition);
153 */ 68 if (!adapter->cmd_wait_q.condition)
154int mwifiex_request_ioctl(struct mwifiex_private *priv, 69 cancel_flag = true;
155 struct mwifiex_wait_queue *wait,
156 int status, u8 wait_option)
157{
158 switch (status) {
159 case -EINPROGRESS:
160 dev_dbg(priv->adapter->dev, "cmd: IOCTL pending: wait=%p, wait_option=%d\n",
161 wait, wait_option);
162 atomic_inc(&priv->adapter->ioctl_pending);
163 /* Status pending, wake up main process */
164 queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
165
166 /* Wait for completion */
167 if (wait_option) {
168 mwifiex_wait_ioctl_complete(priv, wait, wait_option);
169 status = wait->status;
170 }
171 break;
172 case 0:
173 case -1:
174 case -EBUSY:
175 default:
176 break;
177 }
178 return status;
179}
180EXPORT_SYMBOL_GPL(mwifiex_request_ioctl);
181 70
182/* 71 if (cancel_flag) {
183 * IOCTL request handler to set/get MAC address. 72 mwifiex_cancel_pending_ioctl(adapter);
184 * 73 dev_dbg(adapter->dev, "cmd cancel\n");
185 * This function prepares the correct firmware command and
186 * issues it to get the extended version information.
187 */
188static int mwifiex_bss_ioctl_mac_address(struct mwifiex_private *priv,
189 struct mwifiex_wait_queue *wait,
190 u8 action, u8 *mac)
191{
192 int ret = 0;
193
194 if ((action == HostCmd_ACT_GEN_GET) && mac) {
195 memcpy(mac, priv->curr_addr, ETH_ALEN);
196 return 0;
197 } 74 }
75 adapter->cmd_wait_q.status = 0;
198 76
199 /* Send request to firmware */
200 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
201 action, 0, wait, mac);
202 if (!ret)
203 ret = -EINPROGRESS;
204
205 return ret;
206}
207
208/*
209 * Sends IOCTL request to set MAC address.
210 *
211 * This function allocates the IOCTL request buffer, fills it
212 * with requisite parameters and calls the IOCTL handler.
213 */
214int mwifiex_request_set_mac_address(struct mwifiex_private *priv)
215{
216 struct mwifiex_wait_queue *wait = NULL;
217 int status = 0;
218 u8 wait_option = MWIFIEX_CMD_WAIT;
219
220 /* Allocate wait buffer */
221 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
222 if (!wait)
223 return -ENOMEM;
224
225 status = mwifiex_bss_ioctl_mac_address(priv, wait, HostCmd_ACT_GEN_SET,
226 NULL);
227
228 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
229 if (!status)
230 memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
231 else
232 dev_err(priv->adapter->dev, "set mac address failed: status=%d"
233 " error_code=%#x\n", status, wait->status);
234
235 kfree(wait);
236 return status; 77 return status;
237} 78}
238 79
239/* 80/*
240 * IOCTL request handler to set multicast list.
241 *
242 * This function prepares the correct firmware command and 81 * This function prepares the correct firmware command and
243 * issues it to set the multicast list. 82 * issues it to set the multicast list.
244 * 83 *
245 * This function can be used to enable promiscuous mode, or enable all 84 * This function can be used to enable promiscuous mode, or enable all
246 * multicast packets, or to enable selective multicast. 85 * multicast packets, or to enable selective multicast.
247 */ 86 */
248static int 87int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
249mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv, 88 struct mwifiex_multicast_list *mcast_list)
250 struct mwifiex_wait_queue *wait,
251 u16 action,
252 struct mwifiex_multicast_list *mcast_list)
253{ 89{
254 int ret = 0; 90 int ret = 0;
255 u16 old_pkt_filter; 91 u16 old_pkt_filter;
256 92
257 old_pkt_filter = priv->curr_pkt_filter; 93 old_pkt_filter = priv->curr_pkt_filter;
258 if (action == HostCmd_ACT_GEN_GET)
259 return -1;
260 94
261 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) { 95 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
262 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n"); 96 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
@@ -281,16 +115,15 @@ mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv,
281 /* Set multicast addresses to firmware */ 115 /* Set multicast addresses to firmware */
282 if (old_pkt_filter == priv->curr_pkt_filter) { 116 if (old_pkt_filter == priv->curr_pkt_filter) {
283 /* Send request to firmware */ 117 /* Send request to firmware */
284 ret = mwifiex_prepare_cmd(priv, 118 ret = mwifiex_send_cmd_async(priv,
285 HostCmd_CMD_MAC_MULTICAST_ADR, 119 HostCmd_CMD_MAC_MULTICAST_ADR,
286 action, 0, wait, mcast_list); 120 HostCmd_ACT_GEN_SET, 0,
287 if (!ret) 121 mcast_list);
288 ret = -EINPROGRESS;
289 } else { 122 } else {
290 /* Send request to firmware */ 123 /* Send request to firmware */
291 ret = mwifiex_prepare_cmd(priv, 124 ret = mwifiex_send_cmd_async(priv,
292 HostCmd_CMD_MAC_MULTICAST_ADR, 125 HostCmd_CMD_MAC_MULTICAST_ADR,
293 action, 0, NULL, 126 HostCmd_ACT_GEN_SET, 0,
294 mcast_list); 127 mcast_list);
295 } 128 }
296 } 129 }
@@ -300,101 +133,21 @@ mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv,
300 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n", 133 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
301 old_pkt_filter, priv->curr_pkt_filter); 134 old_pkt_filter, priv->curr_pkt_filter);
302 if (old_pkt_filter != priv->curr_pkt_filter) { 135 if (old_pkt_filter != priv->curr_pkt_filter) {
303 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, action, 136 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
304 0, wait, &priv->curr_pkt_filter); 137 HostCmd_ACT_GEN_SET,
305 if (!ret) 138 0, &priv->curr_pkt_filter);
306 ret = -EINPROGRESS;
307 } 139 }
308 140
309 return ret; 141 return ret;
310} 142}
311 143
312/* 144/*
313 * Sends IOCTL request to set multicast list.
314 *
315 * This function allocates the IOCTL request buffer, fills it
316 * with requisite parameters and calls the IOCTL handler.
317 */
318void
319mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
320 struct net_device *dev)
321{
322 struct mwifiex_wait_queue *wait = NULL;
323 struct mwifiex_multicast_list mcast_list;
324 u8 wait_option = MWIFIEX_NO_WAIT;
325 int status = 0;
326
327 /* Allocate wait buffer */
328 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
329 if (!wait)
330 return;
331
332 if (dev->flags & IFF_PROMISC) {
333 mcast_list.mode = MWIFIEX_PROMISC_MODE;
334 } else if (dev->flags & IFF_ALLMULTI ||
335 netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
336 mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
337 } else {
338 mcast_list.mode = MWIFIEX_MULTICAST_MODE;
339 if (netdev_mc_count(dev))
340 mcast_list.num_multicast_addr =
341 mwifiex_copy_mcast_addr(&mcast_list, dev);
342 }
343 status = mwifiex_bss_ioctl_multicast_list(priv, wait,
344 HostCmd_ACT_GEN_SET,
345 &mcast_list);
346
347 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
348 if (wait && status != -EINPROGRESS)
349 kfree(wait);
350
351 return;
352}
353
354/*
355 * IOCTL request handler to disconnect from a BSS/IBSS.
356 */
357static int mwifiex_bss_ioctl_stop(struct mwifiex_private *priv,
358 struct mwifiex_wait_queue *wait, u8 *mac)
359{
360 return mwifiex_deauthenticate(priv, wait, mac);
361}
362
363/*
364 * Sends IOCTL request to disconnect from a BSS.
365 *
366 * This function allocates the IOCTL request buffer, fills it
367 * with requisite parameters and calls the IOCTL handler.
368 */
369int mwifiex_disconnect(struct mwifiex_private *priv, u8 wait_option, u8 *mac)
370{
371 struct mwifiex_wait_queue *wait = NULL;
372 int status = 0;
373
374 /* Allocate wait buffer */
375 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
376 if (!wait)
377 return -ENOMEM;
378
379 status = mwifiex_bss_ioctl_stop(priv, wait, mac);
380
381 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
382
383 kfree(wait);
384 return status;
385}
386EXPORT_SYMBOL_GPL(mwifiex_disconnect);
387
388/*
389 * IOCTL request handler to join a BSS/IBSS.
390 *
391 * In Ad-Hoc mode, the IBSS is created if not found in scan list. 145 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
392 * In both Ad-Hoc and infra mode, an deauthentication is performed 146 * In both Ad-Hoc and infra mode, an deauthentication is performed
393 * first. 147 * first.
394 */ 148 */
395static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv, 149int mwifiex_bss_start(struct mwifiex_private *priv,
396 struct mwifiex_wait_queue *wait, 150 struct mwifiex_ssid_bssid *ssid_bssid)
397 struct mwifiex_ssid_bssid *ssid_bssid)
398{ 151{
399 int ret = 0; 152 int ret = 0;
400 struct mwifiex_adapter *adapter = priv->adapter; 153 struct mwifiex_adapter *adapter = priv->adapter;
@@ -406,7 +159,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
406 159
407 if (priv->bss_mode == NL80211_IFTYPE_STATION) { 160 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
408 /* Infra mode */ 161 /* Infra mode */
409 ret = mwifiex_deauthenticate(priv, NULL, NULL); 162 ret = mwifiex_deauthenticate(priv, NULL);
410 if (ret) 163 if (ret)
411 return ret; 164 return ret;
412 165
@@ -427,7 +180,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
427 /* Clear any past association response stored for 180 /* Clear any past association response stored for
428 * application retrieval */ 181 * application retrieval */
429 priv->assoc_rsp_size = 0; 182 priv->assoc_rsp_size = 0;
430 ret = mwifiex_associate(priv, wait, &adapter->scan_table[i]); 183 ret = mwifiex_associate(priv, &adapter->scan_table[i]);
431 if (ret) 184 if (ret)
432 return ret; 185 return ret;
433 } else { 186 } else {
@@ -441,7 +194,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
441 194
442 /* Exit Adhoc mode first */ 195 /* Exit Adhoc mode first */
443 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n"); 196 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
444 ret = mwifiex_deauthenticate(priv, NULL, NULL); 197 ret = mwifiex_deauthenticate(priv, NULL);
445 if (ret) 198 if (ret)
446 return ret; 199 return ret;
447 200
@@ -460,75 +213,39 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
460 if (i >= 0) { 213 if (i >= 0) {
461 dev_dbg(adapter->dev, "info: network found in scan" 214 dev_dbg(adapter->dev, "info: network found in scan"
462 " list. Joining...\n"); 215 " list. Joining...\n");
463 ret = mwifiex_adhoc_join(priv, wait, 216 ret = mwifiex_adhoc_join(priv, &adapter->scan_table[i]);
464 &adapter->scan_table[i]);
465 if (ret) 217 if (ret)
466 return ret; 218 return ret;
467 } else { /* i >= 0 */ 219 } else { /* i >= 0 */
468 dev_dbg(adapter->dev, "info: Network not found in " 220 dev_dbg(adapter->dev, "info: Network not found in "
469 "the list, creating adhoc with ssid = %s\n", 221 "the list, creating adhoc with ssid = %s\n",
470 ssid_bssid->ssid.ssid); 222 ssid_bssid->ssid.ssid);
471 ret = mwifiex_adhoc_start(priv, wait, 223 ret = mwifiex_adhoc_start(priv, &ssid_bssid->ssid);
472 &ssid_bssid->ssid);
473 if (ret) 224 if (ret)
474 return ret; 225 return ret;
475 } 226 }
476 } 227 }
477 228
478 if (!ret)
479 ret = -EINPROGRESS;
480
481 return ret; 229 return ret;
482} 230}
483 231
484/* 232/*
485 * Sends IOCTL request to connect with a BSS.
486 *
487 * This function allocates the IOCTL request buffer, fills it
488 * with requisite parameters and calls the IOCTL handler.
489 */
490int mwifiex_bss_start(struct mwifiex_private *priv, u8 wait_option,
491 struct mwifiex_ssid_bssid *ssid_bssid)
492{
493 struct mwifiex_wait_queue *wait = NULL;
494 struct mwifiex_ssid_bssid tmp_ssid_bssid;
495 int status = 0;
496
497 /* Stop the O.S. TX queue if needed */
498 if (!netif_queue_stopped(priv->netdev))
499 netif_stop_queue(priv->netdev);
500
501 /* Allocate wait buffer */
502 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
503 if (!wait)
504 return -ENOMEM;
505
506 if (ssid_bssid)
507 memcpy(&tmp_ssid_bssid, ssid_bssid,
508 sizeof(struct mwifiex_ssid_bssid));
509 status = mwifiex_bss_ioctl_start(priv, wait, &tmp_ssid_bssid);
510
511 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
512
513 kfree(wait);
514 return status;
515}
516
517/*
518 * IOCTL request handler to set host sleep configuration. 233 * IOCTL request handler to set host sleep configuration.
519 * 234 *
520 * This function prepares the correct firmware command and 235 * This function prepares the correct firmware command and
521 * issues it. 236 * issues it.
522 */ 237 */
523static int 238int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
524mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv, 239 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
525 struct mwifiex_wait_queue *wait, 240
526 u16 action, struct mwifiex_ds_hs_cfg *hs_cfg)
527{ 241{
528 struct mwifiex_adapter *adapter = priv->adapter; 242 struct mwifiex_adapter *adapter = priv->adapter;
529 int status = 0; 243 int status = 0;
530 u32 prev_cond = 0; 244 u32 prev_cond = 0;
531 245
246 if (!hs_cfg)
247 return -ENOMEM;
248
532 switch (action) { 249 switch (action) {
533 case HostCmd_ACT_GEN_SET: 250 case HostCmd_ACT_GEN_SET:
534 if (adapter->pps_uapsd_mode) { 251 if (adapter->pps_uapsd_mode) {
@@ -561,12 +278,16 @@ mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv,
561 status = -1; 278 status = -1;
562 break; 279 break;
563 } 280 }
564 status = mwifiex_prepare_cmd(priv, 281 if (cmd_type == MWIFIEX_SYNC_CMD)
565 HostCmd_CMD_802_11_HS_CFG_ENH, 282 status = mwifiex_send_cmd_sync(priv,
566 HostCmd_ACT_GEN_SET, 283 HostCmd_CMD_802_11_HS_CFG_ENH,
567 0, wait, &adapter->hs_cfg); 284 HostCmd_ACT_GEN_SET, 0,
568 if (!status) 285 &adapter->hs_cfg);
569 status = -EINPROGRESS; 286 else
287 status = mwifiex_send_cmd_async(priv,
288 HostCmd_CMD_802_11_HS_CFG_ENH,
289 HostCmd_ACT_GEN_SET, 0,
290 &adapter->hs_cfg);
570 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) 291 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
571 /* Restore previous condition */ 292 /* Restore previous condition */
572 adapter->hs_cfg.conditions = 293 adapter->hs_cfg.conditions =
@@ -592,42 +313,12 @@ mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv,
592} 313}
593 314
594/* 315/*
595 * Sends IOCTL request to set Host Sleep parameters.
596 *
597 * This function allocates the IOCTL request buffer, fills it
598 * with requisite parameters and calls the IOCTL handler.
599 */
600int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
601 u8 wait_option,
602 struct mwifiex_ds_hs_cfg *hscfg)
603{
604 int ret = 0;
605 struct mwifiex_wait_queue *wait = NULL;
606
607 if (!hscfg)
608 return -ENOMEM;
609
610 /* Allocate wait buffer */
611 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
612 if (!wait)
613 return -ENOMEM;
614
615 ret = mwifiex_pm_ioctl_hs_cfg(priv, wait, action, hscfg);
616
617 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
618
619 if (wait && (ret != -EINPROGRESS))
620 kfree(wait);
621 return ret;
622}
623
624/*
625 * Sends IOCTL request to cancel the existing Host Sleep configuration. 316 * Sends IOCTL request to cancel the existing Host Sleep configuration.
626 * 317 *
627 * This function allocates the IOCTL request buffer, fills it 318 * This function allocates the IOCTL request buffer, fills it
628 * with requisite parameters and calls the IOCTL handler. 319 * with requisite parameters and calls the IOCTL handler.
629 */ 320 */
630int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option) 321int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
631{ 322{
632 int ret = 0; 323 int ret = 0;
633 struct mwifiex_ds_hs_cfg hscfg; 324 struct mwifiex_ds_hs_cfg hscfg;
@@ -636,7 +327,7 @@ int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option)
636 hscfg.conditions = HOST_SLEEP_CFG_CANCEL; 327 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
637 hscfg.is_invoke_hostcmd = true; 328 hscfg.is_invoke_hostcmd = true;
638 ret = mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET, 329 ret = mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
639 wait_option, &hscfg); 330 cmd_type, &hscfg);
640 331
641 return ret; 332 return ret;
642} 333}
@@ -665,8 +356,8 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
665 356
666 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, 357 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
667 MWIFIEX_BSS_ROLE_STA), 358 MWIFIEX_BSS_ROLE_STA),
668 HostCmd_ACT_GEN_SET, 359 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
669 MWIFIEX_IOCTL_WAIT, &hscfg)) { 360 &hscfg)) {
670 dev_err(adapter->dev, "IOCTL request HS enable failed\n"); 361 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
671 return false; 362 return false;
672 } 363 }
@@ -679,69 +370,6 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
679EXPORT_SYMBOL_GPL(mwifiex_enable_hs); 370EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
680 371
681/* 372/*
682 * IOCTL request handler to get signal information.
683 *
684 * This function prepares the correct firmware command and
685 * issues it to get the signal (RSSI) information.
686 *
687 * This only works in the connected mode.
688 */
689static int mwifiex_get_info_signal(struct mwifiex_private *priv,
690 struct mwifiex_wait_queue *wait,
691 struct mwifiex_ds_get_signal *signal)
692{
693 int ret = 0;
694
695 if (!wait) {
696 dev_err(priv->adapter->dev, "WAIT information is not present\n");
697 return -1;
698 }
699
700 /* Signal info can be obtained only if connected */
701 if (!priv->media_connected) {
702 dev_dbg(priv->adapter->dev,
703 "info: Can not get signal in disconnected state\n");
704 return -1;
705 }
706
707 /* Send request to firmware */
708 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_RSSI_INFO,
709 HostCmd_ACT_GEN_GET, 0, wait, signal);
710
711 if (!ret)
712 ret = -EINPROGRESS;
713
714 return ret;
715}
716
717/*
718 * IOCTL request handler to get statistics.
719 *
720 * This function prepares the correct firmware command and
721 * issues it to get the statistics (RSSI) information.
722 */
723static int mwifiex_get_info_stats(struct mwifiex_private *priv,
724 struct mwifiex_wait_queue *wait,
725 struct mwifiex_ds_get_stats *log)
726{
727 int ret = 0;
728
729 if (!wait) {
730 dev_err(priv->adapter->dev, "MWIFIEX IOCTL information is not present\n");
731 return -1;
732 }
733
734 /* Send request to firmware */
735 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_GET_LOG,
736 HostCmd_ACT_GEN_GET, 0, wait, log);
737
738 if (!ret)
739 ret = -EINPROGRESS;
740
741 return ret;
742}
743
744/*
745 * IOCTL request handler to get BSS information. 373 * IOCTL request handler to get BSS information.
746 * 374 *
747 * This function collates the information from different driver structures 375 * This function collates the information from different driver structures
@@ -813,90 +441,20 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
813} 441}
814 442
815/* 443/*
816 * IOCTL request handler to get extended version information. 444 * The function sets band configurations.
817 *
818 * This function prepares the correct firmware command and
819 * issues it to get the extended version information.
820 */
821static int mwifiex_get_info_ver_ext(struct mwifiex_private *priv,
822 struct mwifiex_wait_queue *wait,
823 struct mwifiex_ver_ext *ver_ext)
824{
825 int ret = 0;
826
827 /* Send request to firmware */
828 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_VERSION_EXT,
829 HostCmd_ACT_GEN_GET, 0, wait, ver_ext);
830 if (!ret)
831 ret = -EINPROGRESS;
832
833 return ret;
834}
835
836/*
837 * IOCTL request handler to set/get SNMP MIB parameters.
838 *
839 * This function prepares the correct firmware command and
840 * issues it.
841 * 445 *
842 * Currently the following parameters are supported - 446 * it performs extra checks to make sure the Ad-Hoc
843 * Set/get RTS Threshold
844 * Set/get fragmentation threshold
845 * Set/get retry count
846 */
847int mwifiex_snmp_mib_ioctl(struct mwifiex_private *priv,
848 struct mwifiex_wait_queue *wait,
849 u32 cmd_oid, u16 action, u32 *value)
850{
851 int ret = 0;
852
853 if (!value)
854 return -1;
855
856 /* Send request to firmware */
857 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB,
858 action, cmd_oid, wait, value);
859
860 if (!ret)
861 ret = -EINPROGRESS;
862
863 return ret;
864}
865
866/*
867 * IOCTL request handler to set/get band configurations.
868 *
869 * For SET operation, it performs extra checks to make sure the Ad-Hoc
870 * band and channel are compatible. Otherwise it returns an error. 447 * band and channel are compatible. Otherwise it returns an error.
871 * 448 *
872 * For GET operation, this function retrieves the following information -
873 * - Infra bands
874 * - Ad-hoc band
875 * - Ad-hoc channel
876 * - Secondary channel offset
877 */ 449 */
878int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *priv, 450int mwifiex_set_radio_band_cfg(struct mwifiex_private *priv,
879 u16 action, 451 struct mwifiex_ds_band_cfg *radio_cfg)
880 struct mwifiex_ds_band_cfg *radio_cfg)
881{ 452{
882 struct mwifiex_adapter *adapter = priv->adapter; 453 struct mwifiex_adapter *adapter = priv->adapter;
883 u8 infra_band = 0; 454 u8 infra_band = 0;
884 u8 adhoc_band = 0; 455 u8 adhoc_band = 0;
885 u32 adhoc_channel = 0; 456 u32 adhoc_channel = 0;
886 457
887 if (action == HostCmd_ACT_GEN_GET) {
888 /* Infra Bands */
889 radio_cfg->config_bands = adapter->config_bands;
890 /* Adhoc Band */
891 radio_cfg->adhoc_start_band = adapter->adhoc_start_band;
892 /* Adhoc channel */
893 radio_cfg->adhoc_channel = priv->adhoc_channel;
894 /* Secondary channel offset */
895 radio_cfg->sec_chan_offset = adapter->chan_offset;
896 return 0;
897 }
898
899 /* For action = SET */
900 infra_band = (u8) radio_cfg->config_bands; 458 infra_band = (u8) radio_cfg->config_bands;
901 adhoc_band = (u8) radio_cfg->adhoc_start_band; 459 adhoc_band = (u8) radio_cfg->adhoc_start_band;
902 adhoc_channel = radio_cfg->adhoc_channel; 460 adhoc_channel = radio_cfg->adhoc_channel;
@@ -950,8 +508,8 @@ int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *priv,
950 * This function performs validity checking on channel/frequency 508 * This function performs validity checking on channel/frequency
951 * compatibility and returns failure if not valid. 509 * compatibility and returns failure if not valid.
952 */ 510 */
953int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action, 511int mwifiex_bss_set_channel(struct mwifiex_private *priv,
954 struct mwifiex_chan_freq_power *chan) 512 struct mwifiex_chan_freq_power *chan)
955{ 513{
956 struct mwifiex_adapter *adapter = priv->adapter; 514 struct mwifiex_adapter *adapter = priv->adapter;
957 struct mwifiex_chan_freq_power *cfp = NULL; 515 struct mwifiex_chan_freq_power *cfp = NULL;
@@ -959,16 +517,6 @@ int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action,
959 if (!chan) 517 if (!chan)
960 return -1; 518 return -1;
961 519
962 if (action == HostCmd_ACT_GEN_GET) {
963 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv,
964 priv->curr_bss_params.band,
965 (u16) priv->curr_bss_params.bss_descriptor.
966 channel);
967 chan->channel = cfp->channel;
968 chan->freq = cfp->freq;
969
970 return 0;
971 }
972 if (!chan->channel && !chan->freq) 520 if (!chan->channel && !chan->freq)
973 return -1; 521 return -1;
974 if (adapter->adhoc_start_band & BAND_AN) 522 if (adapter->adhoc_start_band & BAND_AN)
@@ -1024,7 +572,6 @@ int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action,
1024 * issues it to set or get the ad-hoc channel. 572 * issues it to set or get the ad-hoc channel.
1025 */ 573 */
1026static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv, 574static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1027 struct mwifiex_wait_queue *wait,
1028 u16 action, u16 *channel) 575 u16 action, u16 *channel)
1029{ 576{
1030 int ret = 0; 577 int ret = 0;
@@ -1039,10 +586,8 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1039 } 586 }
1040 587
1041 /* Send request to firmware */ 588 /* Send request to firmware */
1042 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_RF_CHANNEL, 589 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
1043 action, 0, wait, channel); 590 action, 0, channel);
1044 if (!ret)
1045 ret = -EINPROGRESS;
1046 591
1047 return ret; 592 return ret;
1048} 593}
@@ -1054,7 +599,6 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1054 * these are provided, just the best BSS (best RSSI) is returned. 599 * these are provided, just the best BSS (best RSSI) is returned.
1055 */ 600 */
1056int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv, 601int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv,
1057 struct mwifiex_wait_queue *wait,
1058 struct mwifiex_ssid_bssid *ssid_bssid) 602 struct mwifiex_ssid_bssid *ssid_bssid)
1059{ 603{
1060 struct mwifiex_adapter *adapter = priv->adapter; 604 struct mwifiex_adapter *adapter = priv->adapter;
@@ -1114,10 +658,7 @@ int
1114mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel) 658mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1115{ 659{
1116 int ret = 0; 660 int ret = 0;
1117 int status = 0;
1118 struct mwifiex_bss_info bss_info; 661 struct mwifiex_bss_info bss_info;
1119 struct mwifiex_wait_queue *wait = NULL;
1120 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1121 struct mwifiex_ssid_bssid ssid_bssid; 662 struct mwifiex_ssid_bssid ssid_bssid;
1122 u16 curr_chan = 0; 663 u16 curr_chan = 0;
1123 664
@@ -1127,19 +668,10 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1127 if (mwifiex_get_bss_info(priv, &bss_info)) 668 if (mwifiex_get_bss_info(priv, &bss_info))
1128 return -1; 669 return -1;
1129 670
1130 /* Allocate wait buffer */
1131 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1132 if (!wait)
1133 return -ENOMEM;
1134
1135 /* Get current channel */ 671 /* Get current channel */
1136 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_GET, 672 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
1137 &curr_chan); 673 &curr_chan);
1138 674
1139 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1140 ret = -1;
1141 goto done;
1142 }
1143 if (curr_chan == channel) { 675 if (curr_chan == channel) {
1144 ret = 0; 676 ret = 0;
1145 goto done; 677 goto done;
@@ -1154,23 +686,13 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1154 686
1155 /* Do disonnect */ 687 /* Do disonnect */
1156 memset(&ssid_bssid, 0, ETH_ALEN); 688 memset(&ssid_bssid, 0, ETH_ALEN);
1157 status = mwifiex_bss_ioctl_stop(priv, wait, ssid_bssid.bssid); 689 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
1158 690
1159 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) { 691 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
1160 ret = -1; 692 (u16 *) &channel);
1161 goto done;
1162 }
1163
1164 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_SET,
1165 (u16 *) &channel);
1166
1167 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1168 ret = -1;
1169 goto done;
1170 }
1171 693
1172 /* Do specific SSID scanning */ 694 /* Do specific SSID scanning */
1173 if (mwifiex_request_scan(priv, wait_option, &bss_info.ssid)) { 695 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
1174 ret = -1; 696 ret = -1;
1175 goto done; 697 goto done;
1176 } 698 }
@@ -1179,13 +701,8 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1179 memcpy(&ssid_bssid.ssid, &bss_info.ssid, 701 memcpy(&ssid_bssid.ssid, &bss_info.ssid,
1180 sizeof(struct mwifiex_802_11_ssid)); 702 sizeof(struct mwifiex_802_11_ssid));
1181 703
1182 status = mwifiex_bss_ioctl_start(priv, wait, &ssid_bssid); 704 ret = mwifiex_bss_start(priv, &ssid_bssid);
1183
1184 if (mwifiex_request_ioctl(priv, wait, status, wait_option))
1185 ret = -1;
1186
1187done: 705done:
1188 kfree(wait);
1189 return ret; 706 return ret;
1190} 707}
1191 708
@@ -1198,7 +715,6 @@ done:
1198 * for the band. 715 * for the band.
1199 */ 716 */
1200static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv, 717static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1201 struct mwifiex_wait_queue *wait,
1202 struct mwifiex_rate_cfg *rate_cfg) 718 struct mwifiex_rate_cfg *rate_cfg)
1203{ 719{
1204 struct mwifiex_adapter *adapter = priv->adapter; 720 struct mwifiex_adapter *adapter = priv->adapter;
@@ -1242,11 +758,9 @@ static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1242 } 758 }
1243 } else { 759 } else {
1244 /* Send request to firmware */ 760 /* Send request to firmware */
1245 ret = mwifiex_prepare_cmd(priv, 761 ret = mwifiex_send_cmd_sync(priv,
1246 HostCmd_CMD_802_11_TX_RATE_QUERY, 762 HostCmd_CMD_802_11_TX_RATE_QUERY,
1247 HostCmd_ACT_GEN_GET, 0, wait, NULL); 763 HostCmd_ACT_GEN_GET, 0, NULL);
1248 if (!ret)
1249 ret = -EINPROGRESS;
1250 } 764 }
1251 765
1252 return ret; 766 return ret;
@@ -1261,7 +775,6 @@ static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1261 * The function also performs validation checking on the supplied value. 775 * The function also performs validation checking on the supplied value.
1262 */ 776 */
1263static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv, 777static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1264 struct mwifiex_wait_queue *wait,
1265 struct mwifiex_rate_cfg *rate_cfg) 778 struct mwifiex_rate_cfg *rate_cfg)
1266{ 779{
1267 u8 rates[MWIFIEX_SUPPORTED_RATES]; 780 u8 rates[MWIFIEX_SUPPORTED_RATES];
@@ -1316,10 +829,8 @@ static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1316 } 829 }
1317 830
1318 /* Send request to firmware */ 831 /* Send request to firmware */
1319 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TX_RATE_CFG, 832 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
1320 HostCmd_ACT_GEN_SET, 0, wait, bitmap_rates); 833 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
1321 if (!ret)
1322 ret = -EINPROGRESS;
1323 834
1324 return ret; 835 return ret;
1325} 836}
@@ -1331,7 +842,6 @@ static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1331 * rate index. 842 * rate index.
1332 */ 843 */
1333static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv, 844static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
1334 struct mwifiex_wait_queue *wait,
1335 struct mwifiex_rate_cfg *rate_cfg) 845 struct mwifiex_rate_cfg *rate_cfg)
1336{ 846{
1337 int status = 0; 847 int status = 0;
@@ -1340,11 +850,9 @@ static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
1340 return -1; 850 return -1;
1341 851
1342 if (rate_cfg->action == HostCmd_ACT_GEN_GET) 852 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
1343 status = mwifiex_rate_ioctl_get_rate_value( 853 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
1344 priv, wait, rate_cfg);
1345 else 854 else
1346 status = mwifiex_rate_ioctl_set_rate_value( 855 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
1347 priv, wait, rate_cfg);
1348 856
1349 return status; 857 return status;
1350} 858}
@@ -1359,19 +867,11 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1359 struct mwifiex_rate_cfg *rate) 867 struct mwifiex_rate_cfg *rate)
1360{ 868{
1361 int ret = 0; 869 int ret = 0;
1362 struct mwifiex_wait_queue *wait = NULL;
1363 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1364
1365 /* Allocate wait buffer */
1366 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1367 if (!wait)
1368 return -ENOMEM;
1369 870
1370 memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); 871 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
1371 rate->action = HostCmd_ACT_GEN_GET; 872 rate->action = HostCmd_ACT_GEN_GET;
1372 ret = mwifiex_rate_ioctl_cfg(priv, wait, rate); 873 ret = mwifiex_rate_ioctl_cfg(priv, rate);
1373 874
1374 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
1375 if (!ret) { 875 if (!ret) {
1376 if (rate && rate->is_rate_auto) 876 if (rate && rate->is_rate_auto)
1377 rate->rate = mwifiex_index_to_data_rate(priv->adapter, 877 rate->rate = mwifiex_index_to_data_rate(priv->adapter,
@@ -1382,7 +882,6 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1382 ret = -1; 882 ret = -1;
1383 } 883 }
1384 884
1385 kfree(wait);
1386 return ret; 885 return ret;
1387} 886}
1388 887
@@ -1398,9 +897,8 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1398 * - Modulation class HTBW20 897 * - Modulation class HTBW20
1399 * - Modulation class HTBW40 898 * - Modulation class HTBW40
1400 */ 899 */
1401static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv, 900int mwifiex_set_tx_power(struct mwifiex_private *priv,
1402 struct mwifiex_wait_queue *wait, 901 struct mwifiex_power_cfg *power_cfg)
1403 struct mwifiex_power_cfg *power_cfg)
1404{ 902{
1405 int ret = 0; 903 int ret = 0;
1406 struct host_cmd_ds_txpwr_cfg *txp_cfg = NULL; 904 struct host_cmd_ds_txpwr_cfg *txp_cfg = NULL;
@@ -1473,12 +971,10 @@ static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv,
1473 pg->ht_bandwidth = HT_BW_40; 971 pg->ht_bandwidth = HT_BW_40;
1474 } 972 }
1475 /* Send request to firmware */ 973 /* Send request to firmware */
1476 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TXPWR_CFG, 974 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
1477 HostCmd_ACT_GEN_SET, 0, wait, buf); 975 HostCmd_ACT_GEN_SET, 0, buf);
1478 if (!ret)
1479 ret = -EINPROGRESS;
1480 kfree(buf);
1481 976
977 kfree(buf);
1482 return ret; 978 return ret;
1483} 979}
1484 980
@@ -1488,33 +984,23 @@ static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv,
1488 * This function prepares the correct firmware command and 984 * This function prepares the correct firmware command and
1489 * issues it. 985 * issues it.
1490 */ 986 */
1491static int mwifiex_pm_ioctl_ps_mode(struct mwifiex_private *priv, 987int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
1492 struct mwifiex_wait_queue *wait,
1493 u32 *ps_mode, u16 action)
1494{ 988{
1495 int ret = 0; 989 int ret = 0;
1496 struct mwifiex_adapter *adapter = priv->adapter; 990 struct mwifiex_adapter *adapter = priv->adapter;
1497 u16 sub_cmd; 991 u16 sub_cmd;
1498 992
1499 if (action == HostCmd_ACT_GEN_SET) { 993 if (*ps_mode)
1500 if (*ps_mode) 994 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1501 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; 995 else
1502 else 996 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
1503 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; 997 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
1504 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS; 998 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1505 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, 999 sub_cmd, BITMAP_STA_PS, NULL);
1506 sub_cmd, BITMAP_STA_PS, wait, NULL); 1000 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
1507 if ((!ret) && (sub_cmd == DIS_AUTO_PS)) 1001 ret = mwifiex_send_cmd_async(priv,
1508 ret = mwifiex_prepare_cmd(priv, 1002 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS,
1509 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS, 1003 0, NULL);
1510 0, NULL, NULL);
1511 } else {
1512 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1513 GET_PS, 0, wait, NULL);
1514 }
1515
1516 if (!ret)
1517 ret = -EINPROGRESS;
1518 1004
1519 return ret; 1005 return ret;
1520} 1006}
@@ -1600,18 +1086,14 @@ static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1600 * This function prepares the correct firmware command and 1086 * This function prepares the correct firmware command and
1601 * issues it. 1087 * issues it.
1602 */ 1088 */
1603static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_adapter *adapter, 1089static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1604 struct mwifiex_wait_queue *wait,
1605 struct mwifiex_ds_encrypt_key *encrypt_key) 1090 struct mwifiex_ds_encrypt_key *encrypt_key)
1606{ 1091{
1607 int ret = 0; 1092 int ret = 0;
1608 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1609 1093
1610 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1094 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1611 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1095 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1612 wait, encrypt_key); 1096 encrypt_key);
1613 if (!ret)
1614 ret = -EINPROGRESS;
1615 1097
1616 return ret; 1098 return ret;
1617} 1099}
@@ -1622,12 +1104,10 @@ static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_adapter *adapter,
1622 * This function prepares the correct firmware command and 1104 * This function prepares the correct firmware command and
1623 * issues it, after validation checks. 1105 * issues it, after validation checks.
1624 */ 1106 */
1625static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter, 1107static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1626 struct mwifiex_wait_queue *wait,
1627 struct mwifiex_ds_encrypt_key *encrypt_key) 1108 struct mwifiex_ds_encrypt_key *encrypt_key)
1628{ 1109{
1629 int ret = 0; 1110 int ret = 0;
1630 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1631 struct mwifiex_wep_key *wep_key = NULL; 1111 struct mwifiex_wep_key *wep_key = NULL;
1632 int index; 1112 int index;
1633 1113
@@ -1641,7 +1121,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1641 /* Copy the required key as the current key */ 1121 /* Copy the required key as the current key */
1642 wep_key = &priv->wep_key[index]; 1122 wep_key = &priv->wep_key[index];
1643 if (!wep_key->key_length) { 1123 if (!wep_key->key_length) {
1644 dev_err(adapter->dev, 1124 dev_err(priv->adapter->dev,
1645 "key not set, so cannot enable it\n"); 1125 "key not set, so cannot enable it\n");
1646 return -1; 1126 return -1;
1647 } 1127 }
@@ -1661,8 +1141,9 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1661 } 1141 }
1662 if (wep_key->key_length) { 1142 if (wep_key->key_length) {
1663 /* Send request to firmware */ 1143 /* Send request to firmware */
1664 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1144 ret = mwifiex_send_cmd_async(priv,
1665 HostCmd_ACT_GEN_SET, 0, NULL, NULL); 1145 HostCmd_CMD_802_11_KEY_MATERIAL,
1146 HostCmd_ACT_GEN_SET, 0, NULL);
1666 if (ret) 1147 if (ret)
1667 return ret; 1148 return ret;
1668 } 1149 }
@@ -1672,11 +1153,9 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1672 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; 1153 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1673 1154
1674 /* Send request to firmware */ 1155 /* Send request to firmware */
1675 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, 1156 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1676 HostCmd_ACT_GEN_SET, 0, wait, 1157 HostCmd_ACT_GEN_SET, 0,
1677 &priv->curr_pkt_filter); 1158 &priv->curr_pkt_filter);
1678 if (!ret)
1679 ret = -EINPROGRESS;
1680 1159
1681 return ret; 1160 return ret;
1682} 1161}
@@ -1691,18 +1170,16 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1691 * 1170 *
1692 * This function can also be used to disable a currently set key. 1171 * This function can also be used to disable a currently set key.
1693 */ 1172 */
1694static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter, 1173static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1695 struct mwifiex_wait_queue *wait,
1696 struct mwifiex_ds_encrypt_key *encrypt_key) 1174 struct mwifiex_ds_encrypt_key *encrypt_key)
1697{ 1175{
1698 int ret = 0; 1176 int ret = 0;
1699 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1700 u8 remove_key = false; 1177 u8 remove_key = false;
1701 struct host_cmd_ds_802_11_key_material *ibss_key; 1178 struct host_cmd_ds_802_11_key_material *ibss_key;
1702 1179
1703 /* Current driver only supports key length of up to 32 bytes */ 1180 /* Current driver only supports key length of up to 32 bytes */
1704 if (encrypt_key->key_len > MWIFIEX_MAX_KEY_LENGTH) { 1181 if (encrypt_key->key_len > MWIFIEX_MAX_KEY_LENGTH) {
1705 dev_err(adapter->dev, "key length too long\n"); 1182 dev_err(priv->adapter->dev, "key length too long\n");
1706 return -1; 1183 return -1;
1707 } 1184 }
1708 1185
@@ -1713,9 +1190,10 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1713 */ 1190 */
1714 /* Send the key as PTK to firmware */ 1191 /* Send the key as PTK to firmware */
1715 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; 1192 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1716 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1193 ret = mwifiex_send_cmd_async(priv,
1717 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1194 HostCmd_CMD_802_11_KEY_MATERIAL,
1718 NULL, encrypt_key); 1195 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1196 encrypt_key);
1719 if (ret) 1197 if (ret)
1720 return ret; 1198 return ret;
1721 1199
@@ -1740,18 +1218,16 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1740 1218
1741 if (remove_key) 1219 if (remove_key)
1742 /* Send request to firmware */ 1220 /* Send request to firmware */
1743 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1221 ret = mwifiex_send_cmd_sync(priv,
1744 HostCmd_ACT_GEN_SET, 1222 HostCmd_CMD_802_11_KEY_MATERIAL,
1745 !(KEY_INFO_ENABLED), 1223 HostCmd_ACT_GEN_SET, !(KEY_INFO_ENABLED),
1746 wait, encrypt_key); 1224 encrypt_key);
1747 else 1225 else
1748 /* Send request to firmware */ 1226 /* Send request to firmware */
1749 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1227 ret = mwifiex_send_cmd_sync(priv,
1750 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1228 HostCmd_CMD_802_11_KEY_MATERIAL,
1751 wait, encrypt_key); 1229 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1752 1230 encrypt_key);
1753 if (!ret)
1754 ret = -EINPROGRESS;
1755 1231
1756 return ret; 1232 return ret;
1757} 1233}
@@ -1764,21 +1240,16 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1764 */ 1240 */
1765static int 1241static int
1766mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv, 1242mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1767 struct mwifiex_wait_queue *wait,
1768 struct mwifiex_ds_encrypt_key *encrypt_key) 1243 struct mwifiex_ds_encrypt_key *encrypt_key)
1769{ 1244{
1770 int status = 0; 1245 int status = 0;
1771 struct mwifiex_adapter *adapter = priv->adapter;
1772 1246
1773 if (encrypt_key->is_wapi_key) 1247 if (encrypt_key->is_wapi_key)
1774 status = mwifiex_sec_ioctl_set_wapi_key(adapter, wait, 1248 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1775 encrypt_key);
1776 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104) 1249 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1777 status = mwifiex_sec_ioctl_set_wpa_key(adapter, wait, 1250 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1778 encrypt_key);
1779 else 1251 else
1780 status = mwifiex_sec_ioctl_set_wep_key(adapter, wait, 1252 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1781 encrypt_key);
1782 return status; 1253 return status;
1783} 1254}
1784 1255
@@ -1806,94 +1277,31 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1806} 1277}
1807 1278
1808/* 1279/*
1809 * Sends IOCTL request to set Tx power. It can be set to either auto
1810 * or a fixed value.
1811 *
1812 * This function allocates the IOCTL request buffer, fills it
1813 * with requisite parameters and calls the IOCTL handler.
1814 */
1815int
1816mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm)
1817{
1818 struct mwifiex_power_cfg power_cfg;
1819 struct mwifiex_wait_queue *wait = NULL;
1820 int status = 0;
1821 int ret = 0;
1822
1823 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1824 if (!wait)
1825 return -ENOMEM;
1826
1827 if (type == NL80211_TX_POWER_FIXED) {
1828 power_cfg.is_power_auto = 0;
1829 power_cfg.power_level = dbm;
1830 } else {
1831 power_cfg.is_power_auto = 1;
1832 }
1833 status = mwifiex_power_ioctl_set_power(priv, wait, &power_cfg);
1834
1835 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
1836
1837 kfree(wait);
1838 return ret;
1839}
1840
1841/*
1842 * Sends IOCTL request to get scan table.
1843 *
1844 * This function allocates the IOCTL request buffer, fills it
1845 * with requisite parameters and calls the IOCTL handler.
1846 */
1847int mwifiex_get_scan_table(struct mwifiex_private *priv, u8 wait_option,
1848 struct mwifiex_scan_resp *scan_resp)
1849{
1850 struct mwifiex_wait_queue *wait = NULL;
1851 struct mwifiex_scan_resp scan;
1852 int status = 0;
1853
1854 /* Allocate wait buffer */
1855 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1856 if (!wait)
1857 return -ENOMEM;
1858
1859 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_GET,
1860 NULL, &scan);
1861
1862 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1863 if (!status) {
1864 if (scan_resp)
1865 memcpy(scan_resp, &scan,
1866 sizeof(struct mwifiex_scan_resp));
1867 }
1868
1869 if (wait && (status != -EINPROGRESS))
1870 kfree(wait);
1871 return status;
1872}
1873
1874/*
1875 * Sends IOCTL request to get signal information. 1280 * Sends IOCTL request to get signal information.
1876 * 1281 *
1877 * This function allocates the IOCTL request buffer, fills it 1282 * This function allocates the IOCTL request buffer, fills it
1878 * with requisite parameters and calls the IOCTL handler. 1283 * with requisite parameters and calls the IOCTL handler.
1879 */ 1284 */
1880int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option, 1285int mwifiex_get_signal_info(struct mwifiex_private *priv,
1881 struct mwifiex_ds_get_signal *signal) 1286 struct mwifiex_ds_get_signal *signal)
1882{ 1287{
1883 struct mwifiex_ds_get_signal info; 1288 struct mwifiex_ds_get_signal info;
1884 struct mwifiex_wait_queue *wait = NULL;
1885 int status = 0; 1289 int status = 0;
1886 1290
1887 /* Allocate wait buffer */ 1291 memset(&info, 0, sizeof(struct mwifiex_ds_get_signal));
1888 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1889 if (!wait)
1890 return -ENOMEM;
1891
1892 info.selector = ALL_RSSI_INFO_MASK; 1292 info.selector = ALL_RSSI_INFO_MASK;
1893 1293
1894 status = mwifiex_get_info_signal(priv, wait, &info); 1294 /* Signal info can be obtained only if connected */
1295 if (!priv->media_connected) {
1296 dev_dbg(priv->adapter->dev,
1297 "info: Can not get signal in disconnected state\n");
1298 return -1;
1299 }
1300
1301 /* Send request to firmware */
1302 status = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RSSI_INFO,
1303 HostCmd_ACT_GEN_GET, 0, signal);
1895 1304
1896 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1897 if (!status) { 1305 if (!status) {
1898 if (signal) 1306 if (signal)
1899 memcpy(signal, &info, 1307 memcpy(signal, &info,
@@ -1904,8 +1312,6 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option,
1904 priv->w_stats.qual.noise = info.bcn_nf_avg; 1312 priv->w_stats.qual.noise = info.bcn_nf_avg;
1905 } 1313 }
1906 1314
1907 if (wait && (status != -EINPROGRESS))
1908 kfree(wait);
1909 return status; 1315 return status;
1910} 1316}
1911 1317
@@ -1918,15 +1324,9 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option,
1918int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, 1324int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1919 int key_len, u8 key_index, int disable) 1325 int key_len, u8 key_index, int disable)
1920{ 1326{
1921 struct mwifiex_wait_queue *wait = NULL;
1922 struct mwifiex_ds_encrypt_key encrypt_key; 1327 struct mwifiex_ds_encrypt_key encrypt_key;
1923 int status = 0;
1924 int ret = 0; 1328 int ret = 0;
1925 1329
1926 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1927 if (!wait)
1928 return -ENOMEM;
1929
1930 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key)); 1330 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1931 encrypt_key.key_len = key_len; 1331 encrypt_key.key_len = key_len;
1932 if (!disable) { 1332 if (!disable) {
@@ -1937,40 +1337,8 @@ int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1937 encrypt_key.key_disable = true; 1337 encrypt_key.key_disable = true;
1938 } 1338 }
1939 1339
1940 status = mwifiex_sec_ioctl_encrypt_key(priv, wait, &encrypt_key); 1340 ret = mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1941
1942 if (mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT))
1943 ret = -EFAULT;
1944
1945 kfree(wait);
1946 return ret;
1947}
1948
1949/*
1950 * Sends IOCTL request to set power management parameters.
1951 *
1952 * This function allocates the IOCTL request buffer, fills it
1953 * with requisite parameters and calls the IOCTL handler.
1954 */
1955int
1956mwifiex_drv_set_power(struct mwifiex_private *priv, bool power_on)
1957{
1958 int ret = 0;
1959 int status = 0;
1960 struct mwifiex_wait_queue *wait = NULL;
1961 u32 ps_mode;
1962
1963 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1964 if (!wait)
1965 return -ENOMEM;
1966
1967 ps_mode = power_on;
1968 status = mwifiex_pm_ioctl_ps_mode(priv, wait, &ps_mode,
1969 HostCmd_ACT_GEN_SET);
1970 1341
1971 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
1972
1973 kfree(wait);
1974 return ret; 1342 return ret;
1975} 1343}
1976 1344
@@ -1984,26 +1352,17 @@ int
1984mwifiex_get_ver_ext(struct mwifiex_private *priv) 1352mwifiex_get_ver_ext(struct mwifiex_private *priv)
1985{ 1353{
1986 struct mwifiex_ver_ext ver_ext; 1354 struct mwifiex_ver_ext ver_ext;
1987 struct mwifiex_wait_queue *wait = NULL;
1988 int status = 0;
1989 int ret = 0; 1355 int ret = 0;
1990 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1991
1992 /* Allocate wait buffer */
1993 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1994 if (!wait)
1995 return -ENOMEM;
1996 1356
1997 /* get fw version */ 1357 /* get fw version */
1998 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext)); 1358 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
1999 status = mwifiex_get_info_ver_ext(priv, wait, &ver_ext); 1359 /* Send request to firmware */
2000 1360 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
2001 ret = mwifiex_request_ioctl(priv, wait, status, wait_option); 1361 HostCmd_ACT_GEN_GET, 0, &ver_ext);
2002 1362
2003 if (ret) 1363 if (ret)
2004 ret = -1; 1364 ret = -1;
2005 1365
2006 kfree(wait);
2007 return ret; 1366 return ret;
2008} 1367}
2009 1368
@@ -2018,21 +1377,13 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2018 struct mwifiex_ds_get_stats *log) 1377 struct mwifiex_ds_get_stats *log)
2019{ 1378{
2020 int ret = 0; 1379 int ret = 0;
2021 int status = 0;
2022 struct mwifiex_wait_queue *wait = NULL;
2023 struct mwifiex_ds_get_stats get_log; 1380 struct mwifiex_ds_get_stats get_log;
2024 u8 wait_option = MWIFIEX_IOCTL_WAIT;
2025
2026 /* Allocate wait buffer */
2027 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2028 if (!wait)
2029 return -ENOMEM;
2030 1381
2031 memset(&get_log, 0, sizeof(struct mwifiex_ds_get_stats)); 1382 memset(&get_log, 0, sizeof(struct mwifiex_ds_get_stats));
2032 status = mwifiex_get_info_stats(priv, wait, &get_log); 1383 /* Send request to firmware */
1384 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1385 HostCmd_ACT_GEN_GET, 0, &get_log);
2033 1386
2034 /* Send IOCTL request to MWIFIEX */
2035 ret = mwifiex_request_ioctl(priv, wait, status, wait_option);
2036 if (!ret) { 1387 if (!ret) {
2037 if (log) 1388 if (log)
2038 memcpy(log, &get_log, sizeof(struct 1389 memcpy(log, &get_log, sizeof(struct
@@ -2042,7 +1393,6 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2042 priv->w_stats.discard.misc = get_log.ack_failure; 1393 priv->w_stats.discard.misc = get_log.ack_failure;
2043 } 1394 }
2044 1395
2045 kfree(wait);
2046 return ret; 1396 return ret;
2047} 1397}
2048 1398
@@ -2060,7 +1410,6 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2060 * - CAU 1410 * - CAU
2061 */ 1411 */
2062static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv, 1412static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
2063 struct mwifiex_wait_queue *wait,
2064 struct mwifiex_ds_reg_rw *reg_rw, 1413 struct mwifiex_ds_reg_rw *reg_rw,
2065 u16 action) 1414 u16 action)
2066{ 1415{
@@ -2088,10 +1437,7 @@ static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
2088 } 1437 }
2089 1438
2090 /* Send request to firmware */ 1439 /* Send request to firmware */
2091 ret = mwifiex_prepare_cmd(priv, cmd_no, action, 0, wait, reg_rw); 1440 ret = mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
2092
2093 if (!ret)
2094 ret = -EINPROGRESS;
2095 1441
2096 return ret; 1442 return ret;
2097} 1443}
@@ -2107,23 +1453,13 @@ mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
2107 u32 reg_offset, u32 reg_value) 1453 u32 reg_offset, u32 reg_value)
2108{ 1454{
2109 int ret = 0; 1455 int ret = 0;
2110 int status = 0;
2111 struct mwifiex_wait_queue *wait = NULL;
2112 struct mwifiex_ds_reg_rw reg_rw; 1456 struct mwifiex_ds_reg_rw reg_rw;
2113 1457
2114 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2115 if (!wait)
2116 return -ENOMEM;
2117
2118 reg_rw.type = cpu_to_le32(reg_type); 1458 reg_rw.type = cpu_to_le32(reg_type);
2119 reg_rw.offset = cpu_to_le32(reg_offset); 1459 reg_rw.offset = cpu_to_le32(reg_offset);
2120 reg_rw.value = cpu_to_le32(reg_value); 1460 reg_rw.value = cpu_to_le32(reg_value);
2121 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, &reg_rw, 1461 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, &reg_rw, HostCmd_ACT_GEN_SET);
2122 HostCmd_ACT_GEN_SET);
2123 1462
2124 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2125
2126 kfree(wait);
2127 return ret; 1463 return ret;
2128} 1464}
2129 1465
@@ -2138,50 +1474,18 @@ mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
2138 u32 reg_offset, u32 *value) 1474 u32 reg_offset, u32 *value)
2139{ 1475{
2140 int ret = 0; 1476 int ret = 0;
2141 int status = 0;
2142 struct mwifiex_wait_queue *wait = NULL;
2143 struct mwifiex_ds_reg_rw reg_rw; 1477 struct mwifiex_ds_reg_rw reg_rw;
2144 1478
2145 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2146 if (!wait)
2147 return -ENOMEM;
2148
2149 reg_rw.type = cpu_to_le32(reg_type); 1479 reg_rw.type = cpu_to_le32(reg_type);
2150 reg_rw.offset = cpu_to_le32(reg_offset); 1480 reg_rw.offset = cpu_to_le32(reg_offset);
2151 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, &reg_rw, 1481 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, &reg_rw, HostCmd_ACT_GEN_GET);
2152 HostCmd_ACT_GEN_GET);
2153 1482
2154 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2155 if (ret) 1483 if (ret)
2156 goto done; 1484 goto done;
2157 1485
2158 *value = le32_to_cpu(reg_rw.value); 1486 *value = le32_to_cpu(reg_rw.value);
2159 1487
2160done: 1488done:
2161 kfree(wait);
2162 return ret;
2163}
2164
2165/*
2166 * IOCTL request handler to read EEPROM.
2167 *
2168 * This function prepares the correct firmware command and
2169 * issues it.
2170 */
2171static int
2172mwifiex_reg_mem_ioctl_read_eeprom(struct mwifiex_private *priv,
2173 struct mwifiex_wait_queue *wait,
2174 struct mwifiex_ds_read_eeprom *rd_eeprom)
2175{
2176 int ret = 0;
2177
2178 /* Send request to firmware */
2179 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
2180 HostCmd_ACT_GEN_GET, 0, wait, rd_eeprom);
2181
2182 if (!ret)
2183 ret = -EINPROGRESS;
2184
2185 return ret; 1489 return ret;
2186} 1490}
2187 1491
@@ -2196,25 +1500,17 @@ mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
2196 u8 *value) 1500 u8 *value)
2197{ 1501{
2198 int ret = 0; 1502 int ret = 0;
2199 int status = 0;
2200 struct mwifiex_wait_queue *wait = NULL;
2201 struct mwifiex_ds_read_eeprom rd_eeprom; 1503 struct mwifiex_ds_read_eeprom rd_eeprom;
2202 1504
2203 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2204 if (!wait)
2205 return -ENOMEM;
2206
2207 rd_eeprom.offset = cpu_to_le16((u16) offset); 1505 rd_eeprom.offset = cpu_to_le16((u16) offset);
2208 rd_eeprom.byte_count = cpu_to_le16((u16) bytes); 1506 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
2209 status = mwifiex_reg_mem_ioctl_read_eeprom(priv, wait, &rd_eeprom);
2210 1507
2211 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT); 1508 /* Send request to firmware */
2212 if (ret) 1509 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
2213 goto done; 1510 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
2214 1511
2215 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA); 1512 if (!ret)
2216done: 1513 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
2217 kfree(wait);
2218 return ret; 1514 return ret;
2219} 1515}
2220 1516
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c
index e8db6bd021c6..b261d812c4d3 100644
--- a/drivers/net/wireless/mwifiex/sta_tx.c
+++ b/drivers/net/wireless/mwifiex/sta_tx.c
@@ -51,7 +51,7 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv,
51 if (!skb->len) { 51 if (!skb->len) {
52 dev_err(adapter->dev, "Tx: bad packet length: %d\n", 52 dev_err(adapter->dev, "Tx: bad packet length: %d\n",
53 skb->len); 53 skb->len);
54 tx_info->status_code = MWIFIEX_ERROR_PKT_SIZE_INVALID; 54 tx_info->status_code = -1;
55 return skb->data; 55 return skb->data;
56 } 56 }
57 57
diff --git a/drivers/net/wireless/mwifiex/util.c b/drivers/net/wireless/mwifiex/util.c
index 205022aa52f5..9f65587622fd 100644
--- a/drivers/net/wireless/mwifiex/util.c
+++ b/drivers/net/wireless/mwifiex/util.c
@@ -55,17 +55,12 @@ int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter)
55} 55}
56 56
57/* 57/*
58 * IOCTL request handler to send function init/shutdown command 58 * This function sends init/shutdown command
59 * to firmware. 59 * to firmware.
60 *
61 * This function prepares the correct firmware command and
62 * issues it.
63 */ 60 */
64int mwifiex_misc_ioctl_init_shutdown(struct mwifiex_adapter *adapter, 61int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
65 struct mwifiex_wait_queue *wait, 62 u32 func_init_shutdown)
66 u32 func_init_shutdown)
67{ 63{
68 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
69 int ret; 64 int ret;
70 u16 cmd; 65 u16 cmd;
71 66
@@ -74,19 +69,16 @@ int mwifiex_misc_ioctl_init_shutdown(struct mwifiex_adapter *adapter,
74 } else if (func_init_shutdown == MWIFIEX_FUNC_SHUTDOWN) { 69 } else if (func_init_shutdown == MWIFIEX_FUNC_SHUTDOWN) {
75 cmd = HostCmd_CMD_FUNC_SHUTDOWN; 70 cmd = HostCmd_CMD_FUNC_SHUTDOWN;
76 } else { 71 } else {
77 dev_err(adapter->dev, "unsupported parameter\n"); 72 dev_err(priv->adapter->dev, "unsupported parameter\n");
78 return -1; 73 return -1;
79 } 74 }
80 75
81 /* Send command to firmware */ 76 /* Send command to firmware */
82 ret = mwifiex_prepare_cmd(priv, cmd, HostCmd_ACT_GEN_SET, 77 ret = mwifiex_send_cmd_sync(priv, cmd, HostCmd_ACT_GEN_SET, 0, NULL);
83 0, wait, NULL);
84
85 if (!ret)
86 ret = -EINPROGRESS;
87 78
88 return ret; 79 return ret;
89} 80}
81EXPORT_SYMBOL_GPL(mwifiex_init_shutdown_fw);
90 82
91/* 83/*
92 * IOCTL request handler to set/get debug information. 84 * IOCTL request handler to set/get debug information.
@@ -222,31 +214,18 @@ int mwifiex_recv_complete(struct mwifiex_adapter *adapter,
222 * corresponding waiting function. Otherwise, it processes the 214 * corresponding waiting function. Otherwise, it processes the
223 * IOCTL response and frees the response buffer. 215 * IOCTL response and frees the response buffer.
224 */ 216 */
225int mwifiex_ioctl_complete(struct mwifiex_adapter *adapter, 217int mwifiex_complete_cmd(struct mwifiex_adapter *adapter)
226 struct mwifiex_wait_queue *wait_queue,
227 int status)
228{ 218{
229 enum mwifiex_error_code status_code = 219 atomic_dec(&adapter->cmd_pending);
230 (enum mwifiex_error_code) wait_queue->status; 220 dev_dbg(adapter->dev, "cmd completed: status=%d\n",
231 221 adapter->cmd_wait_q.status);
232 atomic_dec(&adapter->ioctl_pending);
233 222
234 dev_dbg(adapter->dev, "cmd: IOCTL completed: status=%d," 223 adapter->cmd_wait_q.condition = true;
235 " status_code=%#x\n", status, status_code);
236 224
237 if (wait_queue->enabled) { 225 if (adapter->cmd_wait_q.status == -ETIMEDOUT)
238 *wait_queue->condition = true; 226 dev_err(adapter->dev, "cmd timeout\n");
239 wait_queue->status = status; 227 else
240 if (status && (status_code == MWIFIEX_ERROR_CMD_TIMEOUT)) 228 wake_up_interruptible(&adapter->cmd_wait_q.wait);
241 dev_err(adapter->dev, "cmd timeout\n");
242 else
243 wake_up_interruptible(wait_queue->wait);
244 } else {
245 if (status)
246 dev_err(adapter->dev, "cmd failed: status_code=%#x\n",
247 status_code);
248 kfree(wait_queue);
249 }
250 229
251 return 0; 230 return 0;
252} 231}