]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw88: Don't use static local variable in rtw8821c_set_tx_power_index_by_rate
authorBitterblue Smith <rtl8821cerfe2@gmail.com>
Sun, 26 Jan 2025 14:04:21 +0000 (16:04 +0200)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 3 Feb 2025 02:41:10 +0000 (10:41 +0800)
Some users want to plug two identical USB devices at the same time.
This static variable could theoretically cause them to use incorrect
TX power values.

Move the variable to the caller and pass a pointer to it to
rtw8821c_set_tx_power_index_by_rate().

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/fe42858c-9b9f-4f03-9aaa-737472c2cd90@gmail.com
drivers/net/wireless/realtek/rtw88/rtw8821c.c

index eb7e34c545d0c82541f8629146da764c589dbb9a..cc152248407c7cb296203f7161faf262d65a18ed 100644 (file)
@@ -680,11 +680,11 @@ static void query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
 }
 
 static void
-rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
+rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path,
+                                   u8 rs, u32 *phy_pwr_idx)
 {
        struct rtw_hal *hal = &rtwdev->hal;
        static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
-       static u32 phy_pwr_idx;
        u8 rate, rate_idx, pwr_index, shift;
        int j;
 
@@ -692,12 +692,12 @@ rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
                rate = rtw_rate_section[rs][j];
                pwr_index = hal->tx_pwr_tbl[path][rate];
                shift = rate & 0x3;
-               phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
+               *phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
                if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) {
                        rate_idx = rate & 0xfc;
                        rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
-                                   phy_pwr_idx);
-                       phy_pwr_idx = 0;
+                                   *phy_pwr_idx);
+                       *phy_pwr_idx = 0;
                }
        }
 }
@@ -705,6 +705,7 @@ rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
 static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
 {
        struct rtw_hal *hal = &rtwdev->hal;
+       u32 phy_pwr_idx = 0;
        int rs, path;
 
        for (path = 0; path < hal->rf_path_num; path++) {
@@ -712,7 +713,8 @@ static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
                        if (rs == RTW_RATE_SECTION_HT_2S ||
                            rs == RTW_RATE_SECTION_VHT_2S)
                                continue;
-                       rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs);
+                       rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs,
+                                                           &phy_pwr_idx);
                }
        }
 }