wifi: mac80211: fix center freq calculation in ieee80211_chandef_downgrade
authorMeiChia Chiu <meichia.chiu@mediatek.com>
Fri, 8 Jul 2022 09:58:23 +0000 (17:58 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 11 Jul 2022 08:21:04 +0000 (10:21 +0200)
When mac80211 downgrades working bandwidth, the
center_freq and center_freq1 need to be recalculated.
There is a typo in the case of downgrading bandwidth from
320MHz to 160MHz which would cause a wrong frequency value.

Reviewed-by: Money Wang <Money.Wang@mediatek.com>
Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
Link: https://lore.kernel.org/r/20220708095823.12959-1-MeiChia.Chiu@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/util.c

index bccc3a3..bcb4aa7 100644 (file)
@@ -4075,7 +4075,7 @@ u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c)
                /* n_P20 */
                tmp = (150 + c->chan->center_freq - c->center_freq1) / 20;
                /* n_P160 */
-               tmp /= 80;
+               tmp /= 8;
                c->center_freq1 = c->center_freq1 - 80 + 160 * tmp;
                c->width = NL80211_CHAN_WIDTH_160;
                ret = IEEE80211_STA_DISABLE_320MHZ;