aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/regd.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-10-14 20:42:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-10-18 14:04:41 -0400
commit8a3b6c800a993bbc7559bcfa77a34e4fc633cf0e (patch)
tree90d72a080888a81432c878dd5d75d58d2bdd1142 /drivers/net/wireless/ath/regd.c
parent03f27120fb935f2a7f1a7471acb6450dbc64e564 (diff)
ath: move common dynamic regulatory domain setting to a helper
This moves the dynamic regulatory domain selection code into a helper. Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/regd.c')
-rw-r--r--drivers/net/wireless/ath/regd.c55
1 files changed, 37 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 7d077c752dd5..8373650a946e 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -356,14 +356,48 @@ static u16 ath_regd_find_country_by_name(char *alpha2)
356 return -1; 356 return -1;
357} 357}
358 358
359static int __ath_reg_dyn_country(struct wiphy *wiphy,
360 struct ath_regulatory *reg,
361 struct regulatory_request *request)
362{
363 u16 country_code;
364
365 if (!ath_is_world_regd(reg))
366 return -EINVAL;
367
368 country_code = ath_regd_find_country_by_name(request->alpha2);
369 if (country_code == (u16) -1)
370 return -EINVAL;
371
372 reg->current_rd = COUNTRY_ERD_FLAG;
373 reg->current_rd |= country_code;
374
375 __ath_regd_init(reg);
376
377 ath_reg_apply_world_flags(wiphy, request->initiator, reg);
378
379 return 0;
380}
381
382static void ath_reg_dyn_country(struct wiphy *wiphy,
383 struct ath_regulatory *reg,
384 struct regulatory_request *request)
385{
386 if (__ath_reg_dyn_country(wiphy, reg, request))
387 return;
388
389 printk(KERN_DEBUG "ath: regdomain 0x%0x "
390 "dynamically updated by %s\n",
391 reg->current_rd,
392 reg_initiator_name(request->initiator));
393}
394
359void ath_reg_notifier_apply(struct wiphy *wiphy, 395void ath_reg_notifier_apply(struct wiphy *wiphy,
360 struct regulatory_request *request, 396 struct regulatory_request *request,
361 struct ath_regulatory *reg) 397 struct ath_regulatory *reg)
362{ 398{
363 struct ath_common *common = container_of(reg, struct ath_common, 399 struct ath_common *common = container_of(reg, struct ath_common,
364 regulatory); 400 regulatory);
365 u16 country_code;
366
367 /* We always apply this */ 401 /* We always apply this */
368 ath_reg_apply_radar_flags(wiphy); 402 ath_reg_apply_radar_flags(wiphy);
369 403
@@ -391,22 +425,7 @@ void ath_reg_notifier_apply(struct wiphy *wiphy,
391 case NL80211_REGDOM_SET_BY_USER: 425 case NL80211_REGDOM_SET_BY_USER:
392 break; 426 break;
393 case NL80211_REGDOM_SET_BY_COUNTRY_IE: 427 case NL80211_REGDOM_SET_BY_COUNTRY_IE:
394 if (!ath_is_world_regd(reg)) 428 ath_reg_dyn_country(wiphy, reg, request);
395 break;
396
397 country_code = ath_regd_find_country_by_name(request->alpha2);
398 if (country_code == (u16) -1)
399 break;
400
401 reg->current_rd = COUNTRY_ERD_FLAG;
402 reg->current_rd |= country_code;
403
404 printk(KERN_DEBUG "ath: regdomain 0x%0x updated by CountryIE\n",
405 reg->current_rd);
406 __ath_regd_init(reg);
407
408 ath_reg_apply_world_flags(wiphy, request->initiator, reg);
409
410 break; 429 break;
411 } 430 }
412} 431}