aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2013-10-21 13:14:48 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-12-05 15:40:10 -0500
commitbc0aa0691806dc30cf1a69fe50ae90cf8f752977 (patch)
treebc0556f1a74b604b53e46af804c83c12982649b8 /drivers/net
parentd44040de6a991999b466adefc7588e479680b98d (diff)
ath: clean up ath_reg_apply_active_scan_flags()
The routine ath_reg_apply_active_scan_flags() can be a bit hard to read, this cleans it up by adding helpers for the two cases of clearing IR flags or adding them. This approach also makes no assumptions on the index of channels 12 and 13 so it should be portable accross different drivers. Cc: smihir@qti.qualcomm.com Cc: tushnimb@qca.qualcomm.com Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/regd.c101
1 files changed, 63 insertions, 38 deletions
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 3d596e25ba82..f4bb9295b6c6 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -178,6 +178,47 @@ static bool ath_is_radar_freq(u16 center_freq)
178 return (center_freq >= 5260 && center_freq <= 5700); 178 return (center_freq >= 5260 && center_freq <= 5700);
179} 179}
180 180
181static void ath_force_clear_no_ir_chan(struct wiphy *wiphy,
182 struct ieee80211_channel *ch)
183{
184 const struct ieee80211_reg_rule *reg_rule;
185
186 reg_rule = freq_reg_info(wiphy, ch->center_freq);
187 if (IS_ERR(reg_rule))
188 return;
189
190 if (!(reg_rule->flags & NL80211_RRF_NO_IR))
191 if (ch->flags & IEEE80211_CHAN_NO_IR)
192 ch->flags &= ~IEEE80211_CHAN_NO_IR;
193}
194
195static void ath_force_clear_no_ir_freq(struct wiphy *wiphy, u16 center_freq)
196{
197 struct ieee80211_channel *ch;
198
199 ch = ieee80211_get_channel(wiphy, center_freq);
200 if (!ch)
201 return;
202
203 ath_force_clear_no_ir_chan(wiphy, ch);
204}
205
206static void ath_force_no_ir_chan(struct ieee80211_channel *ch)
207{
208 ch->flags |= IEEE80211_CHAN_NO_IR;
209}
210
211static void ath_force_no_ir_freq(struct wiphy *wiphy, u16 center_freq)
212{
213 struct ieee80211_channel *ch;
214
215 ch = ieee80211_get_channel(wiphy, center_freq);
216 if (!ch)
217 return;
218
219 ath_force_no_ir_chan(ch);
220}
221
181/* 222/*
182 * N.B: These exception rules do not apply radar freqs. 223 * N.B: These exception rules do not apply radar freqs.
183 * 224 *
@@ -235,54 +276,38 @@ ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
235 276
236} 277}
237 278
238/* Allows active scan scan on Ch 12 and 13 */ 279/**
280 * ath_reg_apply_active_scan_flags()
281 * @wiphy: the wiphy to use
282 * @initiator: the regulatory hint initiator
283 *
284 * If no country IE has been received always enable passive scan
285 * and no-ibss on these channels. This is only done for specific
286 * regulatory SKUs.
287 *
288 * If a country IE has been received check its rule for this
289 * channel first before enabling active scan. The passive scan
290 * would have been enforced by the initial processing of our
291 * custom regulatory domain.
292 */
239static void 293static void
240ath_reg_apply_active_scan_flags(struct wiphy *wiphy, 294ath_reg_apply_active_scan_flags(struct wiphy *wiphy,
241 enum nl80211_reg_initiator initiator) 295 enum nl80211_reg_initiator initiator)
242{ 296{
243 struct ieee80211_supported_band *sband; 297 struct ieee80211_supported_band *sband;
244 struct ieee80211_channel *ch;
245 const struct ieee80211_reg_rule *reg_rule;
246 298
247 sband = wiphy->bands[IEEE80211_BAND_2GHZ]; 299 sband = wiphy->bands[IEEE80211_BAND_2GHZ];
248 if (!sband) 300 if (!sband)
249 return; 301 return;
250 302
251 /* 303 switch(initiator) {
252 * If no country IE has been received always enable passive scan 304 case NL80211_REGDOM_SET_BY_COUNTRY_IE:
253 * and no-ibss on these channels. This is only done for specific 305 ath_force_clear_no_ir_freq(wiphy, 2467);
254 * regulatory SKUs. 306 ath_force_clear_no_ir_freq(wiphy, 2472);
255 */ 307 break;
256 if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) { 308 default:
257 ch = &sband->channels[11]; /* CH 12 */ 309 ath_force_no_ir_freq(wiphy, 2467);
258 ch->flags |= IEEE80211_CHAN_NO_IR; 310 ath_force_no_ir_freq(wiphy, 2472);
259
260 ch = &sband->channels[12]; /* CH 13 */
261 ch->flags |= IEEE80211_CHAN_NO_IR;
262 return;
263 }
264
265 /*
266 * If a country IE has been received check its rule for this
267 * channel first before enabling active scan. The passive scan
268 * would have been enforced by the initial processing of our
269 * custom regulatory domain.
270 */
271
272 ch = &sband->channels[11]; /* CH 12 */
273 reg_rule = freq_reg_info(wiphy, ch->center_freq);
274 if (!IS_ERR(reg_rule)) {
275 if (!(reg_rule->flags & NL80211_RRF_NO_IR))
276 if (ch->flags & IEEE80211_CHAN_NO_IR)
277 ch->flags &= ~IEEE80211_CHAN_NO_IR;
278 }
279
280 ch = &sband->channels[12]; /* CH 13 */
281 reg_rule = freq_reg_info(wiphy, ch->center_freq);
282 if (!IS_ERR(reg_rule)) {
283 if (!(reg_rule->flags & NL80211_RRF_NO_IR))
284 if (ch->flags & IEEE80211_CHAN_NO_IR)
285 ch->flags &= ~IEEE80211_CHAN_NO_IR;
286 } 311 }
287} 312}
288 313