linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH v2 4/6] wireless: Add util method to get channel index from frequency.
Date: Tue, 17 Apr 2012 10:46:45 -0700	[thread overview]
Message-ID: <1334684807-14026-5-git-send-email-greearb@candelatech.com> (raw)
In-Reply-To: <1334684807-14026-1-git-send-email-greearb@candelatech.com>

From: Ben Greear <greearb@candelatech.com>

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 27f9561... be6fb62... M	include/net/cfg80211.h
:100644 100644 6cba001... 2fd0e97... M	net/wireless/util.c
 include/net/cfg80211.h |    7 +++++++
 net/wireless/util.c    |   24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 27f9561..be6fb62 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2388,6 +2388,13 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq)
 }
 
 /**
+ * ieee80211_get_channel_idx - get channel index from wiphy for specified freq
+ * @wiphy: the struct wiphy to get the channel for
+ * @freq: the center frequency of the channel
+ */
+extern int ieee80211_get_channel_idx(struct wiphy *wiphy, int freq);
+
+/**
  * ieee80211_get_response_rate - get basic rate for a given rate
  *
  * @sband: the band to look for rates in
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 6cba001..2fd0e97 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -88,6 +88,30 @@ struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
 }
 EXPORT_SYMBOL(__ieee80211_get_channel);
 
+int ieee80211_get_channel_idx(struct wiphy *wiphy, int freq)
+{
+	enum ieee80211_band band;
+	struct ieee80211_supported_band *sband;
+	int i;
+	int rv = 0;
+
+	for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+		sband = wiphy->bands[band];
+
+		if (!sband)
+			continue;
+
+		for (i = 0; i < sband->n_channels; i++) {
+			if (sband->channels[i].center_freq == freq)
+				return rv;
+			rv++;
+		}
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(ieee80211_get_channel_idx);
+
 static void set_mandatory_flags_band(struct ieee80211_supported_band *sband,
 				     enum ieee80211_band band)
 {
-- 
1.7.3.4


  parent reply	other threads:[~2012-04-17 17:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 17:46 [PATCH v2 0/6] Add ethtool stats support for Wireless Devices greearb
2012-04-17 17:46 ` [PATCH v2 1/6] cfg80211: Add framework to support ethtool stats greearb
2012-04-17 17:46 ` [PATCH v2 2/6] mac80211: Support getting sta_info stats via ethtool greearb
2012-04-18  1:37   ` Johannes Berg
2012-04-18  3:46     ` Ben Greear
2012-04-18  4:00       ` Johannes Berg
2012-04-18 16:27         ` Ben Greear
2012-04-18 22:39           ` Johannes Berg
2012-04-18 22:59             ` Ben Greear
2012-04-19  4:38               ` Johannes Berg
2012-04-17 17:46 ` [PATCH v2 3/6] mac80211: Framework to get wifi-driver " greearb
2012-04-17 17:46 ` greearb [this message]
2012-04-18  1:40   ` [PATCH v2 4/6] wireless: Add util method to get channel index from frequency Johannes Berg
2012-04-18  3:36     ` Ben Greear
2012-04-17 17:46 ` [PATCH v2 5/6] mac80211: Add more ethtools stats: survey, rates, etc greearb
2012-04-18  1:41   ` Johannes Berg
2012-04-18  3:31     ` Ben Greear
2012-04-18  4:05       ` Johannes Berg
2012-04-18 16:19         ` Ben Greear
2012-04-18 22:40           ` Johannes Berg
2012-04-18 22:54             ` Ben Greear
2012-04-19  4:37               ` Johannes Berg
2012-04-17 17:46 ` [PATCH v2 6/6] mac80211: Add sta_state to ethtool stats greearb
2012-04-18  1:42   ` Johannes Berg
2012-04-18  1:44 ` [PATCH v2 0/6] Add ethtool stats support for Wireless Devices Johannes Berg
2012-04-18  3:56   ` Ben Greear

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=1334684807-14026-5-git-send-email-greearb@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-wireless@vger.kernel.org \
    /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).