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 07/19] cfg80211: process driver regulatory requests on its own
Date: Tue, 5 Nov 2013 09:18:05 -0800 [thread overview]
Message-ID: <1383671897-7746-8-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1383671897-7746-1-git-send-email-mcgrof@do-not-panic.com>
This makes the code easier to read and follow.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
net/wireless/reg.c | 103 ++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 86 insertions(+), 17 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ed893ab..bf2ef37 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1338,6 +1338,7 @@ get_reg_request_treatment(struct wiphy *wiphy,
switch (pending_request->initiator) {
case NL80211_REGDOM_SET_BY_CORE:
case NL80211_REGDOM_SET_BY_USER:
+ case NL80211_REGDOM_SET_BY_DRIVER:
return REG_REQ_IGNORE;
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
if (reg_request_cell_base(lr)) {
@@ -1372,23 +1373,6 @@ get_reg_request_treatment(struct wiphy *wiphy,
return REG_REQ_ALREADY_SET;
}
return REG_REQ_OK;
- case NL80211_REGDOM_SET_BY_DRIVER:
- if (lr->initiator == NL80211_REGDOM_SET_BY_CORE) {
- if (regdom_changes(pending_request->alpha2))
- return REG_REQ_OK;
- return REG_REQ_ALREADY_SET;
- }
-
- /*
- * This would happen if you unplug and plug your card
- * back in or if you add a new device for which the previously
- * loaded card also agrees on the regulatory domain.
- */
- if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
- !regdom_changes(pending_request->alpha2))
- return REG_REQ_ALREADY_SET;
-
- return REG_REQ_INTERSECT;
}
return REG_REQ_IGNORE;
@@ -1514,6 +1498,89 @@ reg_process_hint_user(struct regulatory_request *user_request)
return REG_REQ_OK;
}
+static enum reg_request_treatment
+__reg_process_hint_driver(struct regulatory_request *driver_request)
+{
+ struct regulatory_request *lr = get_last_request();
+
+ if (lr->initiator == NL80211_REGDOM_SET_BY_CORE) {
+ if (regdom_changes(driver_request->alpha2))
+ return REG_REQ_OK;
+ return REG_REQ_ALREADY_SET;
+ }
+
+ /*
+ * This would happen if you unplug and plug your card
+ * back in or if you add a new device for which the previously
+ * loaded card also agrees on the regulatory domain.
+ */
+ if (lr->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
+ !regdom_changes(driver_request->alpha2))
+ return REG_REQ_ALREADY_SET;
+
+ return REG_REQ_INTERSECT;
+}
+
+/**
+ * reg_process_hint_driver - process driver regulatory requests
+ * @driver_request: a pending driver regulatory request
+ *
+ * The wireless subsystem can use this function to process
+ * a regulatory request issued by an 802.11 driver.
+ *
+ * Returns one of the different reg request treatment values.
+ */
+static enum reg_request_treatment
+reg_process_hint_driver(struct wiphy *wiphy,
+ struct regulatory_request *driver_request)
+{
+ const struct ieee80211_regdomain *regd;
+ enum reg_request_treatment treatment;
+ struct regulatory_request *lr;
+
+ treatment = __reg_process_hint_driver(driver_request);
+
+ switch (treatment) {
+ case REG_REQ_OK:
+ break;
+ case REG_REQ_IGNORE:
+ kfree(driver_request);
+ return treatment;
+ case REG_REQ_INTERSECT:
+ /* fall through */
+ case REG_REQ_ALREADY_SET:
+ regd = reg_copy_regd(get_cfg80211_regdom());
+ if (IS_ERR(regd)) {
+ kfree(driver_request);
+ return REG_REQ_IGNORE;
+ }
+ rcu_assign_pointer(wiphy->regd, regd);
+ }
+
+ lr = get_last_request();
+ if (lr != &core_request_world && lr)
+ kfree_rcu(lr, rcu_head);
+
+ driver_request->intersect = treatment == REG_REQ_INTERSECT;
+ driver_request->processed = false;
+ rcu_assign_pointer(last_request, driver_request);
+
+ /*
+ * Since CRDA will not be called in this case as we already
+ * have applied the requested regulatory domain before we just
+ * inform userspace we have processed the request
+ */
+ if (treatment == REG_REQ_ALREADY_SET) {
+ nl80211_send_reg_change_event(driver_request);
+ reg_set_request_processed();
+ return treatment;
+ }
+
+ if (call_crda(driver_request->alpha2))
+ return REG_REQ_IGNORE;
+ return REG_REQ_OK;
+}
+
/**
* __regulatory_hint - hint to the wireless core a regulatory domain
* @wiphy: if the hint comes from country information from an AP, this
@@ -1637,6 +1704,8 @@ static void reg_process_hint(struct regulatory_request *reg_request)
schedule_delayed_work(®_timeout, msecs_to_jiffies(3142));
return;
case NL80211_REGDOM_SET_BY_DRIVER:
+ treatment = reg_process_hint_driver(wiphy, reg_request);
+ break;
case NL80211_REGDOM_SET_BY_COUNTRY_IE:
treatment = __regulatory_hint(wiphy, reg_request);
break;
--
1.8.4.rc3
next prev 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 ` Luis R. Rodriguez [this message]
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 ` [PATCH 16/19] cfg80211: set core regulatory updates on its own Luis R. Rodriguez
2013-11-05 17:18 ` [PATCH 17/19] cfg80211: set user " 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-8-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.