From patchwork Tue Dec 31 15:32:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 3421861 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53CE9C02DC for ; Tue, 31 Dec 2013 15:31:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FF752010F for ; Tue, 31 Dec 2013 15:31:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C2B2200E0 for ; Tue, 31 Dec 2013 15:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753583Ab3LaPa4 (ORCPT ); Tue, 31 Dec 2013 10:30:56 -0500 Received: from mga02.intel.com ([134.134.136.20]:40864 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752842Ab3LaPa4 (ORCPT ); Tue, 31 Dec 2013 10:30:56 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 31 Dec 2013 07:30:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,581,1384329600"; d="scan'208";a="432235407" Received: from ipeer-e6430-1.jer.intel.com ([10.12.217.171]) by orsmga001.jf.intel.com with ESMTP; 31 Dec 2013 07:30:53 -0800 From: Ilan Peer To: linux-wireless@vger.kernel.org Cc: Ilan Peer Subject: [PATCH 1/2] cfg80211: Add a function to get the number of enabled channels Date: Tue, 31 Dec 2013 17:32:25 +0200 Message-Id: <1388503946-25862-2-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1388503946-25862-1-git-send-email-ilan.peer@intel.com> References: <1388503946-25862-1-git-send-email-ilan.peer@intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a utility function to get the number of channels enabled by the device. Signed-off-by: Ilan Peer --- 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) =