From: Gabor Juhos <juhosg@openwrt.org>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com,
Gabor Juhos <juhosg@openwrt.org>
Subject: [PATCH v3 08/20] rt2x00: rt2800lib: add rt2800_txpower_to_dev helper
Date: Mon, 8 Jul 2013 16:08:23 +0200 [thread overview]
Message-ID: <1373292515-21332-9-git-send-email-juhosg@openwrt.org> (raw)
In-Reply-To: <1373292515-21332-1-git-send-email-juhosg@openwrt.org>
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: Gabor Juhos <juhosg@openwrt.org>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
Changes since v2: ---
---
drivers/net/wireless/rt2x00/rt2800.h | 6 ------
drivers/net/wireless/rt2x00/rt2800lib.c | 21 ++++++++++++++-------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 7b7caeb..d3e8f6d 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -2887,15 +2887,9 @@ enum rt2800_eeprom_word {
#define TXPOWER_G_FROM_DEV(__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) \
((__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
*/
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 958215c..1738a9d 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2724,6 +2724,16 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel)
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,
struct ieee80211_conf *conf,
struct rf_channel *rf,
@@ -2733,13 +2743,10 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
unsigned int tx_pin;
u8 bbp, rfcsr;
- if (rf->channel <= 14) {
- info->default_power1 = TXPOWER_G_TO_DEV(info->default_power1);
- info->default_power2 = TXPOWER_G_TO_DEV(info->default_power2);
- } else {
- info->default_power1 = TXPOWER_A_TO_DEV(info->default_power1);
- info->default_power2 = TXPOWER_A_TO_DEV(info->default_power2);
- }
+ info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
+ info->default_power1);
+ info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
+ info->default_power2);
switch (rt2x00dev->chip.rf) {
case RF2020:
--
1.7.10
next prev parent reply other threads:[~2013-07-08 14:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-08 14:08 [PATCH v3 00/20] rt2x00: add experimental support for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 01/20] rt2x00: rt2800lib: add MAC register initialization " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 02/20] rt2x00: rt2800lib: add BBP " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 03/20] rt2x00: rt2800lib: add RFCSR " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 04/20] rt2x00: rt2800lib: add BBP post " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 05/20] rt2x00: rt2800lib: add TX power configuration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 06/20] rt2x00: rt2800lib: fix BBP1_TX_ANTENNA field configuration for 3T devices Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 07/20] rt2x00: rt2800lib: fix antenna configuration for RT3593 Gabor Juhos
2013-07-08 14:08 ` Gabor Juhos [this message]
2013-07-08 14:08 ` [PATCH v3 09/20] rt2x00: rt2800lib: fix default TX power values " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 10/20] rt2x00: rt2800lib: introduce rt2800_get_txmixer_gain_{24,5}g helpers Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 11/20] rt2x00: rt2800lib: hardcode TX mixer gain values for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 12/20] rt2x00: rt2800lib: fix LNA_A[12] " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 13/20] rt2x00: rt2800lib: add default_power3 field for three-chain devices Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 14/20] rt2x00: rt2800lib: add rf_vals for RF3053 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 15/20] rt2x00: rt2800lib: add channel configuration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 16/20] rt2x00: rt2800lib: enable VCO recalibration " Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 17/20] rt2x00: rt2800lib: enable RF3053 support Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 18/20] rt2x00: rt2800lib: enable RT3593 support Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 19/20] rt2x00: rt2800usb: use correct [RT]XWI size for RT3593 Gabor Juhos
2013-07-08 14:08 ` [PATCH v3 20/20] rt2x00: rt2800usb: add USB device ID for Linksys AE3000 Gabor Juhos
2013-07-22 15:48 ` [PATCH v3 00/20] rt2x00: add experimental support for RT3593 Gertjan van Wingerde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373292515-21332-9-git-send-email-juhosg@openwrt.org \
--to=juhosg@openwrt.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=users@rt2x00.serialmonkey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox