All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilan Peer <ilan.peer@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Ilan Peer <ilan.peer@intel.com>
Subject: [PATCH 1/2] cfg80211: Add a function to get the number of enabled channels
Date: Tue, 31 Dec 2013 17:32:25 +0200	[thread overview]
Message-ID: <1388503946-25862-2-git-send-email-ilan.peer@intel.com> (raw)
In-Reply-To: <1388503946-25862-1-git-send-email-ilan.peer@intel.com>

Add a utility function to get the number of channels enabled by
the device.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
 include/net/cfg80211.h |    9 +++++++++
 net/wireless/util.c    |   21 +++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 80a1021..405ef5b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4532,6 +4532,15 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
  */
 void cfg80211_crit_proto_stopped(struct wireless_dev *wdev, gfp_t gfp);
 
+/**
+ * ieee80211_get_num_enabled_channels - get the number of channels supported
+ * and enabled by the device.
+ * @wiphy: the wiphy
+ *
+ * Return: the number of channels supported and enabled by the device.
+ */
+unsigned int ieee80211_get_num_enabled_channels(struct wiphy *wiphy);
+
 /* Logging, debugging and troubleshooting/diagnostic helpers. */
 
 /* wiphy_printk helpers, similar to dev_printk */
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 935dea9..fb5f685 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1462,6 +1462,27 @@ int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
 	return 0;
 }
 
+unsigned int ieee80211_get_num_enabled_channels(struct wiphy *wiphy)
+{
+	struct ieee80211_supported_band *sband;
+	unsigned int n_channels, i, j;
+
+	for (i = 0, n_channels = 0; i < IEEE80211_NUM_BANDS; i++) {
+		sband = wiphy->bands[i];
+		if (!sband)
+			continue;
+
+		for (j = 0; j < sband->n_channels; j++) {
+			if (!(sband->channels[j].flags &
+			      IEEE80211_CHAN_DISABLED))
+				n_channels++;
+		}
+	}
+
+	return n_channels;
+}
+EXPORT_SYMBOL(ieee80211_get_num_enabled_channels);
+
 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
 const unsigned char rfc1042_header[] __aligned(2) =
-- 
1.7.10.4


  reply	other threads:[~2013-12-31 15:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-31 15:32 [PATCH 0/2] modify the inclusion of supported channels IE Ilan Peer
2013-12-31 15:32 ` Ilan Peer [this message]
2014-01-09  9:17   ` [PATCH 1/2 v2] cfg80211: Add a function to get the number of supported channels Ilan Peer
2014-01-09  9:18     ` Johannes Berg
2014-01-09  9:18     ` Johannes Berg
2014-01-09  9:37     ` [PATCH 1/2 v3] " Ilan Peer
2014-01-09 12:57       ` Johannes Berg
2013-12-31 15:32 ` [PATCH 2/2] [RFC] mac80211: Add all enabled channels to the supported channels element Ilan Peer
2013-12-31 15:33   ` Peer, Ilan
2014-01-07 15:30   ` Johannes Berg
2014-01-09  7:42     ` Peer, Ilan
2014-01-09  9:18   ` [PATCH 2/2 v2] [RFC]mac80211: " Ilan Peer

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=1388503946-25862-2-git-send-email-ilan.peer@intel.com \
    --to=ilan.peer@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.