Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[sfrench/cifs-2.6.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index be7c9f42a34079440a48411e1a732ad9eedd6a9a..1a6b0e0edf6f026d8f3c98bc1e1cd454936ef4c0 100644 (file)
@@ -2915,6 +2915,10 @@ static void iwl_set_rate(struct iwl_priv *priv)
        int i;
 
        hw = iwl_get_hw_mode(priv, priv->phymode);
+       if (!hw) {
+               IWL_ERROR("Failed to set rate: unable to get hw mode\n");
+               return;
+       }
 
        priv->active_rate = 0;
        priv->active_rate_basic = 0;
@@ -4739,8 +4743,10 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
                 *   when we loaded driver, and is now set to "enable".
                 * After we're Alive, RF_KILL gets handled by
                 *   iwl_rx_card_state_notif() */
-               if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status))
+               if (!hw_rf_kill && !test_bit(STATUS_ALIVE, &priv->status)) {
+                       clear_bit(STATUS_RF_KILL_HW, &priv->status);
                        queue_work(priv->workqueue, &priv->restart);
+               }
 
                handled |= CSR_INT_BIT_RF_KILL;
        }
@@ -4850,7 +4856,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
        if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) {
                /* Hardware disappeared */
                IWL_WARNING("HARDWARE GONE?? INTA == 0x%080x\n", inta);
-               goto none;
+               goto unplugged;
        }
 
        IWL_DEBUG_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
@@ -4858,6 +4864,7 @@ static irqreturn_t iwl_isr(int irq, void *data)
 
        /* iwl_irq_tasklet() will service interrupts and re-enable them */
        tasklet_schedule(&priv->irq_tasklet);
+unplugged:
        spin_unlock(&priv->lock);
 
        return IRQ_HANDLED;
@@ -5331,13 +5338,13 @@ static int iwl_init_geos(struct iwl_priv *priv)
        /* 5.2GHz channels start after the 2.4GHz channels */
        modes[A].mode = MODE_IEEE80211A;
        modes[A].channels = &channels[ARRAY_SIZE(iwl_eeprom_band_1)];
-       modes[A].rates = rates;
+       modes[A].rates = &rates[4];
        modes[A].num_rates = 8; /* just OFDM */
        modes[A].num_channels = 0;
 
        modes[B].mode = MODE_IEEE80211B;
        modes[B].channels = channels;
-       modes[B].rates = &rates[8];
+       modes[B].rates = rates;
        modes[B].num_rates = 4; /* just CCK */
        modes[B].num_channels = 0;
 
@@ -6166,6 +6173,7 @@ static void iwl_alive_start(struct iwl_priv *priv)
                mutex_lock(&priv->mutex);
 
                if (rc) {
+                       iwl_rate_control_unregister(priv->hw);
                        IWL_ERROR("Failed to register network "
                                  "device (error %d)\n", rc);
                        return;
@@ -6238,8 +6246,6 @@ static void __iwl_down(struct iwl_priv *priv)
        /* Unblock any waiting calls */
        wake_up_interruptible_all(&priv->wait_command_queue);
 
-       iwl_cancel_deferred_work(priv);
-
        /* Wipe out the EXIT_PENDING status bit if we are not actually
         * exiting the module */
        if (!exit_pending)
@@ -6314,6 +6320,8 @@ static void iwl_down(struct iwl_priv *priv)
        mutex_lock(&priv->mutex);
        __iwl_down(priv);
        mutex_unlock(&priv->mutex);
+
+       iwl_cancel_deferred_work(priv);
 }
 
 #define MAX_HW_RESTARTS 5
@@ -6935,13 +6943,10 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        DECLARE_MAC_BUF(mac);
 
        IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
-       if (conf->mac_addr)
-               IWL_DEBUG_MAC80211("enter: MAC %s\n",
-                                  print_mac(mac, conf->mac_addr));
 
        if (priv->interface_id) {
                IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
-               return 0;
+               return -EOPNOTSUPP;
        }
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -6950,6 +6955,12 @@ static int iwl_mac_add_interface(struct ieee80211_hw *hw,
        spin_unlock_irqrestore(&priv->lock, flags);
 
        mutex_lock(&priv->mutex);
+
+       if (conf->mac_addr) {
+               IWL_DEBUG_MAC80211("Set: %s\n", print_mac(mac, conf->mac_addr));
+               memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
+       }
+
        iwl_set_mode(priv, conf->type);
 
        IWL_DEBUG_MAC80211("leave\n");
@@ -8269,6 +8280,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
 {
        iwl_hw_cancel_deferred_work(priv);
 
+       cancel_delayed_work_sync(&priv->init_alive_start);
        cancel_delayed_work(&priv->scan_check);
        cancel_delayed_work(&priv->alive_start);
        cancel_delayed_work(&priv->post_associate);
@@ -8568,10 +8580,9 @@ static void iwl_pci_remove(struct pci_dev *pdev)
 
        IWL_DEBUG_INFO("*** UNLOAD DRIVER ***\n");
 
-       mutex_lock(&priv->mutex);
        set_bit(STATUS_EXIT_PENDING, &priv->status);
-       __iwl_down(priv);
-       mutex_unlock(&priv->mutex);
+
+       iwl_down(priv);
 
        /* Free MAC hash list for ADHOC */
        for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++) {
@@ -8630,12 +8641,10 @@ static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
        struct iwl_priv *priv = pci_get_drvdata(pdev);
 
-       mutex_lock(&priv->mutex);
-
        set_bit(STATUS_IN_SUSPEND, &priv->status);
 
        /* Take down the device; powers it off, etc. */
-       __iwl_down(priv);
+       iwl_down(priv);
 
        if (priv->mac80211_registered)
                ieee80211_stop_queues(priv->hw);
@@ -8644,8 +8653,6 @@ static int iwl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        pci_disable_device(pdev);
        pci_set_power_state(pdev, PCI_D3hot);
 
-       mutex_unlock(&priv->mutex);
-
        return 0;
 }
 
@@ -8703,8 +8710,6 @@ static int iwl_pci_resume(struct pci_dev *pdev)
 
        printk(KERN_INFO "Coming out of suspend...\n");
 
-       mutex_lock(&priv->mutex);
-
        pci_set_power_state(pdev, PCI_D0);
        err = pci_enable_device(pdev);
        pci_restore_state(pdev);
@@ -8718,7 +8723,6 @@ static int iwl_pci_resume(struct pci_dev *pdev)
        pci_write_config_byte(pdev, 0x41, 0x00);
 
        iwl_resume(priv);
-       mutex_unlock(&priv->mutex);
 
        return 0;
 }