]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211: don't use cfg80211_chandef_create() for default chandef
authorLachlan Hodges <lachlan.hodges@morsemicro.com>
Thu, 12 Mar 2026 04:58:02 +0000 (15:58 +1100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 13 Mar 2026 06:14:26 +0000 (07:14 +0100)
cfg80211_chandef_create() is called universally to create the
default chandef during hw registration, however it only really
makes sense to be used for 2GHz, 5GHz, and 6GHz (and by extension
the 'LC' band) as it relies on the channel type which is only
relevant to those specific bands.

To reduce some confusion, create a generic helper for creating the
default chandef that makes sense for all supported bands.

Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
Link: https://patch.msgid.link/20260312045804.362974-2-lachlan.hodges@morsemicro.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/main.c

index b0451f1c8e79e94e146a55cef590c06f8ef7fc15..d1bb6353908dbcb9257c39e1ed73ef49c9d17491 100644 (file)
@@ -1118,6 +1118,19 @@ ieee80211_ifcomb_check(const struct ieee80211_iface_combination *c, int n_comb)
        return true;
 }
 
+static void ieee80211_create_default_chandef(struct cfg80211_chan_def *chandef,
+                                            struct ieee80211_channel *chan)
+{
+       *chandef = (struct cfg80211_chan_def) {
+               .chan = chan,
+               .width = chan->band == NL80211_BAND_S1GHZ ?
+                                NL80211_CHAN_WIDTH_1 :
+                                NL80211_CHAN_WIDTH_20_NOHT,
+               .center_freq1 = chan->center_freq,
+               .freq1_offset = chan->freq_offset,
+       };
+}
+
 int ieee80211_register_hw(struct ieee80211_hw *hw)
 {
        struct ieee80211_local *local = hw_to_local(hw);
@@ -1261,9 +1274,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
                        /* if none found then use the first anyway */
                        if (i == sband->n_channels)
                                i = 0;
-                       cfg80211_chandef_create(&dflt_chandef,
-                                               &sband->channels[i],
-                                               NL80211_CHAN_NO_HT);
+                       ieee80211_create_default_chandef(&dflt_chandef,
+                                                        &sband->channels[i]);
                        /* init channel we're on */
                        local->monitor_chanreq.oper = dflt_chandef;
                        if (local->emulate_chanctx) {