]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/iwlwifi/iwl4965-base.c
iwlwifi: don't bring up interface if RF-kill avoids radio
[linux-2.6] / drivers / net / wireless / iwlwifi / iwl4965-base.c
index a87e870f96d0614408c6556cb9d8468f5e356af8..2d0d079a24ec7ad68b0e3168cb212144ead76af7 100644 (file)
@@ -344,16 +344,19 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv)
 
        /* If we have set the ASSOC_MSK and we are in BSS mode then
         * add the IWL_AP_ID to the station rate table */
-       if (new_assoc && (priv->iw_mode == IEEE80211_IF_TYPE_STA)) {
-               if (iwl_rxon_add_station(priv, priv->active_rxon.bssid_addr, 1)
-                   == IWL_INVALID_STATION) {
-                       IWL_ERROR("Error adding AP address for transmit.\n");
-                       return -EIO;
+       if (new_assoc) {
+               if (priv->iw_mode == IEEE80211_IF_TYPE_STA) {
+                       ret = iwl_rxon_add_station(priv,
+                                          priv->active_rxon.bssid_addr, 1);
+                       if (ret == IWL_INVALID_STATION) {
+                               IWL_ERROR("Error adding AP address for TX.\n");
+                               return -EIO;
+                       }
+                       priv->assoc_station_added = 1;
+                       if (priv->default_wep_key &&
+                           iwl_send_static_wepkey_cmd(priv, 0))
+                               IWL_ERROR("Could not send WEP static key.\n");
                }
-               priv->assoc_station_added = 1;
-               if (priv->default_wep_key &&
-                   iwl_send_static_wepkey_cmd(priv, 0))
-                       IWL_ERROR("Could not send WEP static key.\n");
 
                /* Apply the new configuration
                 * RXON assoc doesn't clear the station table in uCode,
@@ -2100,7 +2103,9 @@ static void __iwl4965_down(struct iwl_priv *priv)
                               test_bit(STATUS_GEO_CONFIGURED, &priv->status) <<
                                        STATUS_GEO_CONFIGURED |
                               test_bit(STATUS_IN_SUSPEND, &priv->status) <<
-                                       STATUS_IN_SUSPEND;
+                                       STATUS_IN_SUSPEND |
+                              test_bit(STATUS_EXIT_PENDING, &priv->status) <<
+                                       STATUS_EXIT_PENDING;
                goto exit;
        }
 
@@ -2115,7 +2120,9 @@ static void __iwl4965_down(struct iwl_priv *priv)
                        test_bit(STATUS_IN_SUSPEND, &priv->status) <<
                                STATUS_IN_SUSPEND |
                        test_bit(STATUS_FW_ERROR, &priv->status) <<
-                               STATUS_FW_ERROR;
+                               STATUS_FW_ERROR |
+                      test_bit(STATUS_EXIT_PENDING, &priv->status) <<
+                               STATUS_EXIT_PENDING;
 
        spin_lock_irqsave(&priv->lock, flags);
        iwl_clear_bit(priv, CSR_GP_CNTRL,
@@ -2180,13 +2187,15 @@ static int __iwl4965_up(struct iwl_priv *priv)
        if (iwl_read32(priv, CSR_GP_CNTRL) &
                                CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)
                clear_bit(STATUS_RF_KILL_HW, &priv->status);
-       else {
+       else
                set_bit(STATUS_RF_KILL_HW, &priv->status);
-               if (!test_bit(STATUS_IN_SUSPEND, &priv->status)) {
-                       iwl_rfkill_set_hw_state(priv);
-                       IWL_WARNING("Radio disabled by HW RF Kill switch\n");
-                       return -ENODEV;
-               }
+
+       if (!test_bit(STATUS_IN_SUSPEND, &priv->status) &&
+           iwl_is_rfkill(priv)) {
+               iwl_rfkill_set_hw_state(priv);
+               IWL_WARNING("Radio disabled by %s RF Kill switch\n",
+                   test_bit(STATUS_RF_KILL_HW, &priv->status) ? "HW" : "SW");
+               return -ENODEV;
        }
 
        iwl_rfkill_set_hw_state(priv);
@@ -2483,7 +2492,6 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
 
        switch (priv->iw_mode) {
        case IEEE80211_IF_TYPE_STA:
-               iwl4965_rate_scale_init(priv->hw, IWL_AP_ID);
                break;
 
        case IEEE80211_IF_TYPE_IBSS:
@@ -2492,7 +2500,6 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
                priv->assoc_id = 1;
 
                iwl_rxon_add_station(priv, priv->bssid, 0);
-               iwl4965_rate_scale_init(priv->hw, IWL_STA_ID);
                iwl4965_send_beacon_cmd(priv);
 
                break;
@@ -3425,7 +3432,6 @@ static void iwl4965_mac_reset_tsf(struct ieee80211_hw *hw)
        mutex_lock(&priv->mutex);
        IWL_DEBUG_MAC80211("enter\n");
 
-       priv->lq_mngr.lq_ready = 0;
        spin_lock_irqsave(&priv->lock, flags);
        memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_info));
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -3488,6 +3494,7 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
 {
        struct iwl_priv *priv = hw->priv;
        unsigned long flags;
+       __le64 timestamp;
 
        mutex_lock(&priv->mutex);
        IWL_DEBUG_MAC80211("enter\n");
@@ -3512,6 +3519,8 @@ static int iwl4965_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
        priv->ibss_beacon = skb;
 
        priv->assoc_id = 0;
+       timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp;
+       priv->timestamp = le64_to_cpu(timestamp) +  (priv->beacon_int * 1000);
 
        IWL_DEBUG_MAC80211("leave\n");
        spin_unlock_irqrestore(&priv->lock, flags);