From: Nick Kossifidis <mickflemm@gmail.com>
To: ath5k-devel@lists.ath5k.org, linux-wireless@vger.kernel.org
Cc: linville@tuxdriver.com, mcgrof@gmail.com, jirislaby@gmail.com,
thomas@net.t-labs.tu-berlin.de, nbd@openwrt.org,
Nick Kossifidis <mickflemm@gmail.com>
Subject: [PATCH v2 2/5] ath5k: Fix range scaling when setting rate power table
Date: Sun, 5 Aug 2012 22:35:34 +0300 [thread overview]
Message-ID: <1344195337-27461-3-git-send-email-mickflemm@gmail.com> (raw)
In-Reply-To: <1344195337-27461-1-git-send-email-mickflemm@gmail.com>
rates[i] is unsigned but txp_offset can be negative for newer parts
with PDADC table. We cover the case when rates[i] + txp_offset > 63
but we must also cover the case when its < 0 or else rates[i] will overflow.
Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
---
drivers/net/wireless/ath/ath5k/phy.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index aa1a77d..84a9aaf 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -3516,6 +3516,7 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
{
unsigned int i;
u16 *rates;
+ s16 rate_idx_scaled = 0;
/* max_pwr is power level we got from driver/user in 0.5dB
* units, switch to 0.25dB units so we can compare */
@@ -3580,10 +3581,13 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr,
* match the power range set by user with the power indices
* on PCDAC/PDADC table */
for (i = 0; i < 16; i++) {
- rates[i] += ah->ah_txpower.txp_offset;
+ rate_idx_scaled = rates[i] + ah->ah_txpower.txp_offset;
/* Don't get out of bounds */
- if (rates[i] > 63)
- rates[i] = 63;
+ if (rate_idx_scaled > 63)
+ rate_idx_scaled = 63;
+ if (rate_idx_scaled < 0)
+ rate_idx_scaled = 0;
+ rates[i] = rate_idx_scaled;
}
}
--
1.7.3.4
next prev parent reply other threads:[~2012-08-05 19:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-05 19:35 [PATCH v2 0/5] ath5k: Various tx power fixes Nick Kossifidis
2012-08-05 19:35 ` [PATCH v2 1/5] ath5k: Use correct value for min_pwr and cur_pwr Nick Kossifidis
2012-08-05 19:35 ` Nick Kossifidis [this message]
2012-08-05 19:35 ` [PATCH v2 3/5] ath5k: Preserve tx power level requested from above on phy_init Nick Kossifidis
2012-08-05 19:35 ` [PATCH v2 4/5] ath5k: Put power_level where it belongs and rename it Nick Kossifidis
2012-08-05 19:35 ` [PATCH v2 5/5] ath5k: Return correct offset when reading frequencies Nick Kossifidis
2012-08-08 16:55 ` [ath5k-devel] " Thomas Huehn
2012-08-08 17:56 ` Nick Kossifidis
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=1344195337-27461-3-git-send-email-mickflemm@gmail.com \
--to=mickflemm@gmail.com \
--cc=ath5k-devel@lists.ath5k.org \
--cc=jirislaby@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcgrof@gmail.com \
--cc=nbd@openwrt.org \
--cc=thomas@net.t-labs.tu-berlin.de \
/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;
as well as URLs for NNTP newsgroup(s).