ath9k: merge a regulatory handling fix
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 337-ath-use-CTL-region-from-cfg80211-if-unset-in-EEPROM.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Wed, 22 Oct 2014 15:21:22 +0200
3 Subject: [PATCH] ath: use CTL region from cfg80211 if unset in EEPROM
4
5 Many AP devices do not have the proper regulatory domain programmed in
6 EEPROM. Instead they expect the software to set the appropriate region.
7 For these devices, the country code defaults to US, and the driver uses
8 the US CTL tables as well.
9 On devices bought in Europe this can lead to tx power being set too high
10 on the band edges, even if the cfg80211 regdomain is set correctly.
11 Fix this issue by taking into account the DFS region, but only when the
12 EEPROM regdomain is set to default.
13
14 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
15 ---
16
17 --- a/drivers/net/wireless/ath/ath.h
18 +++ b/drivers/net/wireless/ath/ath.h
19 @@ -80,6 +80,7 @@ struct reg_dmn_pair_mapping {
20
21 struct ath_regulatory {
22 char alpha2[2];
23 + enum nl80211_dfs_regions region;
24 u16 country_code;
25 u16 max_power_level;
26 u16 current_rd;
27 --- a/drivers/net/wireless/ath/regd.c
28 +++ b/drivers/net/wireless/ath/regd.c
29 @@ -515,6 +515,7 @@ void ath_reg_notifier_apply(struct wiphy
30 if (!request)
31 return;
32
33 + reg->region = request->dfs_region;
34 switch (request->initiator) {
35 case NL80211_REGDOM_SET_BY_CORE:
36 /*
37 @@ -779,6 +780,19 @@ u32 ath_regd_get_band_ctl(struct ath_reg
38 return SD_NO_CTL;
39 }
40
41 + if (ath_regd_get_eepromRD(reg) == CTRY_DEFAULT) {
42 + switch (reg->region) {
43 + case NL80211_DFS_FCC:
44 + return CTL_FCC;
45 + case NL80211_DFS_ETSI:
46 + return CTL_ETSI;
47 + case NL80211_DFS_JP:
48 + return CTL_MKK;
49 + default:
50 + break;
51 + }
52 + }
53 +
54 switch (band) {
55 case IEEE80211_BAND_2GHZ:
56 return reg->regpair->reg_2ghz_ctl;