* [PATCH 0/4] cfg80211: few minor enhancements based on reg requests
@ 2009-02-21 5:24 Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 1/4] cfg80211: make __regulatory_hint() static Luis R. Rodriguez
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2009-02-21 5:24 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez
These are a few cleanups based on the new strategy to use regutory requests
structures from the workqueue. We still pass the wiphy directly to
__regulatory_hint() and ignore_request() as its used often.
Luis R. Rodriguez (4):
cfg80211: make __regulatory_hint() static
cfg80211: pass the regulatory_request struct in __regulatory_hint()
cfg80211: do not kzalloc() again for a new request on
__regulatory_hint
cfg80211: pass the regulatory_request to ignore_request
net/wireless/reg.c | 106 ++++++++++++++++++++++-----------------------------
net/wireless/reg.h | 23 -----------
2 files changed, 46 insertions(+), 83 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] cfg80211: make __regulatory_hint() static
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
@ 2009-02-21 5:24 ` Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 2/4] cfg80211: pass the regulatory_request struct in __regulatory_hint() Luis R. Rodriguez
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2009-02-21 5:24 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 23 +++++++++++++++++++++--
net/wireless/reg.h | 23 -----------------------
2 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index e5e432d..0253d01 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1324,8 +1324,27 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
return -EINVAL;
}
-/* Caller must hold &cfg80211_mutex */
-int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
+/**
+ * __regulatory_hint - hint to the wireless core a regulatory domain
+ * @wiphy: if the hint comes from country information from an AP, this
+ * is required to be set to the wiphy that received the information
+ * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain
+ * should be in.
+ * @country_ie_checksum: checksum of processed country IE, set this to 0
+ * if the hint did not come from a country IE
+ * @country_ie_env: the environment the IE told us we are in, %ENVIRON_*
+ *
+ * The Wireless subsystem can use this function to hint to the wireless core
+ * what it believes should be the current regulatory domain by giving it an
+ * ISO/IEC 3166 alpha2 country code it knows its regulatory domain should be
+ * in.
+ *
+ * Returns zero if all went fine, %-EALREADY if a regulatory domain had
+ * already been set or other standard error codes.
+ *
+ * Caller must hold &cfg80211_mutex
+ */
+static int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
const char *alpha2,
u32 country_ie_checksum,
enum environment_cap env)
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index 65bfd05..e37829a 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -16,29 +16,6 @@ void regulatory_exit(void);
int set_regdom(const struct ieee80211_regdomain *rd);
/**
- * __regulatory_hint - hint to the wireless core a regulatory domain
- * @wiphy: if the hint comes from country information from an AP, this
- * is required to be set to the wiphy that received the information
- * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain
- * should be in.
- * @country_ie_checksum: checksum of processed country IE, set this to 0
- * if the hint did not come from a country IE
- * @country_ie_env: the environment the IE told us we are in, %ENVIRON_*
- *
- * The Wireless subsystem can use this function to hint to the wireless core
- * what it believes should be the current regulatory domain by giving it an
- * ISO/IEC 3166 alpha2 country code it knows its regulatory domain should be
- * in.
- *
- * Returns zero if all went fine, %-EALREADY if a regulatory domain had
- * already been set or other standard error codes.
- *
- */
-extern int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
- const char *alpha2, u32 country_ie_checksum,
- enum environment_cap country_ie_env);
-
-/**
* regulatory_hint_found_beacon - hints a beacon was found on a channel
* @wiphy: the wireless device where the beacon was found on
* @beacon_chan: the channel on which the beacon was found on
--
1.6.0.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] cfg80211: pass the regulatory_request struct in __regulatory_hint()
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 1/4] cfg80211: make __regulatory_hint() static Luis R. Rodriguez
@ 2009-02-21 5:24 ` Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 3/4] cfg80211: do not kzalloc() again for a new request on __regulatory_hint Luis R. Rodriguez
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2009-02-21 5:24 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez
We were passing value by value, lets just pass the struct.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 45 ++++++++++++++++++---------------------------
1 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 0253d01..6e17337 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1328,26 +1328,18 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
* __regulatory_hint - hint to the wireless core a regulatory domain
* @wiphy: if the hint comes from country information from an AP, this
* is required to be set to the wiphy that received the information
- * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain
- * should be in.
- * @country_ie_checksum: checksum of processed country IE, set this to 0
- * if the hint did not come from a country IE
- * @country_ie_env: the environment the IE told us we are in, %ENVIRON_*
+ * @pending_request: the regulatory request currently being processed
*
* The Wireless subsystem can use this function to hint to the wireless core
- * what it believes should be the current regulatory domain by giving it an
- * ISO/IEC 3166 alpha2 country code it knows its regulatory domain should be
- * in.
+ * what it believes should be the current regulatory domain.
*
* Returns zero if all went fine, %-EALREADY if a regulatory domain had
* already been set or other standard error codes.
*
* Caller must hold &cfg80211_mutex
*/
-static int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
- const char *alpha2,
- u32 country_ie_checksum,
- enum environment_cap env)
+static int __regulatory_hint(struct wiphy *wiphy,
+ struct regulatory_request *pending_request)
{
struct regulatory_request *request;
bool intersect = false;
@@ -1355,10 +1347,12 @@ static int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
assert_cfg80211_lock();
- r = ignore_request(wiphy, set_by, alpha2);
+ r = ignore_request(wiphy,
+ pending_request->initiator,
+ pending_request->alpha2);
if (r == REG_INTERSECT) {
- if (set_by == REGDOM_SET_BY_DRIVER) {
+ if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r)
return r;
@@ -1370,7 +1364,8 @@ static int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
* driver has already been set just copy it to the
* wiphy
*/
- if (r == -EALREADY && set_by == REGDOM_SET_BY_DRIVER) {
+ if (r == -EALREADY &&
+ pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
if (r)
return r;
@@ -1386,13 +1381,13 @@ new_request:
if (!request)
return -ENOMEM;
- request->alpha2[0] = alpha2[0];
- request->alpha2[1] = alpha2[1];
- request->initiator = set_by;
- request->wiphy_idx = get_wiphy_idx(wiphy);
+ request->alpha2[0] = pending_request->alpha2[0];
+ request->alpha2[1] = pending_request->alpha2[1];
+ request->initiator = pending_request->initiator;
+ request->wiphy_idx = pending_request->wiphy_idx;
request->intersect = intersect;
- request->country_ie_checksum = country_ie_checksum;
- request->country_ie_env = env;
+ request->country_ie_checksum = pending_request->country_ie_checksum;
+ request->country_ie_env = pending_request->country_ie_env;
kfree(last_request);
last_request = request;
@@ -1411,7 +1406,7 @@ new_request:
*
* to intersect with the static rd
*/
- return call_crda(alpha2);
+ return call_crda(request->alpha2);
}
/* This currently only processes user and driver regulatory hints */
@@ -1433,11 +1428,7 @@ static int reg_process_hint(struct regulatory_request *reg_request)
goto out;
}
- r = __regulatory_hint(wiphy,
- reg_request->initiator,
- reg_request->alpha2,
- reg_request->country_ie_checksum,
- reg_request->country_ie_env);
+ r = __regulatory_hint(wiphy, reg_request);
/* This is required so that the orig_* parameters are saved */
if (r == -EALREADY && wiphy && wiphy->strict_regulatory)
wiphy_update_regulatory(wiphy, reg_request->initiator);
--
1.6.0.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] cfg80211: do not kzalloc() again for a new request on __regulatory_hint
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 1/4] cfg80211: make __regulatory_hint() static Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 2/4] cfg80211: pass the regulatory_request struct in __regulatory_hint() Luis R. Rodriguez
@ 2009-02-21 5:24 ` Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 4/4] cfg80211: pass the regulatory_request to ignore_request Luis R. Rodriguez
2009-02-24 2:00 ` [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2009-02-21 5:24 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez
Since we already have a regulatory request from the workqueue use that
and avoid a new kzalloc()
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 54 +++++++++++++++------------------------------------
1 files changed, 16 insertions(+), 38 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 6e17337..6152a7a 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1341,7 +1341,6 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
static int __regulatory_hint(struct wiphy *wiphy,
struct regulatory_request *pending_request)
{
- struct regulatory_request *request;
bool intersect = false;
int r = 0;
@@ -1354,8 +1353,10 @@ static int __regulatory_hint(struct wiphy *wiphy,
if (r == REG_INTERSECT) {
if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
- if (r)
+ if (r) {
+ kfree(pending_request);
return r;
+ }
}
intersect = true;
} else if (r) {
@@ -1367,30 +1368,24 @@ static int __regulatory_hint(struct wiphy *wiphy,
if (r == -EALREADY &&
pending_request->initiator == REGDOM_SET_BY_DRIVER) {
r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain);
- if (r)
+ if (r) {
+ kfree(pending_request);
return r;
+ }
r = -EALREADY;
goto new_request;
}
+ kfree(pending_request);
return r;
}
new_request:
- request = kzalloc(sizeof(struct regulatory_request),
- GFP_KERNEL);
- if (!request)
- return -ENOMEM;
+ kfree(last_request);
- request->alpha2[0] = pending_request->alpha2[0];
- request->alpha2[1] = pending_request->alpha2[1];
- request->initiator = pending_request->initiator;
- request->wiphy_idx = pending_request->wiphy_idx;
- request->intersect = intersect;
- request->country_ie_checksum = pending_request->country_ie_checksum;
- request->country_ie_env = pending_request->country_ie_env;
+ last_request = pending_request;
+ last_request->intersect = intersect;
- kfree(last_request);
- last_request = request;
+ pending_request = NULL;
/* When r == REG_INTERSECT we do need to call CRDA */
if (r < 0)
@@ -1406,11 +1401,11 @@ new_request:
*
* to intersect with the static rd
*/
- return call_crda(request->alpha2);
+ return call_crda(last_request->alpha2);
}
/* This currently only processes user and driver regulatory hints */
-static int reg_process_hint(struct regulatory_request *reg_request)
+static void reg_process_hint(struct regulatory_request *reg_request)
{
int r = 0;
struct wiphy *wiphy = NULL;
@@ -1424,7 +1419,7 @@ static int reg_process_hint(struct regulatory_request *reg_request)
if (reg_request->initiator == REGDOM_SET_BY_DRIVER &&
!wiphy) {
- r = -ENODEV;
+ kfree(reg_request);
goto out;
}
@@ -1434,18 +1429,12 @@ static int reg_process_hint(struct regulatory_request *reg_request)
wiphy_update_regulatory(wiphy, reg_request->initiator);
out:
mutex_unlock(&cfg80211_mutex);
-
- if (r == -EALREADY)
- r = 0;
-
- return r;
}
/* Processes regulatory hints, this is all the REGDOM_SET_BY_* */
static void reg_process_pending_hints(void)
{
struct regulatory_request *reg_request;
- int r;
spin_lock(®_requests_lock);
while (!list_empty(®_requests_list)) {
@@ -1453,20 +1442,9 @@ static void reg_process_pending_hints(void)
struct regulatory_request,
list);
list_del_init(®_request->list);
- spin_unlock(®_requests_lock);
- r = reg_process_hint(reg_request);
-#ifdef CONFIG_CFG80211_REG_DEBUG
- if (r && (reg_request->initiator == REGDOM_SET_BY_DRIVER ||
- reg_request->initiator == REGDOM_SET_BY_COUNTRY_IE))
- printk(KERN_ERR "cfg80211: wiphy_idx %d sent a "
- "regulatory hint for %c%c but now has "
- "gone fishing, ignoring request\n",
- reg_request->wiphy_idx,
- reg_request->alpha2[0],
- reg_request->alpha2[1]);
-#endif
- kfree(reg_request);
+ spin_unlock(®_requests_lock);
+ reg_process_hint(reg_request);
spin_lock(®_requests_lock);
}
spin_unlock(®_requests_lock);
--
1.6.0.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] cfg80211: pass the regulatory_request to ignore_request
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
` (2 preceding siblings ...)
2009-02-21 5:24 ` [PATCH 3/4] cfg80211: do not kzalloc() again for a new request on __regulatory_hint Luis R. Rodriguez
@ 2009-02-21 5:24 ` Luis R. Rodriguez
2009-02-24 2:00 ` [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2009-02-21 5:24 UTC (permalink / raw)
To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/reg.c | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 6152a7a..ce66bfd 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1231,8 +1231,8 @@ static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd,
/* This has the logic which determines when a new request
* should be ignored. */
-static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
- const char *alpha2)
+static int ignore_request(struct wiphy *wiphy,
+ struct regulatory_request *pending_request)
{
struct wiphy *last_wiphy = NULL;
@@ -1242,7 +1242,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
if (!last_request)
return 0;
- switch (set_by) {
+ switch (pending_request->initiator) {
case REGDOM_SET_BY_INIT:
return -EINVAL;
case REGDOM_SET_BY_CORE:
@@ -1251,7 +1251,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx);
- if (unlikely(!is_an_alpha2(alpha2)))
+ if (unlikely(!is_an_alpha2(pending_request->alpha2)))
return -EINVAL;
if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) {
if (last_wiphy != wiphy) {
@@ -1261,7 +1261,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
* intersect them, but that seems unlikely
* to be correct. Reject second one for now.
*/
- if (regdom_changes(alpha2))
+ if (regdom_changes(pending_request->alpha2))
return -EOPNOTSUPP;
return -EALREADY;
}
@@ -1269,7 +1269,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
* Two consecutive Country IE hints on the same wiphy.
* This should be picked up early by the driver/stack
*/
- if (WARN_ON(regdom_changes(alpha2)))
+ if (WARN_ON(regdom_changes(pending_request->alpha2)))
return 0;
return -EALREADY;
}
@@ -1278,7 +1278,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
if (last_request->initiator == REGDOM_SET_BY_CORE) {
if (is_old_static_regdom(cfg80211_regdomain))
return 0;
- if (regdom_changes(alpha2))
+ if (regdom_changes(pending_request->alpha2))
return 0;
return -EALREADY;
}
@@ -1289,7 +1289,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
* loaded card also agrees on the regulatory domain.
*/
if (last_request->initiator == REGDOM_SET_BY_DRIVER &&
- !regdom_changes(alpha2))
+ !regdom_changes(pending_request->alpha2))
return -EALREADY;
return REG_INTERSECT;
@@ -1315,7 +1315,7 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
}
if (!is_old_static_regdom(cfg80211_regdomain) &&
- !regdom_changes(alpha2))
+ !regdom_changes(pending_request->alpha2))
return -EALREADY;
return 0;
@@ -1346,9 +1346,7 @@ static int __regulatory_hint(struct wiphy *wiphy,
assert_cfg80211_lock();
- r = ignore_request(wiphy,
- pending_request->initiator,
- pending_request->alpha2);
+ r = ignore_request(wiphy, pending_request);
if (r == REG_INTERSECT) {
if (pending_request->initiator == REGDOM_SET_BY_DRIVER) {
--
1.6.0.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] cfg80211: few minor enhancements based on reg requests
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
` (3 preceding siblings ...)
2009-02-21 5:24 ` [PATCH 4/4] cfg80211: pass the regulatory_request to ignore_request Luis R. Rodriguez
@ 2009-02-24 2:00 ` Johannes Berg
4 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2009-02-24 2:00 UTC (permalink / raw)
To: Luis R. Rodriguez; +Cc: linville, linux-wireless
[-- Attachment #1: Type: text/plain, Size: 405 bytes --]
On Sat, 2009-02-21 at 00:24 -0500, Luis R. Rodriguez wrote:
> These are a few cleanups based on the new strategy to use regutory requests
> structures from the workqueue. We still pass the wiphy directly to
> __regulatory_hint() and ignore_request() as its used often.
Looks good, and the "[PATCH v2 0/5] cfg80211: enhance world roaming"
looks good too (well I had two comments or so)
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-24 2:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21 5:24 [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 1/4] cfg80211: make __regulatory_hint() static Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 2/4] cfg80211: pass the regulatory_request struct in __regulatory_hint() Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 3/4] cfg80211: do not kzalloc() again for a new request on __regulatory_hint Luis R. Rodriguez
2009-02-21 5:24 ` [PATCH 4/4] cfg80211: pass the regulatory_request to ignore_request Luis R. Rodriguez
2009-02-24 2:00 ` [PATCH 0/4] cfg80211: few minor enhancements based on reg requests Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox