aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-09-15 05:26:47 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-24 16:17:59 -0400
commit942b25cf9028e7c2f6446ee7c6618bd70dafec5f (patch)
treebbda96c17ac19cad03240829ad943ea6ebe740f3 /net
parenta3d2eaf0dcad6dfdf44f3093aef688dfca714b6c (diff)
cfg80211: clean up static regdomain mess
The statically defined regdomains are used in a very convoluted way, use them instead to prime the information we have and then continue operating normally. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/wireless/reg.c73
1 files changed, 20 insertions, 53 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7aba46efc7dd..626dbb688499 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -174,32 +174,27 @@ static bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
174 return true; 174 return true;
175 return false; 175 return false;
176} 176}
177 177#else
178/* The old crap never deals with a world regulatory domain, it only 178static inline bool is_old_static_regdom(const struct ieee80211_regdomain *rd)
179 * deals with the static regulatory domain passed and if possible
180 * an updated "US" or "JP" regulatory domain. We do however store the
181 * old static regulatory domain in cfg80211_world_regdom for convenience
182 * of use here */
183static void reset_regdomains_static(void)
184{ 179{
185 if (!is_old_static_regdom(cfg80211_regdomain)) 180 return false;
186 kfree(cfg80211_regdomain);
187 /* This is setting the regdom to the old static regdom */
188 cfg80211_regdomain =
189 (struct ieee80211_regdomain *) cfg80211_world_regdom;
190} 181}
191#else 182#endif
183
192static void reset_regdomains(void) 184static void reset_regdomains(void)
193{ 185{
194 if (cfg80211_world_regdom && cfg80211_world_regdom != &world_regdom) { 186 /* avoid freeing static information or freeing something twice */
195 if (cfg80211_world_regdom == cfg80211_regdomain) { 187 if (cfg80211_regdomain == cfg80211_world_regdom)
196 kfree(cfg80211_regdomain); 188 cfg80211_regdomain = NULL;
197 } else { 189 if (cfg80211_world_regdom == &world_regdom)
198 kfree(cfg80211_world_regdom); 190 cfg80211_world_regdom = NULL;
199 kfree(cfg80211_regdomain); 191 if (cfg80211_regdomain == &world_regdom)
200 } 192 cfg80211_regdomain = NULL;
201 } else if (cfg80211_regdomain && cfg80211_regdomain != &world_regdom) 193 if (is_old_static_regdom(cfg80211_regdomain))
202 kfree(cfg80211_regdomain); 194 cfg80211_regdomain = NULL;
195
196 kfree(cfg80211_regdomain);
197 kfree(cfg80211_world_regdom);
203 198
204 cfg80211_world_regdom = &world_regdom; 199 cfg80211_world_regdom = &world_regdom;
205 cfg80211_regdomain = NULL; 200 cfg80211_regdomain = NULL;
@@ -216,7 +211,6 @@ static void update_world_regdomain(const struct ieee80211_regdomain *rd)
216 cfg80211_world_regdom = rd; 211 cfg80211_world_regdom = rd;
217 cfg80211_regdomain = rd; 212 cfg80211_regdomain = rd;
218} 213}
219#endif
220 214
221bool is_world_regdom(const char *alpha2) 215bool is_world_regdom(const char *alpha2)
222{ 216{
@@ -297,12 +291,8 @@ static int call_crda(const char *alpha2)
297 printk(KERN_INFO "cfg80211: Calling CRDA for country: %c%c\n", 291 printk(KERN_INFO "cfg80211: Calling CRDA for country: %c%c\n",
298 alpha2[0], alpha2[1]); 292 alpha2[0], alpha2[1]);
299 else 293 else
300#ifdef CONFIG_WIRELESS_OLD_REGULATORY
301 return -EINVAL;
302#else
303 printk(KERN_INFO "cfg80211: Calling CRDA to update world " 294 printk(KERN_INFO "cfg80211: Calling CRDA to update world "
304 "regulatory domain\n"); 295 "regulatory domain\n");
305#endif
306 296
307 country_env[8] = alpha2[0]; 297 country_env[8] = alpha2[0];
308 country_env[9] = alpha2[1]; 298 country_env[9] = alpha2[1];
@@ -728,20 +718,12 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
728 718
729 /* Some basic sanity checks first */ 719 /* Some basic sanity checks first */
730 720
731#ifdef CONFIG_WIRELESS_OLD_REGULATORY
732 /* We ignore the world regdom with the old static regdomains setup
733 * as there is no point to it with static regulatory definitions :(
734 * Don't worry this shit will be removed soon... */
735 if (is_world_regdom(rd->alpha2))
736 return -EINVAL;
737#else
738 if (is_world_regdom(rd->alpha2)) { 721 if (is_world_regdom(rd->alpha2)) {
739 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request))) 722 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request)))
740 return -EINVAL; 723 return -EINVAL;
741 update_world_regdomain(rd); 724 update_world_regdomain(rd);
742 return 0; 725 return 0;
743 } 726 }
744#endif
745 727
746 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && 728 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) &&
747 !is_unknown_alpha2(rd->alpha2)) 729 !is_unknown_alpha2(rd->alpha2))
@@ -750,15 +732,10 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
750 if (list_empty(&regulatory_requests)) 732 if (list_empty(&regulatory_requests))
751 return -EINVAL; 733 return -EINVAL;
752 734
753#ifdef CONFIG_WIRELESS_OLD_REGULATORY 735 /* allow overriding the static definitions if CRDA is present */
754 /* Static "US" and "JP" will be overridden, but just once */
755 if (!is_old_static_regdom(cfg80211_regdomain) && 736 if (!is_old_static_regdom(cfg80211_regdomain) &&
756 !regdom_changed(rd->alpha2)) 737 !regdom_changed(rd->alpha2))
757 return -EINVAL;
758#else
759 if (!regdom_changed(rd->alpha2))
760 return -EINVAL; 738 return -EINVAL;
761#endif
762 739
763 /* Now lets set the regulatory domain, update all driver channels 740 /* Now lets set the regulatory domain, update all driver channels
764 * and finally inform them of what we have done, in case they want 741 * and finally inform them of what we have done, in case they want
@@ -768,11 +745,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
768 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request))) 745 if (WARN_ON(!__reg_is_valid_request(rd->alpha2, &request)))
769 return -EINVAL; 746 return -EINVAL;
770 747
771#ifdef CONFIG_WIRELESS_OLD_REGULATORY
772 reset_regdomains_static();
773#else
774 reset_regdomains(); 748 reset_regdomains();
775#endif
776 749
777 /* Country IE parsing coming soon */ 750 /* Country IE parsing coming soon */
778 switch (request->initiator) { 751 switch (request->initiator) {
@@ -858,10 +831,8 @@ int regulatory_init(void)
858 831
859#ifdef CONFIG_WIRELESS_OLD_REGULATORY 832#ifdef CONFIG_WIRELESS_OLD_REGULATORY
860 cfg80211_regdomain = static_regdom(ieee80211_regdom); 833 cfg80211_regdomain = static_regdom(ieee80211_regdom);
861 /* Used during reset_regdomains_static() */
862 cfg80211_world_regdom = cfg80211_regdomain;
863 834
864 printk(KERN_INFO "cfg80211: Using old static regulatory domain:\n"); 835 printk(KERN_INFO "cfg80211: Using static regulatory domain info\n");
865 print_regdomain_info(cfg80211_regdomain); 836 print_regdomain_info(cfg80211_regdomain);
866 /* The old code still requests for a new regdomain and if 837 /* The old code still requests for a new regdomain and if
867 * you have CRDA you get it updated, otherwise you get 838 * you have CRDA you get it updated, otherwise you get
@@ -889,11 +860,7 @@ void regulatory_exit(void)
889 860
890 mutex_lock(&cfg80211_drv_mutex); 861 mutex_lock(&cfg80211_drv_mutex);
891 862
892#ifdef CONFIG_WIRELESS_OLD_REGULATORY
893 reset_regdomains_static();
894#else
895 reset_regdomains(); 863 reset_regdomains();
896#endif
897 864
898 list_for_each_entry_safe(req, req_tmp, &regulatory_requests, list) { 865 list_for_each_entry_safe(req, req_tmp, &regulatory_requests, list) {
899 list_del(&req->list); 866 list_del(&req->list);