Search Linux Wireless

[PATCH 1/2] cfg80211: Add a function to get the number of enabled channels

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

 



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

Signed-off-by: Ilan Peer <ilan.peer@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux