Search Linux Wireless

Re: [PATCH v2 4/6] wireless: Add util method to get channel index from frequency.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On 04/17/2012 06:40 PM, Johannes Berg wrote:
On Tue, 2012-04-17 at 10:46 -0700, greearb@xxxxxxxxxxxxxxx wrote:
From: Ben Greear<greearb@xxxxxxxxxxxxxxx>

Signed-off-by: Ben Greear<greearb@xxxxxxxxxxxxxxx>
: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);

I prefer you drop the extern, but ...

+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;

"return NULL"? Really?

Gah, that is wrong.

Also, what use is the index? It's some kind of global channel index, but
that's almost completely useless. I think you need a very very very good
reason to have this function and you're not even stating a single one.

Well, it's used in the next patch that gets the survey info by index.

Wouldn't hurt my feelings to re-write how the get-survey() method
is called, but that would touch a lot of drivers, break out-of-tree drivers,

When you get a chance, please take a look at how the survey code
appears to work and let me know if you want it changed to take
channel objects instead of channel indexes.


Ben Greear <greearb@xxxxxxxxxxxxxxx>
Candela Technologies Inc
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at

[Linux Kernel]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Photo]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]     [Free Dating]     [M2M Wireless]

Add to Google Powered by Linux