aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/cmdevt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/mwifiex/cmdevt.c')
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c194
1 files changed, 75 insertions, 119 deletions
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index a9aeb31af455..776146a104ec 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,39 +87,13 @@ 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);
94 cmd_node->resp_skb = NULL; 95 cmd_node->resp_skb = NULL;
95 } 96 }
96
97 return;
98}
99
100/*
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} 97}
123 98
124/* 99/*
@@ -155,7 +130,6 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
155 struct mwifiex_adapter *adapter = priv->adapter; 130 struct mwifiex_adapter *adapter = priv->adapter;
156 int ret = 0; 131 int ret = 0;
157 struct host_cmd_ds_command *host_cmd; 132 struct host_cmd_ds_command *host_cmd;
158 struct mwifiex_wait_queue *wait_queue = NULL;
159 uint16_t cmd_code; 133 uint16_t cmd_code;
160 uint16_t cmd_size; 134 uint16_t cmd_size;
161 struct timeval tstamp; 135 struct timeval tstamp;
@@ -165,15 +139,13 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
165 return -1; 139 return -1;
166 140
167 host_cmd = (struct host_cmd_ds_command *) (cmd_node->cmd_skb->data); 141 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 142
171 /* Sanity test */ 143 /* Sanity test */
172 if (host_cmd == NULL || host_cmd->size == 0) { 144 if (host_cmd == NULL || host_cmd->size == 0) {
173 dev_err(adapter->dev, "DNLD_CMD: host_cmd is null" 145 dev_err(adapter->dev, "DNLD_CMD: host_cmd is null"
174 " or cmd size is 0, not sending\n"); 146 " or cmd size is 0, not sending\n");
175 if (wait_queue) 147 if (cmd_node->wait_q_enabled)
176 wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL; 148 adapter->cmd_wait_q.status = -1;
177 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 149 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
178 return -1; 150 return -1;
179 } 151 }
@@ -206,10 +178,12 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
206 cmd_node->cmd_skb->data, 178 cmd_node->cmd_skb->data,
207 cmd_node->cmd_skb->len, NULL); 179 cmd_node->cmd_skb->len, NULL);
208 180
181 skb_pull(cmd_node->cmd_skb, INTF_HEADER_LEN);
182
209 if (ret == -1) { 183 if (ret == -1) {
210 dev_err(adapter->dev, "DNLD_CMD: host to card failed\n"); 184 dev_err(adapter->dev, "DNLD_CMD: host to card failed\n");
211 if (wait_queue) 185 if (cmd_node->wait_q_enabled)
212 wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL; 186 adapter->cmd_wait_q.status = -1;
213 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 187 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
214 188
215 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 189 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
@@ -435,7 +409,31 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
435} 409}
436 410
437/* 411/*
438 * This function prepares a command before sending it to the firmware. 412 * This function is used to send synchronous command to the firmware.
413 *
414 * it allocates a wait queue for the command and wait for the command
415 * response.
416 */
417int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
418 u16 cmd_action, u32 cmd_oid, void *data_buf)
419{
420 int ret = 0;
421 struct mwifiex_adapter *adapter = priv->adapter;
422
423 adapter->cmd_wait_q_required = true;
424 adapter->cmd_wait_q.condition = false;
425
426 ret = mwifiex_send_cmd_async(priv, cmd_no, cmd_action, cmd_oid,
427 data_buf);
428 if (!ret)
429 ret = mwifiex_wait_queue_complete(adapter);
430
431 return ret;
432}
433
434
435/*
436 * This function prepares a command and asynchronously send it to the firmware.
439 * 437 *
440 * Preparation includes - 438 * Preparation includes -
441 * - Sanity tests to make sure the card is still present or the FW 439 * - Sanity tests to make sure the card is still present or the FW
@@ -445,9 +443,8 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter)
445 * - Fill up the non-default parameters and buffer pointers 443 * - Fill up the non-default parameters and buffer pointers
446 * - Add the command to pending queue 444 * - Add the command to pending queue
447 */ 445 */
448int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, 446int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
449 u16 cmd_action, u32 cmd_oid, 447 u16 cmd_action, u32 cmd_oid, void *data_buf)
450 void *wait_queue, void *data_buf)
451{ 448{
452 int ret = 0; 449 int ret = 0;
453 struct mwifiex_adapter *adapter = priv->adapter; 450 struct mwifiex_adapter *adapter = priv->adapter;
@@ -485,7 +482,7 @@ int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
485 } 482 }
486 483
487 /* Initialize the command node */ 484 /* Initialize the command node */
488 mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, wait_queue, data_buf); 485 mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, data_buf);
489 486
490 if (!cmd_node->cmd_skb) { 487 if (!cmd_node->cmd_skb) {
491 dev_err(adapter->dev, "PREP_CMD: no free cmd buf\n"); 488 dev_err(adapter->dev, "PREP_CMD: no free cmd buf\n");
@@ -535,18 +532,13 @@ void
535mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, 532mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
536 struct cmd_ctrl_node *cmd_node) 533 struct cmd_ctrl_node *cmd_node)
537{ 534{
538 struct mwifiex_wait_queue *wait_queue = NULL;
539 unsigned long flags; 535 unsigned long flags;
540 536
541 if (cmd_node == NULL) 537 if (!cmd_node)
542 return; 538 return;
543 if (cmd_node->wq_buf) { 539
544 wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf; 540 if (cmd_node->wait_q_enabled)
545 if (wait_queue->status != MWIFIEX_ERROR_NO_ERROR) 541 mwifiex_complete_cmd(adapter);
546 mwifiex_ioctl_complete(adapter, wait_queue, -1);
547 else
548 mwifiex_ioctl_complete(adapter, wait_queue, 0);
549 }
550 /* Clean the node */ 542 /* Clean the node */
551 mwifiex_clean_cmd_node(adapter, cmd_node); 543 mwifiex_clean_cmd_node(adapter, cmd_node);
552 544
@@ -554,8 +546,6 @@ mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
554 spin_lock_irqsave(&adapter->cmd_free_q_lock, flags); 546 spin_lock_irqsave(&adapter->cmd_free_q_lock, flags);
555 list_add_tail(&cmd_node->list, &adapter->cmd_free_q); 547 list_add_tail(&cmd_node->list, &adapter->cmd_free_q);
556 spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags); 548 spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags);
557
558 return;
559} 549}
560 550
561/* 551/*
@@ -600,8 +590,6 @@ mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
600 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); 590 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
601 591
602 dev_dbg(adapter->dev, "cmd: QUEUE_CMD: cmd=%#x is queued\n", command); 592 dev_dbg(adapter->dev, "cmd: QUEUE_CMD: cmd=%#x is queued\n", command);
603
604 return;
605} 593}
606 594
607/* 595/*
@@ -692,7 +680,6 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
692 uint16_t orig_cmdresp_no; 680 uint16_t orig_cmdresp_no;
693 uint16_t cmdresp_no; 681 uint16_t cmdresp_no;
694 uint16_t cmdresp_result; 682 uint16_t cmdresp_result;
695 struct mwifiex_wait_queue *wait_queue = NULL;
696 struct timeval tstamp; 683 struct timeval tstamp;
697 unsigned long flags; 684 unsigned long flags;
698 685
@@ -706,10 +693,6 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
706 return -1; 693 return -1;
707 } 694 }
708 695
709 if (adapter->curr_cmd->wq_buf)
710 wait_queue = (struct mwifiex_wait_queue *)
711 adapter->curr_cmd->wq_buf;
712
713 adapter->num_cmd_timeout = 0; 696 adapter->num_cmd_timeout = 0;
714 697
715 resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data; 698 resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data;
@@ -764,8 +747,8 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
764 747
765 if (!(orig_cmdresp_no & HostCmd_RET_BIT)) { 748 if (!(orig_cmdresp_no & HostCmd_RET_BIT)) {
766 dev_err(adapter->dev, "CMD_RESP: invalid cmd resp\n"); 749 dev_err(adapter->dev, "CMD_RESP: invalid cmd resp\n");
767 if (wait_queue) 750 if (adapter->curr_cmd->wait_q_enabled)
768 wait_queue->status = MWIFIEX_ERROR_FW_CMDRESP; 751 adapter->cmd_wait_q.status = -1;
769 752
770 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 753 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
771 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 754 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
@@ -781,8 +764,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
781 ret = mwifiex_ret_802_11_hs_cfg(priv, resp); 764 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
782 } else { 765 } else {
783 /* handle response */ 766 /* handle response */
784 ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp, 767 ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp);
785 wait_queue);
786 } 768 }
787 769
788 /* Check init command response */ 770 /* Check init command response */
@@ -797,10 +779,10 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
797 } 779 }
798 780
799 if (adapter->curr_cmd) { 781 if (adapter->curr_cmd) {
800 if (wait_queue && (!ret)) 782 if (adapter->curr_cmd->wait_q_enabled && (!ret))
801 wait_queue->status = MWIFIEX_ERROR_NO_ERROR; 783 adapter->cmd_wait_q.status = 0;
802 else if (wait_queue && (ret == -1)) 784 else if (adapter->curr_cmd->wait_q_enabled && (ret == -1))
803 wait_queue->status = MWIFIEX_ERROR_CMD_RESP_FAIL; 785 adapter->cmd_wait_q.status = -1;
804 786
805 /* Clean up and put current command back to cmd_free_q */ 787 /* Clean up and put current command back to cmd_free_q */
806 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); 788 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
@@ -824,7 +806,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
824 struct mwifiex_adapter *adapter = 806 struct mwifiex_adapter *adapter =
825 (struct mwifiex_adapter *) function_context; 807 (struct mwifiex_adapter *) function_context;
826 struct cmd_ctrl_node *cmd_node = NULL; 808 struct cmd_ctrl_node *cmd_node = NULL;
827 struct mwifiex_wait_queue *wait_queue = NULL;
828 struct timeval tstamp; 809 struct timeval tstamp;
829 810
830 adapter->num_cmd_timeout++; 811 adapter->num_cmd_timeout++;
@@ -834,10 +815,8 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
834 return; 815 return;
835 } 816 }
836 cmd_node = adapter->curr_cmd; 817 cmd_node = adapter->curr_cmd;
837 if (cmd_node->wq_buf) { 818 if (cmd_node->wait_q_enabled)
838 wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf; 819 adapter->cmd_wait_q.status = -ETIMEDOUT;
839 wait_queue->status = MWIFIEX_ERROR_CMD_TIMEOUT;
840 }
841 820
842 if (cmd_node) { 821 if (cmd_node) {
843 adapter->dbg.timeout_cmd_id = 822 adapter->dbg.timeout_cmd_id =
@@ -886,8 +865,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
886 } 865 }
887 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) 866 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
888 mwifiex_init_fw_complete(adapter); 867 mwifiex_init_fw_complete(adapter);
889
890 return;
891} 868}
892 869
893/* 870/*
@@ -901,18 +878,15 @@ void
901mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter) 878mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
902{ 879{
903 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 880 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
904 struct mwifiex_wait_queue *wait_queue = NULL;
905 unsigned long flags; 881 unsigned long flags;
906 882
907 /* Cancel current cmd */ 883 /* Cancel current cmd */
908 if ((adapter->curr_cmd) && (adapter->curr_cmd->wq_buf)) { 884 if ((adapter->curr_cmd) && (adapter->curr_cmd->wait_q_enabled)) {
909 wait_queue =
910 (struct mwifiex_wait_queue *) adapter->curr_cmd->wq_buf;
911 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 885 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
912 adapter->curr_cmd->wq_buf = NULL; 886 adapter->curr_cmd->wait_q_enabled = false;
913 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); 887 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
914 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 888 adapter->cmd_wait_q.status = -1;
915 mwifiex_ioctl_complete(adapter, wait_queue, -1); 889 mwifiex_complete_cmd(adapter);
916 } 890 }
917 /* Cancel all pending command */ 891 /* Cancel all pending command */
918 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); 892 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
@@ -921,12 +895,10 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
921 list_del(&cmd_node->list); 895 list_del(&cmd_node->list);
922 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); 896 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
923 897
924 if (cmd_node->wq_buf) { 898 if (cmd_node->wait_q_enabled) {
925 wait_queue = 899 adapter->cmd_wait_q.status = -1;
926 (struct mwifiex_wait_queue *) cmd_node->wq_buf; 900 mwifiex_complete_cmd(adapter);
927 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 901 cmd_node->wait_q_enabled = false;
928 mwifiex_ioctl_complete(adapter, wait_queue, -1);
929 cmd_node->wq_buf = NULL;
930 } 902 }
931 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 903 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
932 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); 904 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
@@ -940,7 +912,7 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
940 list_del(&cmd_node->list); 912 list_del(&cmd_node->list);
941 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 913 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
942 914
943 cmd_node->wq_buf = NULL; 915 cmd_node->wait_q_enabled = false;
944 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 916 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
945 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 917 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
946 } 918 }
@@ -962,8 +934,7 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
962 * are cancelled. 934 * are cancelled.
963 */ 935 */
964void 936void
965mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter, 937mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
966 struct mwifiex_wait_queue *wait_queue)
967{ 938{
968 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; 939 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
969 unsigned long cmd_flags; 940 unsigned long cmd_flags;
@@ -972,45 +943,33 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
972 uint16_t cancel_scan_cmd = false; 943 uint16_t cancel_scan_cmd = false;
973 944
974 if ((adapter->curr_cmd) && 945 if ((adapter->curr_cmd) &&
975 (adapter->curr_cmd->wq_buf == wait_queue)) { 946 (adapter->curr_cmd->wait_q_enabled)) {
976 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags); 947 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
977 cmd_node = adapter->curr_cmd; 948 cmd_node = adapter->curr_cmd;
978 cmd_node->wq_buf = NULL; 949 cmd_node->wait_q_enabled = false;
979 cmd_node->cmd_flag |= CMD_F_CANCELED; 950 cmd_node->cmd_flag |= CMD_F_CANCELED;
980 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
981 }
982
983 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
984 while (1) {
985 cmd_node = mwifiex_get_pending_ioctl_cmd(adapter, wait_queue);
986 if (!cmd_node)
987 break;
988
989 spin_lock_irqsave(&adapter->cmd_pending_q_lock, 951 spin_lock_irqsave(&adapter->cmd_pending_q_lock,
990 cmd_pending_q_flags); 952 cmd_pending_q_flags);
991 list_del(&cmd_node->list); 953 list_del(&cmd_node->list);
992 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, 954 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
993 cmd_pending_q_flags); 955 cmd_pending_q_flags);
994
995 cmd_node->wq_buf = NULL;
996 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 956 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
957 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
997 } 958 }
998 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 959
999 /* Cancel all pending scan command */ 960 /* Cancel all pending scan command */
1000 spin_lock_irqsave(&adapter->scan_pending_q_lock, 961 spin_lock_irqsave(&adapter->scan_pending_q_lock,
1001 scan_pending_q_flags); 962 scan_pending_q_flags);
1002 list_for_each_entry_safe(cmd_node, tmp_node, 963 list_for_each_entry_safe(cmd_node, tmp_node,
1003 &adapter->scan_pending_q, list) { 964 &adapter->scan_pending_q, list) {
1004 if (cmd_node->wq_buf == wait_queue) { 965 list_del(&cmd_node->list);
1005 list_del(&cmd_node->list); 966 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1006 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 967 scan_pending_q_flags);
1007 scan_pending_q_flags); 968 cmd_node->wait_q_enabled = false;
1008 cmd_node->wq_buf = NULL; 969 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
1009 mwifiex_insert_cmd_to_free_q(adapter, cmd_node); 970 spin_lock_irqsave(&adapter->scan_pending_q_lock,
1010 spin_lock_irqsave(&adapter->scan_pending_q_lock, 971 scan_pending_q_flags);
1011 scan_pending_q_flags); 972 cancel_scan_cmd = true;
1012 cancel_scan_cmd = true;
1013 }
1014 } 973 }
1015 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 974 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
1016 scan_pending_q_flags); 975 scan_pending_q_flags);
@@ -1020,10 +979,8 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
1020 adapter->scan_processing = false; 979 adapter->scan_processing = false;
1021 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); 980 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
1022 } 981 }
1023 wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL; 982 adapter->cmd_wait_q.status = -1;
1024 mwifiex_ioctl_complete(adapter, wait_queue, -1); 983 mwifiex_complete_cmd(adapter);
1025
1026 return;
1027} 984}
1028 985
1029/* 986/*
@@ -1127,7 +1084,6 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter)
1127 adapter->is_hs_configured = false; 1084 adapter->is_hs_configured = false;
1128 mwifiex_hs_activated_event(mwifiex_get_priv(adapter, 1085 mwifiex_hs_activated_event(mwifiex_get_priv(adapter,
1129 MWIFIEX_BSS_ROLE_ANY), false); 1086 MWIFIEX_BSS_ROLE_ANY), false);
1130 return;
1131} 1087}
1132 1088
1133/* 1089/*