Commit 332704a5 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by John W. Linville

iwlegacy: fix tx_power initialization

priv->tx_power_next is not initialized to max supported power,
but instead default value is used, what cause errors like

[   58.597834] iwl3945 0000:03:00.0: Requested user TXPOWER 15 above upper limit 14.
[   58.597839] iwl3945 0000:03:00.0: Error setting Tx power (-22).

if maximum tx power read from the eeprom is smaller than default.
In consequence card is unable to initialize properly. Fix the problem
and cleanup tx power initialization.
Reported-and-tested-by: default avatarRobin Dong <hao.bigrat@gmail.com>
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 50f68712
...@@ -74,8 +74,6 @@ ...@@ -74,8 +74,6 @@
/* RSSI to dBm */ /* RSSI to dBm */
#define IWL39_RSSI_OFFSET 95 #define IWL39_RSSI_OFFSET 95
#define IWL_DEFAULT_TX_POWER 0x0F
/* /*
* EEPROM related constants, enums, and structures. * EEPROM related constants, enums, and structures.
*/ */
......
...@@ -804,9 +804,6 @@ struct iwl4965_scd_bc_tbl { ...@@ -804,9 +804,6 @@ struct iwl4965_scd_bc_tbl {
#define IWL4965_DEFAULT_TX_RETRY 15 #define IWL4965_DEFAULT_TX_RETRY 15
/* Limit range of txpower output target to be between these values */
#define IWL4965_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm: 1 milliwatt */
/* EEPROM */ /* EEPROM */
#define IWL4965_FIRST_AMPDU_QUEUE 10 #define IWL4965_FIRST_AMPDU_QUEUE 10
......
...@@ -160,6 +160,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) ...@@ -160,6 +160,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
struct ieee80211_channel *geo_ch; struct ieee80211_channel *geo_ch;
struct ieee80211_rate *rates; struct ieee80211_rate *rates;
int i = 0; int i = 0;
s8 max_tx_power = 0;
if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates ||
priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) {
...@@ -235,8 +236,8 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) ...@@ -235,8 +236,8 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
geo_ch->flags |= ch->ht40_extension_channel; geo_ch->flags |= ch->ht40_extension_channel;
if (ch->max_power_avg > priv->tx_power_device_lmt) if (ch->max_power_avg > max_tx_power)
priv->tx_power_device_lmt = ch->max_power_avg; max_tx_power = ch->max_power_avg;
} else { } else {
geo_ch->flags |= IEEE80211_CHAN_DISABLED; geo_ch->flags |= IEEE80211_CHAN_DISABLED;
} }
...@@ -249,6 +250,10 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) ...@@ -249,6 +250,10 @@ int iwl_legacy_init_geos(struct iwl_priv *priv)
geo_ch->flags); geo_ch->flags);
} }
priv->tx_power_device_lmt = max_tx_power;
priv->tx_power_user_lmt = max_tx_power;
priv->tx_power_next = max_tx_power;
if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
priv->cfg->sku & IWL_SKU_A) { priv->cfg->sku & IWL_SKU_A) {
IWL_INFO(priv, "Incorrectly detected BG card as ABG. " IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
...@@ -1124,11 +1129,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) ...@@ -1124,11 +1129,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
if (!priv->cfg->ops->lib->send_tx_power) if (!priv->cfg->ops->lib->send_tx_power)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (tx_power < IWL4965_TX_POWER_TARGET_POWER_MIN) { /* 0 dBm mean 1 milliwatt */
if (tx_power < 0) {
IWL_WARN(priv, IWL_WARN(priv,
"Requested user TXPOWER %d below lower limit %d.\n", "Requested user TXPOWER %d below 1 mW.\n",
tx_power, tx_power);
IWL4965_TX_POWER_TARGET_POWER_MIN);
return -EINVAL; return -EINVAL;
} }
......
...@@ -471,13 +471,6 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ...@@ -471,13 +471,6 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv)
flags & EEPROM_CHANNEL_RADAR)) flags & EEPROM_CHANNEL_RADAR))
? "" : "not "); ? "" : "not ");
/* Set the tx_power_user_lmt to the highest power
* supported by any channel */
if (eeprom_ch_info[ch].max_power_avg >
priv->tx_power_user_lmt)
priv->tx_power_user_lmt =
eeprom_ch_info[ch].max_power_avg;
ch_info++; ch_info++;
} }
} }
......
...@@ -3825,10 +3825,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv) ...@@ -3825,10 +3825,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
priv->force_reset[IWL_FW_RESET].reset_duration = priv->force_reset[IWL_FW_RESET].reset_duration =
IWL_DELAY_NEXT_FORCE_FW_RELOAD; IWL_DELAY_NEXT_FORCE_FW_RELOAD;
priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER;
priv->tx_power_next = IWL_DEFAULT_TX_POWER;
if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { if (eeprom->version < EEPROM_3945_EEPROM_VERSION) {
IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n",
eeprom->version); eeprom->version);
......
...@@ -3140,12 +3140,6 @@ static int iwl4965_init_drv(struct iwl_priv *priv) ...@@ -3140,12 +3140,6 @@ static int iwl4965_init_drv(struct iwl_priv *priv)
iwl_legacy_init_scan_params(priv); iwl_legacy_init_scan_params(priv);
/* Set the tx_power_user_lmt to the lowest power level
* this value will get overwritten by channel max power avg
* from eeprom */
priv->tx_power_user_lmt = IWL4965_TX_POWER_TARGET_POWER_MIN;
priv->tx_power_next = IWL4965_TX_POWER_TARGET_POWER_MIN;
ret = iwl_legacy_init_channel_map(priv); ret = iwl_legacy_init_channel_map(priv);
if (ret) { if (ret) {
IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); IWL_ERR(priv, "initializing regulatory failed: %d\n", ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment