diff options
author | Luigi Tarenga <luigi.tarenga@gmail.com> | 2012-01-31 12:51:23 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-02-01 15:25:59 -0500 |
commit | 7fc417556473f15efac269523c17eb92103c6484 (patch) | |
tree | 89dab8636f96f2648e54fe69c1a17f29954e4bae /drivers/net/wireless/rt2x00 | |
parent | f9721ed2707661af75a414d09cdcd71f99a13f62 (diff) |
rt2800lib: fix wrong -128dBm when signal is stronger than -12dBm
This patch correct the type of variables containing the rssi
values read from the rxwi.
In function rt2800_agc_to_rssi() 3 variables (rssi0, rssi1, rss2)
defined as int was assigned a 16bit signed values as unsigned.
From a test with a hi-gain antenna I verified that the rxwi
contains signed rssi values in the range -13/+81 (inclusive)
with 0 as an error condition. In case of negative values a
condition is triggered and the function return -128dBm while
the signal is at its maximum. This patch correct the cast so
negative values are not treated as very high positive values
(ex. -13 does not become 243).
Signed-off-by: Luigi Tarenga <luigi.tarenga@gmail.com>
Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 22a1a8fc6e02..7bef66def10c 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -514,9 +514,9 @@ EXPORT_SYMBOL_GPL(rt2800_write_tx_data); | |||
514 | 514 | ||
515 | static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2) | 515 | static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2) |
516 | { | 516 | { |
517 | int rssi0 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI0); | 517 | s8 rssi0 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI0); |
518 | int rssi1 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI1); | 518 | s8 rssi1 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI1); |
519 | int rssi2 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI2); | 519 | s8 rssi2 = rt2x00_get_field32(rxwi_w2, RXWI_W2_RSSI2); |
520 | u16 eeprom; | 520 | u16 eeprom; |
521 | u8 offset0; | 521 | u8 offset0; |
522 | u8 offset1; | 522 | u8 offset1; |
@@ -552,7 +552,7 @@ static int rt2800_agc_to_rssi(struct rt2x00_dev *rt2x00dev, u32 rxwi_w2) | |||
552 | * which gives less energy... | 552 | * which gives less energy... |
553 | */ | 553 | */ |
554 | rssi0 = max(rssi0, rssi1); | 554 | rssi0 = max(rssi0, rssi1); |
555 | return max(rssi0, rssi2); | 555 | return (int)max(rssi0, rssi2); |
556 | } | 556 | } |
557 | 557 | ||
558 | void rt2800_process_rxwi(struct queue_entry *entry, | 558 | void rt2800_process_rxwi(struct queue_entry *entry, |