ath5k: Fix range scaling when setting rate power table

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 29 10:59:29 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=755051993bfcdf07acd84a7ffd08d463b85bfd69
Commit:     755051993bfcdf07acd84a7ffd08d463b85bfd69
Parent:     d12c5c53ce4c8c65c694d1103673182ef5afdc65
Author:     Nick Kossifidis <mickflemm at gmail.com>
AuthorDate: Sun Aug 5 22:35:34 2012 +0300
Committer:  John W. Linville <linville at tuxdriver.com>
CommitDate: Fri Aug 10 15:26:55 2012 -0400

    ath5k: Fix range scaling when setting rate power table
    
    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 at gmail.com>
    Signed-off-by: John W. Linville <linville at tuxdriver.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;
 	}
 }
 



More information about the linux-mtd-cvs mailing list