mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
ath5k: Track current TX power separately from max TX power
Add a new variable to keep track of the currently configured tx power. Before max_pwr was re-used for keeping the maximum allowed power as well as the current configuration. Doing a min() on it allows you to lower the txpower, but how would you be able to make it higher again? This patch fixes that by adding a new variable ah_cur_pwr which is used instead of txp_max_pwr to keep the current configuration. txp_max_pwr is used to check if we are within the limits. Another problem fixed by this patch is that it avoids setting a zero txpower when things are initialized first and the current power is not yet set. Signed-off-by: Bruno Randolf <br1@einfach.org> Acked-by: Nick Kossifidis <mickflemm@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
56bd29d361
commit
51f00622e5
@ -1107,6 +1107,7 @@ struct ath5k_hw {
|
|||||||
/* Values in 0.25dB units */
|
/* Values in 0.25dB units */
|
||||||
s16 txp_min_pwr;
|
s16 txp_min_pwr;
|
||||||
s16 txp_max_pwr;
|
s16 txp_max_pwr;
|
||||||
|
s16 txp_cur_pwr;
|
||||||
/* Values in 0.5dB units */
|
/* Values in 0.5dB units */
|
||||||
s16 txp_offset;
|
s16 txp_offset;
|
||||||
s16 txp_ofdm;
|
s16 txp_ofdm;
|
||||||
|
@ -3096,7 +3096,7 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
|
|||||||
|
|
||||||
/* Min/max in 0.25dB units */
|
/* Min/max in 0.25dB units */
|
||||||
ah->ah_txpower.txp_min_pwr = 2 * rates[7];
|
ah->ah_txpower.txp_min_pwr = 2 * rates[7];
|
||||||
ah->ah_txpower.txp_max_pwr = 2 * rates[0];
|
ah->ah_txpower.txp_cur_pwr = 2 * rates[0];
|
||||||
ah->ah_txpower.txp_ofdm = rates[7];
|
ah->ah_txpower.txp_ofdm = rates[7];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3150,8 +3150,6 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
|
|||||||
/* Reset TX power values */
|
/* Reset TX power values */
|
||||||
memset(&ah->ah_txpower, 0, sizeof(ah->ah_txpower));
|
memset(&ah->ah_txpower, 0, sizeof(ah->ah_txpower));
|
||||||
ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
|
ah->ah_txpower.txp_tpc = AR5K_TUNE_TPC_TXPOWER;
|
||||||
ah->ah_txpower.txp_min_pwr = 0;
|
|
||||||
ah->ah_txpower.txp_max_pwr = AR5K_TUNE_MAX_TXPOWER;
|
|
||||||
|
|
||||||
/* Calculate the powertable */
|
/* Calculate the powertable */
|
||||||
ret = ath5k_setup_channel_powertable(ah, channel,
|
ret = ath5k_setup_channel_powertable(ah, channel,
|
||||||
@ -3290,7 +3288,8 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
|
|||||||
* properly set curve indices.
|
* properly set curve indices.
|
||||||
*/
|
*/
|
||||||
ret = ath5k_hw_txpower(ah, channel, ee_mode,
|
ret = ath5k_hw_txpower(ah, channel, ee_mode,
|
||||||
ah->ah_txpower.txp_max_pwr / 2);
|
ah->ah_txpower.txp_cur_pwr ?
|
||||||
|
ah->ah_txpower.txp_cur_pwr / 2 : AR5K_TUNE_MAX_TXPOWER);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user