aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
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/net/wireless/iwlwifi/iwl-agn-lib.c
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/net/wireless/iwlwifi/iwl-agn-lib.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-lib.c88
1 files changed, 21 insertions, 67 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
index 35470d280c1..12170cfcff4 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,