From patchwork Wed Dec 28 15:59:55 2016 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: 9490481 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 C7CFE60838 for ; Wed, 28 Dec 2016 16:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E0C2623C for ; Wed, 28 Dec 2016 16:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC9F126247; Wed, 28 Dec 2016 16:00:42 +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 B37042623C for ; Wed, 28 Dec 2016 16:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751771AbcL1QA1 (ORCPT ); Wed, 28 Dec 2016 11:00:27 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35155 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751748AbcL1QAY (ORCPT ); Wed, 28 Dec 2016 11:00:24 -0500 Received: by mail-lf0-f68.google.com with SMTP id x140so15954415lfa.2; Wed, 28 Dec 2016 08:00:23 -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=wJ5wG7DNBWoED33RWsDY47LMTOwpbN3Nsigo6ZuIOxc=; b=q1iQGAl0F06FFE5RcEnciASTOpFuTxbLe1leB0n8qXdmjEH6+2AYlEYyp1HI8bJygr IpvBm1GCIln+1mLPwqqqUiD4L5Cmjr6ju/t/wrycTKc3SaoZ1WrJZNnn6t4VDnMDk8pW pzktfrt3zsmus6pKYuaChtYs6plG+9MsTwNmPqPIoz53qX37LI8QKqnSBh1Ab+mVTDN/ CqpWc9VxC2qv8pMft0lS33Mj3shtZWDC7ajsU4elHKHJJPw6/TIqi/U7elLTp/BU6CNM Z5wzPm+3isxnJJ5vKyXvMC/hCQQ/eS++0RGb1MS6gRnNDDkVDOlh7NXRBs9LZdXCS5bp +tIQ== 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=wJ5wG7DNBWoED33RWsDY47LMTOwpbN3Nsigo6ZuIOxc=; b=K5WKMftbIPuS8nGCyXfydo4Sl6uw+UHO6P2RMhjoIIc3U4eY1Y6fWP3PnzTzTUnldX a7G7FZi0zFXhhpsQTBDWy8C+Db/qB9a0M2GCZLFTk8PUrKXeD305Y1XQlq+gzwV3qAND Q2/uX1xWsnXVeN8etq8kNPRTYAAjfRE3uLnzG4NrnF606aIlsBSIeEidFT50QBi1QH05 jKcOJzrei1KLsF4YQ5l9zej2qDuzIbs+duJ3x/dQzDmu+AptDiimmf8bLhAjFDl/Aruh d4xSN/Tk9pACvloU/Mwezhtk1rv5zRc5S6T3Ypz/w8XE7RamVAQ6XU5fjr9c+i2DQoin rQtA== X-Gm-Message-State: AIkVDXIKMqauOfL8ObZLF5X4YINXcos2U4ozixGJaJPfAxATO76xLzjsvozwWznSWn2qJw== X-Received: by 10.46.7.9 with SMTP id 9mr12870171ljh.75.1482940822413; Wed, 28 Dec 2016 08:00:22 -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 p9sm5421401lfd.49.2016.12.28.08.00.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Dec 2016 08:00:21 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo , linux-wireless@vger.kernel.org Cc: Martin Blumenstingl , Felix Fietkau , Arnd Bergmann , devicetree@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH 2/2] cfg80211: reg: support ieee80211-(min|max)-center-freq DT properties Date: Wed, 28 Dec 2016 16:59:55 +0100 Message-Id: <20161228155955.25518-2-zajec5@gmail.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161228155955.25518-1-zajec5@gmail.com> References: <20161228155955.25518-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 They allow specifying hardware limitations of supported channels. This may be useful for specifying single band devices or devices that support only some part of the whole band. E.g. some tri-band routers have separated radios for lower and higher part of 5 GHz band. Signed-off-by: Rafał Miłecki --- net/wireless/reg.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5dbac37..35ba5c7 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1123,6 +1123,26 @@ const char *reg_initiator_name(enum nl80211_reg_initiator initiator) } EXPORT_SYMBOL(reg_initiator_name); +static bool reg_center_freq_of_valid(struct wiphy *wiphy, + struct ieee80211_channel *chan) +{ + struct device_node *np = wiphy_dev(wiphy)->of_node; + u32 val; + + if (!np) + return true; + + if (!of_property_read_u32(np, "ieee80211-min-center-freq", &val) && + chan->center_freq < KHZ_TO_MHZ(val)) + return false; + + if (!of_property_read_u32(np, "ieee80211-max-center-freq", &val) && + chan->center_freq > KHZ_TO_MHZ(val)) + return false; + + return true; +} + static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd, const struct ieee80211_reg_rule *reg_rule, const struct ieee80211_channel *chan) @@ -1209,6 +1229,13 @@ static void handle_channel(struct wiphy *wiphy, return; } + if (!reg_center_freq_of_valid(wiphy, chan)) { + pr_debug("Disabling freq %d MHz as it's out of OF limits\n", + chan->center_freq); + chan->flags |= IEEE80211_CHAN_DISABLED; + return; + } + regd = reg_get_regdomain(wiphy); power_rule = ®_rule->power_rule; @@ -1741,6 +1768,13 @@ static void handle_channel_custom(struct wiphy *wiphy, return; } + if (!reg_center_freq_of_valid(wiphy, chan)) { + pr_debug("Disabling freq %d MHz as it's out of OF limits\n", + chan->center_freq); + chan->flags |= IEEE80211_CHAN_DISABLED; + return; + } + power_rule = ®_rule->power_rule; bw_flags = reg_rule_to_chan_bw_flags(regd, reg_rule, chan);