diff options
author | Samuel Ortiz <samuel.ortiz@intel.com> | 2009-01-21 12:27:54 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:05 -0500 |
commit | c0af96a6e63ef93c605ce495fff79c692d4b8c4d (patch) | |
tree | 267d272ba8eee87c32ff05f0714d13cf2c148fd6 /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | 7d049e5abe77c82d6f11a4e5869203f7b2838380 (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>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 151 |
1 files changed, 5 insertions, 146 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index c9f6f8e86440..78271936801a 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 | ||
5113 | static 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 | |||
5146 | static void iwl3945_rfkill_poll(struct work_struct *data) | 5113 | static 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 | ||
5397 | static void iwl3945_bg_restart(struct work_struct *data) | 5364 | static 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 */ | ||
7325 | static 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 | } | ||
7354 | out_unlock: | ||
7355 | mutex_unlock(&priv->mutex); | ||
7356 | |||
7357 | return err; | ||
7358 | } | ||
7359 | |||
7360 | int 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 | |||
7393 | freed_rfkill: | ||
7394 | if (priv->rfkill != NULL) | ||
7395 | rfkill_free(priv->rfkill); | ||
7396 | priv->rfkill = NULL; | ||
7397 | |||
7398 | error: | ||
7399 | IWL_DEBUG_RF_KILL("RFKILL initialization complete.\n"); | ||
7400 | return ret; | ||
7401 | } | ||
7402 | |||
7403 | void 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. */ | ||
7412 | void 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 |