summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/mwifiex/scan.c')
-rw-r--r--drivers/net/wireless/mwifiex/scan.c126
1 files changed, 34 insertions, 92 deletions
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 6bb52d0e6cf..12fe021536d 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,
* with requisite parameters and calls the IOCTL handler.
*/
int mwifiex_find_best_bss(struct mwifiex_private *priv,
- u8 wait_option, struct mwifiex_ssid_bssid *ssid_bssid)
+ struct mwifiex_ssid_bssid *ssid_bssid)
{
- struct mwifiex_wait_queue *wait = NULL;
struct mwifiex_ssid_bssid tmp_ssid_bssid;
int ret = 0;
u8 *mac = NULL;
@@ -188,14 +187,9 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
if (!ssid_bssid)
return -1;
- /* Allocate wait request buffer */
- wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
- if (!wait)
- return -ENOMEM;
-
memcpy(&tmp_ssid_bssid, ssid_bssid,
sizeof(struct mwifiex_ssid_bssid));
- ret = mwifiex_bss_ioctl_find_bss(priv, wait, &tmp_ssid_bssid);
+ ret = mwifiex_bss_ioctl_find_bss(priv, &tmp_ssid_bssid);
if (!ret) {
memcpy(ssid_bssid, &tmp_ssid_bssid,
@@ -205,7 +199,6 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
" %pM\n", ssid_bssid->ssid.ssid, mac);
}
- kfree(wait);
return ret;
}
@@ -221,22 +214,14 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
struct mwifiex_user_scan_cfg *scan_req)
{
- struct mwifiex_wait_queue *wait = NULL;
int status = 0;
- u8 wait_option = MWIFIEX_IOCTL_WAIT;
-
- /* Allocate an IOCTL request buffer */
- wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
- if (!wait)
- return -ENOMEM;
- status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET,
- scan_req, NULL);
+ priv->adapter->cmd_wait_q.condition = false;
- status = mwifiex_request_ioctl(priv, wait, status, wait_option);
+ status = mwifiex_scan_networks(priv, scan_req);
+ if (!status)
+ status = mwifiex_wait_queue_complete(priv->adapter);
- if (wait && (status != -EINPROGRESS))
- kfree(wait);
return status;
}
@@ -674,7 +659,7 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
* along with the other TLVs, to the firmware.
*/
static int
-mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf,
+mwifiex_scan_channel_list(struct mwifiex_private *priv,
u32 max_chan_per_scan, u8 filtered_scan,
struct mwifiex_scan_cmd_config *scan_cfg_out,
struct mwifiex_ie_types_chan_list_param_set
@@ -808,9 +793,9 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf,
/* Send the scan command to the firmware with the specified
cfg */
- ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SCAN,
- HostCmd_ACT_GEN_SET,
- 0, wait_buf, scan_cfg_out);
+ ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SCAN,
+ HostCmd_ACT_GEN_SET, 0,
+ scan_cfg_out);
if (ret)
break;
}
@@ -2271,9 +2256,7 @@ mwifiex_scan_delete_ssid_table_entry(struct mwifiex_private *priv,
* update the internal driver scan table.
*/
int mwifiex_scan_networks(struct mwifiex_private *priv,
- void *wait_buf, u16 action,
- const struct mwifiex_user_scan_cfg *user_scan_in,
- struct mwifiex_scan_resp *scan_resp)
+ const struct mwifiex_user_scan_cfg *user_scan_in)
{
int ret = 0;
struct mwifiex_adapter *adapter = priv->adapter;
@@ -2288,18 +2271,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
u8 max_chan_per_scan;
unsigned long flags;
- if (action == HostCmd_ACT_GEN_GET) {
- if (scan_resp) {
- scan_resp->scan_table = (u8 *) adapter->scan_table;
- scan_resp->num_in_scan_table =
- adapter->num_in_scan_table;
- } else {
- ret = -1;
- }
- return ret;
- }
-
- if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
+ if (adapter->scan_processing) {
dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
return ret;
}
@@ -2308,7 +2280,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
adapter->scan_processing = true;
spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
- if (priv->scan_block && action == HostCmd_ACT_GEN_SET) {
+ if (priv->scan_block) {
dev_dbg(adapter->dev,
"cmd: Scan is blocked during association...\n");
return ret;
@@ -2348,9 +2320,9 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
adapter->bcn_buf_end = adapter->bcn_buf;
}
- ret = mwifiex_scan_channel_list(priv, wait_buf, max_chan_per_scan,
- filtered_scan, &scan_cfg_out->config,
- chan_list_out, scan_chan_list);
+ ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan,
+ &scan_cfg_out->config, chan_list_out,
+ scan_chan_list);
/* Get scan command from scan_pending_q and put to cmd_pending_q */
if (!ret) {
@@ -2367,7 +2339,6 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
flags);
}
- ret = -EINPROGRESS;
} else {
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
adapter->scan_processing = true;
@@ -2437,11 +2408,10 @@ int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv,
* .-------------------------------------------------------------.
*/
int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
- struct host_cmd_ds_command *resp, void *wq_buf)
+ struct host_cmd_ds_command *resp)
{
int ret = 0;
struct mwifiex_adapter *adapter = priv->adapter;
- struct mwifiex_wait_queue *wait_queue = NULL;
struct cmd_ctrl_node *cmd_node = NULL;
struct host_cmd_ds_802_11_scan_rsp *scan_rsp = NULL;
struct mwifiex_bssdescriptor *bss_new_entry = NULL;
@@ -2653,13 +2623,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
mwifiex_process_scan_results(priv);
/* Need to indicate IOCTL complete */
- wait_queue = (struct mwifiex_wait_queue *) wq_buf;
- if (wait_queue) {
- wait_queue->status = MWIFIEX_ERROR_NO_ERROR;
-
- /* Indicate ioctl complete */
- mwifiex_ioctl_complete(adapter,
- (struct mwifiex_wait_queue *) wait_queue, 0);
+ if (adapter->curr_cmd->wait_q_enabled) {
+ adapter->cmd_wait_q.status = 0;
+ mwifiex_complete_cmd(adapter);
}
if (priv->report_scan_result)
priv->report_scan_result = false;
@@ -2853,6 +2819,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
struct mwifiex_adapter *adapter = priv->adapter;
unsigned long flags;
+ cmd_node->wait_q_enabled = true;
spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
list_add_tail(&cmd_node->list, &adapter->scan_pending_q);
spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
@@ -2899,9 +2866,7 @@ int mwifiex_find_best_network(struct mwifiex_private *priv,
* firmware, filtered on a specific SSID.
*/
static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
- void *wait_buf, u16 action,
- struct mwifiex_802_11_ssid *req_ssid,
- struct mwifiex_scan_resp *scan_resp)
+ struct mwifiex_802_11_ssid *req_ssid)
{
struct mwifiex_adapter *adapter = priv->adapter;
int ret = 0;
@@ -2910,24 +2875,12 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
if (!req_ssid)
return -1;
- if (action == HostCmd_ACT_GEN_GET) {
- if (scan_resp) {
- scan_resp->scan_table =
- (u8 *) &priv->curr_bss_params.bss_descriptor;
- scan_resp->num_in_scan_table =
- adapter->num_in_scan_table;
- } else {
- ret = -1;
- }
- return ret;
- }
-
- if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
+ if (adapter->scan_processing) {
dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
return ret;
}
- if (priv->scan_block && action == HostCmd_ACT_GEN_SET) {
+ if (priv->scan_block) {
dev_dbg(adapter->dev,
"cmd: Scan is blocked during association...\n");
return ret;
@@ -2945,7 +2898,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
req_ssid->ssid_len);
scan_cfg->keep_previous_scan = true;
- ret = mwifiex_scan_networks(priv, wait_buf, action, scan_cfg, NULL);
+ ret = mwifiex_scan_networks(priv, scan_cfg);
kfree(scan_cfg);
return ret;
@@ -2960,12 +2913,10 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
* Scan command can be issued for both normal scan and specific SSID
* scan, depending upon whether an SSID is provided or not.
*/
-int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option,
+int mwifiex_request_scan(struct mwifiex_private *priv,
struct mwifiex_802_11_ssid *req_ssid)
{
int ret = 0;
- struct mwifiex_wait_queue *wait = NULL;
- int status = 0;
if (down_interruptible(&priv->async_sem)) {
dev_err(priv->adapter->dev, "%s: acquire semaphore\n",
@@ -2974,32 +2925,23 @@ int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option,
}
priv->scan_pending_on_block = true;
- /* Allocate wait request buffer */
- wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
- if (!wait) {
- ret = -1;
- goto done;
- }
+ priv->adapter->cmd_wait_q.condition = false;
if (req_ssid && req_ssid->ssid_len != 0)
/* Specific SSID scan */
- status = mwifiex_scan_specific_ssid(priv, wait,
- HostCmd_ACT_GEN_SET,
- req_ssid, NULL);
+ ret = mwifiex_scan_specific_ssid(priv, req_ssid);
else
/* Normal scan */
- status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET,
- NULL, NULL);
- status = mwifiex_request_ioctl(priv, wait, status, wait_option);
- if (status == -1)
- ret = -1;
-done:
- if ((wait) && (status != -EINPROGRESS))
- kfree(wait);
+ ret = mwifiex_scan_networks(priv, NULL);
+
+ if (!ret)
+ ret = mwifiex_wait_queue_complete(priv->adapter);
+
if (ret == -1) {
priv->scan_pending_on_block = false;
up(&priv->async_sem);
}
+
return ret;
}