From patchwork Tue Jan 3 22:57:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9495797 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 668EF60405 for ; Tue, 3 Jan 2017 22:57:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59DAF1FF35 for ; Tue, 3 Jan 2017 22:57:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E4C52793A; Tue, 3 Jan 2017 22:57:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D94FD1FF35 for ; Tue, 3 Jan 2017 22:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761683AbdACW5k (ORCPT ); Tue, 3 Jan 2017 17:57:40 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35965 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761671AbdACW5i (ORCPT ); Tue, 3 Jan 2017 17:57:38 -0500 Received: by mail-lf0-f67.google.com with SMTP id t196so26930781lff.3; Tue, 03 Jan 2017 14:57:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fgs5IDcNJBLdfQvqHPhnelCcVLs++kkC14xOzu18q7Q=; b=ij23WPxo+JPk/1u4l/uqN1Eu6tUxyC2f6MLdxrIuOEPfVeSl8cTT7+RkQydp2aGFxA Zlx9Mt72RV5595M9ymdhM45IQZWaZGpP7EJINVBq7qdMTl8HnyEYsiqJM95lV+S7RkeK 4JpVyhX6Bk2r0bPQUZPhQQo8uWCTxgW0oeMfT09NeWpad4org6xTDwajaiI9RHPvOmqy AyXCr41F3E9B1Hwte/ovKaEVn8SVfes8HtDoYOKs8Lt/zqkmlEYMXie4Y4Ie4sKuyS7e dgAxLNIVghEdsrRqrcnQQKdYAYDKHBuatLftdyiCFgR9Z96UEDbJAapel9IXKQHCjdBw bslA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fgs5IDcNJBLdfQvqHPhnelCcVLs++kkC14xOzu18q7Q=; b=j1jif4Io9uGQlD+WVaeE1BKjYtAyVbnNG1uwb9/vIxt0pDs3fwJMeo2b8icl+NCCm5 lDcUDEG9lk3inliRWO0/ykKCZyzGk4kZgR3iV5nu2gfxgoSTg4pjYSKbhZhYC/sTLXEE nnCmEOfEB2mnK+x2XEbJKMqVdm7ireKlGYXX/VOqRgYC6MexcZvgLw3YOZc1jXMshDW8 Any0uxCl2q8f5aJP2xjLEPiQL2FqkjNO4yvMIfNEuasOBFX70TP30Sf0zgZnHhULHHfw ygCQD2R4yMUAj5WaUQopxo5Ra4MZ2kS6Ve7P2db5CHYAoUyxgFQbJaRZ6UtSna5OhSt/ CyOw== X-Gm-Message-State: AIkVDXKpA+smO90P1SNa0u3T8f2esVDWQMpf3zsULo3shzfwuMex71SLi/t21tnDLWx3fw== X-Received: by 10.25.215.212 with SMTP id q81mr22969830lfi.126.1483484254812; Tue, 03 Jan 2017 14:57:34 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id 26sm16783366lji.37.2017.01.03.14.57.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jan 2017 14:57:34 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Johannes Berg , linux-wireless@vger.kernel.org Cc: Martin Blumenstingl , Felix Fietkau , Arend van Spriel , Arnd Bergmann , devicetree@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH V5 2/3] cfg80211: move function checking range fit to util.c Date: Tue, 3 Jan 2017 23:57:13 +0100 Message-Id: <20170103225715.14072-2-zajec5@gmail.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170103225715.14072-1-zajec5@gmail.com> References: <20170103225715.14072-1-zajec5@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafał Miłecki It is needed for another cfg80211 helper that will be out of reg.c so move it to common util.c file and make it non-static. Signed-off-by: Rafał Miłecki --- V5: Add this patch as suggested by Arend --- net/wireless/core.h | 3 +++ net/wireless/reg.c | 27 +++++++-------------------- net/wireless/util.c | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/net/wireless/core.h b/net/wireless/core.h index af6e023..bc8ba6e 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -430,6 +430,9 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev); void cfg80211_process_wdev_events(struct wireless_dev *wdev); +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range, + u32 center_freq_khz, u32 bw_khz); + /** * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable * @wiphy: the wiphy to validate against diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5dbac37..753efcd 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -748,21 +748,6 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd) return true; } -static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range, - u32 center_freq_khz, u32 bw_khz) -{ - u32 start_freq_khz, end_freq_khz; - - start_freq_khz = center_freq_khz - (bw_khz/2); - end_freq_khz = center_freq_khz + (bw_khz/2); - - if (start_freq_khz >= freq_range->start_freq_khz && - end_freq_khz <= freq_range->end_freq_khz) - return true; - - return false; -} - /** * freq_in_rule_band - tells us if a frequency is in a frequency band * @freq_range: frequency rule we want to query @@ -1070,7 +1055,7 @@ freq_reg_info_regd(u32 center_freq, if (!band_rule_found) band_rule_found = freq_in_rule_band(fr, center_freq); - bw_fits = reg_does_bw_fit(fr, center_freq, bw); + bw_fits = cfg80211_does_bw_fit_range(fr, center_freq, bw); if (band_rule_found && bw_fits) return rr; @@ -1138,11 +1123,13 @@ static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); /* If we get a reg_rule we can assume that at least 5Mhz fit */ - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq), - MHZ_TO_KHZ(10))) + if (!cfg80211_does_bw_fit_range(freq_range, + MHZ_TO_KHZ(chan->center_freq), + MHZ_TO_KHZ(10))) bw_flags |= IEEE80211_CHAN_NO_10MHZ; - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq), - MHZ_TO_KHZ(20))) + if (!cfg80211_does_bw_fit_range(freq_range, + MHZ_TO_KHZ(chan->center_freq), + MHZ_TO_KHZ(20))) bw_flags |= IEEE80211_CHAN_NO_20MHZ; if (max_bandwidth_khz < MHZ_TO_KHZ(10)) diff --git a/net/wireless/util.c b/net/wireless/util.c index 2cf7df8..62dc214 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1847,6 +1847,21 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f) } EXPORT_SYMBOL(cfg80211_free_nan_func); +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range, + u32 center_freq_khz, u32 bw_khz) +{ + u32 start_freq_khz, end_freq_khz; + + start_freq_khz = center_freq_khz - (bw_khz / 2); + end_freq_khz = center_freq_khz + (bw_khz / 2); + + if (start_freq_khz >= freq_range->start_freq_khz && + end_freq_khz <= freq_range->end_freq_khz) + return true; + + return false; +} + /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ const unsigned char rfc1042_header[] __aligned(2) =