mac80211: rtl8xxxu: sync with linux-next 20240229
[openwrt/staging/mans0n.git] / package / kernel / mac80211 / patches / rtl / 002-02-v6.9-wifi-rtl8xxxu-Fix-off-by-one-initial-RTS-rate.patch
1 From 80850ca041f2c7ee28fa5e47c5c1b106415f099f Mon Sep 17 00:00:00 2001
2 From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
3 Date: Tue, 2 Jan 2024 21:33:07 +0200
4 Subject: [PATCH 2/2] wifi: rtl8xxxu: Fix off by one initial RTS rate
5
6 rtl8xxxu_set_basic_rates() sets the wrong initial RTS rate. It sets the
7 next higher rate than the one it should set, e.g. 36M instead of 24M.
8
9 The while loop was supposed to find the index of the most significant
10 bit which is 1, but it was copied incorrectly from the vendor driver.
11 Use __fls() instead.
12
13 Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
14 Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
15 Signed-off-by: Kalle Valo <kvalo@kernel.org>
16 Link: https://msgid.link/761e6836-6cd6-4930-91b6-0446834655c5@gmail.com
17 ---
18 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 +++----
19 1 file changed, 3 insertions(+), 4 deletions(-)
20
21 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
22 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
23 @@ -4870,10 +4870,9 @@ static void rtl8xxxu_set_basic_rates(str
24
25 dev_dbg(&priv->udev->dev, "%s: rates %08x\n", __func__, rate_cfg);
26
27 - while (rate_cfg) {
28 - rate_cfg = (rate_cfg >> 1);
29 - rate_idx++;
30 - }
31 + if (rate_cfg)
32 + rate_idx = __fls(rate_cfg);
33 +
34 rtl8xxxu_write8(priv, REG_INIRTS_RATE_SEL, rate_idx);
35 }
36