ath5k: Simplify powertable recalculation

Let ath5k_hw_txpower() decide if it can re-use the powertable or if it has to
be recalculated instead of passing a 'fast' flag from the outside.

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:
Bruno Randolf 2010-12-21 17:30:20 +09:00 committed by John W. Linville
parent 6dab55bf7e
commit 26c7fc4364
2 changed files with 14 additions and 22 deletions

View File

@ -1113,6 +1113,7 @@ struct ath5k_hw {
s16 txp_cck_ofdm_gainf_delta; s16 txp_cck_ofdm_gainf_delta;
/* Value in dB units */ /* Value in dB units */
s16 txp_cck_ofdm_pwr_delta; s16 txp_cck_ofdm_pwr_delta;
bool txp_setup;
} ah_txpower; } ah_txpower;
struct { struct {

View File

@ -3004,6 +3004,8 @@ ath5k_setup_channel_powertable(struct ath5k_hw *ah,
return -EINVAL; return -EINVAL;
} }
ah->ah_txpower.txp_setup = true;
return 0; return 0;
} }
@ -3105,9 +3107,10 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
*/ */
static int static int
ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
u8 ee_mode, u8 txpower, bool fast) u8 ee_mode, u8 txpower)
{ {
struct ath5k_rate_pcal_info rate_info; struct ath5k_rate_pcal_info rate_info;
struct ieee80211_channel *curr_channel = ah->ah_current_channel;
u8 type; u8 type;
int ret; int ret;
@ -3138,10 +3141,13 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
return -EINVAL; return -EINVAL;
} }
/* If fast is set it means we are on the same channel/mode /*
* so there is no need to recalculate the powertable, we 'll * If we don't change channel/mode skip tx powertable calculation
* just use the cached one */ * and use the cached one.
if (!fast) { */
if (!ah->ah_txpower.txp_setup ||
(channel->hw_value != curr_channel->hw_value) ||
(channel->center_freq != curr_channel->center_freq)) {
/* 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;
@ -3159,8 +3165,6 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
else else
ath5k_setup_pcdac_table(ah); ath5k_setup_pcdac_table(ah);
/* Limit max power if we have a CTL available */ /* Limit max power if we have a CTL available */
ath5k_get_max_ctl_power(ah, channel); ath5k_get_max_ctl_power(ah, channel);
@ -3238,7 +3242,7 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower)
ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER, ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_TXPOWER,
"changing txpower to %d\n", txpower); "changing txpower to %d\n", txpower);
return ath5k_hw_txpower(ah, channel, ee_mode, txpower, true); return ath5k_hw_txpower(ah, channel, ee_mode, txpower);
} }
/*************\ /*************\
@ -3251,7 +3255,6 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
struct ieee80211_channel *curr_channel; struct ieee80211_channel *curr_channel;
int ret, i; int ret, i;
u32 phy_tst1; u32 phy_tst1;
bool fast_txp;
ret = 0; ret = 0;
/* /*
@ -3281,17 +3284,6 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
return -EIO; return -EIO;
} }
/*
* If we don't change channel/mode skip
* tx powertable calculation and use the
* cached one.
*/
if ((channel->hw_value == curr_channel->hw_value) &&
(channel->center_freq == curr_channel->center_freq))
fast_txp = true;
else
fast_txp = false;
/* /*
* Set TX power * Set TX power
* *
@ -3300,8 +3292,7 @@ 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_max_pwr / 2);
fast_txp);
if (ret) if (ret)
return ret; return ret;