airo: fix endianness bug in ->dBm handling

airo_translate_scan() reads BSSListRid directly, does _not_ byteswap
and uses ->dBm (__le16) as host-endian.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Al Viro 2007-12-19 19:20:12 -05:00 committed by David S. Miller
parent 977b143c13
commit 851b3e5e3d

View file

@ -7239,6 +7239,7 @@ static inline char *airo_translate_scan(struct net_device *dev,
char * current_val; /* For rates */ char * current_val; /* For rates */
int i; int i;
char * buf; char * buf;
u16 dBm;
/* First entry *MUST* be the AP MAC address */ /* First entry *MUST* be the AP MAC address */
iwe.cmd = SIOCGIWAP; iwe.cmd = SIOCGIWAP;
@ -7277,16 +7278,18 @@ static inline char *airo_translate_scan(struct net_device *dev,
iwe.u.freq.e = 1; iwe.u.freq.e = 1;
current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
dBm = le16_to_cpu(bss->dBm);
/* Add quality statistics */ /* Add quality statistics */
iwe.cmd = IWEVQUAL; iwe.cmd = IWEVQUAL;
if (ai->rssi) { if (ai->rssi) {
iwe.u.qual.level = 0x100 - bss->dBm; iwe.u.qual.level = 0x100 - dBm;
iwe.u.qual.qual = airo_dbm_to_pct( ai->rssi, bss->dBm ); iwe.u.qual.qual = airo_dbm_to_pct(ai->rssi, dBm);
iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED
| IW_QUAL_LEVEL_UPDATED | IW_QUAL_LEVEL_UPDATED
| IW_QUAL_DBM; | IW_QUAL_DBM;
} else { } else {
iwe.u.qual.level = (bss->dBm + 321) / 2; iwe.u.qual.level = (dBm + 321) / 2;
iwe.u.qual.qual = 0; iwe.u.qual.qual = 0;
iwe.u.qual.updated = IW_QUAL_QUAL_INVALID iwe.u.qual.updated = IW_QUAL_QUAL_INVALID
| IW_QUAL_LEVEL_UPDATED | IW_QUAL_LEVEL_UPDATED