linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bruno Randolf <br1@einfach.org>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 1/8] ath5k: Use mac80211 channel mapping function
Date: Wed, 19 Jan 2011 18:20:36 +0900	[thread overview]
Message-ID: <20110119092036.19628.84273.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20110119091949.19628.28309.stgit@localhost6.localdomain6>

Use mac80211 channel mapping function instead of own homegrown version.

Signed-off-by: Bruno Randolf <br1@einfach.org>
---
 drivers/net/wireless/ath/ath5k/base.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

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:


  reply	other threads:[~2011-01-19  9:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19  9:20 [PATCH 0/8] ath5k 802.11j preparation and cleanup Bruno Randolf
2011-01-19  9:20 ` Bruno Randolf [this message]
2011-01-19 15:39   ` [PATCH 1/8] ath5k: Use mac80211 channel mapping function Bob Copeland
2011-01-19  9:20 ` [PATCH 2/8] ath5k: Simplify loop when setting up channels Bruno Randolf
2011-01-19 11:07   ` Bob Copeland
2011-01-19 11:51     ` Bruno Randolf
2011-01-19  9:20 ` [PATCH 3/8] ath5k: Rename ath5k_copy_channels Bruno Randolf
2011-01-19 11:08   ` Bob Copeland
2011-01-19 15:54   ` Nick Kossifidis
2011-01-19  9:20 ` [PATCH 4/8] ath5k: ath5k_setup_channels cleanup and whitespace Bruno Randolf
2011-01-19 11:09   ` Bob Copeland
2011-01-19 15:57   ` Nick Kossifidis
2011-01-19  9:20 ` [PATCH 5/8] ath5k: Add 802.11j 4.9GHz channels to allowed channels Bruno Randolf
2011-01-19 11:14   ` Bob Copeland
2011-01-19 11:52     ` Bruno Randolf
2011-01-19 15:18       ` Bob Copeland
2011-01-19 15:55   ` Nick Kossifidis
2011-01-19  9:21 ` [PATCH 6/8] ath5: Remove unused CTL definitions Bruno Randolf
2011-01-19 11:15   ` Bob Copeland
2011-01-19 15:55   ` Nick Kossifidis
2011-01-19  9:21 ` [PATCH 7/8] ath5k: Remove unused sc->curmode Bruno Randolf
2011-01-19 11:17   ` Bob Copeland
2011-01-19 15:56   ` Nick Kossifidis
2011-01-19  9:21 ` [PATCH 8/8] ath5k: Remove redundant sc->curband Bruno Randolf
2011-01-19 11:19   ` Bob Copeland
2011-01-19 15:57   ` Nick Kossifidis
2011-01-19 15:58 ` [PATCH 0/8] ath5k 802.11j preparation and cleanup Nick Kossifidis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110119092036.19628.84273.stgit@localhost6.localdomain6 \
    --to=br1@einfach.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).