linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcm43xx-mac80211: Rescale link quality output
@ 2007-08-05  6:23 Larry Finger
  2007-08-05  6:43 ` Andy Green
  0 siblings, 1 reply; 4+ messages in thread
From: Larry Finger @ 2007-08-05  6:23 UTC (permalink / raw)
  To: Michael Buesch; +Cc: Bcm43xx-dev, linux-wireless

The link quality output from wireless extensions is too small by the ratio
of 100/BCM43xx_RX_MAX_SSI (60) for bcm43xx-mac80211. This patch puts the
quantity on the proper scale.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---

Index: wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
===================================================================
--- wireless-dev.orig/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
+++ wireless-dev/drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c
@@ -537,7 +537,8 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
 					      (phystat0 & BCM43xx_RX_PHYST0_GAINCTL),
 					      (phystat3 & BCM43xx_RX_PHYST3_TRSTATE));
 	status.noise = dev->stats.link_noise;
-	status.signal = jssi; /* this looks wrong, but is what mac80211 wants */
+	/* the next line looks wrong, but is what mac80211 wants */
+	status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
 	if (phystat0 & BCM43xx_RX_PHYST0_OFDM)
 		status.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp);
 	else

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bcm43xx-mac80211: Rescale link quality output
  2007-08-05  6:23 [PATCH] bcm43xx-mac80211: Rescale link quality output Larry Finger
@ 2007-08-05  6:43 ` Andy Green
  2007-08-05  7:26   ` Larry Finger
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Green @ 2007-08-05  6:43 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless

Somebody in the thread at some point said:
> BCM43xx_RX_MAX_SSI (60)

> +	status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;

That can't be doing what you intended... (int)100/60 == 1, it just
multiplies jssi by 1.  Maybe some brackets around the multiply?

-Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bcm43xx-mac80211: Rescale link quality output
  2007-08-05  6:43 ` Andy Green
@ 2007-08-05  7:26   ` Larry Finger
  2007-08-05  7:31     ` Andy Green
  0 siblings, 1 reply; 4+ messages in thread
From: Larry Finger @ 2007-08-05  7:26 UTC (permalink / raw)
  To: Andy Green; +Cc: linux-wireless

Andy Green wrote:
> Somebody in the thread at some point said:
>> BCM43xx_RX_MAX_SSI (60)
> 
>> +	status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
> 
> That can't be doing what you intended... (int)100/60 == 1, it just
> multiplies jssi by 1.  Maybe some brackets around the multiply?

I think gcc does equal rank operations from left to right, and the change does have the desired 
result, but the parentheses should be there for clarity.

Thanks,

Larry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bcm43xx-mac80211: Rescale link quality output
  2007-08-05  7:26   ` Larry Finger
@ 2007-08-05  7:31     ` Andy Green
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Green @ 2007-08-05  7:31 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless

Somebody in the thread at some point said:
> Andy Green wrote:
>> Somebody in the thread at some point said:
>>> BCM43xx_RX_MAX_SSI (60)
>>
>>> +    status.signal = jssi * 100 / BCM43xx_RX_MAX_SSI;
>>
>> That can't be doing what you intended... (int)100/60 == 1, it just
>> multiplies jssi by 1.  Maybe some brackets around the multiply?
> 
> I think gcc does equal rank operations from left to right, and the
> change does have the desired result, but the parentheses should be there
> for clarity.

Man I don't know when * started to have equal precedence to /, but you
are right:

#include <stdio.h>
main()
{
        printf("%d\n", 5 * 100 / 60);
        printf("%d\n", (5 * 100) / 60);
        printf("%d\n", 5 * (100 / 60));
}

$ gcc test.c -o test
$ ./test
8
8
5

Sorry for the noise.

-Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-05  7:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-05  6:23 [PATCH] bcm43xx-mac80211: Rescale link quality output Larry Finger
2007-08-05  6:43 ` Andy Green
2007-08-05  7:26   ` Larry Finger
2007-08-05  7:31     ` Andy Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).