diff options
author | Amitkumar Karwar <akarwar@marvell.com> | 2011-04-13 20:27:06 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-04-14 15:35:11 -0400 |
commit | 600f5d909a54a8dccf8c8c23898fc2e91bc0953e (patch) | |
tree | dad2709218946398c370647f16d0dd6f2f9a1919 /drivers/net/wireless/mwifiex/cmdevt.c | |
parent | 3a9dddea89eb2132ba919fe04cb3b44a3b1e6db7 (diff) |
mwifiex: cleanup ioctl wait queue and abstraction layer
1) remove mwifiex_alloc_fill_wait_queue() and
mwifiex_request_ioctl()
2) avoid dynamic allocation of wait queue
3) remove unnecessary mwifiex_error_code macros that
were used mainly by the wait queue status code
4) remove some abstraction functions
5) split mwifiex_prepare_cmd() to mwifiex_send_cmd_async()
and mwifiex_send_sync() to handle asynchronous and
synchronous commands respectively
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/cmdevt.c')
-rw-r--r-- | drivers/net/wireless/mwifiex/cmdevt.c | 179 |
1 files changed, 72 insertions, 107 deletions
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 @@ | |||
36 | static void | 36 | static void |
37 | mwifiex_init_cmd_node(struct mwifiex_private *priv, | 37 | mwifiex_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 | */ | ||
104 | static struct cmd_ctrl_node * | ||
105 | mwifiex_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 | */ | ||
419 | int 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 | */ |
450 | int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, | 448 | int 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 | |||
537 | mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter, | 534 | mwifiex_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 | |||
903 | mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter) | 886 | mwifiex_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 | */ |
966 | void | 944 | void |
967 | mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter, | 945 | mwifiex_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 | } |