Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111933
b: refs/heads/master
c: 942b25c
h: refs/heads/master
i:
  111931: d9e73c8
v: v3
  • Loading branch information
Johannes Berg authored and John W. Linville committed Sep 24, 2008
1 parent 7e5bb9b commit 41c9ae3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 54 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a3d2eaf0dcad6dfdf44f3093aef688dfca714b6c
refs/heads/master: 942b25cf9028e7c2f6446ee7c6618bd70dafec5f
73 changes: 20 additions & 53 deletions trunk/net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,32 +174,27 @@ static bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
return true;
return false;
}

/* The old crap never deals with a world regulatory domain, it only
* deals with the static regulatory domain passed and if possible
* an updated "US" or "JP" regulatory domain. We do however store the
* old static regulatory domain in cfg80211_world_regdom for convenience
* of use here */
static void reset_regdomains_static(void)
#else
static inline bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
{
if (!is_old_static_regdom(cfg80211_regdomain))
kfree(cfg80211_regdomain);
/* This is setting the regdom to the old static regdom */
cfg80211_regdomain =
(struct ieee80211_regdomain *) cfg80211_world_regdom;
return false;
}
#else
#endif

static void reset_regdomains(void)
{
if (cfg80211_world_regdom && cfg80211_world_regdom != &world_regdom) {
if (cfg80211_world_regdom == cfg80211_regdomain) {
kfree(cfg80211_regdomain);
} else {
kfree(cfg80211_world_regdom);
kfree(cfg80211_regdomain);
}
} else if (cfg80211_regdomain && cfg80211_regdomain != &world_regdom)
kfree(cfg80211_regdomain);
/* avoid freeing static information or freeing something twice */
if (cfg80211_regdomain == cfg80211_world_regdom)
cfg80211_regdomain = NULL;
if (cfg80211_world_regdom == &world_regdom)
cfg80211_world_regdom = NULL;
if (cfg80211_regdomain == &world_regdom)
cfg80211_regdomain = NULL;
if (is_old_static_regdom(cfg80211_regdomain))
cfg80211_regdomain = NULL;

kfree(cfg80211_regdomain);
kfree(cfg80211_world_regdom);

cfg80211_world_regdom = &world_regdom;
cfg80211_regdomain = NULL;
Expand All @@ -216,7 +211,6 @@ static void update_world_regdomain(const struct ieee80211_regdomain *rd)
cfg80211_world_regdom = rd;
cfg80211_regdomain = rd;
}
#endif

bool is_world_regdom(const char *alpha2)
{
Expand Down Expand Up @@ -297,12 +291,8 @@ static int call_crda(const char *alpha2)
printk(KERN_INFO "cfg80211: Calling CRDA for country: %c%c\n",
alpha2[0], alpha2[1]);
else
#ifdef CONFIG_WIRELESS_OLD_REGULATORY
return -EINVAL;
#else
printk(KERN_INFO "cfg80211: Calling CRDA to update world "
"regulatory domain\n");
#endif

country_env[8] = alpha2[0];
country_env[9] = alpha2[1];
Expand Down Expand Up @@ -728,20 +718,12 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)

/* Some basic sanity checks first */

#ifdef CONFIG_WIRELESS_OLD_REGULATORY
/* We ignore the world regdom with the old static regdomains setup
* as there is no point to it with static regulatory definitions :(
* Don't worry this shit will be removed soon... */
if (is_world_regdom(rd->alpha2))
return -EINVAL;
#else
if (is_world_regdom(rd->alpha2)) {
if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request)))
return -EINVAL;
update_world_regdomain(rd);
return 0;
}
#endif

if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) &&
!is_unknown_alpha2(rd->alpha2))
Expand All @@ -750,15 +732,10 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
if (list_empty(&regulatory_requests))
return -EINVAL;

#ifdef CONFIG_WIRELESS_OLD_REGULATORY
/* Static "US" and "JP" will be overridden, but just once */
/* allow overriding the static definitions if CRDA is present */
if (!is_old_static_regdom(cfg80211_regdomain) &&
!regdom_changed(rd->alpha2))
return -EINVAL;
#else
if (!regdom_changed(rd->alpha2))
!regdom_changed(rd->alpha2))
return -EINVAL;
#endif

/* Now lets set the regulatory domain, update all driver channels
* and finally inform them of what we have done, in case they want
Expand All @@ -768,11 +745,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request)))
return -EINVAL;

#ifdef CONFIG_WIRELESS_OLD_REGULATORY
reset_regdomains_static();
#else
reset_regdomains();
#endif

/* Country IE parsing coming soon */
switch (request->initiator) {
Expand Down Expand Up @@ -858,10 +831,8 @@ int regulatory_init(void)

#ifdef CONFIG_WIRELESS_OLD_REGULATORY
cfg80211_regdomain = static_regdom(ieee80211_regdom);
/* Used during reset_regdomains_static() */
cfg80211_world_regdom = cfg80211_regdomain;

printk(KERN_INFO "cfg80211: Using old static regulatory domain:\n");
printk(KERN_INFO "cfg80211: Using static regulatory domain info\n");
print_regdomain_info(cfg80211_regdomain);
/* The old code still requests for a new regdomain and if
* you have CRDA you get it updated, otherwise you get
Expand Down Expand Up @@ -889,11 +860,7 @@ void regulatory_exit(void)

mutex_lock(&cfg80211_drv_mutex);

#ifdef CONFIG_WIRELESS_OLD_REGULATORY
reset_regdomains_static();
#else
reset_regdomains();
#endif

list_for_each_entry_safe(req, req_tmp, &regulatory_requests, list) {
list_del(&req->list);
Expand Down

0 comments on commit 41c9ae3

Please sign in to comment.