aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/reg.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-10-24 14:32:21 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-10-31 19:02:30 -0400
commitbe3d48106c1e5d075784e5e67928a6b5ffc0f3b6 (patch)
tree40f9a5d6beefa0f6812f06368a94f0b17658f247 /net/wireless/reg.c
parentd2372b315289aec9f565a855023c40654a5bff68 (diff)
wireless: remove struct regdom hinting
The code needs to be split out and cleaned up, so as a first step remove the capability, to add it back in a subsequent patch as a separate function. Also remove the publically facing return value of the function and the wiphy argument. A number of internal functions go from being generic helpers to just being used for alpha2 setting. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r--net/wireless/reg.c63
1 files changed, 16 insertions, 47 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 038f8f133c54..dc10071deaaa 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -42,7 +42,10 @@
42#include "core.h" 42#include "core.h"
43#include "reg.h" 43#include "reg.h"
44 44
45/* wiphy is set if this request's initiator is REGDOM_SET_BY_DRIVER */ 45/*
46 * wiphy is set if this request's initiator is
47 * REGDOM_SET_BY_COUNTRY_IE or _DRIVER
48 */
46struct regulatory_request { 49struct regulatory_request {
47 struct wiphy *wiphy; 50 struct wiphy *wiphy;
48 enum reg_set_by initiator; 51 enum reg_set_by initiator;
@@ -298,7 +301,7 @@ static int call_crda(const char *alpha2)
298/* This has the logic which determines when a new request 301/* This has the logic which determines when a new request
299 * should be ignored. */ 302 * should be ignored. */
300static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by, 303static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
301 char *alpha2, struct ieee80211_regdomain *rd) 304 const char *alpha2)
302{ 305{
303 /* All initial requests are respected */ 306 /* All initial requests are respected */
304 if (!last_request) 307 if (!last_request)
@@ -343,22 +346,8 @@ static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
343 return 1; 346 return 1;
344 case REGDOM_SET_BY_DRIVER: 347 case REGDOM_SET_BY_DRIVER:
345 BUG_ON(!wiphy); 348 BUG_ON(!wiphy);
346 if (last_request->initiator == REGDOM_SET_BY_DRIVER) { 349 if (last_request->initiator == REGDOM_SET_BY_DRIVER)
347 /* Two separate drivers hinting different things,
348 * this is possible if you have two devices present
349 * on a system with different EEPROM regulatory
350 * readings. XXX: Do intersection, we support only
351 * the first regulatory hint for now */
352 if (last_request->wiphy != wiphy)
353 return -EALREADY;
354 if (rd)
355 return -EALREADY;
356 /* Driver should not be trying to hint different
357 * regulatory domains! */
358 BUG_ON(!alpha2_equal(alpha2,
359 cfg80211_regdomain->alpha2));
360 return -EALREADY; 350 return -EALREADY;
361 }
362 if (last_request->initiator == REGDOM_SET_BY_CORE) 351 if (last_request->initiator == REGDOM_SET_BY_CORE)
363 return 0; 352 return 0;
364 /* XXX: Handle intersection, and add the 353 /* XXX: Handle intersection, and add the
@@ -557,40 +546,32 @@ void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby)
557 546
558/* Caller must hold &cfg80211_drv_mutex */ 547/* Caller must hold &cfg80211_drv_mutex */
559int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by, 548int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
560 const char *alpha2, struct ieee80211_regdomain *rd) 549 const char *alpha2)
561{ 550{
562 struct regulatory_request *request; 551 struct regulatory_request *request;
563 char *rd_alpha2;
564 int r = 0; 552 int r = 0;
565 553
566 r = ignore_request(wiphy, set_by, (char *) alpha2, rd); 554 r = ignore_request(wiphy, set_by, alpha2);
567 if (r) 555 if (r)
568 return r; 556 return r;
569 557
570 if (rd)
571 rd_alpha2 = rd->alpha2;
572 else
573 rd_alpha2 = (char *) alpha2;
574
575 switch (set_by) { 558 switch (set_by) {
576 case REGDOM_SET_BY_CORE: 559 case REGDOM_SET_BY_CORE:
577 case REGDOM_SET_BY_COUNTRY_IE: 560 case REGDOM_SET_BY_COUNTRY_IE:
578 case REGDOM_SET_BY_DRIVER: 561 case REGDOM_SET_BY_DRIVER:
579 case REGDOM_SET_BY_USER: 562 case REGDOM_SET_BY_USER:
580 request = kzalloc(sizeof(struct regulatory_request), 563 request = kzalloc(sizeof(struct regulatory_request),
581 GFP_KERNEL); 564 GFP_KERNEL);
582 if (!request) 565 if (!request)
583 return -ENOMEM; 566 return -ENOMEM;
584 567
585 request->alpha2[0] = rd_alpha2[0]; 568 request->alpha2[0] = alpha2[0];
586 request->alpha2[1] = rd_alpha2[1]; 569 request->alpha2[1] = alpha2[1];
587 request->initiator = set_by; 570 request->initiator = set_by;
588 request->wiphy = wiphy; 571 request->wiphy = wiphy;
589 572
590 kfree(last_request); 573 kfree(last_request);
591 last_request = request; 574 last_request = request;
592 if (rd)
593 break;
594 r = call_crda(alpha2); 575 r = call_crda(alpha2);
595#ifndef CONFIG_WIRELESS_OLD_REGULATORY 576#ifndef CONFIG_WIRELESS_OLD_REGULATORY
596 if (r) 577 if (r)
@@ -605,25 +586,13 @@ int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
605 return r; 586 return r;
606} 587}
607 588
608int regulatory_hint(struct wiphy *wiphy, const char *alpha2, 589void regulatory_hint(struct wiphy *wiphy, const char *alpha2)
609 struct ieee80211_regdomain *rd)
610{ 590{
611 int r; 591 BUG_ON(!alpha2);
612 BUG_ON(!rd && !alpha2);
613 592
614 mutex_lock(&cfg80211_drv_mutex); 593 mutex_lock(&cfg80211_drv_mutex);
615 594 __regulatory_hint(wiphy, REGDOM_SET_BY_DRIVER, alpha2);
616 r = __regulatory_hint(wiphy, REGDOM_SET_BY_DRIVER, alpha2, rd);
617 if (r || !rd)
618 goto unlock_and_exit;
619
620 /* If the driver passed a regulatory domain we skipped asking
621 * userspace for one so we can now go ahead and set it */
622 r = set_regdom(rd);
623
624unlock_and_exit:
625 mutex_unlock(&cfg80211_drv_mutex); 595 mutex_unlock(&cfg80211_drv_mutex);
626 return r;
627} 596}
628EXPORT_SYMBOL(regulatory_hint); 597EXPORT_SYMBOL(regulatory_hint);
629 598
@@ -792,11 +761,11 @@ int regulatory_init(void)
792 * that is not a valid ISO / IEC 3166 alpha2 */ 761 * that is not a valid ISO / IEC 3166 alpha2 */
793 if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U') 762 if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U')
794 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, 763 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE,
795 ieee80211_regdom, NULL); 764 ieee80211_regdom);
796#else 765#else
797 cfg80211_regdomain = cfg80211_world_regdom; 766 cfg80211_regdomain = cfg80211_world_regdom;
798 767
799 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00", NULL); 768 err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00");
800 if (err) 769 if (err)
801 printk(KERN_ERR "cfg80211: calling CRDA failed - " 770 printk(KERN_ERR "cfg80211: calling CRDA failed - "
802 "unable to update world regulatory domain, " 771 "unable to update world regulatory domain, "