iwlwifi: remove STATUS_MODE_PENDING
[safe/jmp/linux-2.6] / drivers / net / wireless / iwlwifi / iwl-core.c
index 1cfcc9f..a962fb3 100644 (file)
@@ -897,23 +897,10 @@ EXPORT_SYMBOL(iwl_full_rxon_required);
 
 u8 iwl_rate_get_lowest_plcp(struct iwl_priv *priv)
 {
-       int i;
-       int rate_mask;
-
-       /* Set rate mask*/
-       if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
-               rate_mask = priv->active_rate_basic & IWL_CCK_RATES_MASK;
-       else
-               rate_mask = priv->active_rate_basic & IWL_OFDM_RATES_MASK;
-
-       /* Find lowest valid rate */
-       for (i = IWL_RATE_1M_INDEX; i != IWL_RATE_INVALID;
-                                       i = iwl_rates[i].next_ieee) {
-               if (rate_mask & (1 << i))
-                       return iwl_rates[i].plcp;
-       }
-
-       /* No valid rate was found. Assign the lowest one */
+       /*
+        * Assign the lowest rate -- should really get this from
+        * the beacon skb from mac80211.
+        */
        if (priv->staging_rxon.flags & RXON_FLG_BAND_24G_MSK)
                return IWL_RATE_1M_PLCP;
        else
@@ -1272,7 +1259,6 @@ static void iwl_set_rate(struct iwl_priv *priv)
        }
 
        priv->active_rate = 0;
-       priv->active_rate_basic = 0;
 
        for (i = 0; i < hw->n_bitrates; i++) {
                rate = &(hw->bitrates[i]);
@@ -1280,30 +1266,13 @@ static void iwl_set_rate(struct iwl_priv *priv)
                        priv->active_rate |= (1 << rate->hw_value);
        }
 
-       IWL_DEBUG_RATE(priv, "Set active_rate = %0x, active_rate_basic = %0x\n",
-                      priv->active_rate, priv->active_rate_basic);
+       IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate);
 
-       /*
-        * If a basic rate is configured, then use it (adding IWL_RATE_1M_MASK)
-        * otherwise set it to the default of all CCK rates and 6, 12, 24 for
-        * OFDM
-        */
-       if (priv->active_rate_basic & IWL_CCK_BASIC_RATES_MASK)
-               priv->staging_rxon.cck_basic_rates =
-                   ((priv->active_rate_basic &
-                     IWL_CCK_RATES_MASK) >> IWL_FIRST_CCK_RATE) & 0xF;
-       else
-               priv->staging_rxon.cck_basic_rates =
-                   (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
-
-       if (priv->active_rate_basic & IWL_OFDM_BASIC_RATES_MASK)
-               priv->staging_rxon.ofdm_basic_rates =
-                   ((priv->active_rate_basic &
-                     (IWL_OFDM_BASIC_RATES_MASK | IWL_RATE_6M_MASK)) >>
-                     IWL_FIRST_OFDM_RATE) & 0xFF;
-       else
-               priv->staging_rxon.ofdm_basic_rates =
-                  (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
+       priv->staging_rxon.cck_basic_rates =
+           (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF;
+
+       priv->staging_rxon.ofdm_basic_rates =
+          (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF;
 }
 
 void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
@@ -2283,11 +2252,6 @@ int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
                return -EIO;
        }
 
-       if (priv->iw_mode != NL80211_IFTYPE_ADHOC) {
-               IWL_DEBUG_MAC80211(priv, "leave - not IBSS\n");
-               return -EIO;
-       }
-
        spin_lock_irqsave(&priv->lock, flags);
 
        if (priv->ibss_beacon)
@@ -2311,23 +2275,9 @@ int iwl_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
 }
 EXPORT_SYMBOL(iwl_mac_beacon_update);
 
-int iwl_set_mode(struct iwl_priv *priv, int mode)
+static int iwl_set_mode(struct iwl_priv *priv, struct ieee80211_vif *vif)
 {
-       if (mode == NL80211_IFTYPE_ADHOC) {
-               const struct iwl_channel_info *ch_info;
-
-               ch_info = iwl_get_channel_info(priv,
-                       priv->band,
-                       le16_to_cpu(priv->staging_rxon.channel));
-
-               if (!ch_info || !is_channel_ibss(ch_info)) {
-                       IWL_ERR(priv, "channel %d not IBSS channel\n",
-                                 le16_to_cpu(priv->staging_rxon.channel));
-                       return -EINVAL;
-               }
-       }
-
-       iwl_connection_init_rx_config(priv, mode);
+       iwl_connection_init_rx_config(priv, vif->type);
 
        if (priv->cfg->ops->hcmd->set_rxon_chain)
                priv->cfg->ops->hcmd->set_rxon_chain(priv);
@@ -2336,18 +2286,10 @@ int iwl_set_mode(struct iwl_priv *priv, int mode)
 
        iwl_clear_stations_table(priv);
 
-       /* dont commit rxon if rf-kill is on*/
-       if (!iwl_is_ready_rf(priv))
-               return -EAGAIN;
-
-       iwlcore_commit_rxon(priv);
-
-       return 0;
+       return iwlcore_commit_rxon(priv);
 }
-EXPORT_SYMBOL(iwl_set_mode);
 
-int iwl_mac_add_interface(struct ieee80211_hw *hw,
-                                struct ieee80211_vif *vif)
+int iwl_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
        struct iwl_priv *priv = hw->priv;
        int err = 0;
@@ -2356,6 +2298,11 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
 
        mutex_lock(&priv->mutex);
 
+       if (WARN_ON(!iwl_is_ready_rf(priv))) {
+               err = -EINVAL;
+               goto out;
+       }
+
        if (priv->vif) {
                IWL_DEBUG_MAC80211(priv, "leave - vif != NULL\n");
                err = -EOPNOTSUPP;
@@ -2365,15 +2312,17 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
        priv->vif = vif;
        priv->iw_mode = vif->type;
 
-       if (vif->addr) {
-               IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr);
-               memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
-       }
+       IWL_DEBUG_MAC80211(priv, "Set %pM\n", vif->addr);
+       memcpy(priv->mac_addr, vif->addr, ETH_ALEN);
 
-       if (iwl_set_mode(priv, vif->type) == -EAGAIN)
-               /* we are not ready, will run again when ready */
-               set_bit(STATUS_MODE_PENDING, &priv->status);
+       err = iwl_set_mode(priv, vif);
+       if (err)
+               goto out_err;
+       goto out;
 
+ out_err:
+       priv->vif = NULL;
+       priv->iw_mode = NL80211_IFTYPE_STATION;
  out:
        mutex_unlock(&priv->mutex);
 
@@ -2383,7 +2332,7 @@ int iwl_mac_add_interface(struct ieee80211_hw *hw,
 EXPORT_SYMBOL(iwl_mac_add_interface);
 
 void iwl_mac_remove_interface(struct ieee80211_hw *hw,
-                                    struct ieee80211_vif *vif)
+                             struct ieee80211_vif *vif)
 {
        struct iwl_priv *priv = hw->priv;
 
@@ -2467,15 +2416,6 @@ int iwl_mac_config(struct ieee80211_hw *hw, u32 changed)
                        goto set_ch_out;
                }
 
-               if (priv->iw_mode == NL80211_IFTYPE_ADHOC &&
-                       !is_channel_ibss(ch_info)) {
-                       IWL_ERR(priv, "channel %d in band %d not "
-                               "IBSS channel\n",
-                               conf->channel->hw_value, conf->channel->band);
-                       ret = -EINVAL;
-                       goto set_ch_out;
-               }
-
                spin_lock_irqsave(&priv->lock, flags);
 
                /* Configure HT40 channels */