aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-12-03 11:21:11 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-01-03 07:01:22 -0500
commit1a9193185f462a51815fe48491f8a6fb6b942551 (patch)
tree9c89b47fdecbbd005fa5795393fab31e6a2e6e97 /net/wireless
parent75e2dba866706ab9b133983b7fd9a6297b24c22d (diff)
regulatory: code cleanup
Clean up various things like indentation, extra parentheses, too many/few line breaks, etc. Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c15
-rw-r--r--net/wireless/reg.c286
-rw-r--r--net/wireless/reg.h4
-rw-r--r--net/wireless/sme.c6
4 files changed, 116 insertions, 195 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f45706adaf34..a19583cf4b6e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4259,7 +4259,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
4259 dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]); 4259 dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]);
4260 4260
4261 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], 4261 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
4262 rem_reg_rules) { 4262 rem_reg_rules) {
4263 num_rules++; 4263 num_rules++;
4264 if (num_rules > NL80211_MAX_SUPP_REG_RULES) 4264 if (num_rules > NL80211_MAX_SUPP_REG_RULES)
4265 return -EINVAL; 4265 return -EINVAL;
@@ -4273,7 +4273,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
4273 } 4273 }
4274 4274
4275 size_of_regd = sizeof(struct ieee80211_regdomain) + 4275 size_of_regd = sizeof(struct ieee80211_regdomain) +
4276 (num_rules * sizeof(struct ieee80211_reg_rule)); 4276 num_rules * sizeof(struct ieee80211_reg_rule);
4277 4277
4278 rd = kzalloc(size_of_regd, GFP_KERNEL); 4278 rd = kzalloc(size_of_regd, GFP_KERNEL);
4279 if (!rd) { 4279 if (!rd) {
@@ -4293,10 +4293,10 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
4293 rd->dfs_region = dfs_region; 4293 rd->dfs_region = dfs_region;
4294 4294
4295 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES], 4295 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
4296 rem_reg_rules) { 4296 rem_reg_rules) {
4297 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX, 4297 nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
4298 nla_data(nl_reg_rule), nla_len(nl_reg_rule), 4298 nla_data(nl_reg_rule), nla_len(nl_reg_rule),
4299 reg_rule_policy); 4299 reg_rule_policy);
4300 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]); 4300 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
4301 if (r) 4301 if (r)
4302 goto bad_reg; 4302 goto bad_reg;
@@ -4312,10 +4312,7 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
4312 BUG_ON(rule_idx != num_rules); 4312 BUG_ON(rule_idx != num_rules);
4313 4313
4314 r = set_regdom(rd); 4314 r = set_regdom(rd);
4315 4315 rd = NULL;
4316 mutex_unlock(&cfg80211_mutex);
4317
4318 return r;
4319 4316
4320 bad_reg: 4317 bad_reg:
4321 mutex_unlock(&cfg80211_mutex); 4318 mutex_unlock(&cfg80211_mutex);
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index cd99d285e8d8..cf2fb3425a63 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -48,7 +48,6 @@
48#include <linux/export.h> 48#include <linux/export.h>
49#include <linux/slab.h> 49#include <linux/slab.h>
50#include <linux/list.h> 50#include <linux/list.h>
51#include <linux/random.h>
52#include <linux/ctype.h> 51#include <linux/ctype.h>
53#include <linux/nl80211.h> 52#include <linux/nl80211.h>
54#include <linux/platform_device.h> 53#include <linux/platform_device.h>
@@ -219,18 +218,14 @@ bool is_world_regdom(const char *alpha2)
219{ 218{
220 if (!alpha2) 219 if (!alpha2)
221 return false; 220 return false;
222 if (alpha2[0] == '0' && alpha2[1] == '0') 221 return alpha2[0] == '0' && alpha2[1] == '0';
223 return true;
224 return false;
225} 222}
226 223
227static bool is_alpha2_set(const char *alpha2) 224static bool is_alpha2_set(const char *alpha2)
228{ 225{
229 if (!alpha2) 226 if (!alpha2)
230 return false; 227 return false;
231 if (alpha2[0] != 0 && alpha2[1] != 0) 228 return alpha2[0] && alpha2[1];
232 return true;
233 return false;
234} 229}
235 230
236static bool is_unknown_alpha2(const char *alpha2) 231static bool is_unknown_alpha2(const char *alpha2)
@@ -241,9 +236,7 @@ static bool is_unknown_alpha2(const char *alpha2)
241 * Special case where regulatory domain was built by driver 236 * Special case where regulatory domain was built by driver
242 * but a specific alpha2 cannot be determined 237 * but a specific alpha2 cannot be determined
243 */ 238 */
244 if (alpha2[0] == '9' && alpha2[1] == '9') 239 return alpha2[0] == '9' && alpha2[1] == '9';
245 return true;
246 return false;
247} 240}
248 241
249static bool is_intersected_alpha2(const char *alpha2) 242static bool is_intersected_alpha2(const char *alpha2)
@@ -255,28 +248,21 @@ static bool is_intersected_alpha2(const char *alpha2)
255 * result of an intersection between two regulatory domain 248 * result of an intersection between two regulatory domain
256 * structures 249 * structures
257 */ 250 */
258 if (alpha2[0] == '9' && alpha2[1] == '8') 251 return alpha2[0] == '9' && alpha2[1] == '8';
259 return true;
260 return false;
261} 252}
262 253
263static bool is_an_alpha2(const char *alpha2) 254static bool is_an_alpha2(const char *alpha2)
264{ 255{
265 if (!alpha2) 256 if (!alpha2)
266 return false; 257 return false;
267 if (isalpha(alpha2[0]) && isalpha(alpha2[1])) 258 return isalpha(alpha2[0]) && isalpha(alpha2[1]);
268 return true;
269 return false;
270} 259}
271 260
272static bool alpha2_equal(const char *alpha2_x, const char *alpha2_y) 261static bool alpha2_equal(const char *alpha2_x, const char *alpha2_y)
273{ 262{
274 if (!alpha2_x || !alpha2_y) 263 if (!alpha2_x || !alpha2_y)
275 return false; 264 return false;
276 if (alpha2_x[0] == alpha2_y[0] && 265 return alpha2_x[0] == alpha2_y[0] && alpha2_x[1] == alpha2_y[1];
277 alpha2_x[1] == alpha2_y[1])
278 return true;
279 return false;
280} 266}
281 267
282static bool regdom_changes(const char *alpha2) 268static bool regdom_changes(const char *alpha2)
@@ -285,9 +271,7 @@ static bool regdom_changes(const char *alpha2)
285 271
286 if (!cfg80211_regdomain) 272 if (!cfg80211_regdomain)
287 return true; 273 return true;
288 if (alpha2_equal(cfg80211_regdomain->alpha2, alpha2)) 274 return !alpha2_equal(cfg80211_regdomain->alpha2, alpha2);
289 return false;
290 return true;
291} 275}
292 276
293/* 277/*
@@ -301,11 +285,9 @@ static bool is_user_regdom_saved(void)
301 return false; 285 return false;
302 286
303 /* This would indicate a mistake on the design */ 287 /* This would indicate a mistake on the design */
304 if (WARN((!is_world_regdom(user_alpha2) && 288 if (WARN(!is_world_regdom(user_alpha2) && !is_an_alpha2(user_alpha2),
305 !is_an_alpha2(user_alpha2)),
306 "Unexpected user alpha2: %c%c\n", 289 "Unexpected user alpha2: %c%c\n",
307 user_alpha2[0], 290 user_alpha2[0], user_alpha2[1]))
308 user_alpha2[1]))
309 return false; 291 return false;
310 292
311 return true; 293 return true;
@@ -359,10 +341,10 @@ static void reg_regdb_search(struct work_struct *work)
359 list); 341 list);
360 list_del(&request->list); 342 list_del(&request->list);
361 343
362 for (i=0; i<reg_regdb_size; i++) { 344 for (i = 0; i < reg_regdb_size; i++) {
363 curdom = reg_regdb[i]; 345 curdom = reg_regdb[i];
364 346
365 if (!memcmp(request->alpha2, curdom->alpha2, 2)) { 347 if (alpha2_equal(request->alpha2, curdom->alpha2)) {
366 regdom = reg_copy_regd(curdom); 348 regdom = reg_copy_regd(curdom);
367 break; 349 break;
368 } 350 }
@@ -456,7 +438,7 @@ static bool is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
456 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; 438 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
457 439
458 if (freq_range->end_freq_khz <= freq_range->start_freq_khz || 440 if (freq_range->end_freq_khz <= freq_range->start_freq_khz ||
459 freq_range->max_bandwidth_khz > freq_diff) 441 freq_range->max_bandwidth_khz > freq_diff)
460 return false; 442 return false;
461 443
462 return true; 444 return true;
@@ -514,7 +496,7 @@ static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
514 * regulatory rule support for other "bands". 496 * regulatory rule support for other "bands".
515 **/ 497 **/
516static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, 498static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
517 u32 freq_khz) 499 u32 freq_khz)
518{ 500{
519#define ONE_GHZ_IN_KHZ 1000000 501#define ONE_GHZ_IN_KHZ 1000000
520 /* 502 /*
@@ -536,10 +518,9 @@ static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
536 * Helper for regdom_intersect(), this does the real 518 * Helper for regdom_intersect(), this does the real
537 * mathematical intersection fun 519 * mathematical intersection fun
538 */ 520 */
539static int reg_rules_intersect( 521static int reg_rules_intersect(const struct ieee80211_reg_rule *rule1,
540 const struct ieee80211_reg_rule *rule1, 522 const struct ieee80211_reg_rule *rule2,
541 const struct ieee80211_reg_rule *rule2, 523 struct ieee80211_reg_rule *intersected_rule)
542 struct ieee80211_reg_rule *intersected_rule)
543{ 524{
544 const struct ieee80211_freq_range *freq_range1, *freq_range2; 525 const struct ieee80211_freq_range *freq_range1, *freq_range2;
545 struct ieee80211_freq_range *freq_range; 526 struct ieee80211_freq_range *freq_range;
@@ -556,11 +537,11 @@ static int reg_rules_intersect(
556 power_rule = &intersected_rule->power_rule; 537 power_rule = &intersected_rule->power_rule;
557 538
558 freq_range->start_freq_khz = max(freq_range1->start_freq_khz, 539 freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
559 freq_range2->start_freq_khz); 540 freq_range2->start_freq_khz);
560 freq_range->end_freq_khz = min(freq_range1->end_freq_khz, 541 freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
561 freq_range2->end_freq_khz); 542 freq_range2->end_freq_khz);
562 freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz, 543 freq_range->max_bandwidth_khz = min(freq_range1->max_bandwidth_khz,
563 freq_range2->max_bandwidth_khz); 544 freq_range2->max_bandwidth_khz);
564 545
565 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz; 546 freq_diff = freq_range->end_freq_khz - freq_range->start_freq_khz;
566 if (freq_range->max_bandwidth_khz > freq_diff) 547 if (freq_range->max_bandwidth_khz > freq_diff)
@@ -571,7 +552,7 @@ static int reg_rules_intersect(
571 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain, 552 power_rule->max_antenna_gain = min(power_rule1->max_antenna_gain,
572 power_rule2->max_antenna_gain); 553 power_rule2->max_antenna_gain);
573 554
574 intersected_rule->flags = (rule1->flags | rule2->flags); 555 intersected_rule->flags = rule1->flags | rule2->flags;
575 556
576 if (!is_valid_reg_rule(intersected_rule)) 557 if (!is_valid_reg_rule(intersected_rule))
577 return -EINVAL; 558 return -EINVAL;
@@ -592,9 +573,9 @@ static int reg_rules_intersect(
592 * resulting intersection of rules between rd1 and rd2. We will 573 * resulting intersection of rules between rd1 and rd2. We will
593 * kzalloc() this structure for you. 574 * kzalloc() this structure for you.
594 */ 575 */
595static struct ieee80211_regdomain *regdom_intersect( 576static struct ieee80211_regdomain *
596 const struct ieee80211_regdomain *rd1, 577regdom_intersect(const struct ieee80211_regdomain *rd1,
597 const struct ieee80211_regdomain *rd2) 578 const struct ieee80211_regdomain *rd2)
598{ 579{
599 int r, size_of_regd; 580 int r, size_of_regd;
600 unsigned int x, y; 581 unsigned int x, y;
@@ -645,8 +626,7 @@ static struct ieee80211_regdomain *regdom_intersect(
645 * a memcpy() 626 * a memcpy()
646 */ 627 */
647 intersected_rule = &rd->reg_rules[rule_idx]; 628 intersected_rule = &rd->reg_rules[rule_idx];
648 r = reg_rules_intersect(rule1, rule2, 629 r = reg_rules_intersect(rule1, rule2, intersected_rule);
649 intersected_rule);
650 /* 630 /*
651 * No need to memset here the intersected rule here as 631 * No need to memset here the intersected rule here as
652 * we're not using the stack anymore 632 * we're not using the stack anymore
@@ -731,9 +711,7 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
731 if (!band_rule_found) 711 if (!band_rule_found)
732 band_rule_found = freq_in_rule_band(fr, center_freq); 712 band_rule_found = freq_in_rule_band(fr, center_freq);
733 713
734 bw_fits = reg_does_bw_fit(fr, 714 bw_fits = reg_does_bw_fit(fr, center_freq, desired_bw_khz);
735 center_freq,
736 desired_bw_khz);
737 715
738 if (band_rule_found && bw_fits) { 716 if (band_rule_found && bw_fits) {
739 *reg_rule = rr; 717 *reg_rule = rr;
@@ -747,17 +725,13 @@ static int freq_reg_info_regd(struct wiphy *wiphy,
747 return -EINVAL; 725 return -EINVAL;
748} 726}
749 727
750int freq_reg_info(struct wiphy *wiphy, 728int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 desired_bw_khz,
751 u32 center_freq,
752 u32 desired_bw_khz,
753 const struct ieee80211_reg_rule **reg_rule) 729 const struct ieee80211_reg_rule **reg_rule)
754{ 730{
755 assert_cfg80211_lock(); 731 assert_cfg80211_lock();
756 return freq_reg_info_regd(wiphy, 732
757 center_freq, 733 return freq_reg_info_regd(wiphy, center_freq, desired_bw_khz,
758 desired_bw_khz, 734 reg_rule, NULL);
759 reg_rule,
760 NULL);
761} 735}
762EXPORT_SYMBOL(freq_reg_info); 736EXPORT_SYMBOL(freq_reg_info);
763 737
@@ -795,16 +769,12 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
795 else 769 else
796 snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain); 770 snprintf(max_antenna_gain, 32, "%d", power_rule->max_antenna_gain);
797 771
798 REG_DBG_PRINT("Updating information on frequency %d MHz " 772 REG_DBG_PRINT("Updating information on frequency %d MHz for a %d MHz width channel with regulatory rule:\n",
799 "for a %d MHz width channel with regulatory rule:\n", 773 chan->center_freq, KHZ_TO_MHZ(desired_bw_khz));
800 chan->center_freq,
801 KHZ_TO_MHZ(desired_bw_khz));
802 774
803 REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n", 775 REG_DBG_PRINT("%d KHz - %d KHz @ %d KHz), (%s mBi, %d mBm)\n",
804 freq_range->start_freq_khz, 776 freq_range->start_freq_khz, freq_range->end_freq_khz,
805 freq_range->end_freq_khz, 777 freq_range->max_bandwidth_khz, max_antenna_gain,
806 freq_range->max_bandwidth_khz,
807 max_antenna_gain,
808 power_rule->max_eirp); 778 power_rule->max_eirp);
809} 779}
810#else 780#else
@@ -850,11 +820,8 @@ static void handle_channel(struct wiphy *wiphy,
850 820
851 flags = chan->orig_flags; 821 flags = chan->orig_flags;
852 822
853 r = freq_reg_info(wiphy, 823 r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq),
854 MHZ_TO_KHZ(chan->center_freq), 824 desired_bw_khz, &reg_rule);
855 desired_bw_khz,
856 &reg_rule);
857
858 if (r) { 825 if (r) {
859 /* 826 /*
860 * We will disable all channels that do not match our 827 * We will disable all channels that do not match our
@@ -902,8 +869,9 @@ static void handle_channel(struct wiphy *wiphy,
902 869
903 chan->beacon_found = false; 870 chan->beacon_found = false;
904 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags); 871 chan->flags = flags | bw_flags | map_regdom_flags(reg_rule->flags);
905 chan->max_antenna_gain = min(chan->orig_mag, 872 chan->max_antenna_gain =
906 (int) MBI_TO_DBI(power_rule->max_antenna_gain)); 873 min_t(int, chan->orig_mag,
874 MBI_TO_DBI(power_rule->max_antenna_gain));
907 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp); 875 chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
908 if (chan->orig_mpwr) { 876 if (chan->orig_mpwr) {
909 /* 877 /*
@@ -922,8 +890,7 @@ static void handle_channel(struct wiphy *wiphy,
922 chan->max_power = chan->max_reg_power; 890 chan->max_power = chan->max_reg_power;
923} 891}
924 892
925static void handle_band(struct wiphy *wiphy, 893static void handle_band(struct wiphy *wiphy, enum ieee80211_band band,
926 enum ieee80211_band band,
927 enum nl80211_reg_initiator initiator) 894 enum nl80211_reg_initiator initiator)
928{ 895{
929 unsigned int i; 896 unsigned int i;
@@ -940,51 +907,48 @@ static bool reg_request_cell_base(struct regulatory_request *request)
940{ 907{
941 if (request->initiator != NL80211_REGDOM_SET_BY_USER) 908 if (request->initiator != NL80211_REGDOM_SET_BY_USER)
942 return false; 909 return false;
943 if (request->user_reg_hint_type != NL80211_USER_REG_HINT_CELL_BASE) 910 return request->user_reg_hint_type == NL80211_USER_REG_HINT_CELL_BASE;
944 return false;
945 return true;
946} 911}
947 912
948bool reg_last_request_cell_base(void) 913bool reg_last_request_cell_base(void)
949{ 914{
950 bool val; 915 bool val;
916
951 assert_cfg80211_lock(); 917 assert_cfg80211_lock();
952 918
953 mutex_lock(&reg_mutex); 919 mutex_lock(&reg_mutex);
954 val = reg_request_cell_base(last_request); 920 val = reg_request_cell_base(last_request);
955 mutex_unlock(&reg_mutex); 921 mutex_unlock(&reg_mutex);
922
956 return val; 923 return val;
957} 924}
958 925
959#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS 926#ifdef CONFIG_CFG80211_CERTIFICATION_ONUS
960
961/* Core specific check */ 927/* Core specific check */
962static int reg_ignore_cell_hint(struct regulatory_request *pending_request) 928static int reg_ignore_cell_hint(struct regulatory_request *pending_request)
963{ 929{
964 if (!reg_num_devs_support_basehint) 930 if (!reg_num_devs_support_basehint)
965 return -EOPNOTSUPP; 931 return -EOPNOTSUPP;
966 932
967 if (reg_request_cell_base(last_request)) { 933 if (reg_request_cell_base(last_request) &&
968 if (!regdom_changes(pending_request->alpha2)) 934 !regdom_changes(pending_request->alpha2))
969 return -EALREADY; 935 return -EALREADY;
970 return 0; 936
971 }
972 return 0; 937 return 0;
973} 938}
974 939
975/* Device specific check */ 940/* Device specific check */
976static bool reg_dev_ignore_cell_hint(struct wiphy *wiphy) 941static bool reg_dev_ignore_cell_hint(struct wiphy *wiphy)
977{ 942{
978 if (!(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS)) 943 return !(wiphy->features & NL80211_FEATURE_CELL_BASE_REG_HINTS);
979 return true;
980 return false;
981} 944}
982#else 945#else
983static int reg_ignore_cell_hint(struct regulatory_request *pending_request) 946static int reg_ignore_cell_hint(struct regulatory_request *pending_request)
984{ 947{
985 return -EOPNOTSUPP; 948 return -EOPNOTSUPP;
986} 949}
987static int reg_dev_ignore_cell_hint(struct wiphy *wiphy) 950
951static bool reg_dev_ignore_cell_hint(struct wiphy *wiphy)
988{ 952{
989 return true; 953 return true;
990} 954}
@@ -995,17 +959,14 @@ static bool ignore_reg_update(struct wiphy *wiphy,
995 enum nl80211_reg_initiator initiator) 959 enum nl80211_reg_initiator initiator)
996{ 960{
997 if (!last_request) { 961 if (!last_request) {
998 REG_DBG_PRINT("Ignoring regulatory request %s since " 962 REG_DBG_PRINT("Ignoring regulatory request %s since last_request is not set\n",
999 "last_request is not set\n",
1000 reg_initiator_name(initiator)); 963 reg_initiator_name(initiator));
1001 return true; 964 return true;
1002 } 965 }
1003 966
1004 if (initiator == NL80211_REGDOM_SET_BY_CORE && 967 if (initiator == NL80211_REGDOM_SET_BY_CORE &&
1005 wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) { 968 wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) {
1006 REG_DBG_PRINT("Ignoring regulatory request %s " 969 REG_DBG_PRINT("Ignoring regulatory request %s since the driver uses its own custom regulatory domain\n",
1007 "since the driver uses its own custom "
1008 "regulatory domain\n",
1009 reg_initiator_name(initiator)); 970 reg_initiator_name(initiator));
1010 return true; 971 return true;
1011 } 972 }
@@ -1017,9 +978,7 @@ static bool ignore_reg_update(struct wiphy *wiphy,
1017 if (wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY && !wiphy->regd && 978 if (wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY && !wiphy->regd &&
1018 initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && 979 initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
1019 !is_world_regdom(last_request->alpha2)) { 980 !is_world_regdom(last_request->alpha2)) {
1020 REG_DBG_PRINT("Ignoring regulatory request %s " 981 REG_DBG_PRINT("Ignoring regulatory request %s since the driver requires its own regulatory domain to be set first\n",
1021 "since the driver requires its own regulatory "
1022 "domain to be set first\n",
1023 reg_initiator_name(initiator)); 982 reg_initiator_name(initiator));
1024 return true; 983 return true;
1025 } 984 }
@@ -1030,8 +989,7 @@ static bool ignore_reg_update(struct wiphy *wiphy,
1030 return false; 989 return false;
1031} 990}
1032 991
1033static void handle_reg_beacon(struct wiphy *wiphy, 992static void handle_reg_beacon(struct wiphy *wiphy, unsigned int chan_idx,
1034 unsigned int chan_idx,
1035 struct reg_beacon *reg_beacon) 993 struct reg_beacon *reg_beacon)
1036{ 994{
1037 struct ieee80211_supported_band *sband; 995 struct ieee80211_supported_band *sband;
@@ -1139,16 +1097,14 @@ static void reg_process_beacons(struct wiphy *wiphy)
1139 wiphy_update_beacon_reg(wiphy); 1097 wiphy_update_beacon_reg(wiphy);
1140} 1098}
1141 1099
1142static bool is_ht40_not_allowed(struct ieee80211_channel *chan) 1100static bool is_ht40_allowed(struct ieee80211_channel *chan)
1143{ 1101{
1144 if (!chan) 1102 if (!chan)
1145 return true; 1103 return false;
1146 if (chan->flags & IEEE80211_CHAN_DISABLED) 1104 if (chan->flags & IEEE80211_CHAN_DISABLED)
1147 return true; 1105 return false;
1148 /* This would happen when regulatory rules disallow HT40 completely */ 1106 /* This would happen when regulatory rules disallow HT40 completely */
1149 if (IEEE80211_CHAN_NO_HT40 == (chan->flags & (IEEE80211_CHAN_NO_HT40))) 1107 return !(chan->flags & IEEE80211_CHAN_NO_HT40);
1150 return true;
1151 return false;
1152} 1108}
1153 1109
1154static void reg_process_ht_flags_channel(struct wiphy *wiphy, 1110static void reg_process_ht_flags_channel(struct wiphy *wiphy,
@@ -1166,7 +1122,7 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
1166 BUG_ON(chan_idx >= sband->n_channels); 1122 BUG_ON(chan_idx >= sband->n_channels);
1167 channel = &sband->channels[chan_idx]; 1123 channel = &sband->channels[chan_idx];
1168 1124
1169 if (is_ht40_not_allowed(channel)) { 1125 if (!is_ht40_allowed(channel)) {
1170 channel->flags |= IEEE80211_CHAN_NO_HT40; 1126 channel->flags |= IEEE80211_CHAN_NO_HT40;
1171 return; 1127 return;
1172 } 1128 }
@@ -1177,6 +1133,7 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
1177 */ 1133 */
1178 for (i = 0; i < sband->n_channels; i++) { 1134 for (i = 0; i < sband->n_channels; i++) {
1179 struct ieee80211_channel *c = &sband->channels[i]; 1135 struct ieee80211_channel *c = &sband->channels[i];
1136
1180 if (c->center_freq == (channel->center_freq - 20)) 1137 if (c->center_freq == (channel->center_freq - 20))
1181 channel_before = c; 1138 channel_before = c;
1182 if (c->center_freq == (channel->center_freq + 20)) 1139 if (c->center_freq == (channel->center_freq + 20))
@@ -1188,12 +1145,12 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
1188 * if that ever changes we also need to change the below logic 1145 * if that ever changes we also need to change the below logic
1189 * to include that as well. 1146 * to include that as well.
1190 */ 1147 */
1191 if (is_ht40_not_allowed(channel_before)) 1148 if (!is_ht40_allowed(channel_before))
1192 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; 1149 channel->flags |= IEEE80211_CHAN_NO_HT40MINUS;
1193 else 1150 else
1194 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; 1151 channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS;
1195 1152
1196 if (is_ht40_not_allowed(channel_after)) 1153 if (!is_ht40_allowed(channel_after))
1197 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; 1154 channel->flags |= IEEE80211_CHAN_NO_HT40PLUS;
1198 else 1155 else
1199 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; 1156 channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS;
@@ -1245,6 +1202,7 @@ static void wiphy_update_regulatory(struct wiphy *wiphy,
1245 1202
1246 reg_process_beacons(wiphy); 1203 reg_process_beacons(wiphy);
1247 reg_process_ht_flags(wiphy); 1204 reg_process_ht_flags(wiphy);
1205
1248 if (wiphy->reg_notifier) 1206 if (wiphy->reg_notifier)
1249 wiphy->reg_notifier(wiphy, last_request); 1207 wiphy->reg_notifier(wiphy, last_request);
1250} 1208}
@@ -1289,18 +1247,12 @@ static void handle_channel_custom(struct wiphy *wiphy,
1289 BUG_ON(chan_idx >= sband->n_channels); 1247 BUG_ON(chan_idx >= sband->n_channels);
1290 chan = &sband->channels[chan_idx]; 1248 chan = &sband->channels[chan_idx];
1291 1249
1292 r = freq_reg_info_regd(wiphy, 1250 r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq),
1293 MHZ_TO_KHZ(chan->center_freq), 1251 desired_bw_khz, &reg_rule, regd);
1294 desired_bw_khz,
1295 &reg_rule,
1296 regd);
1297 1252
1298 if (r) { 1253 if (r) {
1299 REG_DBG_PRINT("Disabling freq %d MHz as custom " 1254 REG_DBG_PRINT("Disabling freq %d MHz as custom regd has no rule that fits a %d MHz wide channel\n",
1300 "regd has no rule that fits a %d MHz " 1255 chan->center_freq, KHZ_TO_MHZ(desired_bw_khz));
1301 "wide channel\n",
1302 chan->center_freq,
1303 KHZ_TO_MHZ(desired_bw_khz));
1304 chan->flags = IEEE80211_CHAN_DISABLED; 1256 chan->flags = IEEE80211_CHAN_DISABLED;
1305 return; 1257 return;
1306 } 1258 }
@@ -1350,7 +1302,7 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
1350 1302
1351 /* 1303 /*
1352 * no point in calling this if it won't have any effect 1304 * no point in calling this if it won't have any effect
1353 * on your device's supportd bands. 1305 * on your device's supported bands.
1354 */ 1306 */
1355 WARN_ON(!bands_set); 1307 WARN_ON(!bands_set);
1356} 1308}
@@ -1379,7 +1331,6 @@ static int ignore_request(struct wiphy *wiphy,
1379 case NL80211_REGDOM_SET_BY_CORE: 1331 case NL80211_REGDOM_SET_BY_CORE:
1380 return 0; 1332 return 0;
1381 case NL80211_REGDOM_SET_BY_COUNTRY_IE: 1333 case NL80211_REGDOM_SET_BY_COUNTRY_IE:
1382
1383 if (reg_request_cell_base(last_request)) { 1334 if (reg_request_cell_base(last_request)) {
1384 /* Trust a Cell base station over the AP's country IE */ 1335 /* Trust a Cell base station over the AP's country IE */
1385 if (regdom_changes(pending_request->alpha2)) 1336 if (regdom_changes(pending_request->alpha2))
@@ -1444,18 +1395,17 @@ static int ignore_request(struct wiphy *wiphy,
1444 * to their country before the IE is picked up 1395 * to their country before the IE is picked up
1445 */ 1396 */
1446 if (last_request->initiator == NL80211_REGDOM_SET_BY_USER && 1397 if (last_request->initiator == NL80211_REGDOM_SET_BY_USER &&
1447 last_request->intersect) 1398 last_request->intersect)
1448 return -EOPNOTSUPP; 1399 return -EOPNOTSUPP;
1449 /* 1400 /*
1450 * Process user requests only after previous user/driver/core 1401 * Process user requests only after previous user/driver/core
1451 * requests have been processed 1402 * requests have been processed
1452 */ 1403 */
1453 if (last_request->initiator == NL80211_REGDOM_SET_BY_CORE || 1404 if ((last_request->initiator == NL80211_REGDOM_SET_BY_CORE ||
1454 last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER || 1405 last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER ||
1455 last_request->initiator == NL80211_REGDOM_SET_BY_USER) { 1406 last_request->initiator == NL80211_REGDOM_SET_BY_USER) &&
1456 if (regdom_changes(last_request->alpha2)) 1407 regdom_changes(last_request->alpha2))
1457 return -EAGAIN; 1408 return -EAGAIN;
1458 }
1459 1409
1460 if (!regdom_changes(pending_request->alpha2)) 1410 if (!regdom_changes(pending_request->alpha2))
1461 return -EALREADY; 1411 return -EALREADY;
@@ -1585,8 +1535,7 @@ static void reg_process_hint(struct regulatory_request *reg_request,
1585 if (wiphy_idx_valid(reg_request->wiphy_idx)) 1535 if (wiphy_idx_valid(reg_request->wiphy_idx))
1586 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); 1536 wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
1587 1537
1588 if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && 1538 if (reg_initiator == NL80211_REGDOM_SET_BY_DRIVER && !wiphy) {
1589 !wiphy) {
1590 kfree(reg_request); 1539 kfree(reg_request);
1591 return; 1540 return;
1592 } 1541 }
@@ -1603,8 +1552,7 @@ static void reg_process_hint(struct regulatory_request *reg_request,
1603 * We only time out user hints, given that they should be the only 1552 * We only time out user hints, given that they should be the only
1604 * source of bogus requests. 1553 * source of bogus requests.
1605 */ 1554 */
1606 if (r != -EALREADY && 1555 if (r != -EALREADY && reg_initiator == NL80211_REGDOM_SET_BY_USER)
1607 reg_initiator == NL80211_REGDOM_SET_BY_USER)
1608 schedule_delayed_work(&reg_timeout, msecs_to_jiffies(3142)); 1556 schedule_delayed_work(&reg_timeout, msecs_to_jiffies(3142));
1609} 1557}
1610 1558
@@ -1622,8 +1570,7 @@ static void reg_process_pending_hints(void)
1622 1570
1623 /* When last_request->processed becomes true this will be rescheduled */ 1571 /* When last_request->processed becomes true this will be rescheduled */
1624 if (last_request && !last_request->processed) { 1572 if (last_request && !last_request->processed) {
1625 REG_DBG_PRINT("Pending regulatory request, waiting " 1573 REG_DBG_PRINT("Pending regulatory request, waiting for it to be processed...\n");
1626 "for it to be processed...\n");
1627 goto out; 1574 goto out;
1628 } 1575 }
1629 1576
@@ -1665,7 +1612,6 @@ static void reg_process_pending_beacon_hints(void)
1665 1612
1666 list_for_each_entry_safe(pending_beacon, tmp, 1613 list_for_each_entry_safe(pending_beacon, tmp,
1667 &reg_pending_beacons, list) { 1614 &reg_pending_beacons, list) {
1668
1669 list_del_init(&pending_beacon->list); 1615 list_del_init(&pending_beacon->list);
1670 1616
1671 /* Applies the beacon hint to current wiphys */ 1617 /* Applies the beacon hint to current wiphys */
@@ -1708,8 +1654,7 @@ static int regulatory_hint_core(const char *alpha2)
1708{ 1654{
1709 struct regulatory_request *request; 1655 struct regulatory_request *request;
1710 1656
1711 request = kzalloc(sizeof(struct regulatory_request), 1657 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
1712 GFP_KERNEL);
1713 if (!request) 1658 if (!request)
1714 return -ENOMEM; 1659 return -ENOMEM;
1715 1660
@@ -1776,10 +1721,8 @@ EXPORT_SYMBOL(regulatory_hint);
1776 * We hold wdev_lock() here so we cannot hold cfg80211_mutex() and 1721 * We hold wdev_lock() here so we cannot hold cfg80211_mutex() and
1777 * therefore cannot iterate over the rdev list here. 1722 * therefore cannot iterate over the rdev list here.
1778 */ 1723 */
1779void regulatory_hint_11d(struct wiphy *wiphy, 1724void regulatory_hint_11d(struct wiphy *wiphy, enum ieee80211_band band,
1780 enum ieee80211_band band, 1725 const u8 *country_ie, u8 country_ie_len)
1781 const u8 *country_ie,
1782 u8 country_ie_len)
1783{ 1726{
1784 char alpha2[2]; 1727 char alpha2[2];
1785 enum environment_cap env = ENVIRON_ANY; 1728 enum environment_cap env = ENVIRON_ANY;
@@ -1811,8 +1754,8 @@ void regulatory_hint_11d(struct wiphy *wiphy,
1811 * cfg80211_mutex. 1754 * cfg80211_mutex.
1812 */ 1755 */
1813 if (likely(last_request->initiator == 1756 if (likely(last_request->initiator ==
1814 NL80211_REGDOM_SET_BY_COUNTRY_IE && 1757 NL80211_REGDOM_SET_BY_COUNTRY_IE &&
1815 wiphy_idx_valid(last_request->wiphy_idx))) 1758 wiphy_idx_valid(last_request->wiphy_idx)))
1816 goto out; 1759 goto out;
1817 1760
1818 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1761 request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
@@ -1840,8 +1783,7 @@ static void restore_alpha2(char *alpha2, bool reset_user)
1840 if (is_user_regdom_saved()) { 1783 if (is_user_regdom_saved()) {
1841 /* Unless we're asked to ignore it and reset it */ 1784 /* Unless we're asked to ignore it and reset it */
1842 if (reset_user) { 1785 if (reset_user) {
1843 REG_DBG_PRINT("Restoring regulatory settings " 1786 REG_DBG_PRINT("Restoring regulatory settings including user preference\n");
1844 "including user preference\n");
1845 user_alpha2[0] = '9'; 1787 user_alpha2[0] = '9';
1846 user_alpha2[1] = '7'; 1788 user_alpha2[1] = '7';
1847 1789
@@ -1851,26 +1793,20 @@ static void restore_alpha2(char *alpha2, bool reset_user)
1851 * back as they were for a full restore. 1793 * back as they were for a full restore.
1852 */ 1794 */
1853 if (!is_world_regdom(ieee80211_regdom)) { 1795 if (!is_world_regdom(ieee80211_regdom)) {
1854 REG_DBG_PRINT("Keeping preference on " 1796 REG_DBG_PRINT("Keeping preference on module parameter ieee80211_regdom: %c%c\n",
1855 "module parameter ieee80211_regdom: %c%c\n", 1797 ieee80211_regdom[0], ieee80211_regdom[1]);
1856 ieee80211_regdom[0],
1857 ieee80211_regdom[1]);
1858 alpha2[0] = ieee80211_regdom[0]; 1798 alpha2[0] = ieee80211_regdom[0];
1859 alpha2[1] = ieee80211_regdom[1]; 1799 alpha2[1] = ieee80211_regdom[1];
1860 } 1800 }
1861 } else { 1801 } else {
1862 REG_DBG_PRINT("Restoring regulatory settings " 1802 REG_DBG_PRINT("Restoring regulatory settings while preserving user preference for: %c%c\n",
1863 "while preserving user preference for: %c%c\n", 1803 user_alpha2[0], user_alpha2[1]);
1864 user_alpha2[0],
1865 user_alpha2[1]);
1866 alpha2[0] = user_alpha2[0]; 1804 alpha2[0] = user_alpha2[0];
1867 alpha2[1] = user_alpha2[1]; 1805 alpha2[1] = user_alpha2[1];
1868 } 1806 }
1869 } else if (!is_world_regdom(ieee80211_regdom)) { 1807 } else if (!is_world_regdom(ieee80211_regdom)) {
1870 REG_DBG_PRINT("Keeping preference on " 1808 REG_DBG_PRINT("Keeping preference on module parameter ieee80211_regdom: %c%c\n",
1871 "module parameter ieee80211_regdom: %c%c\n", 1809 ieee80211_regdom[0], ieee80211_regdom[1]);
1872 ieee80211_regdom[0],
1873 ieee80211_regdom[1]);
1874 alpha2[0] = ieee80211_regdom[0]; 1810 alpha2[0] = ieee80211_regdom[0];
1875 alpha2[1] = ieee80211_regdom[1]; 1811 alpha2[1] = ieee80211_regdom[1];
1876 } else 1812 } else
@@ -1986,10 +1922,8 @@ static void restore_regulatory_settings(bool reset_user)
1986 1922
1987 spin_lock(&reg_requests_lock); 1923 spin_lock(&reg_requests_lock);
1988 list_for_each_entry_safe(reg_request, tmp, &tmp_reg_req_list, list) { 1924 list_for_each_entry_safe(reg_request, tmp, &tmp_reg_req_list, list) {
1989 REG_DBG_PRINT("Adding request for country %c%c back " 1925 REG_DBG_PRINT("Adding request for country %c%c back into the queue\n",
1990 "into the queue\n", 1926 reg_request->alpha2[0], reg_request->alpha2[1]);
1991 reg_request->alpha2[0],
1992 reg_request->alpha2[1]);
1993 list_move_tail(&reg_request->list, &reg_requests_list); 1927 list_move_tail(&reg_request->list, &reg_requests_list);
1994 } 1928 }
1995 spin_unlock(&reg_requests_lock); 1929 spin_unlock(&reg_requests_lock);
@@ -2004,8 +1938,7 @@ static void restore_regulatory_settings(bool reset_user)
2004 1938
2005void regulatory_hint_disconnect(void) 1939void regulatory_hint_disconnect(void)
2006{ 1940{
2007 REG_DBG_PRINT("All devices are disconnected, going to " 1941 REG_DBG_PRINT("All devices are disconnected, going to restore regulatory settings\n");
2008 "restore regulatory settings\n");
2009 restore_regulatory_settings(false); 1942 restore_regulatory_settings(false);
2010} 1943}
2011 1944
@@ -2024,25 +1957,23 @@ int regulatory_hint_found_beacon(struct wiphy *wiphy,
2024{ 1957{
2025 struct reg_beacon *reg_beacon; 1958 struct reg_beacon *reg_beacon;
2026 1959
2027 if (likely((beacon_chan->beacon_found || 1960 if (beacon_chan->beacon_found ||
2028 (beacon_chan->flags & IEEE80211_CHAN_RADAR) || 1961 beacon_chan->flags & IEEE80211_CHAN_RADAR ||
2029 (beacon_chan->band == IEEE80211_BAND_2GHZ && 1962 (beacon_chan->band == IEEE80211_BAND_2GHZ &&
2030 !freq_is_chan_12_13_14(beacon_chan->center_freq))))) 1963 !freq_is_chan_12_13_14(beacon_chan->center_freq)))
2031 return 0; 1964 return 0;
2032 1965
2033 reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp); 1966 reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp);
2034 if (!reg_beacon) 1967 if (!reg_beacon)
2035 return -ENOMEM; 1968 return -ENOMEM;
2036 1969
2037 REG_DBG_PRINT("Found new beacon on " 1970 REG_DBG_PRINT("Found new beacon on frequency: %d MHz (Ch %d) on %s\n",
2038 "frequency: %d MHz (Ch %d) on %s\n",
2039 beacon_chan->center_freq, 1971 beacon_chan->center_freq,
2040 ieee80211_frequency_to_channel(beacon_chan->center_freq), 1972 ieee80211_frequency_to_channel(beacon_chan->center_freq),
2041 wiphy_name(wiphy)); 1973 wiphy_name(wiphy));
2042 1974
2043 memcpy(&reg_beacon->chan, beacon_chan, 1975 memcpy(&reg_beacon->chan, beacon_chan,
2044 sizeof(struct ieee80211_channel)); 1976 sizeof(struct ieee80211_channel));
2045
2046 1977
2047 /* 1978 /*
2048 * Since we can be called from BH or and non-BH context 1979 * Since we can be called from BH or and non-BH context
@@ -2122,7 +2053,7 @@ static void print_dfs_region(u8 dfs_region)
2122 pr_info(" DFS Master region JP"); 2053 pr_info(" DFS Master region JP");
2123 break; 2054 break;
2124 default: 2055 default:
2125 pr_info(" DFS Master region Uknown"); 2056 pr_info(" DFS Master region Unknown");
2126 break; 2057 break;
2127 } 2058 }
2128} 2059}
@@ -2131,7 +2062,6 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
2131{ 2062{
2132 2063
2133 if (is_intersected_alpha2(rd->alpha2)) { 2064 if (is_intersected_alpha2(rd->alpha2)) {
2134
2135 if (last_request->initiator == 2065 if (last_request->initiator ==
2136 NL80211_REGDOM_SET_BY_COUNTRY_IE) { 2066 NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2137 struct cfg80211_registered_device *rdev; 2067 struct cfg80211_registered_device *rdev;
@@ -2145,22 +2075,21 @@ static void print_regdomain(const struct ieee80211_regdomain *rd)
2145 pr_info("Current regulatory domain intersected:\n"); 2075 pr_info("Current regulatory domain intersected:\n");
2146 } else 2076 } else
2147 pr_info("Current regulatory domain intersected:\n"); 2077 pr_info("Current regulatory domain intersected:\n");
2148 } else if (is_world_regdom(rd->alpha2)) 2078 } else if (is_world_regdom(rd->alpha2)) {
2149 pr_info("World regulatory domain updated:\n"); 2079 pr_info("World regulatory domain updated:\n");
2150 else { 2080 } else {
2151 if (is_unknown_alpha2(rd->alpha2)) 2081 if (is_unknown_alpha2(rd->alpha2))
2152 pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n"); 2082 pr_info("Regulatory domain changed to driver built-in settings (unknown country)\n");
2153 else { 2083 else {
2154 if (reg_request_cell_base(last_request)) 2084 if (reg_request_cell_base(last_request))
2155 pr_info("Regulatory domain changed " 2085 pr_info("Regulatory domain changed to country: %c%c by Cell Station\n",
2156 "to country: %c%c by Cell Station\n",
2157 rd->alpha2[0], rd->alpha2[1]); 2086 rd->alpha2[0], rd->alpha2[1]);
2158 else 2087 else
2159 pr_info("Regulatory domain changed " 2088 pr_info("Regulatory domain changed to country: %c%c\n",
2160 "to country: %c%c\n",
2161 rd->alpha2[0], rd->alpha2[1]); 2089 rd->alpha2[0], rd->alpha2[1]);
2162 } 2090 }
2163 } 2091 }
2092
2164 print_dfs_region(rd->dfs_region); 2093 print_dfs_region(rd->dfs_region);
2165 print_rd_rules(rd); 2094 print_rd_rules(rd);
2166} 2095}
@@ -2187,7 +2116,7 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
2187 } 2116 }
2188 2117
2189 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) && 2118 if (!is_alpha2_set(rd->alpha2) && !is_an_alpha2(rd->alpha2) &&
2190 !is_unknown_alpha2(rd->alpha2)) 2119 !is_unknown_alpha2(rd->alpha2))
2191 return -EINVAL; 2120 return -EINVAL;
2192 2121
2193 if (!last_request) 2122 if (!last_request)
@@ -2263,7 +2192,6 @@ static int __set_regdom(const struct ieee80211_regdomain *rd)
2263 /* Intersection requires a bit more work */ 2192 /* Intersection requires a bit more work */
2264 2193
2265 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) { 2194 if (last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2266
2267 intersected_rd = regdom_intersect(rd, cfg80211_regdomain); 2195 intersected_rd = regdom_intersect(rd, cfg80211_regdomain);
2268 if (!intersected_rd) 2196 if (!intersected_rd)
2269 return -EINVAL; 2197 return -EINVAL;
@@ -2315,8 +2243,7 @@ int set_regdom(const struct ieee80211_regdomain *rd)
2315 } 2243 }
2316 2244
2317 /* This would make this whole thing pointless */ 2245 /* This would make this whole thing pointless */
2318 if (!last_request->intersect) 2246 BUG_ON(!last_request->intersect && rd != cfg80211_regdomain);
2319 BUG_ON(rd != cfg80211_regdomain);
2320 2247
2321 /* update all wiphys now with the new established regulatory domain */ 2248 /* update all wiphys now with the new established regulatory domain */
2322 update_all_wiphy_regulatory(last_request->initiator); 2249 update_all_wiphy_regulatory(last_request->initiator);
@@ -2393,8 +2320,7 @@ out:
2393 2320
2394static void reg_timeout_work(struct work_struct *work) 2321static void reg_timeout_work(struct work_struct *work)
2395{ 2322{
2396 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, " 2323 REG_DBG_PRINT("Timeout while waiting for CRDA to reply, restoring regulatory settings\n");
2397 "restoring regulatory settings\n");
2398 restore_regulatory_settings(true); 2324 restore_regulatory_settings(true);
2399} 2325}
2400 2326
@@ -2448,7 +2374,7 @@ int __init regulatory_init(void)
2448 return 0; 2374 return 0;
2449} 2375}
2450 2376
2451void /* __init_or_exit */ regulatory_exit(void) 2377void regulatory_exit(void)
2452{ 2378{
2453 struct regulatory_request *reg_request, *tmp; 2379 struct regulatory_request *reg_request, *tmp;
2454 struct reg_beacon *reg_beacon, *btmp; 2380 struct reg_beacon *reg_beacon, *btmp;
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index 4c0a32ffd530..37891e813a74 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -55,8 +55,8 @@ bool reg_last_request_cell_base(void);
55 * set the wiphy->disable_beacon_hints to true. 55 * set the wiphy->disable_beacon_hints to true.
56 */ 56 */
57int regulatory_hint_found_beacon(struct wiphy *wiphy, 57int regulatory_hint_found_beacon(struct wiphy *wiphy,
58 struct ieee80211_channel *beacon_chan, 58 struct ieee80211_channel *beacon_chan,
59 gfp_t gfp); 59 gfp_t gfp);
60 60
61/** 61/**
62 * regulatory_hint_11d - hints a country IE as a regulatory domain 62 * regulatory_hint_11d - hints a country IE as a regulatory domain
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index f2431e41a373..d2d26518cdd7 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -519,10 +519,8 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
519 * - country_ie + 2, the start of the country ie data, and 519 * - country_ie + 2, the start of the country ie data, and
520 * - and country_ie[1] which is the IE length 520 * - and country_ie[1] which is the IE length
521 */ 521 */
522 regulatory_hint_11d(wdev->wiphy, 522 regulatory_hint_11d(wdev->wiphy, bss->channel->band,
523 bss->channel->band, 523 country_ie + 2, country_ie[1]);
524 country_ie + 2,
525 country_ie[1]);
526 kfree(country_ie); 524 kfree(country_ie);
527} 525}
528 526