Skip to content

Commit c1ee94b

Browse files
Bitterblue SmithSasha Levin
authored andcommitted
wifi: rtw88: Don't use static local variable in rtw8822b_set_tx_power_index_by_rate
[ Upstream commit 00451eb ] 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 rtw8822b_set_tx_power_index_by_rate(). Signed-off-by: Bitterblue Smith <[email protected]> Acked-by: Ping-Ke Shih <[email protected]> Signed-off-by: Ping-Ke Shih <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 692a820 commit c1ee94b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/net/wireless/realtek/rtw88/rtw8822b.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,36 +976,38 @@ static void rtw8822b_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
976976
}
977977

978978
static void
979-
rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
979+
rtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path,
980+
u8 rs, u32 *phy_pwr_idx)
980981
{
981982
struct rtw_hal *hal = &rtwdev->hal;
982983
static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
983-
static u32 phy_pwr_idx;
984984
u8 rate, rate_idx, pwr_index, shift;
985985
int j;
986986

987987
for (j = 0; j < rtw_rate_size[rs]; j++) {
988988
rate = rtw_rate_section[rs][j];
989989
pwr_index = hal->tx_pwr_tbl[path][rate];
990990
shift = rate & 0x3;
991-
phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
991+
*phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
992992
if (shift == 0x3) {
993993
rate_idx = rate & 0xfc;
994994
rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
995-
phy_pwr_idx);
996-
phy_pwr_idx = 0;
995+
*phy_pwr_idx);
996+
*phy_pwr_idx = 0;
997997
}
998998
}
999999
}
10001000

10011001
static void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev)
10021002
{
10031003
struct rtw_hal *hal = &rtwdev->hal;
1004+
u32 phy_pwr_idx = 0;
10041005
int rs, path;
10051006

10061007
for (path = 0; path < hal->rf_path_num; path++) {
10071008
for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++)
1008-
rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs);
1009+
rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs,
1010+
&phy_pwr_idx);
10091011
}
10101012
}
10111013

0 commit comments

Comments
 (0)