diff options
Diffstat (limited to 'drivers/net/wireless/ath/regd.c')
-rw-r--r-- | drivers/net/wireless/ath/regd.c | 140 |
1 files changed, 122 insertions, 18 deletions
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index 7d077c752dd5..c00687e05688 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c | |||
@@ -356,14 +356,131 @@ static u16 ath_regd_find_country_by_name(char *alpha2) | |||
356 | return -1; | 356 | return -1; |
357 | } | 357 | } |
358 | 358 | ||
359 | static 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 | |||
382 | static 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 | |||
395 | static bool dynamic_country_user_possible(struct ath_regulatory *reg) | ||
396 | { | ||
397 | if (config_enabled(CONFIG_ATH_REG_DYNAMIC_USER_CERT_TESTING)) | ||
398 | return true; | ||
399 | |||
400 | switch (reg->country_code) { | ||
401 | case CTRY_UNITED_STATES: | ||
402 | case CTRY_JAPAN1: | ||
403 | case CTRY_JAPAN2: | ||
404 | case CTRY_JAPAN3: | ||
405 | case CTRY_JAPAN4: | ||
406 | case CTRY_JAPAN5: | ||
407 | case CTRY_JAPAN6: | ||
408 | case CTRY_JAPAN7: | ||
409 | case CTRY_JAPAN8: | ||
410 | case CTRY_JAPAN9: | ||
411 | case CTRY_JAPAN10: | ||
412 | case CTRY_JAPAN11: | ||
413 | case CTRY_JAPAN12: | ||
414 | case CTRY_JAPAN13: | ||
415 | case CTRY_JAPAN14: | ||
416 | case CTRY_JAPAN15: | ||
417 | case CTRY_JAPAN16: | ||
418 | case CTRY_JAPAN17: | ||
419 | case CTRY_JAPAN18: | ||
420 | case CTRY_JAPAN19: | ||
421 | case CTRY_JAPAN20: | ||
422 | case CTRY_JAPAN21: | ||
423 | case CTRY_JAPAN22: | ||
424 | case CTRY_JAPAN23: | ||
425 | case CTRY_JAPAN24: | ||
426 | case CTRY_JAPAN25: | ||
427 | case CTRY_JAPAN26: | ||
428 | case CTRY_JAPAN27: | ||
429 | case CTRY_JAPAN28: | ||
430 | case CTRY_JAPAN29: | ||
431 | case CTRY_JAPAN30: | ||
432 | case CTRY_JAPAN31: | ||
433 | case CTRY_JAPAN32: | ||
434 | case CTRY_JAPAN33: | ||
435 | case CTRY_JAPAN34: | ||
436 | case CTRY_JAPAN35: | ||
437 | case CTRY_JAPAN36: | ||
438 | case CTRY_JAPAN37: | ||
439 | case CTRY_JAPAN38: | ||
440 | case CTRY_JAPAN39: | ||
441 | case CTRY_JAPAN40: | ||
442 | case CTRY_JAPAN41: | ||
443 | case CTRY_JAPAN42: | ||
444 | case CTRY_JAPAN43: | ||
445 | case CTRY_JAPAN44: | ||
446 | case CTRY_JAPAN45: | ||
447 | case CTRY_JAPAN46: | ||
448 | case CTRY_JAPAN47: | ||
449 | case CTRY_JAPAN48: | ||
450 | case CTRY_JAPAN49: | ||
451 | case CTRY_JAPAN50: | ||
452 | case CTRY_JAPAN51: | ||
453 | case CTRY_JAPAN52: | ||
454 | case CTRY_JAPAN53: | ||
455 | case CTRY_JAPAN54: | ||
456 | case CTRY_JAPAN55: | ||
457 | case CTRY_JAPAN56: | ||
458 | case CTRY_JAPAN57: | ||
459 | case CTRY_JAPAN58: | ||
460 | case CTRY_JAPAN59: | ||
461 | return false; | ||
462 | } | ||
463 | |||
464 | return true; | ||
465 | } | ||
466 | |||
467 | static void ath_reg_dyn_country_user(struct wiphy *wiphy, | ||
468 | struct ath_regulatory *reg, | ||
469 | struct regulatory_request *request) | ||
470 | { | ||
471 | if (!config_enabled(CONFIG_ATH_REG_DYNAMIC_USER_REG_HINTS)) | ||
472 | return; | ||
473 | if (!dynamic_country_user_possible(reg)) | ||
474 | return; | ||
475 | ath_reg_dyn_country(wiphy, reg, request); | ||
476 | } | ||
477 | |||
359 | void ath_reg_notifier_apply(struct wiphy *wiphy, | 478 | void ath_reg_notifier_apply(struct wiphy *wiphy, |
360 | struct regulatory_request *request, | 479 | struct regulatory_request *request, |
361 | struct ath_regulatory *reg) | 480 | struct ath_regulatory *reg) |
362 | { | 481 | { |
363 | struct ath_common *common = container_of(reg, struct ath_common, | 482 | struct ath_common *common = container_of(reg, struct ath_common, |
364 | regulatory); | 483 | regulatory); |
365 | u16 country_code; | ||
366 | |||
367 | /* We always apply this */ | 484 | /* We always apply this */ |
368 | ath_reg_apply_radar_flags(wiphy); | 485 | ath_reg_apply_radar_flags(wiphy); |
369 | 486 | ||
@@ -388,25 +505,12 @@ void ath_reg_notifier_apply(struct wiphy *wiphy, | |||
388 | sizeof(struct ath_regulatory)); | 505 | sizeof(struct ath_regulatory)); |
389 | break; | 506 | break; |
390 | case NL80211_REGDOM_SET_BY_DRIVER: | 507 | case NL80211_REGDOM_SET_BY_DRIVER: |
508 | break; | ||
391 | case NL80211_REGDOM_SET_BY_USER: | 509 | case NL80211_REGDOM_SET_BY_USER: |
510 | ath_reg_dyn_country_user(wiphy, reg, request); | ||
392 | break; | 511 | break; |
393 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: | 512 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: |
394 | if (!ath_is_world_regd(reg)) | 513 | 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; | 514 | break; |
411 | } | 515 | } |
412 | } | 516 | } |