aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <samuel.ortiz@intel.com>2009-01-21 12:27:54 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:01:05 -0500
commitc0af96a6e63ef93c605ce495fff79c692d4b8c4d (patch)
tree267d272ba8eee87c32ff05f0714d13cf2c148fd6
parent7d049e5abe77c82d6f11a4e5869203f7b2838380 (diff)
iwl3945: Use iwl-rfkill
Here again, the rfkill routines are duplicated between agn and 3945. Let's move the agn one to iwlcore, and so we can get rid of the 3945 ones. Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c35
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c36
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c151
6 files changed, 43 insertions, 199 deletions
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 022122603c1..f38130abab0 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -110,7 +110,7 @@ config IWL3945
110 select LIB80211 110 select LIB80211
111 select MAC80211_LEDS if IWL3945_LEDS 111 select MAC80211_LEDS if IWL3945_LEDS
112 select LEDS_CLASS if IWL3945_LEDS 112 select LEDS_CLASS if IWL3945_LEDS
113 select RFKILL if IWL3945_RFKILL 113 select RFKILL if IWLWIFI_RFKILL
114 ---help--- 114 ---help---
115 Select to build the driver supporting the: 115 Select to build the driver supporting the:
116 116
@@ -133,10 +133,6 @@ config IWL3945
133 say M here and read <file:Documentation/kbuild/modules.txt>. The 133 say M here and read <file:Documentation/kbuild/modules.txt>. The
134 module will be called iwl3945.ko. 134 module will be called iwl3945.ko.
135 135
136config IWL3945_RFKILL
137 bool "Enable RF kill support in iwl3945 drivers"
138 depends on IWL3945
139
140config IWL3945_SPECTRUM_MEASUREMENT 136config IWL3945_SPECTRUM_MEASUREMENT
141 bool "Enable Spectrum Measurement in iwl3945 drivers" 137 bool "Enable Spectrum Measurement in iwl3945 drivers"
142 depends on IWL3945 138 depends on IWL3945
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index 54538df50d3..77e97eaa4e4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -304,18 +304,6 @@ extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv);
304extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, 304extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id,
305 u16 tx_rate, u8 flags); 305 u16 tx_rate, u8 flags);
306 306
307#ifdef CONFIG_IWL3945_RFKILL
308struct iwl_priv;
309
310void iwl3945_rfkill_set_hw_state(struct iwl_priv *priv);
311void iwl3945_rfkill_unregister(struct iwl_priv *priv);
312int iwl3945_rfkill_init(struct iwl_priv *priv);
313#else
314static inline void iwl3945_rfkill_set_hw_state(struct iwl_priv *priv) {}
315static inline void iwl3945_rfkill_unregister(struct iwl_priv *priv) {}
316static inline int iwl3945_rfkill_init(struct iwl_priv *priv) { return 0; }
317#endif
318
319static inline int iwl3945_is_associated(struct iwl_priv *priv) 307static inline int iwl3945_is_associated(struct iwl_priv *priv)
320{ 308{
321 return (priv->active39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; 309 return (priv->active39_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index fc92c37735f..c72a99a9ab3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2266,41 +2266,6 @@ static void iwl_bg_alive_start(struct work_struct *data)
2266 mutex_unlock(&priv->mutex); 2266 mutex_unlock(&priv->mutex);
2267} 2267}
2268 2268
2269static void iwl_bg_rf_kill(struct work_struct *work)
2270{
2271 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill);
2272
2273 wake_up_interruptible(&priv->wait_command_queue);
2274
2275 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
2276 return;
2277
2278 mutex_lock(&priv->mutex);
2279
2280 if (!iwl_is_rfkill(priv)) {
2281 IWL_DEBUG(IWL_DL_RF_KILL,
2282 "HW and/or SW RF Kill no longer active, restarting "
2283 "device\n");
2284 if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
2285 test_bit(STATUS_ALIVE, &priv->status))
2286 queue_work(priv->workqueue, &priv->restart);
2287 } else {
2288 /* make sure mac80211 stop sending Tx frame */
2289 if (priv->mac80211_registered)
2290 ieee80211_stop_queues(priv->hw);
2291
2292 if (!test_bit(STATUS_RF_KILL_HW, &priv->status))
2293 IWL_DEBUG_RF_KILL("Can not turn radio back on - "
2294 "disabled by SW switch\n");
2295 else
2296 IWL_WARN(priv, "Radio Frequency Kill Switch is On:\n"
2297 "Kill switch must be turned off for "
2298 "wireless networking to work.\n");
2299 }
2300 mutex_unlock(&priv->mutex);
2301 iwl_rfkill_set_hw_state(priv);
2302}
2303
2304static void iwl_bg_run_time_calib_work(struct work_struct *work) 2269static void iwl_bg_run_time_calib_work(struct work_struct *work)
2305{ 2270{
2306 struct iwl_priv *priv = container_of(work, struct iwl_priv, 2271 struct iwl_priv *priv = container_of(work, struct iwl_priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index d2ef3e142bc..f24d3b40e8e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1465,3 +1465,39 @@ int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv)
1465 return 1; 1465 return 1;
1466} 1466}
1467EXPORT_SYMBOL(iwl_radio_kill_sw_enable_radio); 1467EXPORT_SYMBOL(iwl_radio_kill_sw_enable_radio);
1468
1469void iwl_bg_rf_kill(struct work_struct *work)
1470{
1471 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill);
1472
1473 wake_up_interruptible(&priv->wait_command_queue);
1474
1475 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1476 return;
1477
1478 mutex_lock(&priv->mutex);
1479
1480 if (!iwl_is_rfkill(priv)) {
1481 IWL_DEBUG(IWL_DL_RF_KILL,
1482 "HW and/or SW RF Kill no longer active, restarting "
1483 "device\n");
1484 if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
1485 test_bit(STATUS_ALIVE, &priv->status))
1486 queue_work(priv->workqueue, &priv->restart);
1487 } else {
1488 /* make sure mac80211 stop sending Tx frame */
1489 if (priv->mac80211_registered)
1490 ieee80211_stop_queues(priv->hw);
1491
1492 if (!test_bit(STATUS_RF_KILL_HW, &priv->status))
1493 IWL_DEBUG_RF_KILL("Can not turn radio back on - "
1494 "disabled by SW switch\n");
1495 else
1496 IWL_WARN(priv, "Radio Frequency Kill Switch is On:\n"
1497 "Kill switch must be turned off for "
1498 "wireless networking to work.\n");
1499 }
1500 mutex_unlock(&priv->mutex);
1501 iwl_rfkill_set_hw_state(priv);
1502}
1503EXPORT_SYMBOL(iwl_bg_rf_kill);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 9abdfb4acbf..2f23f78296e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -277,7 +277,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);
277 * RF -Kill - here and not in iwl-rfkill.h to be available when 277 * RF -Kill - here and not in iwl-rfkill.h to be available when
278 * RF-kill subsystem is not compiled. 278 * RF-kill subsystem is not compiled.
279 ****************************************************/ 279 ****************************************************/
280void iwl_rf_kill(struct iwl_priv *priv); 280void iwl_bg_rf_kill(struct work_struct *work);
281void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv); 281void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv);
282int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv); 282int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv);
283 283
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index c9f6f8e8644..78271936801 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -5110,39 +5110,6 @@ static void iwl3945_bg_alive_start(struct work_struct *data)
5110 mutex_unlock(&priv->mutex); 5110 mutex_unlock(&priv->mutex);
5111} 5111}
5112 5112
5113static void iwl3945_bg_rf_kill(struct work_struct *work)
5114{
5115 struct iwl_priv *priv = container_of(work, struct iwl_priv, rf_kill);
5116
5117 wake_up_interruptible(&priv->wait_command_queue);
5118
5119 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
5120 return;
5121
5122 mutex_lock(&priv->mutex);
5123
5124 if (!iwl_is_rfkill(priv)) {
5125 IWL_DEBUG(IWL_DL_INFO | IWL_DL_RF_KILL,
5126 "HW and/or SW RF Kill no longer active, restarting "
5127 "device\n");
5128 if (!test_bit(STATUS_EXIT_PENDING, &priv->status) &&
5129 test_bit(STATUS_ALIVE, &priv->status))
5130 queue_work(priv->workqueue, &priv->restart);
5131 } else {
5132
5133 if (!test_bit(STATUS_RF_KILL_HW, &priv->status))
5134 IWL_DEBUG_RF_KILL("Can not turn radio back on - "
5135 "disabled by SW switch\n");
5136 else
5137 IWL_WARN(priv, "Radio Frequency Kill Switch is On:\n"
5138 "Kill switch must be turned off for "
5139 "wireless networking to work.\n");
5140 }
5141
5142 mutex_unlock(&priv->mutex);
5143 iwl3945_rfkill_set_hw_state(priv);
5144}
5145
5146static void iwl3945_rfkill_poll(struct work_struct *data) 5113static void iwl3945_rfkill_poll(struct work_struct *data)
5147{ 5114{
5148 struct iwl_priv *priv = 5115 struct iwl_priv *priv =
@@ -5391,7 +5358,7 @@ static void iwl3945_bg_up(struct work_struct *data)
5391 mutex_lock(&priv->mutex); 5358 mutex_lock(&priv->mutex);
5392 __iwl3945_up(priv); 5359 __iwl3945_up(priv);
5393 mutex_unlock(&priv->mutex); 5360 mutex_unlock(&priv->mutex);
5394 iwl3945_rfkill_set_hw_state(priv); 5361 iwl_rfkill_set_hw_state(priv);
5395} 5362}
5396 5363
5397static void iwl3945_bg_restart(struct work_struct *data) 5364static void iwl3945_bg_restart(struct work_struct *data)
@@ -5584,7 +5551,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw)
5584 5551
5585 mutex_unlock(&priv->mutex); 5552 mutex_unlock(&priv->mutex);
5586 5553
5587 iwl3945_rfkill_set_hw_state(priv); 5554 iwl_rfkill_set_hw_state(priv);
5588 5555
5589 if (ret) 5556 if (ret)
5590 goto out_release_irq; 5557 goto out_release_irq;
@@ -6852,7 +6819,7 @@ static void iwl3945_setup_deferred_work(struct iwl_priv *priv)
6852 INIT_WORK(&priv->scan_completed, iwl3945_bg_scan_completed); 6819 INIT_WORK(&priv->scan_completed, iwl3945_bg_scan_completed);
6853 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan); 6820 INIT_WORK(&priv->request_scan, iwl3945_bg_request_scan);
6854 INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan); 6821 INIT_WORK(&priv->abort_scan, iwl3945_bg_abort_scan);
6855 INIT_WORK(&priv->rf_kill, iwl3945_bg_rf_kill); 6822 INIT_WORK(&priv->rf_kill, iwl_bg_rf_kill);
6856 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update); 6823 INIT_WORK(&priv->beacon_update, iwl3945_bg_beacon_update);
6857 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); 6824 INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start);
6858 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); 6825 INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start);
@@ -7180,7 +7147,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
7180 priv->hw->conf.beacon_int = 100; 7147 priv->hw->conf.beacon_int = 100;
7181 priv->mac80211_registered = 1; 7148 priv->mac80211_registered = 1;
7182 7149
7183 err = iwl3945_rfkill_init(priv); 7150 err = iwl_rfkill_init(priv);
7184 if (err) 7151 if (err)
7185 IWL_ERR(priv, "Unable to initialize RFKILL system. " 7152 IWL_ERR(priv, "Unable to initialize RFKILL system. "
7186 "Ignoring error: %d\n", err); 7153 "Ignoring error: %d\n", err);
@@ -7246,7 +7213,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev)
7246 7213
7247 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); 7214 sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group);
7248 7215
7249 iwl3945_rfkill_unregister(priv); 7216 iwl_rfkill_unregister(priv);
7250 cancel_delayed_work(&priv->rfkill_poll); 7217 cancel_delayed_work(&priv->rfkill_poll);
7251 7218
7252 iwl3945_dealloc_ucode_pci(priv); 7219 iwl3945_dealloc_ucode_pci(priv);
@@ -7319,114 +7286,6 @@ static int iwl3945_pci_resume(struct pci_dev *pdev)
7319 7286
7320#endif /* CONFIG_PM */ 7287#endif /* CONFIG_PM */
7321 7288
7322/*************** RFKILL FUNCTIONS **********/
7323#ifdef CONFIG_IWL3945_RFKILL
7324/* software rf-kill from user */
7325static int iwl3945_rfkill_soft_rf_kill(void *data, enum rfkill_state state)
7326{
7327 struct iwl_priv *priv = data;
7328 int err = 0;
7329
7330 if (!priv->rfkill)
7331 return 0;
7332
7333 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
7334 return 0;
7335
7336 IWL_DEBUG_RF_KILL("we received soft RFKILL set to state %d\n", state);
7337 mutex_lock(&priv->mutex);
7338
7339 switch (state) {
7340 case RFKILL_STATE_UNBLOCKED:
7341 if (iwl_is_rfkill_hw(priv)) {
7342 err = -EBUSY;
7343 goto out_unlock;
7344 }
7345 iwl3945_radio_kill_sw(priv, 0);
7346 break;
7347 case RFKILL_STATE_SOFT_BLOCKED:
7348 iwl3945_radio_kill_sw(priv, 1);
7349 break;
7350 default:
7351 IWL_WARN(priv, "received unexpected RFKILL state %d\n", state);
7352 break;
7353 }
7354out_unlock:
7355 mutex_unlock(&priv->mutex);
7356
7357 return err;
7358}
7359
7360int iwl3945_rfkill_init(struct iwl_priv *priv)
7361{
7362 struct device *device = wiphy_dev(priv->hw->wiphy);
7363 int ret = 0;
7364
7365 BUG_ON(device == NULL);
7366
7367 IWL_DEBUG_RF_KILL("Initializing RFKILL.\n");
7368 priv->rfkill = rfkill_allocate(device, RFKILL_TYPE_WLAN);
7369 if (!priv->rfkill) {
7370 IWL_ERR(priv, "Unable to allocate rfkill device.\n");
7371 ret = -ENOMEM;
7372 goto error;
7373 }
7374
7375 priv->rfkill->name = priv->cfg->name;
7376 priv->rfkill->data = priv;
7377 priv->rfkill->state = RFKILL_STATE_UNBLOCKED;
7378 priv->rfkill->toggle_radio = iwl3945_rfkill_soft_rf_kill;
7379 priv->rfkill->user_claim_unsupported = 1;
7380
7381 priv->rfkill->dev.class->suspend = NULL;
7382 priv->rfkill->dev.class->resume = NULL;
7383
7384 ret = rfkill_register(priv->rfkill);
7385 if (ret) {
7386 IWL_ERR(priv, "Unable to register rfkill: %d\n", ret);
7387 goto freed_rfkill;
7388 }
7389
7390 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
7391 return ret;
7392
7393freed_rfkill:
7394 if (priv->rfkill != NULL)
7395 rfkill_free(priv->rfkill);
7396 priv->rfkill = NULL;
7397
7398error:
7399 IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n");
7400 return ret;
7401}
7402
7403void iwl3945_rfkill_unregister(struct iwl_priv *priv)
7404{
7405 if (priv->rfkill)
7406 rfkill_unregister(priv->rfkill);
7407
7408 priv->rfkill = NULL;
7409}
7410
7411/* set rf-kill to the right state. */
7412void iwl3945_rfkill_set_hw_state(struct iwl_priv *priv)
7413{
7414
7415 if (!priv->rfkill)
7416 return;
7417
7418 if (iwl_is_rfkill_hw(priv)) {
7419 rfkill_force_state(priv->rfkill, RFKILL_STATE_HARD_BLOCKED);
7420 return;
7421 }
7422
7423 if (!iwl_is_rfkill_sw(priv))
7424 rfkill_force_state(priv->rfkill, RFKILL_STATE_UNBLOCKED);
7425 else
7426 rfkill_force_state(priv->rfkill, RFKILL_STATE_SOFT_BLOCKED);
7427}
7428#endif
7429
7430/***************************************************************************** 7289/*****************************************************************************
7431 * 7290 *
7432 * driver and module entry point 7291 * driver and module entry point