ath10k-ct: depend on kmod-hwmon-core, it gets used when CONFIG_THERMAL is set
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 347-0001-cfg80211-move-function-checking-range-fit-to-util.c.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Wed, 4 Jan 2017 18:58:30 +0100
3 Subject: [PATCH] cfg80211: move function checking range fit to util.c
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 It is needed for another cfg80211 helper that will be out of reg.c so
9 move it to common util.c file and make it non-static.
10
11 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
12 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 ---
14
15 --- a/net/wireless/core.h
16 +++ b/net/wireless/core.h
17 @@ -429,6 +429,9 @@ int cfg80211_change_iface(struct cfg8021
18 void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
19 void cfg80211_process_wdev_events(struct wireless_dev *wdev);
20
21 +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
22 + u32 center_freq_khz, u32 bw_khz);
23 +
24 /**
25 * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable
26 * @wiphy: the wiphy to validate against
27 --- a/net/wireless/reg.c
28 +++ b/net/wireless/reg.c
29 @@ -748,21 +748,6 @@ static bool is_valid_rd(const struct iee
30 return true;
31 }
32
33 -static bool reg_does_bw_fit(const struct ieee80211_freq_range *freq_range,
34 - u32 center_freq_khz, u32 bw_khz)
35 -{
36 - u32 start_freq_khz, end_freq_khz;
37 -
38 - start_freq_khz = center_freq_khz - (bw_khz/2);
39 - end_freq_khz = center_freq_khz + (bw_khz/2);
40 -
41 - if (start_freq_khz >= freq_range->start_freq_khz &&
42 - end_freq_khz <= freq_range->end_freq_khz)
43 - return true;
44 -
45 - return false;
46 -}
47 -
48 /**
49 * freq_in_rule_band - tells us if a frequency is in a frequency band
50 * @freq_range: frequency rule we want to query
51 @@ -1070,7 +1055,7 @@ freq_reg_info_regd(u32 center_freq,
52 if (!band_rule_found)
53 band_rule_found = freq_in_rule_band(fr, center_freq);
54
55 - bw_fits = reg_does_bw_fit(fr, center_freq, bw);
56 + bw_fits = cfg80211_does_bw_fit_range(fr, center_freq, bw);
57
58 if (band_rule_found && bw_fits)
59 return rr;
60 @@ -1138,11 +1123,13 @@ static uint32_t reg_rule_to_chan_bw_flag
61 max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
62
63 /* If we get a reg_rule we can assume that at least 5Mhz fit */
64 - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
65 - MHZ_TO_KHZ(10)))
66 + if (!cfg80211_does_bw_fit_range(freq_range,
67 + MHZ_TO_KHZ(chan->center_freq),
68 + MHZ_TO_KHZ(10)))
69 bw_flags |= IEEE80211_CHAN_NO_10MHZ;
70 - if (!reg_does_bw_fit(freq_range, MHZ_TO_KHZ(chan->center_freq),
71 - MHZ_TO_KHZ(20)))
72 + if (!cfg80211_does_bw_fit_range(freq_range,
73 + MHZ_TO_KHZ(chan->center_freq),
74 + MHZ_TO_KHZ(20)))
75 bw_flags |= IEEE80211_CHAN_NO_20MHZ;
76
77 if (max_bandwidth_khz < MHZ_TO_KHZ(10))
78 --- a/net/wireless/util.c
79 +++ b/net/wireless/util.c
80 @@ -1788,6 +1788,21 @@ void cfg80211_free_nan_func(struct cfg80
81 }
82 EXPORT_SYMBOL(cfg80211_free_nan_func);
83
84 +bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
85 + u32 center_freq_khz, u32 bw_khz)
86 +{
87 + u32 start_freq_khz, end_freq_khz;
88 +
89 + start_freq_khz = center_freq_khz - (bw_khz / 2);
90 + end_freq_khz = center_freq_khz + (bw_khz / 2);
91 +
92 + if (start_freq_khz >= freq_range->start_freq_khz &&
93 + end_freq_khz <= freq_range->end_freq_khz)
94 + return true;
95 +
96 + return false;
97 +}
98 +
99 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
100 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
101 const unsigned char rfc1042_header[] __aligned(2) =