Skip to contentSkip to conversation

carl9170: fix bad rssi reading

PATCH Applied Hiroaki KAWAI 3 participants 5 messages Sep 10, 2015 – Sep 29, 2015 1 message not in the archive CARL9170 Linux community wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 carl9170: fix bad rssi reading

Fix rssi calculation error which was introduced in otus to ar9170 porting.

---
 drivers/net/wireless/ath/carl9170/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/rx.c +1 -1
index 924135b..d66533c 100644
@@ -453,7 +453,7 @@ static void carl9170_rx_phy_status(struct ar9170 *ar,
 	/* post-process RSSI */
 	for (i = 0; i < 7; i++)
 		if (phy->rssi[i] & 0x80)
-			phy->rssi[i] = ((phy->rssi[i] & 0x7f) + 1) & 0x7f;
+			phy->rssi[i] = ((~phy->rssi[i] & 0x7f) + 1) & 0x7f;
 
 	/* TODO: we could do something with phy_errors */
 	status->signal = ar->noise[0] + phy->rssi_combined;
Signature · 1 line
2.5.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hiroaki KAWAI

Fix rssi calculation error which was introduced in otus to ar9170 porting.

For reference: Here's the line in the original otus code:
<http://lxr.free-electrons.com/source/drivers/staging/otus/hal/hpusb.c?v=2.6.33#L818>

This value/result isn't used anywhere, so we could also remove it.

Quoted 18 lines
---
 drivers/net/wireless/ath/carl9170/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/rx.c +1 -1
index 924135b..d66533c 100644
@@ -453,7 +453,7 @@ static void carl9170_rx_phy_status(struct ar9170 *ar,
 	/* post-process RSSI */
 	for (i = 0; i < 7; i++)
 		if (phy->rssi[i] & 0x80)
-			phy->rssi[i] = ((phy->rssi[i] & 0x7f) + 1) & 0x7f;
+			phy->rssi[i] = ((~phy->rssi[i] & 0x7f) + 1) & 0x7f;
 
 	/* TODO: we could do something with phy_errors */
 	status->signal = ar->noise[0] + phy->rssi_combined;
#2 lore raw

That field is union and referenced as rssi_combined at two lines below.

The status->signal will show up in radiotap IEEE80211_RADIOTAP_DBM_ANTSIGNAL header field at userland finally.

2015-09-10 22:07 GMT+09:00 Christian Lamparter <[email protected]>:

Quoted 31 lines · Hiroaki KAWAI
Quoted 4 lines

Fix rssi calculation error which was introduced in otus to ar9170 porting.

For reference: Here's the line in the original otus code:
<http://lxr.free-electrons.com/source/drivers/staging/otus/hal/hpusb.c?v=2.6.33#L818>

This value/result isn't used anywhere, so we could also remove it.

Quoted 18 lines
---
 drivers/net/wireless/ath/carl9170/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/rx.c +1 -1
index 924135b..d66533c 100644
@@ -453,7 +453,7 @@ static void carl9170_rx_phy_status(struct ar9170 *ar,
      /* post-process RSSI */
      for (i = 0; i < 7; i++)
              if (phy->rssi[i] & 0x80)
-                     phy->rssi[i] = ((phy->rssi[i] & 0x7f) + 1) & 0x7f;
+                     phy->rssi[i] = ((~phy->rssi[i] & 0x7f) + 1) & 0x7f;
 
      /* TODO: we could do something with phy_errors */
      status->signal = ar->noise[0] + phy->rssi_combined;

A message that is not in the archive (sent off-list or not yet received): CABD3darfGTc8gVgAo4j7S4M0uymoF2gy8ihLraN2qcXJFO9cWw@mail.gmail.com

#4 lore raw
Quoted 1 line · Hiroaki Kawai

That field is union and referenced as rssi_combined at two lines below.

Correct

Quoted 3 lines

The status->signal will show up in radiotap
IEEE80211_RADIOTAP_DBM_ANTSIGNAL
header field at userland finally.

so, this patch should go to -stable too.

Thanks

Quoted 21 lines
Quoted 21 lines

Review

Quoted 5 lines
---
 drivers/net/wireless/ath/carl9170/rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/net/wireless/ath/carl9170/rx.c

Quoted 13 lines

index 924135b..d66533c 100644

drivers/net/wireless/ath/carl9170/rx.c +1 -1
@@ -453,7 +453,7 @@ static void carl9170_rx_phy_status(struct ar9170 *ar,
      /* post-process RSSI */
      for (i = 0; i < 7; i++)
              if (phy->rssi[i] & 0x80)
-                     phy->rssi[i] = ((phy->rssi[i] & 0x7f) + 1) & 0x7f;
+                     phy->rssi[i] = ((~phy->rssi[i] & 0x7f) + 1) & 0x7f;
 
      /* TODO: we could do something with phy_errors */
      status->signal = ar->noise[0] + phy->rssi_combined;