diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2011-06-20 07:42:28 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-06-22 16:09:45 -0400 |
commit | 7a1d6564a15183cb5994656040966df09af8390f (patch) | |
tree | d9637c519b66007d6b98249c3477051fa4bba870 /drivers/net/wireless/zd1211rw | |
parent | 670dc2833d144375eac36ad74111495a825a9288 (diff) |
zd1211rw: fix invalid signal values from device
Driver uses IEEE80211_HW_SIGNAL_UNSPEC and so signal values reported to
mac80211 should be in range 0..100. Sometimes device return out of range
values. These out of range values can then trigger warning in
cfg80211_inform_bss_frame.
This patch adds checks to enforce range returned from driver to
mac80211 be in 0..100 range.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_def.h | 6 | ||||
-rw-r--r-- | drivers/net/wireless/zd1211rw/zd_mac.c | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h index 5463ca9ebc01..9a1b013f81be 100644 --- a/drivers/net/wireless/zd1211rw/zd_def.h +++ b/drivers/net/wireless/zd1211rw/zd_def.h | |||
@@ -37,9 +37,15 @@ typedef u16 __nocast zd_addr_t; | |||
37 | if (net_ratelimit()) \ | 37 | if (net_ratelimit()) \ |
38 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ | 38 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ |
39 | } while (0) | 39 | } while (0) |
40 | # define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \ | ||
41 | bool __cond = !!(cond); \ | ||
42 | if (unlikely(__cond)) \ | ||
43 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ | ||
44 | }) | ||
40 | #else | 45 | #else |
41 | # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) | 46 | # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) |
42 | # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) | 47 | # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) |
48 | # define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0) | ||
43 | #endif /* DEBUG */ | 49 | #endif /* DEBUG */ |
44 | 50 | ||
45 | #ifdef DEBUG | 51 | #ifdef DEBUG |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 5037c8b2b415..5de28bf6fa5f 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -160,6 +160,22 @@ static int zd_reg2alpha2(u8 regdomain, char *alpha2) | |||
160 | return 1; | 160 | return 1; |
161 | } | 161 | } |
162 | 162 | ||
163 | static int zd_check_signal(struct ieee80211_hw *hw, int signal) | ||
164 | { | ||
165 | struct zd_mac *mac = zd_hw_mac(hw); | ||
166 | |||
167 | dev_dbg_f_cond(zd_mac_dev(mac), signal < 0 || signal > 100, | ||
168 | "%s: signal value from device not in range 0..100, " | ||
169 | "but %d.\n", __func__, signal); | ||
170 | |||
171 | if (signal < 0) | ||
172 | signal = 0; | ||
173 | else if (signal > 100) | ||
174 | signal = 100; | ||
175 | |||
176 | return signal; | ||
177 | } | ||
178 | |||
163 | int zd_mac_preinit_hw(struct ieee80211_hw *hw) | 179 | int zd_mac_preinit_hw(struct ieee80211_hw *hw) |
164 | { | 180 | { |
165 | int r; | 181 | int r; |
@@ -461,7 +477,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
461 | if (i<IEEE80211_TX_MAX_RATES) | 477 | if (i<IEEE80211_TX_MAX_RATES) |
462 | info->status.rates[i].idx = -1; /* terminate */ | 478 | info->status.rates[i].idx = -1; /* terminate */ |
463 | 479 | ||
464 | info->status.ack_signal = ackssi; | 480 | info->status.ack_signal = zd_check_signal(hw, ackssi); |
465 | ieee80211_tx_status_irqsafe(hw, skb); | 481 | ieee80211_tx_status_irqsafe(hw, skb); |
466 | } | 482 | } |
467 | 483 | ||
@@ -982,7 +998,7 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
982 | 998 | ||
983 | stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; | 999 | stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; |
984 | stats.band = IEEE80211_BAND_2GHZ; | 1000 | stats.band = IEEE80211_BAND_2GHZ; |
985 | stats.signal = status->signal_strength; | 1001 | stats.signal = zd_check_signal(hw, status->signal_strength); |
986 | 1002 | ||
987 | rate = zd_rx_rate(buffer, status); | 1003 | rate = zd_rx_rate(buffer, status); |
988 | 1004 | ||