mac80211: update to backports-4.14-rc2
[openwrt/staging/lynxis.git] / package / kernel / mac80211 / patches / 402-ath_regd_optional.patch
1 --- a/drivers/net/wireless/ath/regd.c
2 +++ b/drivers/net/wireless/ath/regd.c
3 @@ -24,6 +24,7 @@
4 #include "regd_common.h"
5
6 static int __ath_regd_init(struct ath_regulatory *reg);
7 +static struct reg_dmn_pair_mapping *ath_get_regpair(int regdmn);
8
9 /*
10 * This is a set of common rules used by our world regulatory domains.
11 @@ -116,6 +117,9 @@ static const struct ieee80211_regdomain
12
13 static bool dynamic_country_user_possible(struct ath_regulatory *reg)
14 {
15 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
16 + return true;
17 +
18 if (IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_CERT_TESTING))
19 return true;
20
21 @@ -188,6 +192,8 @@ static bool dynamic_country_user_possibl
22
23 static bool ath_reg_dyn_country_user_allow(struct ath_regulatory *reg)
24 {
25 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
26 + return true;
27 if (!IS_ENABLED(CPTCFG_ATH_REG_DYNAMIC_USER_REG_HINTS))
28 return false;
29 if (!dynamic_country_user_possible(reg))
30 @@ -345,6 +351,9 @@ ath_reg_apply_beaconing_flags(struct wip
31 struct ieee80211_channel *ch;
32 unsigned int i;
33
34 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
35 + return;
36 +
37 for (band = 0; band < NUM_NL80211_BANDS; band++) {
38 if (!wiphy->bands[band])
39 continue;
40 @@ -378,6 +387,9 @@ ath_reg_apply_ir_flags(struct wiphy *wip
41 {
42 struct ieee80211_supported_band *sband;
43
44 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
45 + return;
46 +
47 sband = wiphy->bands[NL80211_BAND_2GHZ];
48 if (!sband)
49 return;
50 @@ -407,6 +419,9 @@ static void ath_reg_apply_radar_flags(st
51 struct ieee80211_channel *ch;
52 unsigned int i;
53
54 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
55 + return;
56 +
57 if (!wiphy->bands[NL80211_BAND_5GHZ])
58 return;
59
60 @@ -544,6 +559,11 @@ void ath_reg_notifier_apply(struct wiphy
61 ath_reg_dyn_country(wiphy, reg, request);
62 break;
63 }
64 +
65 + /* Prevent broken CTLs from being applied */
66 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD) &&
67 + reg->regpair != common->reg_world_copy.regpair)
68 + reg->regpair = ath_get_regpair(WOR0_WORLD);
69 }
70 EXPORT_SYMBOL(ath_reg_notifier_apply);
71
72 @@ -639,6 +659,10 @@ ath_regd_init_wiphy(struct ath_regulator
73 const struct ieee80211_regdomain *regd;
74
75 wiphy->reg_notifier = reg_notifier;
76 +
77 + if (IS_ENABLED(CPTCFG_ATH_USER_REGD))
78 + return 0;
79 +
80 wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
81 REGULATORY_CUSTOM_REG;
82
83 @@ -767,10 +791,7 @@ ath_regd_init(struct ath_regulatory *reg
84 if (r)
85 return r;
86
87 - if (ath_is_world_regd(reg))
88 - memcpy(&common->reg_world_copy, reg,
89 - sizeof(struct ath_regulatory));
90 -
91 + memcpy(&common->reg_world_copy, reg, sizeof(struct ath_regulatory));
92 ath_regd_init_wiphy(reg, wiphy, reg_notifier);
93
94 return 0;
95 --- a/drivers/net/wireless/ath/Kconfig
96 +++ b/drivers/net/wireless/ath/Kconfig
97 @@ -23,6 +23,9 @@ config WLAN_VENDOR_ATH
98
99 if WLAN_VENDOR_ATH
100
101 +config ATH_USER_REGD
102 + bool "Do not enforce EEPROM regulatory restrictions"
103 +
104 config ATH_DEBUG
105 bool "Atheros wireless debugging"
106 ---help---
107 --- a/local-symbols
108 +++ b/local-symbols
109 @@ -82,6 +82,7 @@ ADM8211=
110 ATH_COMMON=
111 WLAN_VENDOR_ATH=
112 ATH_DEBUG=
113 +ATH_USER_REGD=
114 ATH_TRACEPOINTS=
115 ATH_REG_DYNAMIC_USER_REG_HINTS=
116 ATH_REG_DYNAMIC_USER_CERT_TESTING=