Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end
@ 2025-10-21 11:07 Lachlan Hodges
  2025-10-21 12:20 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Lachlan Hodges @ 2025-10-21 11:07 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, arien.judge, Lachlan Hodges

The frequencies returned by cfg80211_s1g_get_{start/end}_freq_khz()
for 1MHz chandefs are off by +-1000KHz. This prevents some 1MHz
channels from being used as the range returned is larger leading to
adjacent 1MHz channels being included in the validation process.
Channels on the band edge may be prevented from being used if any
of those extra channels are disabled / no primary etc. To fix return
the center frequency as 1MHz channels don't contain any subchannels.

Fixes: d0688dc2b172 ("wifi: cfg80211: correctly implement and validate S1G chandef")
Signed-off-by: Lachlan Hodges <lachlan.hodges@morsemicro.com>
---
 include/net/cfg80211.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 781624f5913a..a1e362e0054d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -10194,7 +10194,8 @@ cfg80211_s1g_get_start_freq_khz(const struct cfg80211_chan_def *chandef)
 	u32 bw_mhz = cfg80211_chandef_get_width(chandef);
 	u32 center_khz =
 		MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
-	return center_khz - bw_mhz * 500 + 500;
+
+	return (bw_mhz == 1) ? center_khz : center_khz - bw_mhz * 500 + 500;
 }
 
 /**
@@ -10209,7 +10210,8 @@ cfg80211_s1g_get_end_freq_khz(const struct cfg80211_chan_def *chandef)
 	u32 bw_mhz = cfg80211_chandef_get_width(chandef);
 	u32 center_khz =
 		MHZ_TO_KHZ(chandef->center_freq1) + chandef->freq1_offset;
-	return center_khz + bw_mhz * 500 - 500;
+
+	return (bw_mhz == 1) ? center_khz : center_khz + bw_mhz * 500 - 500;
 }
 
 /**
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-21 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 11:07 [PATCH wireless] wifi: cfg80211: return center freq for 1Mhz S1G chan start/end Lachlan Hodges
2025-10-21 12:20 ` Johannes Berg
2025-10-21 12:30   ` Lachlan Hodges

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox