Commit 97aa03f1 authored by Gabor Juhos's avatar Gabor Juhos Committed by John W. Linville

rt2x00: rt2800lib: add rt2800_txpower_to_dev helper

Introduce a new helper function for converting
the default TX power values from EEPROM into
mac80211 values.

The change improves the readability and it makes
it easier to add support for other chipsets.
Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Acked-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
Acked-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5cddb3c2
...@@ -2887,15 +2887,9 @@ enum rt2800_eeprom_word { ...@@ -2887,15 +2887,9 @@ enum rt2800_eeprom_word {
#define TXPOWER_G_FROM_DEV(__txpower) \ #define TXPOWER_G_FROM_DEV(__txpower) \
((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
#define TXPOWER_G_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_G_TXPOWER, MAX_G_TXPOWER)
#define TXPOWER_A_FROM_DEV(__txpower) \ #define TXPOWER_A_FROM_DEV(__txpower) \
((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower) ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
#define TXPOWER_A_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_A_TXPOWER, MAX_A_TXPOWER)
/* /*
* Board's maximun TX power limitation * Board's maximun TX power limitation
*/ */
......
...@@ -2724,6 +2724,16 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel) ...@@ -2724,6 +2724,16 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel)
rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0); rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0);
} }
static char rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
unsigned int channel,
char txpower)
{
if (channel <= 14)
return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
else
return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
}
static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
struct ieee80211_conf *conf, struct ieee80211_conf *conf,
struct rf_channel *rf, struct rf_channel *rf,
...@@ -2733,13 +2743,10 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, ...@@ -2733,13 +2743,10 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
unsigned int tx_pin; unsigned int tx_pin;
u8 bbp, rfcsr; u8 bbp, rfcsr;
if (rf->channel <= 14) { info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
info->default_power1 = TXPOWER_G_TO_DEV(info->default_power1); info->default_power1);
info->default_power2 = TXPOWER_G_TO_DEV(info->default_power2); info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
} else { info->default_power2);
info->default_power1 = TXPOWER_A_TO_DEV(info->default_power1);
info->default_power2 = TXPOWER_A_TO_DEV(info->default_power2);
}
switch (rt2x00dev->chip.rf) { switch (rt2x00dev->chip.rf) {
case RF2020: case RF2020:
......
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