ath: use CTL region from cfg80211 if unset in EEPROM
authorFelix Fietkau <nbd@openwrt.org>
Wed, 22 Oct 2014 13:27:53 +0000 (15:27 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 23 Oct 2014 18:02:06 +0000 (14:02 -0400)
Many AP devices do not have the proper regulatory domain programmed in
EEPROM. Instead they expect the software to set the appropriate region.
For these devices, the country code defaults to US, and the driver uses
the US CTL tables as well.
On devices bought in Europe this can lead to tx power being set too high
on the band edges, even if the cfg80211 regdomain is set correctly.
Fix this issue by taking into account the DFS region, but only when the
EEPROM regdomain is set to default.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath.h
drivers/net/wireless/ath/regd.c

index e5ba6faf32815173fa47fa81fd303082688202bd..86907e5ba6ca21a5e7e6d8ff8b6b20499e004cce 100644 (file)
@@ -80,6 +80,7 @@ struct reg_dmn_pair_mapping {
 
 struct ath_regulatory {
        char alpha2[2];
+       enum nl80211_dfs_regions region;
        u16 country_code;
        u16 max_power_level;
        u16 current_rd;
index 415393dfb6fc17b51d33f4d24e70c6700620d4b5..06ea6cc9e30a5e07c379116a8e1ec0996e3f189e 100644 (file)
@@ -515,6 +515,7 @@ void ath_reg_notifier_apply(struct wiphy *wiphy,
        if (!request)
                return;
 
+       reg->region = request->dfs_region;
        switch (request->initiator) {
        case NL80211_REGDOM_SET_BY_CORE:
                /*
@@ -779,6 +780,19 @@ u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
                return SD_NO_CTL;
        }
 
+       if (ath_regd_get_eepromRD(reg) == CTRY_DEFAULT) {
+               switch (reg->region) {
+               case NL80211_DFS_FCC:
+                       return CTL_FCC;
+               case NL80211_DFS_ETSI:
+                       return CTL_ETSI;
+               case NL80211_DFS_JP:
+                       return CTL_MKK;
+               default:
+                       break;
+               }
+       }
+
        switch (band) {
        case IEEE80211_BAND_2GHZ:
                return reg->regpair->reg_2ghz_ctl;