From patchwork Wed Jan 19 09:20:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruno Randolf X-Patchwork-Id: 488691 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0J9KG88030597 for ; Wed, 19 Jan 2011 09:20:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753891Ab1ASJUO (ORCPT ); Wed, 19 Jan 2011 04:20:14 -0500 Received: from mail30t.wh2.ocn.ne.jp ([125.206.180.136]:23113 "HELO mail30t.wh2.ocn.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753885Ab1ASJUL (ORCPT ); Wed, 19 Jan 2011 04:20:11 -0500 Received: from vs3003.wh2.ocn.ne.jp (125.206.180.231) by mail30t.wh2.ocn.ne.jp (RS ver 1.0.95vs) with SMTP id 4-0118318810 for ; Wed, 19 Jan 2011 18:20:10 +0900 (JST) Received: (qmail 98246 invoked from network); 19 Jan 2011 09:20:10 -0000 Received: from unknown (HELO localhost6.localdomain6) (220.110.201.18) by with SMTP; 19 Jan 2011 09:20:10 -0000 Subject: [PATCH 1/8] ath5k: Use mac80211 channel mapping function To: linville@tuxdriver.com From: Bruno Randolf Cc: linux-wireless@vger.kernel.org Date: Wed, 19 Jan 2011 18:20:36 +0900 Message-ID: <20110119092036.19628.84273.stgit@localhost6.localdomain6> In-Reply-To: <20110119091949.19628.28309.stgit@localhost6.localdomain6> References: <20110119091949.19628.28309.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 X-SF-Loop: 1 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]); Wed, 19 Jan 2011 09:20:17 +0000 (UTC) diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 09ae4ef..6850112 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -242,18 +242,6 @@ static int ath5k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *re \********************/ /* - * Convert IEEE channel number to MHz frequency. - */ -static inline short -ath5k_ieee2mhz(short chan) -{ - if (chan <= 14 || chan >= 27) - return ieee80211chan2mhz(chan); - else - return 2212 + chan * 20; -} - -/* * Returns true for the channel numbers used without all_channels modparam. */ static bool ath5k_is_standard_channel(short chan) @@ -274,6 +262,7 @@ ath5k_copy_channels(struct ath5k_hw *ah, unsigned int max) { unsigned int i, count, size, chfreq, freq, ch; + enum ieee80211_band band; if (!test_bit(mode, ah->ah_modes)) return 0; @@ -283,11 +272,13 @@ ath5k_copy_channels(struct ath5k_hw *ah, /* 1..220, but 2GHz frequencies are filtered by check_channel */ size = 220 ; chfreq = CHANNEL_5GHZ; + band = IEEE80211_BAND_5GHZ; break; case AR5K_MODE_11B: case AR5K_MODE_11G: size = 26; chfreq = CHANNEL_2GHZ; + band = IEEE80211_BAND_2GHZ; break; default: ATH5K_WARN(ah->ah_sc, "bad mode, not copying channels\n"); @@ -296,7 +287,10 @@ ath5k_copy_channels(struct ath5k_hw *ah, for (i = 0, count = 0; i < size && max > 0; i++) { ch = i + 1 ; - freq = ath5k_ieee2mhz(ch); + freq = ieee80211_channel_to_frequency(ch, band); + + if (freq == 0) /* mapping failed - not a standard channel */ + continue; /* Check if channel is supported by the chipset */ if (!ath5k_channel_ok(ah, freq, chfreq)) @@ -307,8 +301,7 @@ ath5k_copy_channels(struct ath5k_hw *ah, /* Write channel info and increment counter */ channels[count].center_freq = freq; - channels[count].band = (chfreq == CHANNEL_2GHZ) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + channels[count].band = band; switch (mode) { case AR5K_MODE_11A: case AR5K_MODE_11G: