linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Subject: [PATCH 16/19] cfg80211: set core regulatory updates on its own
Date: Tue,  5 Nov 2013 09:18:14 -0800	[thread overview]
Message-ID: <1383671897-7746-17-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1383671897-7746-1-git-send-email-mcgrof@do-not-panic.com>

This splits up the core regulatory update to be
set on its own helper. This should make it easier
to read exactly what type of requests should be
expected there. In this case its clear that
NL80211_REGDOM_SET_BY_CORE is only used by the
core for updating the world regulatory domain.
This is consistant with the nl80211.h documentation.

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 net/wireless/reg.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index dc99f3e..cb20ccc 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2188,6 +2188,14 @@ static void print_regdomain_info(const struct ieee80211_regdomain *rd)
 	print_rd_rules(rd);
 }
 
+static int reg_set_rd_core(const struct ieee80211_regdomain *rd)
+{
+	if (!is_world_regdom(rd->alpha2))
+		return -EINVAL;
+	update_world_regdomain(rd);
+	return 0;
+}
+
 /* Takes ownership of rd only if it doesn't fail */
 static int __set_regdom(const struct ieee80211_regdomain *rd,
 			struct regulatory_request *lr)
@@ -2196,18 +2204,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd,
 	const struct ieee80211_regdomain *intersected_rd = NULL;
 	struct wiphy *request_wiphy;
 
-	/* Some basic sanity checks first */
-
-	if (!reg_is_valid_request(rd->alpha2))
-		return -EINVAL;
-
-	if (is_world_regdom(rd->alpha2)) {
-		if (lr->initiator != NL80211_REGDOM_SET_BY_CORE)
-			return -EINVAL;
-		update_world_regdomain(rd);
-		return 0;
-	}
-
 	if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) &&
 	    !is_unknown_alpha2(rd->alpha2))
 		return -EINVAL;
@@ -2317,10 +2313,25 @@ int set_regdom(const struct ieee80211_regdomain *rd)
 	struct regulatory_request *lr;
 	int r;
 
+	if (!reg_is_valid_request(rd->alpha2)) {
+		kfree(rd);
+		return -EINVAL;
+	}
+
 	lr = get_last_request();
 
 	/* Note that this doesn't update the wiphys, this is done below */
-	r = __set_regdom(rd, lr);
+	switch (lr->initiator) {
+	case NL80211_REGDOM_SET_BY_CORE:
+		r = reg_set_rd_core(rd);
+		break;
+	case NL80211_REGDOM_SET_BY_USER:
+	case NL80211_REGDOM_SET_BY_DRIVER:
+	case NL80211_REGDOM_SET_BY_COUNTRY_IE:
+		r = __set_regdom(rd, lr);
+		break;
+	}
+
 	if (r) {
 		if (r == -EALREADY)
 			reg_set_request_processed();
-- 
1.8.4.rc3


  parent reply	other threads:[~2013-11-05 17:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05 17:17 [PATCH 00/19] cfg80211: regulatory updates Luis R. Rodriguez
2013-11-05 17:17 ` [PATCH 01/19] cfg80211: enforce disabling channels by custom or strict settings Luis R. Rodriguez
2013-11-06 10:15   ` Johannes Berg
2013-11-06 16:54     ` Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 02/19] cfg80211: force WIPHY_FLAG_CUSTOM_REGULATORY on wiphy_apply_custom_regulatory() Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 03/19] cfg80211: check regulatory request alpha2 early Luis R. Rodriguez
2013-11-06 10:17   ` Johannes Berg
2013-11-06 16:39     ` Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 04/19] cfg80211: remove second argument from reg_process_hint() Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 05/19] cfg80211: processing core regulatory hints on its own Luis R. Rodriguez
2013-11-06 10:24   ` Johannes Berg
2013-11-06 10:26     ` Johannes Berg
2013-11-06 16:35     ` Luis R. Rodriguez
2013-11-07  0:47       ` Julian Calaby
2013-11-11 14:41         ` Johannes Berg
2013-11-05 17:18 ` [PATCH 06/19] cfg80211: process user regulatory requests " Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 07/19] cfg80211: process driver " Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 08/19] cfg80211: process country IE regulatory requests on their own Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 09/19] cfg80211: process non country IE conflicting first Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 10/19] cfg80211: add helper for kfree'ing last_request Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 11/19] cfg80211: add helper for kfree'ing and assigning last_request Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 12/19] cfg80211: add helper for calling CRDA Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 13/19] cfg80211: allow only the core to request to update the world regdom Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 14/19] cfg80211: move core reg_notfier() check to source Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 15/19] cfg80211: pass the last_request to __set_regdom() Luis R. Rodriguez
2013-11-05 17:18 ` Luis R. Rodriguez [this message]
2013-11-05 17:18 ` [PATCH 17/19] cfg80211: set user regulatory updates on its own Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 18/19] cfg80211: set driver " Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 19/19] cfg80211: rename __set_regdom() to reg_set_rd_country_ie() Luis R. Rodriguez
2013-11-11 14:50 ` [PATCH 00/19] cfg80211: regulatory updates Johannes Berg

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=1383671897-7746-17-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=johannes@sipsolutions.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).