From patchwork Mon Jun 20 11:42:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jussi Kivilinna X-Patchwork-Id: 897012 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5KBgY3E000439 for ; Mon, 20 Jun 2011 11:42:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753351Ab1FTLmb (ORCPT ); Mon, 20 Jun 2011 07:42:31 -0400 Received: from sd-mail-sa-01.sanoma.fi ([158.127.18.161]:59433 "EHLO sd-mail-sa-01.sanoma.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753293Ab1FTLmb (ORCPT ); Mon, 20 Jun 2011 07:42:31 -0400 Received: from localhost (localhost [127.0.0.1]) by sd-mail-sa-01.sanoma.fi (Postfix) with ESMTP id 63F2FF09DA; Mon, 20 Jun 2011 14:42:29 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at sd-mail-sa-01.sanoma.fi Received: from sd-mail-sa-01.sanoma.fi ([127.0.0.1]) by localhost (sd-mail-sa-01.sanoma.fi [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r9O5ZCIP5b+q; Mon, 20 Jun 2011 14:42:29 +0300 (EEST) Received: from hayate.81.fi (dyn2-85-23-163-91.psoas.suomi.net [85.23.163.91]) by sd-mail-sa-01.sanoma.fi (Postfix) with ESMTPSA id 357AEF07DB; Mon, 20 Jun 2011 14:42:29 +0300 (EEST) Received: from fate.lan ([10.0.0.10] helo=fate) by hayate.81.fi with esmtp (Exim 4.72) (envelope-from ) id 1QYcs8-0000m2-UM; Mon, 20 Jun 2011 14:42:28 +0300 Received: from localhost6.localdomain6 (unknown [127.0.0.1]) by fate (Postfix) with ESMTP id DE31025206; Mon, 20 Jun 2011 14:42:28 +0300 (EEST) Subject: [PATCH 1/6] zd1211rw: fix invalid signal values from device To: linux-wireless@vger.kernel.org From: Jussi Kivilinna Cc: Daniel Drake , "John W. Linville" , Ulrich Kunitz Date: Mon, 20 Jun 2011 14:42:28 +0300 Message-ID: <20110620114228.964.35459.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Jun 2011 11:42:36 +0000 (UTC) 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 --- drivers/net/wireless/zd1211rw/zd_def.h | 6 ++++++ drivers/net/wireless/zd1211rw/zd_mac.c | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h index 5463ca9..9a1b013 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; if (net_ratelimit()) \ dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ } while (0) +# define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \ + bool __cond = !!(cond); \ + if (unlikely(__cond)) \ + dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ +}) #else # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) +# define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0) #endif /* DEBUG */ #ifdef DEBUG diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 5037c8b..5de28bf 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) return 1; } +static int zd_check_signal(struct ieee80211_hw *hw, int signal) +{ + struct zd_mac *mac = zd_hw_mac(hw); + + dev_dbg_f_cond(zd_mac_dev(mac), signal < 0 || signal > 100, + "%s: signal value from device not in range 0..100, " + "but %d.\n", __func__, signal); + + if (signal < 0) + signal = 0; + else if (signal > 100) + signal = 100; + + return signal; +} + int zd_mac_preinit_hw(struct ieee80211_hw *hw) { int r; @@ -461,7 +477,7 @@ static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, if (istatus.rates[i].idx = -1; /* terminate */ - info->status.ack_signal = ackssi; + info->status.ack_signal = zd_check_signal(hw, ackssi); ieee80211_tx_status_irqsafe(hw, skb); } @@ -982,7 +998,7 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; stats.band = IEEE80211_BAND_2GHZ; - stats.signal = status->signal_strength; + stats.signal = zd_check_signal(hw, status->signal_strength); rate = zd_rx_rate(buffer, status);