aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-09-13 08:46:33 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-09-14 16:08:03 -0400
commit3eecce527c7434dfd16517ce08b49632c8a26717 (patch)
tree7495b3970b2f34d40dc0adbfc8a5a8627a515851 /drivers
parentb5be3efc34294cc34e305903df6a388950e8d1f3 (diff)
iwlwifi: unify scan start checks
Rather than duplicating all the checks and even in case of errors accepting the scan request from mac80211, we can push the checks to the caller and in all error cases reject the scan request right away (rather than accepting and then saying it was aborted). Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Acked-by: Wey-Yi W Guy <wey-yi.w.guy@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c88
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c127
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c74
6 files changed, 108 insertions, 187 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index bb2aeebf3652..98509c5e708d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -295,7 +295,7 @@ extern const struct iwl_channel_info *iwl3945_get_channel_info(
295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); 295extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate);
296 296
297/* scanning */ 297/* scanning */
298void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); 298int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
299 299
300/* Requires full declaration of iwl_priv before including */ 300/* Requires full declaration of iwl_priv before including */
301#include "iwl-io.h" 301#include "iwl-io.h"
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 35470d280c14..12170cfcff4e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
@@ -1150,7 +1150,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv,
1150 return added; 1150 return added;
1151} 1151}
1152 1152
1153void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) 1153int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1154{ 1154{
1155 struct iwl_host_cmd cmd = { 1155 struct iwl_host_cmd cmd = {
1156 .id = REPLY_SCAN_CMD, 1156 .id = REPLY_SCAN_CMD,
@@ -1170,57 +1170,20 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1170 int chan_mod; 1170 int chan_mod;
1171 u8 active_chains; 1171 u8 active_chains;
1172 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; 1172 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
1173 int ret;
1174
1175 lockdep_assert_held(&priv->mutex);
1173 1176
1174 if (vif) 1177 if (vif)
1175 ctx = iwl_rxon_ctx_from_vif(vif); 1178 ctx = iwl_rxon_ctx_from_vif(vif);
1176 1179
1177 cancel_delayed_work(&priv->scan_check);
1178
1179 if (!iwl_is_ready(priv)) {
1180 IWL_WARN(priv, "request scan called when driver not ready.\n");
1181 goto done;
1182 }
1183
1184 /* Make sure the scan wasn't canceled before this queued work
1185 * was given the chance to run... */
1186 if (!test_bit(STATUS_SCANNING, &priv->status))
1187 goto done;
1188
1189 /* This should never be called or scheduled if there is currently
1190 * a scan active in the hardware. */
1191 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
1192 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests in parallel. "
1193 "Ignoring second request.\n");
1194 goto done;
1195 }
1196
1197 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
1198 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
1199 goto done;
1200 }
1201
1202 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
1203 IWL_DEBUG_HC(priv, "Scan request while abort pending. Queuing.\n");
1204 goto done;
1205 }
1206
1207 if (iwl_is_rfkill(priv)) {
1208 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
1209 goto done;
1210 }
1211
1212 if (!test_bit(STATUS_READY, &priv->status)) {
1213 IWL_DEBUG_HC(priv, "Scan request while uninitialized. Queuing.\n");
1214 goto done;
1215 }
1216
1217 if (!priv->scan_cmd) { 1180 if (!priv->scan_cmd) {
1218 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) + 1181 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) +
1219 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 1182 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
1220 if (!priv->scan_cmd) { 1183 if (!priv->scan_cmd) {
1221 IWL_DEBUG_SCAN(priv, 1184 IWL_DEBUG_SCAN(priv,
1222 "fail to allocate memory for scan\n"); 1185 "fail to allocate memory for scan\n");
1223 goto done; 1186 return -ENOMEM;
1224 } 1187 }
1225 } 1188 }
1226 scan = priv->scan_cmd; 1189 scan = priv->scan_cmd;
@@ -1327,8 +1290,8 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1327 IWL_GOOD_CRC_TH_NEVER; 1290 IWL_GOOD_CRC_TH_NEVER;
1328 break; 1291 break;
1329 default: 1292 default:
1330 IWL_WARN(priv, "Invalid scan band count\n"); 1293 IWL_WARN(priv, "Invalid scan band\n");
1331 goto done; 1294 return -EIO;
1332 } 1295 }
1333 1296
1334 band = priv->scan_band; 1297 band = priv->scan_band;
@@ -1408,7 +1371,7 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1408 } 1371 }
1409 if (scan->channel_count == 0) { 1372 if (scan->channel_count == 0) {
1410 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 1373 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
1411 goto done; 1374 return -EIO;
1412 } 1375 }
1413 1376
1414 cmd.len += le16_to_cpu(scan->tx_cmd.len) + 1377 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
@@ -1416,30 +1379,21 @@ void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1416 cmd.data = scan; 1379 cmd.data = scan;
1417 scan->len = cpu_to_le16(cmd.len); 1380 scan->len = cpu_to_le16(cmd.len);
1418 1381
1419 set_bit(STATUS_SCAN_HW, &priv->status); 1382 if (priv->cfg->ops->hcmd->set_pan_params) {
1420 1383 ret = priv->cfg->ops->hcmd->set_pan_params(priv);
1421 if (priv->cfg->ops->hcmd->set_pan_params && 1384 if (ret)
1422 priv->cfg->ops->hcmd->set_pan_params(priv)) 1385 return ret;
1423 goto done; 1386 }
1424 1387
1425 if (iwl_send_cmd_sync(priv, &cmd)) 1388 set_bit(STATUS_SCAN_HW, &priv->status);
1426 goto done; 1389 ret = iwl_send_cmd_sync(priv, &cmd);
1390 if (ret) {
1391 clear_bit(STATUS_SCAN_HW, &priv->status);
1392 if (priv->cfg->ops->hcmd->set_pan_params)
1393 priv->cfg->ops->hcmd->set_pan_params(priv);
1394 }
1427 1395
1428 queue_delayed_work(priv->workqueue, &priv->scan_check, 1396 return ret;
1429 IWL_SCAN_CHECK_WATCHDOG);
1430
1431 return;
1432
1433 done:
1434 /* Cannot perform scan. Make sure we clear scanning
1435 * bits from status so next scan request can be performed.
1436 * If we don't clear scanning status bit here all next scan
1437 * will fail
1438 */
1439 clear_bit(STATUS_SCAN_HW, &priv->status);
1440 clear_bit(STATUS_SCANNING, &priv->status);
1441 /* inform mac80211 scan aborted */
1442 queue_work(priv->workqueue, &priv->scan_completed);
1443} 1397}
1444 1398
1445int iwlagn_manage_ibss_station(struct iwl_priv *priv, 1399int iwlagn_manage_ibss_station(struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index ab7c16f365f0..e1f85ae9da59 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -219,7 +219,7 @@ void iwl_reply_statistics(struct iwl_priv *priv,
219 struct iwl_rx_mem_buffer *rxb); 219 struct iwl_rx_mem_buffer *rxb);
220 220
221/* scan */ 221/* scan */
222void iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); 222int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif);
223 223
224/* station mgmt */ 224/* station mgmt */
225int iwlagn_manage_ibss_station(struct iwl_priv *priv, 225int iwlagn_manage_ibss_station(struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index f7b57ed84f66..8dab074e491f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -111,7 +111,7 @@ struct iwl_hcmd_utils_ops {
111 __le16 fc, __le32 *tx_flags); 111 __le16 fc, __le32 *tx_flags);
112 int (*calc_rssi)(struct iwl_priv *priv, 112 int (*calc_rssi)(struct iwl_priv *priv,
113 struct iwl_rx_phy_res *rx_resp); 113 struct iwl_rx_phy_res *rx_resp);
114 void (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif); 114 int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif);
115}; 115};
116 116
117struct iwl_apm_ops { 117struct iwl_apm_ops {
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 7727f0966d31..6bd14bc33478 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -324,19 +324,68 @@ void iwl_init_scan_params(struct iwl_priv *priv)
324} 324}
325EXPORT_SYMBOL(iwl_init_scan_params); 325EXPORT_SYMBOL(iwl_init_scan_params);
326 326
327static int iwl_scan_initiate(struct iwl_priv *priv, struct ieee80211_vif *vif) 327static int __must_check iwl_scan_initiate(struct iwl_priv *priv,
328 struct ieee80211_vif *vif,
329 bool internal,
330 enum nl80211_band band)
328{ 331{
332 int ret;
333
329 lockdep_assert_held(&priv->mutex); 334 lockdep_assert_held(&priv->mutex);
330 335
331 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 336 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
337 return -EOPNOTSUPP;
338
339 cancel_delayed_work(&priv->scan_check);
340
341 if (!iwl_is_ready(priv)) {
342 IWL_WARN(priv, "request scan called when driver not ready.\n");
343 return -EIO;
344 }
345
346 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
347 IWL_DEBUG_INFO(priv,
348 "Multiple concurrent scan requests in parallel.\n");
349 return -EBUSY;
350 }
351
352 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
353 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
354 return -EIO;
355 }
356
357 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
358 IWL_DEBUG_HC(priv, "Scan request while abort pending.\n");
359 return -EBUSY;
360 }
361
362 if (iwl_is_rfkill(priv)) {
363 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
364 return -EIO;
365 }
366
367 if (!test_bit(STATUS_READY, &priv->status)) {
368 IWL_DEBUG_HC(priv, "Scan request while uninitialized.\n");
369 return -EBUSY;
370 }
371
372 IWL_DEBUG_INFO(priv, "Starting %sscan...\n",
373 internal ? "internal short " : "");
374
332 set_bit(STATUS_SCANNING, &priv->status); 375 set_bit(STATUS_SCANNING, &priv->status);
333 priv->is_internal_short_scan = false; 376 priv->is_internal_short_scan = internal;
334 priv->scan_start = jiffies; 377 priv->scan_start = jiffies;
378 priv->scan_band = band;
335 379
336 if (WARN_ON(!priv->cfg->ops->utils->request_scan)) 380 ret = priv->cfg->ops->utils->request_scan(priv, vif);
337 return -EOPNOTSUPP; 381 if (ret) {
382 clear_bit(STATUS_SCANNING, &priv->status);
383 priv->is_internal_short_scan = false;
384 return ret;
385 }
338 386
339 priv->cfg->ops->utils->request_scan(priv, vif); 387 queue_delayed_work(priv->workqueue, &priv->scan_check,
388 IWL_SCAN_CHECK_WATCHDOG);
340 389
341 return 0; 390 return 0;
342} 391}
@@ -355,12 +404,6 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
355 404
356 mutex_lock(&priv->mutex); 405 mutex_lock(&priv->mutex);
357 406
358 if (!iwl_is_ready_rf(priv)) {
359 ret = -EIO;
360 IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n");
361 goto out_unlock;
362 }
363
364 if (test_bit(STATUS_SCANNING, &priv->status) && 407 if (test_bit(STATUS_SCANNING, &priv->status) &&
365 !priv->is_internal_short_scan) { 408 !priv->is_internal_short_scan) {
366 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 409 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
@@ -368,14 +411,7 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
368 goto out_unlock; 411 goto out_unlock;
369 } 412 }
370 413
371 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
372 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
373 ret = -EAGAIN;
374 goto out_unlock;
375 }
376
377 /* mac80211 will only ask for one band at a time */ 414 /* mac80211 will only ask for one band at a time */
378 priv->scan_band = req->channels[0]->band;
379 priv->scan_request = req; 415 priv->scan_request = req;
380 priv->scan_vif = vif; 416 priv->scan_vif = vif;
381 417
@@ -386,7 +422,8 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw,
386 if (priv->is_internal_short_scan) 422 if (priv->is_internal_short_scan)
387 ret = 0; 423 ret = 0;
388 else 424 else
389 ret = iwl_scan_initiate(priv, vif); 425 ret = iwl_scan_initiate(priv, vif, false,
426 req->channels[0]->band);
390 427
391 IWL_DEBUG_MAC80211(priv, "leave\n"); 428 IWL_DEBUG_MAC80211(priv, "leave\n");
392 429
@@ -418,31 +455,13 @@ static void iwl_bg_start_internal_scan(struct work_struct *work)
418 goto unlock; 455 goto unlock;
419 } 456 }
420 457
421 if (!iwl_is_ready_rf(priv)) {
422 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
423 goto unlock;
424 }
425
426 if (test_bit(STATUS_SCANNING, &priv->status)) { 458 if (test_bit(STATUS_SCANNING, &priv->status)) {
427 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 459 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
428 goto unlock; 460 goto unlock;
429 } 461 }
430 462
431 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 463 if (iwl_scan_initiate(priv, NULL, true, priv->band))
432 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); 464 IWL_DEBUG_SCAN(priv, "failed to start internal short scan\n");
433 goto unlock;
434 }
435
436 priv->scan_band = priv->band;
437
438 IWL_DEBUG_SCAN(priv, "Start internal short scan...\n");
439 set_bit(STATUS_SCANNING, &priv->status);
440 priv->is_internal_short_scan = true;
441
442 if (WARN_ON(!priv->cfg->ops->utils->request_scan))
443 goto unlock;
444
445 priv->cfg->ops->utils->request_scan(priv, NULL);
446 unlock: 465 unlock:
447 mutex_unlock(&priv->mutex); 466 mutex_unlock(&priv->mutex);
448} 467}
@@ -536,7 +555,6 @@ static void iwl_bg_scan_completed(struct work_struct *work)
536 struct iwl_priv *priv = 555 struct iwl_priv *priv =
537 container_of(work, struct iwl_priv, scan_completed); 556 container_of(work, struct iwl_priv, scan_completed);
538 bool internal = false; 557 bool internal = false;
539 bool scan_completed = false;
540 struct iwl_rxon_context *ctx; 558 struct iwl_rxon_context *ctx;
541 559
542 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n"); 560 IWL_DEBUG_SCAN(priv, "SCAN complete scan\n");
@@ -549,16 +567,27 @@ static void iwl_bg_scan_completed(struct work_struct *work)
549 IWL_DEBUG_SCAN(priv, "internal short scan completed\n"); 567 IWL_DEBUG_SCAN(priv, "internal short scan completed\n");
550 internal = true; 568 internal = true;
551 } else if (priv->scan_request) { 569 } else if (priv->scan_request) {
552 scan_completed = true;
553 priv->scan_request = NULL; 570 priv->scan_request = NULL;
554 priv->scan_vif = NULL; 571 priv->scan_vif = NULL;
572 ieee80211_scan_completed(priv->hw, false);
555 } 573 }
556 574
557 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 575 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
558 goto out; 576 goto out;
559 577
560 if (internal && priv->scan_request) 578 if (internal && priv->scan_request) {
561 iwl_scan_initiate(priv, priv->scan_vif); 579 int err = iwl_scan_initiate(priv, priv->scan_vif, false,
580 priv->scan_request->channels[0]->band);
581
582 if (err) {
583 IWL_DEBUG_SCAN(priv,
584 "failed to initiate pending scan: %d\n", err);
585 priv->scan_request = NULL;
586 priv->scan_vif = NULL;
587 ieee80211_scan_completed(priv->hw, true);
588 } else
589 goto out;
590 }
562 591
563 /* Since setting the TXPOWER may have been deferred while 592 /* Since setting the TXPOWER may have been deferred while
564 * performing the scan, fire one off */ 593 * performing the scan, fire one off */
@@ -571,19 +600,11 @@ static void iwl_bg_scan_completed(struct work_struct *work)
571 for_each_context(priv, ctx) 600 for_each_context(priv, ctx)
572 iwlcore_commit_rxon(priv, ctx); 601 iwlcore_commit_rxon(priv, ctx);
573 602
574 out:
575 if (priv->cfg->ops->hcmd->set_pan_params) 603 if (priv->cfg->ops->hcmd->set_pan_params)
576 priv->cfg->ops->hcmd->set_pan_params(priv); 604 priv->cfg->ops->hcmd->set_pan_params(priv);
577 605
606 out:
578 mutex_unlock(&priv->mutex); 607 mutex_unlock(&priv->mutex);
579
580 /*
581 * Do not hold mutex here since this will cause mac80211 to call
582 * into driver again into functions that will attempt to take
583 * mutex.
584 */
585 if (scan_completed)
586 ieee80211_scan_completed(priv->hw, false);
587} 608}
588 609
589void iwl_setup_scan_deferred_work(struct iwl_priv *priv) 610void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index be1e75e3be55..fc553bacef17 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2816,7 +2816,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data)
2816 2816
2817} 2817}
2818 2818
2819void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) 2819int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2820{ 2820{
2821 struct iwl_host_cmd cmd = { 2821 struct iwl_host_cmd cmd = {
2822 .id = REPLY_SCAN_CMD, 2822 .id = REPLY_SCAN_CMD,
@@ -2827,55 +2827,16 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2827 u8 n_probes = 0; 2827 u8 n_probes = 0;
2828 enum ieee80211_band band; 2828 enum ieee80211_band band;
2829 bool is_active = false; 2829 bool is_active = false;
2830 int ret;
2830 2831
2831 cancel_delayed_work(&priv->scan_check); 2832 lockdep_assert_held(&priv->mutex);
2832
2833 if (!iwl_is_ready(priv)) {
2834 IWL_WARN(priv, "request scan called when driver not ready.\n");
2835 goto done;
2836 }
2837
2838 /* Make sure the scan wasn't canceled before this queued work
2839 * was given the chance to run... */
2840 if (!test_bit(STATUS_SCANNING, &priv->status))
2841 goto done;
2842
2843 /* This should never be called or scheduled if there is currently
2844 * a scan active in the hardware. */
2845 if (test_bit(STATUS_SCAN_HW, &priv->status)) {
2846 IWL_DEBUG_INFO(priv, "Multiple concurrent scan requests "
2847 "Ignoring second request.\n");
2848 goto done;
2849 }
2850
2851 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) {
2852 IWL_DEBUG_SCAN(priv, "Aborting scan due to device shutdown\n");
2853 goto done;
2854 }
2855
2856 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
2857 IWL_DEBUG_HC(priv,
2858 "Scan request while abort pending. Queuing.\n");
2859 goto done;
2860 }
2861
2862 if (iwl_is_rfkill(priv)) {
2863 IWL_DEBUG_HC(priv, "Aborting scan due to RF Kill activation\n");
2864 goto done;
2865 }
2866
2867 if (!test_bit(STATUS_READY, &priv->status)) {
2868 IWL_DEBUG_HC(priv,
2869 "Scan request while uninitialized. Queuing.\n");
2870 goto done;
2871 }
2872 2833
2873 if (!priv->scan_cmd) { 2834 if (!priv->scan_cmd) {
2874 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) + 2835 priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) +
2875 IWL_MAX_SCAN_SIZE, GFP_KERNEL); 2836 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
2876 if (!priv->scan_cmd) { 2837 if (!priv->scan_cmd) {
2877 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); 2838 IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n");
2878 goto done; 2839 return -ENOMEM;
2879 } 2840 }
2880 } 2841 }
2881 scan = priv->scan_cmd; 2842 scan = priv->scan_cmd;
@@ -2970,7 +2931,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
2970 break; 2931 break;
2971 default: 2932 default:
2972 IWL_WARN(priv, "Invalid scan band\n"); 2933 IWL_WARN(priv, "Invalid scan band\n");
2973 goto done; 2934 return -EIO;
2974 } 2935 }
2975 2936
2976 if (!priv->is_internal_short_scan) { 2937 if (!priv->is_internal_short_scan) {
@@ -3005,7 +2966,7 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
3005 2966
3006 if (scan->channel_count == 0) { 2967 if (scan->channel_count == 0) {
3007 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); 2968 IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count);
3008 goto done; 2969 return -EIO;
3009 } 2970 }
3010 2971
3011 cmd.len += le16_to_cpu(scan->tx_cmd.len) + 2972 cmd.len += le16_to_cpu(scan->tx_cmd.len) +
@@ -3014,25 +2975,10 @@ void iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
3014 scan->len = cpu_to_le16(cmd.len); 2975 scan->len = cpu_to_le16(cmd.len);
3015 2976
3016 set_bit(STATUS_SCAN_HW, &priv->status); 2977 set_bit(STATUS_SCAN_HW, &priv->status);
3017 if (iwl_send_cmd_sync(priv, &cmd)) 2978 ret = iwl_send_cmd_sync(priv, &cmd);
3018 goto done; 2979 if (ret)
3019 2980 clear_bit(STATUS_SCAN_HW, &priv->status);
3020 queue_delayed_work(priv->workqueue, &priv->scan_check, 2981 return ret;
3021 IWL_SCAN_CHECK_WATCHDOG);
3022
3023 return;
3024
3025 done:
3026 /* can not perform scan make sure we clear scanning
3027 * bits from status so next scan request can be performed.
3028 * if we dont clear scanning status bit here all next scan
3029 * will fail
3030 */
3031 clear_bit(STATUS_SCAN_HW, &priv->status);
3032 clear_bit(STATUS_SCANNING, &priv->status);
3033
3034 /* inform mac80211 scan aborted */
3035 queue_work(priv->workqueue, &priv->scan_completed);
3036} 2982}
3037 2983
3038static void iwl3945_bg_restart(struct work_struct *data) 2984static void iwl3945_bg_restart(struct work_struct *data)