aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/brcm80211/brcmsmac/channel.c
diff options
context:
space:
mode:
authorArend van Spriel <arend@broadcom.com>2012-04-11 05:52:50 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-04-13 14:32:53 -0400
commit94a2ca311cf4154c566cf5c49b88c13cd4cdce73 (patch)
tree506f9d7a51ac46c745cbd62cac35990de2dc17eb /drivers/net/wireless/brcm80211/brcmsmac/channel.c
parent6b8da423315b5ea7573c8c3a3925941b9a1c3932 (diff)
brcm80211: smac: only provide valid regulatory hint
The driver provides a regulatory hint to cfg80211 as obtained from the SPROM. Mostly, this will be a two-letter ISO country code. However, it may obtain special country code similar to the world regulatory domain as used in cfg80211. This patch avoids setting these special codes as the hint is lost to cfg80211. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Brett Rudley <brudley@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmsmac/channel.c')
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/channel.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
index 55e9f45fce22..0efe88e25a9a 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
@@ -628,6 +628,40 @@ brcms_c_country_aggregate_map(struct brcms_cm_info *wlc_cm, const char *ccode,
628 return false; 628 return false;
629} 629}
630 630
631/*
632 * Indicates whether the country provided is valid to pass
633 * to cfg80211 or not.
634 *
635 * returns true if valid; false if not.
636 */
637static bool brcms_c_country_valid(const char *ccode)
638{
639 /*
640 * only allow ascii alpha uppercase for the first 2
641 * chars.
642 */
643 if (!((0x80 & ccode[0]) == 0 && ccode[0] >= 0x41 && ccode[0] <= 0x5A &&
644 (0x80 & ccode[1]) == 0 && ccode[1] >= 0x41 && ccode[1] <= 0x5A &&
645 ccode[2] == '\0'))
646 return false;
647
648 /*
649 * do not match ISO 3166-1 user assigned country codes
650 * that may be in the driver table
651 */
652 if (!strcmp("AA", ccode) || /* AA */
653 !strcmp("ZZ", ccode) || /* ZZ */
654 ccode[0] == 'X' || /* XA - XZ */
655 (ccode[0] == 'Q' && /* QM - QZ */
656 (ccode[1] >= 'M' && ccode[1] <= 'Z')))
657 return false;
658
659 if (!strcmp("NA", ccode))
660 return false;
661
662 return true;
663}
664
631/* Lookup a country info structure from a null terminated country 665/* Lookup a country info structure from a null terminated country
632 * abbreviation and regrev directly with no translation. 666 * abbreviation and regrev directly with no translation.
633 */ 667 */
@@ -1089,7 +1123,7 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc)
1089 1123
1090 /* store the country code for passing up as a regulatory hint */ 1124 /* store the country code for passing up as a regulatory hint */
1091 ccode = getvar(wlc->hw->sih, BRCMS_SROM_CCODE); 1125 ccode = getvar(wlc->hw->sih, BRCMS_SROM_CCODE);
1092 if (ccode) 1126 if (ccode && brcms_c_country_valid(ccode))
1093 strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1); 1127 strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1);
1094 1128
1095 /* 1129 /*