aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/carl9170/phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/carl9170/phy.c')
-rw-r--r--drivers/net/wireless/ath/carl9170/phy.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index 89deca37a988..82bc81c4c930 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1554,15 +1554,6 @@ static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq,
1554 return carl9170_regwrite_result(); 1554 return carl9170_regwrite_result();
1555} 1555}
1556 1556
1557/* TODO: replace this with sign_extend32(noise, 8) */
1558static int carl9170_calc_noise_dbm(u32 raw_noise)
1559{
1560 if (raw_noise & 0x100)
1561 return ~0x1ff | raw_noise;
1562 else
1563 return raw_noise;
1564}
1565
1566int carl9170_get_noisefloor(struct ar9170 *ar) 1557int carl9170_get_noisefloor(struct ar9170 *ar)
1567{ 1558{
1568 static const u32 phy_regs[] = { 1559 static const u32 phy_regs[] = {
@@ -1578,11 +1569,11 @@ int carl9170_get_noisefloor(struct ar9170 *ar)
1578 return err; 1569 return err;
1579 1570
1580 for (i = 0; i < 2; i++) { 1571 for (i = 0; i < 2; i++) {
1581 ar->noise[i] = carl9170_calc_noise_dbm( 1572 ar->noise[i] = sign_extend32(GET_VAL(
1582 (phy_res[i] >> 19) & 0x1ff); 1573 AR9170_PHY_CCA_MIN_PWR, phy_res[i]), 8);
1583 1574
1584 ar->noise[i + 2] = carl9170_calc_noise_dbm( 1575 ar->noise[i + 2] = sign_extend32(GET_VAL(
1585 (phy_res[i + 2] >> 23) & 0x1ff); 1576 AR9170_PHY_EXT_CCA_MIN_PWR, phy_res[i + 2]), 8);
1586 } 1577 }
1587 1578
1588 return 0; 1579 return 0;