aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2011-04-19 15:33:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-04-19 15:33:54 -0400
commit44c866a0a57b08b7090be24ccb33679ed1d4f476 (patch)
tree9dcc55b1657020f72b7c209934874d56d3cf2eab
parent34a0a2025c8bddc6505b56a58ef2e7333a4e4165 (diff)
parentf212b43c4e4a8f6378c50ce18f3d271983b575a7 (diff)
Merge branch 'wireless-next-2.6' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c11
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-2000.c18
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-led.c73
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-led.h33
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c42
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c26
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c38
19 files changed, 113 insertions, 265 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index 3652931753e0..bb6a737de61f 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -1,6 +1,6 @@
1# AGN 1# AGN
2obj-$(CONFIG_IWLAGN) += iwlagn.o 2obj-$(CONFIG_IWLAGN) += iwlagn.o
3iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o 3iwlagn-objs := iwl-agn.o iwl-agn-rs.o
4iwlagn-objs += iwl-agn-ucode.o iwl-agn-tx.o 4iwlagn-objs += iwl-agn-ucode.o iwl-agn-tx.o
5iwlagn-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o 5iwlagn-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o
6iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o 6iwlagn-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-eeprom.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index d1d7852f0ee4..baf80111efaf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -45,7 +45,6 @@
45#include "iwl-agn.h" 45#include "iwl-agn.h"
46#include "iwl-helpers.h" 46#include "iwl-helpers.h"
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-agn-led.h"
49#include "iwl-agn-debugfs.h" 48#include "iwl-agn-debugfs.h"
50 49
51/* Highest firmware API version supported */ 50/* Highest firmware API version supported */
@@ -196,7 +195,7 @@ static struct iwl_lib_ops iwl1000_lib = {
196 EEPROM_REG_BAND_4_CHANNELS, 195 EEPROM_REG_BAND_4_CHANNELS,
197 EEPROM_REG_BAND_5_CHANNELS, 196 EEPROM_REG_BAND_5_CHANNELS,
198 EEPROM_REG_BAND_24_HT40_CHANNELS, 197 EEPROM_REG_BAND_24_HT40_CHANNELS,
199 EEPROM_REG_BAND_52_HT40_CHANNELS 198 EEPROM_REGULATORY_BAND_NO_HT40,
200 }, 199 },
201 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 200 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
202 .release_semaphore = iwlcore_eeprom_release_semaphore, 201 .release_semaphore = iwlcore_eeprom_release_semaphore,
@@ -215,19 +214,12 @@ static struct iwl_lib_ops iwl1000_lib = {
215 }, 214 },
216 .txfifo_flush = iwlagn_txfifo_flush, 215 .txfifo_flush = iwlagn_txfifo_flush,
217 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 216 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
218 .tt_ops = {
219 .lower_power_detection = iwl_tt_is_low_power_state,
220 .tt_power_mode = iwl_tt_current_power_mode,
221 .ct_kill_check = iwl_check_for_ct_kill,
222 }
223}; 217};
224 218
225static const struct iwl_ops iwl1000_ops = { 219static const struct iwl_ops iwl1000_ops = {
226 .lib = &iwl1000_lib, 220 .lib = &iwl1000_lib,
227 .hcmd = &iwlagn_hcmd, 221 .hcmd = &iwlagn_hcmd,
228 .utils = &iwlagn_hcmd_utils, 222 .utils = &iwlagn_hcmd_utils,
229 .led = &iwlagn_led_ops,
230 .ieee80211_ops = &iwlagn_hw_ops,
231}; 223};
232 224
233static struct iwl_base_params iwl1000_base_params = { 225static struct iwl_base_params iwl1000_base_params = {
@@ -244,7 +236,6 @@ static struct iwl_base_params iwl1000_base_params = {
244 .chain_noise_scale = 1000, 236 .chain_noise_scale = 1000,
245 .wd_timeout = IWL_DEF_WD_TIMEOUT, 237 .wd_timeout = IWL_DEF_WD_TIMEOUT,
246 .max_event_log_size = 128, 238 .max_event_log_size = 128,
247 .ucode_tracing = true,
248}; 239};
249static struct iwl_ht_params iwl1000_ht_params = { 240static struct iwl_ht_params iwl1000_ht_params = {
250 .ht_greenfield_support = true, 241 .ht_greenfield_support = true,
diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c
index a31314fdb053..e76e02c28928 100644
--- a/drivers/net/wireless/iwlwifi/iwl-2000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-2000.c
@@ -46,7 +46,6 @@
46#include "iwl-helpers.h" 46#include "iwl-helpers.h"
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-6000-hw.h" 48#include "iwl-6000-hw.h"
49#include "iwl-agn-led.h"
50#include "iwl-agn-debugfs.h" 49#include "iwl-agn-debugfs.h"
51 50
52/* Highest firmware API version supported */ 51/* Highest firmware API version supported */
@@ -279,7 +278,7 @@ static struct iwl_lib_ops iwl2000_lib = {
279 EEPROM_REG_BAND_4_CHANNELS, 278 EEPROM_REG_BAND_4_CHANNELS,
280 EEPROM_REG_BAND_5_CHANNELS, 279 EEPROM_REG_BAND_5_CHANNELS,
281 EEPROM_6000_REG_BAND_24_HT40_CHANNELS, 280 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
282 EEPROM_REG_BAND_52_HT40_CHANNELS 281 EEPROM_REGULATORY_BAND_NO_HT40,
283 }, 282 },
284 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, 283 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
285 .release_semaphore = iwlcore_eeprom_release_semaphore, 284 .release_semaphore = iwlcore_eeprom_release_semaphore,
@@ -299,43 +298,30 @@ static struct iwl_lib_ops iwl2000_lib = {
299 }, 298 },
300 .txfifo_flush = iwlagn_txfifo_flush, 299 .txfifo_flush = iwlagn_txfifo_flush,
301 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 300 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
302 .tt_ops = {
303 .lower_power_detection = iwl_tt_is_low_power_state,
304 .tt_power_mode = iwl_tt_current_power_mode,
305 .ct_kill_check = iwl_check_for_ct_kill,
306 }
307}; 301};
308 302
309static const struct iwl_ops iwl2000_ops = { 303static const struct iwl_ops iwl2000_ops = {
310 .lib = &iwl2000_lib, 304 .lib = &iwl2000_lib,
311 .hcmd = &iwlagn_hcmd, 305 .hcmd = &iwlagn_hcmd,
312 .utils = &iwlagn_hcmd_utils, 306 .utils = &iwlagn_hcmd_utils,
313 .led = &iwlagn_led_ops,
314 .ieee80211_ops = &iwlagn_hw_ops,
315}; 307};
316 308
317static const struct iwl_ops iwl2030_ops = { 309static const struct iwl_ops iwl2030_ops = {
318 .lib = &iwl2000_lib, 310 .lib = &iwl2000_lib,
319 .hcmd = &iwlagn_bt_hcmd, 311 .hcmd = &iwlagn_bt_hcmd,
320 .utils = &iwlagn_hcmd_utils, 312 .utils = &iwlagn_hcmd_utils,
321 .led = &iwlagn_led_ops,
322 .ieee80211_ops = &iwlagn_hw_ops,
323}; 313};
324 314
325static const struct iwl_ops iwl200_ops = { 315static const struct iwl_ops iwl200_ops = {
326 .lib = &iwl2000_lib, 316 .lib = &iwl2000_lib,
327 .hcmd = &iwlagn_hcmd, 317 .hcmd = &iwlagn_hcmd,
328 .utils = &iwlagn_hcmd_utils, 318 .utils = &iwlagn_hcmd_utils,
329 .led = &iwlagn_led_ops,
330 .ieee80211_ops = &iwlagn_hw_ops,
331}; 319};
332 320
333static const struct iwl_ops iwl230_ops = { 321static const struct iwl_ops iwl230_ops = {
334 .lib = &iwl2000_lib, 322 .lib = &iwl2000_lib,
335 .hcmd = &iwlagn_bt_hcmd, 323 .hcmd = &iwlagn_bt_hcmd,
336 .utils = &iwlagn_hcmd_utils, 324 .utils = &iwlagn_hcmd_utils,
337 .led = &iwlagn_led_ops,
338 .ieee80211_ops = &iwlagn_hw_ops,
339}; 325};
340 326
341static struct iwl_base_params iwl2000_base_params = { 327static struct iwl_base_params iwl2000_base_params = {
@@ -353,7 +339,6 @@ static struct iwl_base_params iwl2000_base_params = {
353 .chain_noise_scale = 1000, 339 .chain_noise_scale = 1000,
354 .wd_timeout = IWL_DEF_WD_TIMEOUT, 340 .wd_timeout = IWL_DEF_WD_TIMEOUT,
355 .max_event_log_size = 512, 341 .max_event_log_size = 512,
356 .ucode_tracing = true,
357 .shadow_reg_enable = true, 342 .shadow_reg_enable = true,
358}; 343};
359 344
@@ -373,7 +358,6 @@ static struct iwl_base_params iwl2030_base_params = {
373 .chain_noise_scale = 1000, 358 .chain_noise_scale = 1000,
374 .wd_timeout = IWL_LONG_WD_TIMEOUT, 359 .wd_timeout = IWL_LONG_WD_TIMEOUT,
375 .max_event_log_size = 512, 360 .max_event_log_size = 512,
376 .ucode_tracing = true,
377 .shadow_reg_enable = true, 361 .shadow_reg_enable = true,
378}; 362};
379 363
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 7c286662d26a..655afc19f68f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -45,7 +45,6 @@
45#include "iwl-sta.h" 45#include "iwl-sta.h"
46#include "iwl-helpers.h" 46#include "iwl-helpers.h"
47#include "iwl-agn.h" 47#include "iwl-agn.h"
48#include "iwl-agn-led.h"
49#include "iwl-agn-hw.h" 48#include "iwl-agn-hw.h"
50#include "iwl-5000-hw.h" 49#include "iwl-5000-hw.h"
51#include "iwl-agn-debugfs.h" 50#include "iwl-agn-debugfs.h"
@@ -384,11 +383,6 @@ static struct iwl_lib_ops iwl5000_lib = {
384 }, 383 },
385 .txfifo_flush = iwlagn_txfifo_flush, 384 .txfifo_flush = iwlagn_txfifo_flush,
386 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 385 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
387 .tt_ops = {
388 .lower_power_detection = iwl_tt_is_low_power_state,
389 .tt_power_mode = iwl_tt_current_power_mode,
390 .ct_kill_check = iwl_check_for_ct_kill,
391 }
392}; 386};
393 387
394static struct iwl_lib_ops iwl5150_lib = { 388static struct iwl_lib_ops iwl5150_lib = {
@@ -436,27 +430,18 @@ static struct iwl_lib_ops iwl5150_lib = {
436 }, 430 },
437 .txfifo_flush = iwlagn_txfifo_flush, 431 .txfifo_flush = iwlagn_txfifo_flush,
438 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 432 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
439 .tt_ops = {
440 .lower_power_detection = iwl_tt_is_low_power_state,
441 .tt_power_mode = iwl_tt_current_power_mode,
442 .ct_kill_check = iwl_check_for_ct_kill,
443 }
444}; 433};
445 434
446static const struct iwl_ops iwl5000_ops = { 435static const struct iwl_ops iwl5000_ops = {
447 .lib = &iwl5000_lib, 436 .lib = &iwl5000_lib,
448 .hcmd = &iwlagn_hcmd, 437 .hcmd = &iwlagn_hcmd,
449 .utils = &iwlagn_hcmd_utils, 438 .utils = &iwlagn_hcmd_utils,
450 .led = &iwlagn_led_ops,
451 .ieee80211_ops = &iwlagn_hw_ops,
452}; 439};
453 440
454static const struct iwl_ops iwl5150_ops = { 441static const struct iwl_ops iwl5150_ops = {
455 .lib = &iwl5150_lib, 442 .lib = &iwl5150_lib,
456 .hcmd = &iwlagn_hcmd, 443 .hcmd = &iwlagn_hcmd,
457 .utils = &iwlagn_hcmd_utils, 444 .utils = &iwlagn_hcmd_utils,
458 .led = &iwlagn_led_ops,
459 .ieee80211_ops = &iwlagn_hw_ops,
460}; 445};
461 446
462static struct iwl_base_params iwl5000_base_params = { 447static struct iwl_base_params iwl5000_base_params = {
@@ -470,7 +455,6 @@ static struct iwl_base_params iwl5000_base_params = {
470 .chain_noise_scale = 1000, 455 .chain_noise_scale = 1000,
471 .wd_timeout = IWL_LONG_WD_TIMEOUT, 456 .wd_timeout = IWL_LONG_WD_TIMEOUT,
472 .max_event_log_size = 512, 457 .max_event_log_size = 512,
473 .ucode_tracing = true,
474}; 458};
475static struct iwl_ht_params iwl5000_ht_params = { 459static struct iwl_ht_params iwl5000_ht_params = {
476 .ht_greenfield_support = true, 460 .ht_greenfield_support = true,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 064981345c84..905eb57f7cab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -46,7 +46,6 @@
46#include "iwl-helpers.h" 46#include "iwl-helpers.h"
47#include "iwl-agn-hw.h" 47#include "iwl-agn-hw.h"
48#include "iwl-6000-hw.h" 48#include "iwl-6000-hw.h"
49#include "iwl-agn-led.h"
50#include "iwl-agn-debugfs.h" 49#include "iwl-agn-debugfs.h"
51 50
52/* Highest firmware API version supported */ 51/* Highest firmware API version supported */
@@ -324,11 +323,6 @@ static struct iwl_lib_ops iwl6000_lib = {
324 }, 323 },
325 .txfifo_flush = iwlagn_txfifo_flush, 324 .txfifo_flush = iwlagn_txfifo_flush,
326 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 325 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
327 .tt_ops = {
328 .lower_power_detection = iwl_tt_is_low_power_state,
329 .tt_power_mode = iwl_tt_current_power_mode,
330 .ct_kill_check = iwl_check_for_ct_kill,
331 }
332}; 326};
333 327
334static struct iwl_lib_ops iwl6030_lib = { 328static struct iwl_lib_ops iwl6030_lib = {
@@ -378,11 +372,6 @@ static struct iwl_lib_ops iwl6030_lib = {
378 }, 372 },
379 .txfifo_flush = iwlagn_txfifo_flush, 373 .txfifo_flush = iwlagn_txfifo_flush,
380 .dev_txfifo_flush = iwlagn_dev_txfifo_flush, 374 .dev_txfifo_flush = iwlagn_dev_txfifo_flush,
381 .tt_ops = {
382 .lower_power_detection = iwl_tt_is_low_power_state,
383 .tt_power_mode = iwl_tt_current_power_mode,
384 .ct_kill_check = iwl_check_for_ct_kill,
385 }
386}; 375};
387 376
388static struct iwl_nic_ops iwl6050_nic_ops = { 377static struct iwl_nic_ops iwl6050_nic_ops = {
@@ -397,34 +386,26 @@ static const struct iwl_ops iwl6000_ops = {
397 .lib = &iwl6000_lib, 386 .lib = &iwl6000_lib,
398 .hcmd = &iwlagn_hcmd, 387 .hcmd = &iwlagn_hcmd,
399 .utils = &iwlagn_hcmd_utils, 388 .utils = &iwlagn_hcmd_utils,
400 .led = &iwlagn_led_ops,
401 .ieee80211_ops = &iwlagn_hw_ops,
402}; 389};
403 390
404static const struct iwl_ops iwl6050_ops = { 391static const struct iwl_ops iwl6050_ops = {
405 .lib = &iwl6000_lib, 392 .lib = &iwl6000_lib,
406 .hcmd = &iwlagn_hcmd, 393 .hcmd = &iwlagn_hcmd,
407 .utils = &iwlagn_hcmd_utils, 394 .utils = &iwlagn_hcmd_utils,
408 .led = &iwlagn_led_ops,
409 .nic = &iwl6050_nic_ops, 395 .nic = &iwl6050_nic_ops,
410 .ieee80211_ops = &iwlagn_hw_ops,
411}; 396};
412 397
413static const struct iwl_ops iwl6150_ops = { 398static const struct iwl_ops iwl6150_ops = {
414 .lib = &iwl6000_lib, 399 .lib = &iwl6000_lib,
415 .hcmd = &iwlagn_hcmd, 400 .hcmd = &iwlagn_hcmd,
416 .utils = &iwlagn_hcmd_utils, 401 .utils = &iwlagn_hcmd_utils,
417 .led = &iwlagn_led_ops,
418 .nic = &iwl6150_nic_ops, 402 .nic = &iwl6150_nic_ops,
419 .ieee80211_ops = &iwlagn_hw_ops,
420}; 403};
421 404
422static const struct iwl_ops iwl6030_ops = { 405static const struct iwl_ops iwl6030_ops = {
423 .lib = &iwl6030_lib, 406 .lib = &iwl6030_lib,
424 .hcmd = &iwlagn_bt_hcmd, 407 .hcmd = &iwlagn_bt_hcmd,
425 .utils = &iwlagn_hcmd_utils, 408 .utils = &iwlagn_hcmd_utils,
426 .led = &iwlagn_led_ops,
427 .ieee80211_ops = &iwlagn_hw_ops,
428}; 409};
429 410
430static struct iwl_base_params iwl6000_base_params = { 411static struct iwl_base_params iwl6000_base_params = {
@@ -442,7 +423,6 @@ static struct iwl_base_params iwl6000_base_params = {
442 .chain_noise_scale = 1000, 423 .chain_noise_scale = 1000,
443 .wd_timeout = IWL_DEF_WD_TIMEOUT, 424 .wd_timeout = IWL_DEF_WD_TIMEOUT,
444 .max_event_log_size = 512, 425 .max_event_log_size = 512,
445 .ucode_tracing = true,
446 .shadow_reg_enable = true, 426 .shadow_reg_enable = true,
447}; 427};
448 428
@@ -461,7 +441,6 @@ static struct iwl_base_params iwl6050_base_params = {
461 .chain_noise_scale = 1500, 441 .chain_noise_scale = 1500,
462 .wd_timeout = IWL_DEF_WD_TIMEOUT, 442 .wd_timeout = IWL_DEF_WD_TIMEOUT,
463 .max_event_log_size = 1024, 443 .max_event_log_size = 1024,
464 .ucode_tracing = true,
465 .shadow_reg_enable = true, 444 .shadow_reg_enable = true,
466}; 445};
467static struct iwl_base_params iwl6000_g2_base_params = { 446static struct iwl_base_params iwl6000_g2_base_params = {
@@ -479,7 +458,6 @@ static struct iwl_base_params iwl6000_g2_base_params = {
479 .chain_noise_scale = 1000, 458 .chain_noise_scale = 1000,
480 .wd_timeout = IWL_LONG_WD_TIMEOUT, 459 .wd_timeout = IWL_LONG_WD_TIMEOUT,
481 .max_event_log_size = 512, 460 .max_event_log_size = 512,
482 .ucode_tracing = true,
483 .shadow_reg_enable = true, 461 .shadow_reg_enable = true,
484}; 462};
485 463
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-led.c b/drivers/net/wireless/iwlwifi/iwl-agn-led.c
deleted file mode 100644
index 4bb877e600c7..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-led.c
+++ /dev/null
@@ -1,73 +0,0 @@
1/******************************************************************************
2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/init.h>
30#include <linux/pci.h>
31#include <linux/dma-mapping.h>
32#include <linux/delay.h>
33#include <linux/skbuff.h>
34#include <linux/netdevice.h>
35#include <linux/wireless.h>
36#include <net/mac80211.h>
37#include <linux/etherdevice.h>
38#include <asm/unaligned.h>
39
40#include "iwl-commands.h"
41#include "iwl-dev.h"
42#include "iwl-core.h"
43#include "iwl-io.h"
44#include "iwl-agn-led.h"
45
46/* Send led command */
47static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
48{
49 struct iwl_host_cmd cmd = {
50 .id = REPLY_LEDS_CMD,
51 .len = sizeof(struct iwl_led_cmd),
52 .data = led_cmd,
53 .flags = CMD_ASYNC,
54 .callback = NULL,
55 };
56 u32 reg;
57
58 reg = iwl_read32(priv, CSR_LED_REG);
59 if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
60 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
61
62 return iwl_send_cmd(priv, &cmd);
63}
64
65/* Set led register off */
66void iwlagn_led_enable(struct iwl_priv *priv)
67{
68 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
69}
70
71const struct iwl_led_ops iwlagn_led_ops = {
72 .cmd = iwl_send_led_cmd,
73};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-led.h b/drivers/net/wireless/iwlwifi/iwl-agn-led.h
deleted file mode 100644
index c0b7611b72c3..000000000000
--- a/drivers/net/wireless/iwlwifi/iwl-agn-led.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/******************************************************************************
2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#ifndef __iwl_agn_led_h__
28#define __iwl_agn_led_h__
29
30extern const struct iwl_led_ops iwlagn_led_ops;
31void iwlagn_led_enable(struct iwl_priv *priv);
32
33#endif /* __iwl_agn_led_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 47a4cda9eb72..cdeb09eee739 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -59,7 +59,6 @@
59#include "iwl-sta.h" 59#include "iwl-sta.h"
60#include "iwl-agn-calib.h" 60#include "iwl-agn-calib.h"
61#include "iwl-agn.h" 61#include "iwl-agn.h"
62#include "iwl-agn-led.h"
63 62
64 63
65/****************************************************************************** 64/******************************************************************************
@@ -254,6 +253,10 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
254 struct iwl_frame *frame; 253 struct iwl_frame *frame;
255 unsigned int frame_size; 254 unsigned int frame_size;
256 int rc; 255 int rc;
256 struct iwl_host_cmd cmd = {
257 .id = REPLY_TX_BEACON,
258 .flags = CMD_SIZE_HUGE,
259 };
257 260
258 frame = iwl_get_free_frame(priv); 261 frame = iwl_get_free_frame(priv);
259 if (!frame) { 262 if (!frame) {
@@ -269,8 +272,10 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
269 return -EINVAL; 272 return -EINVAL;
270 } 273 }
271 274
272 rc = iwl_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, 275 cmd.len = frame_size;
273 &frame->u.cmd[0]); 276 cmd.data = &frame->u.cmd[0];
277
278 rc = iwl_send_cmd_sync(priv, &cmd);
274 279
275 iwl_free_frame(priv, frame); 280 iwl_free_frame(priv, frame);
276 281
@@ -395,7 +400,9 @@ int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
395 return -EINVAL; 400 return -EINVAL;
396 } 401 }
397 402
398 BUG_ON(addr & ~DMA_BIT_MASK(36)); 403 if (WARN_ON(addr & ~DMA_BIT_MASK(36)))
404 return -EINVAL;
405
399 if (unlikely(addr & ~IWL_TX_DMA_MASK)) 406 if (unlikely(addr & ~IWL_TX_DMA_MASK))
400 IWL_ERR(priv, "Unaligned address = %llx\n", 407 IWL_ERR(priv, "Unaligned address = %llx\n",
401 (unsigned long long)addr); 408 (unsigned long long)addr);
@@ -719,7 +726,10 @@ static void iwl_rx_handle(struct iwl_priv *priv)
719 /* If an RXB doesn't have a Rx queue slot associated with it, 726 /* If an RXB doesn't have a Rx queue slot associated with it,
720 * then a bug has been introduced in the queue refilling 727 * then a bug has been introduced in the queue refilling
721 * routines -- catch it here */ 728 * routines -- catch it here */
722 BUG_ON(rxb == NULL); 729 if (WARN_ON(rxb == NULL)) {
730 i = (i + 1) & RX_QUEUE_MASK;
731 continue;
732 }
723 733
724 rxq->queue[i] = NULL; 734 rxq->queue[i] = NULL;
725 735
@@ -3718,6 +3728,28 @@ static const u8 iwlagn_pan_ac_to_queue[] = {
3718 7, 6, 5, 4, 3728 7, 6, 5, 4,
3719}; 3729};
3720 3730
3731/* This function both allocates and initializes hw and priv. */
3732static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg)
3733{
3734 struct iwl_priv *priv;
3735 /* mac80211 allocates memory for this device instance, including
3736 * space for this driver's private structure */
3737 struct ieee80211_hw *hw;
3738
3739 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops);
3740 if (hw == NULL) {
3741 pr_err("%s: Can not allocate network device\n",
3742 cfg->name);
3743 goto out;
3744 }
3745
3746 priv = hw->priv;
3747 priv->hw = hw;
3748
3749out:
3750 return hw;
3751}
3752
3721static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 3753static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3722{ 3754{
3723 int err = 0, i; 3755 int err = 0, i;
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 0e98a8703e55..885167f8168d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -67,30 +67,6 @@ u32 iwl_debug_level;
67 67
68const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 68const u8 iwl_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
69 69
70
71/* This function both allocates and initializes hw and priv. */
72struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg)
73{
74 struct iwl_priv *priv;
75 /* mac80211 allocates memory for this device instance, including
76 * space for this driver's private structure */
77 struct ieee80211_hw *hw;
78
79 hw = ieee80211_alloc_hw(sizeof(struct iwl_priv),
80 cfg->ops->ieee80211_ops);
81 if (hw == NULL) {
82 pr_err("%s: Can not allocate network device\n",
83 cfg->name);
84 goto out;
85 }
86
87 priv = hw->priv;
88 priv->hw = hw;
89
90out:
91 return hw;
92}
93
94#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ 70#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
95#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ 71#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
96static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv, 72static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 6988335328e8..32a990ff09ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -139,12 +139,6 @@ struct iwl_temp_ops {
139 void (*temperature)(struct iwl_priv *priv); 139 void (*temperature)(struct iwl_priv *priv);
140}; 140};
141 141
142struct iwl_tt_ops {
143 bool (*lower_power_detection)(struct iwl_priv *priv);
144 u8 (*tt_power_mode)(struct iwl_priv *priv);
145 bool (*ct_kill_check)(struct iwl_priv *priv);
146};
147
148struct iwl_lib_ops { 142struct iwl_lib_ops {
149 /* set hw dependent parameters */ 143 /* set hw dependent parameters */
150 int (*set_hw_params)(struct iwl_priv *priv); 144 int (*set_hw_params)(struct iwl_priv *priv);
@@ -190,13 +184,6 @@ struct iwl_lib_ops {
190 void (*dev_txfifo_flush)(struct iwl_priv *priv, u16 flush_control); 184 void (*dev_txfifo_flush)(struct iwl_priv *priv, u16 flush_control);
191 185
192 struct iwl_debugfs_ops debugfs_ops; 186 struct iwl_debugfs_ops debugfs_ops;
193
194 /* thermal throttling */
195 struct iwl_tt_ops tt_ops;
196};
197
198struct iwl_led_ops {
199 int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd);
200}; 187};
201 188
202/* NIC specific ops */ 189/* NIC specific ops */
@@ -204,23 +191,11 @@ struct iwl_nic_ops {
204 void (*additional_nic_config)(struct iwl_priv *priv); 191 void (*additional_nic_config)(struct iwl_priv *priv);
205}; 192};
206 193
207struct iwl_legacy_ops {
208 void (*post_associate)(struct iwl_priv *priv);
209 void (*config_ap)(struct iwl_priv *priv);
210 /* station management */
211 int (*update_bcast_stations)(struct iwl_priv *priv);
212 int (*manage_ibss_station)(struct iwl_priv *priv,
213 struct ieee80211_vif *vif, bool add);
214};
215
216struct iwl_ops { 194struct iwl_ops {
217 const struct iwl_lib_ops *lib; 195 const struct iwl_lib_ops *lib;
218 const struct iwl_hcmd_ops *hcmd; 196 const struct iwl_hcmd_ops *hcmd;
219 const struct iwl_hcmd_utils_ops *utils; 197 const struct iwl_hcmd_utils_ops *utils;
220 const struct iwl_led_ops *led;
221 const struct iwl_nic_ops *nic; 198 const struct iwl_nic_ops *nic;
222 const struct iwl_legacy_ops *legacy;
223 const struct ieee80211_ops *ieee80211_ops;
224}; 199};
225 200
226struct iwl_mod_params { 201struct iwl_mod_params {
@@ -250,7 +225,6 @@ struct iwl_mod_params {
250 * @wd_timeout: TX queues watchdog timeout 225 * @wd_timeout: TX queues watchdog timeout
251 * @temperature_kelvin: temperature report by uCode in kelvin 226 * @temperature_kelvin: temperature report by uCode in kelvin
252 * @max_event_log_size: size of event log buffer size for ucode event logging 227 * @max_event_log_size: size of event log buffer size for ucode event logging
253 * @ucode_tracing: support ucode continuous tracing
254 * @shadow_reg_enable: HW shadhow register bit 228 * @shadow_reg_enable: HW shadhow register bit
255 */ 229 */
256struct iwl_base_params { 230struct iwl_base_params {
@@ -272,7 +246,6 @@ struct iwl_base_params {
272 unsigned int wd_timeout; 246 unsigned int wd_timeout;
273 bool temperature_kelvin; 247 bool temperature_kelvin;
274 u32 max_event_log_size; 248 u32 max_event_log_size;
275 const bool ucode_tracing;
276 const bool shadow_reg_enable; 249 const bool shadow_reg_enable;
277}; 250};
278/* 251/*
@@ -376,7 +349,6 @@ struct iwl_cfg {
376 * L i b * 349 * L i b *
377 ***************************/ 350 ***************************/
378 351
379struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg);
380int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, 352int iwl_mac_conf_tx(struct ieee80211_hw *hw, u16 queue,
381 const struct ieee80211_tx_queue_params *params); 353 const struct ieee80211_tx_queue_params *params);
382int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw); 354int iwl_mac_tx_last_beacon(struct ieee80211_hw *hw);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 897efacb96eb..c272204fccff 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -1749,8 +1749,7 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name)
1749 1749
1750 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); 1750 DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR);
1751 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); 1751 DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR);
1752 if (priv->cfg->base_params->ucode_tracing) 1752 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1753 DEBUGFS_ADD_FILE(ucode_tracing, dir_debug, S_IWUSR | S_IRUSR);
1754 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR); 1753 DEBUGFS_ADD_FILE(ucode_bt_stats, dir_debug, S_IRUSR);
1755 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR); 1754 DEBUGFS_ADD_FILE(reply_tx_error, dir_debug, S_IRUSR);
1756 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); 1755 DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR);
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index 859b94a12297..402733638f50 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -215,12 +215,6 @@ static int iwlcore_get_nvm_type(struct iwl_priv *priv, u32 hw_rev)
215 return nvm_type; 215 return nvm_type;
216} 216}
217 217
218const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
219{
220 BUG_ON(offset >= priv->cfg->base_params->eeprom_size);
221 return &priv->eeprom[offset];
222}
223
224static int iwl_init_otp_access(struct iwl_priv *priv) 218static int iwl_init_otp_access(struct iwl_priv *priv)
225{ 219{
226 int ret; 220 int ret;
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 0e9d9703636a..9ce052573c6a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -309,7 +309,6 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv);
309const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); 309const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
310int iwlcore_eeprom_verify_signature(struct iwl_priv *priv); 310int iwlcore_eeprom_verify_signature(struct iwl_priv *priv);
311u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset); 311u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset);
312const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
313int iwl_init_channel_map(struct iwl_priv *priv); 312int iwl_init_channel_map(struct iwl_priv *priv);
314void iwl_free_channel_map(struct iwl_priv *priv); 313void iwl_free_channel_map(struct iwl_priv *priv);
315const struct iwl_channel_info *iwl_get_channel_info( 314const struct iwl_channel_info *iwl_get_channel_info(
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 9177b553fe57..8f0beb992ccf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -143,10 +143,12 @@ static int iwl_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
143{ 143{
144 int ret; 144 int ret;
145 145
146 BUG_ON(!(cmd->flags & CMD_ASYNC)); 146 if (WARN_ON(!(cmd->flags & CMD_ASYNC)))
147 return -EINVAL;
147 148
148 /* An asynchronous command can not expect an SKB to be set. */ 149 /* An asynchronous command can not expect an SKB to be set. */
149 BUG_ON(cmd->flags & CMD_WANT_SKB); 150 if (WARN_ON(cmd->flags & CMD_WANT_SKB))
151 return -EINVAL;
150 152
151 /* Assign a generic callback if one is not provided */ 153 /* Assign a generic callback if one is not provided */
152 if (!cmd->callback) 154 if (!cmd->callback)
@@ -169,10 +171,12 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
169 int cmd_idx; 171 int cmd_idx;
170 int ret; 172 int ret;
171 173
172 lockdep_assert_held(&priv->mutex); 174 if (WARN_ON(cmd->flags & CMD_ASYNC))
175 return -EINVAL;
173 176
174 /* A synchronous command can not have a callback set. */ 177 /* A synchronous command can not have a callback set. */
175 BUG_ON((cmd->flags & CMD_ASYNC) || cmd->callback); 178 if (WARN_ON(cmd->callback))
179 return -EINVAL;
176 180
177 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", 181 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
178 get_cmd_string(cmd->id)); 182 get_cmd_string(cmd->id));
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 0d90004e8b1b..d798c2a152d3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -61,6 +61,12 @@ static const struct ieee80211_tpt_blink iwl_blink[] = {
61 { .throughput = 300 * 1024 - 1, .blink_time = 50 }, 61 { .throughput = 300 * 1024 - 1, .blink_time = 50 },
62}; 62};
63 63
64/* Set led register off */
65void iwlagn_led_enable(struct iwl_priv *priv)
66{
67 iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
68}
69
64/* 70/*
65 * Adjust led blink rate to compensate on a MAC Clock difference on every HW 71 * Adjust led blink rate to compensate on a MAC Clock difference on every HW
66 * Led blink rate analysis showed an average deviation of 20% on 5000 series 72 * Led blink rate analysis showed an average deviation of 20% on 5000 series
@@ -84,6 +90,24 @@ static inline u8 iwl_blink_compensation(struct iwl_priv *priv,
84 return (u8)((time * compensation) >> 6); 90 return (u8)((time * compensation) >> 6);
85} 91}
86 92
93static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
94{
95 struct iwl_host_cmd cmd = {
96 .id = REPLY_LEDS_CMD,
97 .len = sizeof(struct iwl_led_cmd),
98 .data = led_cmd,
99 .flags = CMD_ASYNC,
100 .callback = NULL,
101 };
102 u32 reg;
103
104 reg = iwl_read32(priv, CSR_LED_REG);
105 if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
106 iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
107
108 return iwl_send_cmd(priv, &cmd);
109}
110
87/* Set led pattern command */ 111/* Set led pattern command */
88static int iwl_led_cmd(struct iwl_priv *priv, 112static int iwl_led_cmd(struct iwl_priv *priv,
89 unsigned long on, 113 unsigned long on,
@@ -108,7 +132,7 @@ static int iwl_led_cmd(struct iwl_priv *priv,
108 led_cmd.off = iwl_blink_compensation(priv, off, 132 led_cmd.off = iwl_blink_compensation(priv, off,
109 priv->cfg->base_params->led_compensation); 133 priv->cfg->base_params->led_compensation);
110 134
111 ret = priv->cfg->ops->led->cmd(priv, &led_cmd); 135 ret = iwl_send_led_cmd(priv, &led_cmd);
112 if (!ret) { 136 if (!ret) {
113 priv->blink_on = on; 137 priv->blink_on = on;
114 priv->blink_off = off; 138 priv->blink_off = off;
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.h b/drivers/net/wireless/iwlwifi/iwl-led.h
index 05b8e8f7dd4a..1c93dfef6933 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.h
+++ b/drivers/net/wireless/iwlwifi/iwl-led.h
@@ -50,6 +50,7 @@ enum iwl_led_mode {
50 IWL_LED_BLINK, 50 IWL_LED_BLINK,
51}; 51};
52 52
53void iwlagn_led_enable(struct iwl_priv *priv);
53void iwl_leds_init(struct iwl_priv *priv); 54void iwl_leds_init(struct iwl_priv *priv);
54void iwl_leds_exit(struct iwl_priv *priv); 55void iwl_leds_exit(struct iwl_priv *priv);
55 56
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index ae176d8da9e8..595c930b28ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -188,9 +188,10 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
188 table = range_0; 188 table = range_0;
189 } 189 }
190 190
191 BUG_ON(lvl < 0 || lvl >= IWL_POWER_NUM); 191 if (WARN_ON(lvl < 0 || lvl >= IWL_POWER_NUM))
192 192 memset(cmd, 0, sizeof(*cmd));
193 *cmd = table[lvl].cmd; 193 else
194 *cmd = table[lvl].cmd;
194 195
195 if (period == 0) { 196 if (period == 0) {
196 skip = 0; 197 skip = 0;
@@ -356,12 +357,10 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
356 357
357 if (priv->hw->conf.flags & IEEE80211_CONF_IDLE) 358 if (priv->hw->conf.flags & IEEE80211_CONF_IDLE)
358 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20); 359 iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
359 else if (priv->cfg->ops->lib->tt_ops.lower_power_detection && 360 else if (iwl_tt_is_low_power_state(priv)) {
360 priv->cfg->ops->lib->tt_ops.tt_power_mode &&
361 priv->cfg->ops->lib->tt_ops.lower_power_detection(priv)) {
362 /* in thermal throttling low power state */ 361 /* in thermal throttling low power state */
363 iwl_static_sleep_cmd(priv, cmd, 362 iwl_static_sleep_cmd(priv, cmd,
364 priv->cfg->ops->lib->tt_ops.tt_power_mode(priv), dtimper); 363 iwl_tt_current_power_mode(priv), dtimper);
365 } else if (!enabled) 364 } else if (!enabled)
366 iwl_power_sleep_cam_cmd(priv, cmd); 365 iwl_power_sleep_cam_cmd(priv, cmd);
367 else if (priv->power_data.debug_sleep_level_override >= 0) 366 else if (priv->power_data.debug_sleep_level_override >= 0)
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index c21515640077..3c8cebde16cc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -494,7 +494,8 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id,
494 494
495 priv->num_stations--; 495 priv->num_stations--;
496 496
497 BUG_ON(priv->num_stations < 0); 497 if (WARN_ON(priv->num_stations < 0))
498 priv->num_stations = 0;
498 499
499 spin_unlock_irqrestore(&priv->sta_lock, flags); 500 spin_unlock_irqrestore(&priv->sta_lock, flags);
500 501
@@ -679,7 +680,8 @@ void iwl_dealloc_bcast_stations(struct iwl_priv *priv)
679 680
680 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; 681 priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
681 priv->num_stations--; 682 priv->num_stations--;
682 BUG_ON(priv->num_stations < 0); 683 if (WARN_ON(priv->num_stations < 0))
684 priv->num_stations = 0;
683 kfree(priv->stations[i].lq); 685 kfree(priv->stations[i].lq);
684 priv->stations[i].lq = NULL; 686 priv->stations[i].lq = NULL;
685 } 687 }
@@ -775,7 +777,8 @@ int iwl_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
775 spin_unlock_irqrestore(&priv->sta_lock, flags_spin); 777 spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
776 778
777 iwl_dump_lq_cmd(priv, lq); 779 iwl_dump_lq_cmd(priv, lq);
778 BUG_ON(init && (cmd.flags & CMD_ASYNC)); 780 if (WARN_ON(init && (cmd.flags & CMD_ASYNC)))
781 return -EINVAL;
779 782
780 if (is_lq_table_valid(priv, ctx, lq)) 783 if (is_lq_table_valid(priv, ctx, lq))
781 ret = iwl_send_cmd(priv, &cmd); 784 ret = iwl_send_cmd(priv, &cmd);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 3732380c4ffe..80c3565a66ae 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -263,11 +263,13 @@ static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
263 263
264 /* count must be power-of-two size, otherwise iwl_queue_inc_wrap 264 /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
265 * and iwl_queue_dec_wrap are broken. */ 265 * and iwl_queue_dec_wrap are broken. */
266 BUG_ON(!is_power_of_2(count)); 266 if (WARN_ON(!is_power_of_2(count)))
267 return -EINVAL;
267 268
268 /* slots_num must be power-of-two size, otherwise 269 /* slots_num must be power-of-two size, otherwise
269 * get_cmd_index is broken. */ 270 * get_cmd_index is broken. */
270 BUG_ON(!is_power_of_2(slots_num)); 271 if (WARN_ON(!is_power_of_2(slots_num)))
272 return -EINVAL;
271 273
272 q->low_mark = q->n_window / 4; 274 q->low_mark = q->n_window / 4;
273 if (q->low_mark < 4) 275 if (q->low_mark < 4)
@@ -384,7 +386,9 @@ int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
384 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 386 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
385 387
386 /* Initialize queue's high/low-water marks, and head/tail indexes */ 388 /* Initialize queue's high/low-water marks, and head/tail indexes */
387 iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 389 ret = iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
390 if (ret)
391 return ret;
388 392
389 /* Tell device where to find queue */ 393 /* Tell device where to find queue */
390 priv->cfg->ops->lib->txq_init(priv, txq); 394 priv->cfg->ops->lib->txq_init(priv, txq);
@@ -446,14 +450,19 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
446 cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); 450 cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len);
447 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); 451 fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr));
448 452
449 /* If any of the command structures end up being larger than 453 /*
454 * If any of the command structures end up being larger than
450 * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then 455 * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then
451 * we will need to increase the size of the TFD entries 456 * we will need to increase the size of the TFD entries
452 * Also, check to see if command buffer should not exceed the size 457 * Also, check to see if command buffer should not exceed the size
453 * of device_cmd and max_cmd_size. */ 458 * of device_cmd and max_cmd_size.
454 BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && 459 */
455 !(cmd->flags & CMD_SIZE_HUGE)); 460 if (WARN_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) &&
456 BUG_ON(fix_size > IWL_MAX_CMD_SIZE); 461 !(cmd->flags & CMD_SIZE_HUGE)))
462 return -EINVAL;
463
464 if (WARN_ON(fix_size > IWL_MAX_CMD_SIZE))
465 return -EINVAL;
457 466
458 if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) { 467 if (iwl_is_rfkill(priv) || iwl_is_ctkill(priv)) {
459 IWL_WARN(priv, "Not sending command - %s KILL\n", 468 IWL_WARN(priv, "Not sending command - %s KILL\n",
@@ -461,16 +470,21 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
461 return -EIO; 470 return -EIO;
462 } 471 }
463 472
473 /*
474 * As we only have a single huge buffer, check that the command
475 * is synchronous (otherwise buffers could end up being reused).
476 */
477
478 if (WARN_ON((cmd->flags & CMD_ASYNC) && (cmd->flags & CMD_SIZE_HUGE)))
479 return -EINVAL;
480
464 spin_lock_irqsave(&priv->hcmd_lock, flags); 481 spin_lock_irqsave(&priv->hcmd_lock, flags);
465 482
466 if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { 483 if (iwl_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
467 spin_unlock_irqrestore(&priv->hcmd_lock, flags); 484 spin_unlock_irqrestore(&priv->hcmd_lock, flags);
468 485
469 IWL_ERR(priv, "No space in command queue\n"); 486 IWL_ERR(priv, "No space in command queue\n");
470 if (priv->cfg->ops->lib->tt_ops.ct_kill_check) { 487 is_ct_kill = iwl_check_for_ct_kill(priv);
471 is_ct_kill =
472 priv->cfg->ops->lib->tt_ops.ct_kill_check(priv);
473 }
474 if (!is_ct_kill) { 488 if (!is_ct_kill) {
475 IWL_ERR(priv, "Restarting adapter due to queue full\n"); 489 IWL_ERR(priv, "Restarting adapter due to queue full\n");
476 iwlagn_fw_error(priv, false); 490 iwlagn_fw_error(priv, false);