iwlwifi: use valid TX/RX antenna from hw_params
authorJohannes Berg <johannes.berg@intel.com>
Mon, 5 Mar 2012 19:24:32 +0000 (11:24 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 6 Mar 2012 20:16:11 +0000 (15:16 -0500)
It's not really a good idea to write to the
global static configuration. Use the valid
TX/RX antenna information only from the HW
params struct except in the case where the
values from the config are used to override
the values from the EEPROM.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-1000.c
drivers/net/wireless/iwlwifi/iwl-2000.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-6000.c
drivers/net/wireless/iwlwifi/iwl-agn-calib.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-debugfs.c
drivers/net/wireless/iwlwifi/iwl-eeprom.c

index 605ee3df1d82dffd1db92ffd9bfbb90a7bd80104..22eb0622ac216a680142919ed46868db42b87d24 100644 (file)
@@ -131,14 +131,13 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl1000_set_ct_threshold(priv);
 
index e6e8c79a80d8e731f7bc624b695dafeb8e1f3967..43d17a4564e3bfffb8cf67bbe186049636c0b14e 100644 (file)
@@ -127,14 +127,13 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
 
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl2000_set_ct_threshold(priv);
 
index ccaeead29c2fa0e1b2055b3f668a3f49b3e54d8c..8cdc4a35a973dfa21d21b9d79c0afde09dc1aadc 100644 (file)
@@ -167,10 +167,10 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
-       hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
+       hw_params(priv).rx_chains_num =
+               num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl5000_set_ct_threshold(priv);
 
@@ -190,10 +190,10 @@ static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
-       hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
+       hw_params(priv).rx_chains_num =
+               num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl5150_set_ct_threshold(priv);
 
index 223e60a1b79d7e3979c4b67cd75837516cb4a64d..720e8e6e62aec47385df51194f31414df3467052 100644 (file)
@@ -149,14 +149,13 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
        hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant);
+       hw_params(priv).tx_chains_num =
+               num_of_ant(hw_params(priv).valid_tx_ant);
        if (cfg(priv)->rx_with_siso_diversity)
                hw_params(priv).rx_chains_num = 1;
        else
                hw_params(priv).rx_chains_num =
-                       num_of_ant(cfg(priv)->valid_rx_ant);
-       hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
-       hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+                       num_of_ant(hw_params(priv).valid_rx_ant);
 
        iwl6000_set_ct_threshold(priv);
 
index 12acc81ed4194bb7e31739ba2991733f5a675749..84fc5ce91b3539442c2e61e4034f1f7307638238 100644 (file)
@@ -848,7 +848,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
                         * connect the first valid tx chain
                         */
                        first_chain =
-                               find_first_chain(cfg(priv)->valid_tx_ant);
+                               find_first_chain(hw_params(priv).valid_tx_ant);
                        data->disconn_array[first_chain] = 0;
                        active_chains |= BIT(first_chain);
                        IWL_DEBUG_CALIB(priv,
@@ -1082,7 +1082,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
 
        iwlagn_gain_computation(priv, average_noise,
                                min_average_noise_antenna_i, min_average_noise,
-                               find_first_chain(cfg(priv)->valid_rx_ant));
+                               find_first_chain(hw_params(priv).valid_rx_ant));
 
        /* Some power changes may have been made during the calibration.
         * Update and commit the RXON
index e1bf12578f87055b88e3070636ef20be26c728e8..6cec7e63c1714b4767f506ab08a0aa9de44bccf5 100644 (file)
@@ -699,7 +699,7 @@ int iwl_alive_start(struct iwl_priv *priv)
        priv->active_rate = IWL_RATES_MASK;
 
        /* Configure Tx antenna selection based on H/W config */
-       iwlagn_send_tx_ant_config(priv, cfg(priv)->valid_tx_ant);
+       iwlagn_send_tx_ant_config(priv, hw_params(priv).valid_tx_ant);
 
        if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) {
                struct iwl_rxon_cmd *active_rxon =
index dd502e82e4104c38ee98d6e0839c1a6f6ebd9a46..b6740c33b519b7ee539e206f78f7a1f5534f7ada 100644 (file)
@@ -1546,15 +1546,18 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
        if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
                pos += scnprintf(buf + pos, bufsz - pos,
                        "tx power: (1/2 dB step)\n");
-               if ((cfg(priv)->valid_tx_ant & ANT_A) && tx->tx_power.ant_a)
+               if ((hw_params(priv).valid_tx_ant & ANT_A) &&
+                   tx->tx_power.ant_a)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna A:",
                                        tx->tx_power.ant_a);
-               if ((cfg(priv)->valid_tx_ant & ANT_B) && tx->tx_power.ant_b)
+               if ((hw_params(priv).valid_tx_ant & ANT_B) &&
+                   tx->tx_power.ant_b)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna B:",
                                        tx->tx_power.ant_b);
-               if ((cfg(priv)->valid_tx_ant & ANT_C) && tx->tx_power.ant_c)
+               if ((hw_params(priv).valid_tx_ant & ANT_C) &&
+                   tx->tx_power.ant_c)
                        pos += scnprintf(buf + pos, bufsz - pos,
                                        fmt_hex, "antenna C:",
                                        tx->tx_power.ant_c);
index d8668bccc083565354f3517681c0ea43049059c9..6915b33add3612313e2ac52772f942a16da2b343 100644 (file)
@@ -271,25 +271,27 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
 
        IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku);
 
-       if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) {
-               /* not using .cfg overwrite */
-               radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
-               cfg(priv)->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
-               cfg(priv)->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
-               if (!cfg(priv)->valid_tx_ant || !cfg(priv)->valid_rx_ant) {
-                       IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
-                               cfg(priv)->valid_tx_ant,
-                               cfg(priv)->valid_rx_ant);
-                       return -EINVAL;
-               }
-               IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
-                        cfg(priv)->valid_tx_ant, cfg(priv)->valid_rx_ant);
+       radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
+
+       hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
+       hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
+
+       /* check overrides (some devices have wrong EEPROM) */
+       if (cfg(priv)->valid_tx_ant)
+               hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
+       if (cfg(priv)->valid_rx_ant)
+               hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
+
+       if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) {
+               IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
+                       hw_params(priv).valid_tx_ant,
+                       hw_params(priv).valid_rx_ant);
+               return -EINVAL;
        }
-       /*
-        * for some special cases,
-        * EEPROM did not reflect the correct antenna setting
-        * so overwrite the valid tx/rx antenna from .cfg
-        */
+
+       IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
+                hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant);
+
        return 0;
 }