When the EEPROM contains weird values for the power levels we have to
fix the interpolation process.
Signed-off-by: Fabio Rossi <[email protected]>
---
diff --git a/drivers/net/wireless/ath5k/phy.c b/drivers/net/wireless/ath5k/phy.c
index 9e2faae..0e3e0e0 100644
--- a/drivers/net/wireless/ath5k/phy.c
+++ b/drivers/net/wireless/ath5k/phy.c
@@ -1487,28 +1487,35 @@ ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR,
{
s8 tmp;
s16 min_pwrL, min_pwrR;
- s16 pwr_i = pwrL[0];
-
- do {
- pwr_i--;
- tmp = (s8) ath5k_get_interpolated_value(pwr_i,
- pwrL[0], pwrL[1],
- stepL[0], stepL[1]);
-
- } while (tmp > 1);
-
- min_pwrL = pwr_i;
-
- pwr_i = pwrR[0];
- do {
- pwr_i--;
- tmp = (s8) ath5k_get_interpolated_value(pwr_i,
- pwrR[0], pwrR[1],
- stepR[0], stepR[1]);
-
- } while (tmp > 1);
+ s16 pwr_i;
+
+ if (pwrL[0] == pwrL[1])
+ min_pwrL = pwrL[0];
+ else {
+ pwr_i = pwrL[0];
+ do {
+ pwr_i--;
+ tmp = (s8) ath5k_get_interpolated_value(pwr_i,
+ pwrL[0], pwrL[1],
+ stepL[0], stepL[1]);
+ } while (tmp > 1);
+
+ min_pwrL = pwr_i;
+ }
- min_pwrR = pwr_i;
+ if (pwrR[0] == pwrR[1])
+ min_pwrR = pwrR[0];
+ else {
+ pwr_i = pwrR[0];
+ do {
+ pwr_i--;
+ tmp = (s8) ath5k_get_interpolated_value(pwr_i,
+ pwrR[0], pwrR[1],
+ stepR[0], stepR[1]);
+ } while (tmp > 1);
+
+ min_pwrR = pwr_i;
+ }
/* Keep the right boundary so that it works for both curves */
return max(min_pwrL, min_pwrR);
MjAwOS8zLzMxIEZhYmlvIFJvc3NpIDxyb3NzaS5mQGlud2luZC5pdD46Cj4gV2hlbiB0aGUgRUVQ
Uk9NIGNvbnRhaW5zIHdlaXJkIHZhbHVlcyBmb3IgdGhlIHBvd2Vy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IMKg
IMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIHB3clJbMF0sIHB3clJbMV0sCj4gKyDCoCDCoCDCoCDC
oCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDCoCDC
oCDCoCDCoCDCoCDCoCBzdGVwUlswXSwgc3RlcFJbMV0pOwo+ICsgwqAgwqAgwqAgwqAgwqAgwqAg
wqAgfSB3aGlsZSAodG1wID4gMSk7Cj4gKwo+ICsgwqAgwqAgwqAgwqAgwqAgwqAgwqAgbWluX3B3
clIgPSBwd3JfaTsKPiArIMKgIMKgIMKgIH0KPgo+IMKgIMKgIMKgIMKgLyogS2VlcCB0aGUgcmln
aHQgYm91bmRhcnkgc28gdGhhdCBpdCB3b3JrcyBmb3IgYm90aCBjdXJ2ZXMgKi8KPiDCoCDCoCDC
oCDCoHJldHVybiBtYXgobWluX3B3ckwsIG1pbl9wd3JSKTsKPgoKCkFja2VkLWJ5OiBOaWNrIEtv
c3NpZmlkaXMgPG1pY2tmbGVtbUBnbWFpbC5jb20+CgotLSAKR1BHIElEOiAweEQyMURCMkRCCkFz
IHlvdSByZWFkIHRoaXMgcG9zdCBnbG9iYWwgZW50cm9weSByaXNlcy4gSGF2ZSBGdW4gOy0pCk5p
Y2sK
On Tue, Mar 31, 2009 at 10:18 AM, Nick Kossifidis <[email protected]> wrote:
> 2009/3/31 Fabio Rossi <[email protected]>:
>> When the EEPROM contains weird values for the power levels we have to
>> fix the interpolation process.
>>
>> Signed-off-by: Fabio Rossi <[email protected]>
> Acked-by: Nick Kossifidis <[email protected]>
Can this be rebased on top of the ath5k/ath9k/ar9170 merge series?
Luis