diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-04-14 22:01:58 +0200 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-16 14:38:53 -0400 |
commit | ea6f792b2b893249e0eeffdb3fe0ea191eaf80d7 (patch) | |
tree | 1e306360812654cd4988b09ea01ab8eb53c8cf37 /drivers/net/wireless/ath/ath9k/eeprom.c | |
parent | 21bd6ea3116998e429dad796bce785e18df39daa (diff) |
ath9k: introduce ath9k_hw_get_scaled_power helper
The computation of the scaled power value in
various eeprom files uses identical code. Move
that code into a helper function and use that
instead of code duplication.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/eeprom.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/eeprom.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c index c43523233319..61bad99e76dd 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.c +++ b/drivers/net/wireless/ath/ath9k/eeprom.c @@ -290,6 +290,39 @@ u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower, return twiceMaxEdgePower; } +u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit, + u8 antenna_reduction) +{ + u16 scaled_power; + + scaled_power = power_limit - antenna_reduction; + + /* + * Reduce scaled Power by number of chains active + * to get the per chain tx power level. + */ + switch (ar5416_get_ntxchains(ah->txchainmask)) { + case 1: + break; + case 2: + if (scaled_power > REDUCE_SCALED_POWER_BY_TWO_CHAIN) + scaled_power -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; + else + scaled_power = 0; + break; + case 3: + if (scaled_power > REDUCE_SCALED_POWER_BY_THREE_CHAIN) + scaled_power -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; + else + scaled_power = 0; + break; + } + + scaled_power = max((u16)0, scaled_power); + + return scaled_power; +} + void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); |