Skip to content

Commit b1d771e

Browse files
chunkeeylinvjw
authored andcommitted
carl9170: use generic sign_extend32
This patch replaces the handcrafted sign extension cruft with a generic bitop function. Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 7919a57 commit b1d771e

File tree

1 file changed

+4
-13
lines changed
  • drivers/net/wireless/ath/carl9170

1 file changed

+4
-13
lines changed

drivers/net/wireless/ath/carl9170/phy.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,15 +1554,6 @@ static int carl9170_set_power_cal(struct ar9170 *ar, u32 freq,
15541554
return carl9170_regwrite_result();
15551555
}
15561556

1557-
/* TODO: replace this with sign_extend32(noise, 8) */
1558-
static 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-
15661557
int carl9170_get_noisefloor(struct ar9170 *ar)
15671558
{
15681559
static const u32 phy_regs[] = {
@@ -1578,11 +1569,11 @@ int carl9170_get_noisefloor(struct ar9170 *ar)
15781569
return err;
15791570

15801571
for (i = 0; i < 2; i++) {
1581-
ar->noise[i] = carl9170_calc_noise_dbm(
1582-
(phy_res[i] >> 19) & 0x1ff);
1572+
ar->noise[i] = sign_extend32(GET_VAL(
1573+
AR9170_PHY_CCA_MIN_PWR, phy_res[i]), 8);
15831574

1584-
ar->noise[i + 2] = carl9170_calc_noise_dbm(
1585-
(phy_res[i + 2] >> 23) & 0x1ff);
1575+
ar->noise[i + 2] = sign_extend32(GET_VAL(
1576+
AR9170_PHY_EXT_CCA_MIN_PWR, phy_res[i + 2]), 8);
15861577
}
15871578

15881579
return 0;

0 commit comments

Comments
 (0)