*
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2013-2014 Intel Mobile Communications GmbH
- * Copyright 2018-2025 Intel Corporation
+ * Copyright 2018-2026 Intel Corporation
*/
#include <linux/export.h>
return (center - bw / 2 - 5945) % step == 0;
}
+static bool
+cfg80211_chandef_valid_control_freq(const struct cfg80211_chan_def *chandef,
+ u32 control_freq)
+{
+ switch (chandef->width) {
+ case NL80211_CHAN_WIDTH_5:
+ case NL80211_CHAN_WIDTH_10:
+ case NL80211_CHAN_WIDTH_20:
+ case NL80211_CHAN_WIDTH_20_NOHT:
+ case NL80211_CHAN_WIDTH_1:
+ case NL80211_CHAN_WIDTH_2:
+ case NL80211_CHAN_WIDTH_4:
+ case NL80211_CHAN_WIDTH_8:
+ case NL80211_CHAN_WIDTH_16:
+ /* checked separately */
+ break;
+ case NL80211_CHAN_WIDTH_320:
+ if (chandef->center_freq1 == control_freq + 150 ||
+ chandef->center_freq1 == control_freq + 130 ||
+ chandef->center_freq1 == control_freq + 110 ||
+ chandef->center_freq1 == control_freq + 90 ||
+ chandef->center_freq1 == control_freq - 90 ||
+ chandef->center_freq1 == control_freq - 110 ||
+ chandef->center_freq1 == control_freq - 130 ||
+ chandef->center_freq1 == control_freq - 150)
+ break;
+ fallthrough;
+ case NL80211_CHAN_WIDTH_160:
+ if (chandef->center_freq1 == control_freq + 70 ||
+ chandef->center_freq1 == control_freq + 50 ||
+ chandef->center_freq1 == control_freq - 50 ||
+ chandef->center_freq1 == control_freq - 70)
+ break;
+ fallthrough;
+ case NL80211_CHAN_WIDTH_80P80:
+ case NL80211_CHAN_WIDTH_80:
+ if (chandef->center_freq1 == control_freq + 30 ||
+ chandef->center_freq1 == control_freq - 30)
+ break;
+ fallthrough;
+ case NL80211_CHAN_WIDTH_40:
+ if (chandef->center_freq1 == control_freq + 10 ||
+ chandef->center_freq1 == control_freq - 10)
+ break;
+ fallthrough;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef)
{
u32 control_freq, control_freq_khz, start_khz, end_khz;
break;
}
- switch (chandef->width) {
- case NL80211_CHAN_WIDTH_5:
- case NL80211_CHAN_WIDTH_10:
- case NL80211_CHAN_WIDTH_20:
- case NL80211_CHAN_WIDTH_20_NOHT:
- case NL80211_CHAN_WIDTH_1:
- case NL80211_CHAN_WIDTH_2:
- case NL80211_CHAN_WIDTH_4:
- case NL80211_CHAN_WIDTH_8:
- case NL80211_CHAN_WIDTH_16:
- /* all checked above */
- break;
- case NL80211_CHAN_WIDTH_320:
- if (chandef->center_freq1 == control_freq + 150 ||
- chandef->center_freq1 == control_freq + 130 ||
- chandef->center_freq1 == control_freq + 110 ||
- chandef->center_freq1 == control_freq + 90 ||
- chandef->center_freq1 == control_freq - 90 ||
- chandef->center_freq1 == control_freq - 110 ||
- chandef->center_freq1 == control_freq - 130 ||
- chandef->center_freq1 == control_freq - 150)
- break;
- fallthrough;
- case NL80211_CHAN_WIDTH_160:
- if (chandef->center_freq1 == control_freq + 70 ||
- chandef->center_freq1 == control_freq + 50 ||
- chandef->center_freq1 == control_freq - 50 ||
- chandef->center_freq1 == control_freq - 70)
- break;
- fallthrough;
- case NL80211_CHAN_WIDTH_80P80:
- case NL80211_CHAN_WIDTH_80:
- if (chandef->center_freq1 == control_freq + 30 ||
- chandef->center_freq1 == control_freq - 30)
- break;
- fallthrough;
- case NL80211_CHAN_WIDTH_40:
- if (chandef->center_freq1 == control_freq + 10 ||
- chandef->center_freq1 == control_freq - 10)
- break;
- fallthrough;
- default:
+ if (!cfg80211_chandef_valid_control_freq(chandef, control_freq))
return false;
- }
if (!cfg80211_valid_center_freq(chandef->center_freq1, chandef->width))
return false;