Skip to contentSkip to conversation

wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled

PATCH In review Bitterblue Smith 3 participants 5 messages Dec 8, 2022 – Dec 14, 2022 RTL8XXXU wireless driver (rtl8xxxu)

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled

Just because priv->pi_enabled is only one bit doesn't mean it works like a bool. The value assigned to it loses all bits except bit 0, so only assign 0 or 1 to it.

This affects the RTL8188FU, but fixing the assignment didn't make a difference for my device.

Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +1 -1
index 2c4f403ba68f..97e7ff7289fa 100644
@@ -1122,7 +1122,7 @@ static void rtl8188fu_phy_iqcalibrate(struct rtl8xxxu_priv *priv,
 
 	if (t == 0) {
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_HSSI_PARM1);
-		priv->pi_enabled = val32 & FPGA0_HSSI_PARM1_PI;
+		priv->pi_enabled = u32_get_bits(val32, FPGA0_HSSI_PARM1_PI);
 	}
 
 	/* save RF path */
Signature · 1 line
2.38.0
#1 lore raw

PATCH 2/2 wifi: rtl8xxxu: Fix assignment to bit field priv->cck_agc_report_type

Just because priv->cck_agc_report_type is only one bit doesn't mean it works like a bool. The value assigned to it loses all bits except bit 0, so only assign 0 or 1 to it.

This affects the RTL8192EU, but rtl8xxxu already can't connect to any networks with this chip, so it probably didn't bother anyone.

Fixes 2ad2a813b803 ("wifi: rtl8xxxu: Fix the CCK RSSI calculation")
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +4 -2
index 3ed435401e57..799b03ec1980 100644
@@ -4208,10 +4208,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 		 * should be equal or CCK RSSI report may be incorrect
 		 */
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_HSSI_PARM2);
-		priv->cck_agc_report_type = val32 & FPGA0_HSSI_PARM2_CCK_HIGH_PWR;
+		priv->cck_agc_report_type =
+			u32_get_bits(val32, FPGA0_HSSI_PARM2_CCK_HIGH_PWR);
 
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_HSSI_PARM2);
-		if (priv->cck_agc_report_type != (bool)(val32 & FPGA0_HSSI_PARM2_CCK_HIGH_PWR)) {
+		if (priv->cck_agc_report_type !=
+		    u32_get_bits(val32, FPGA0_HSSI_PARM2_CCK_HIGH_PWR)) {
 			if (priv->cck_agc_report_type)
 				val32 |= FPGA0_HSSI_PARM2_CCK_HIGH_PWR;
 			else
Signature · 1 line
2.38.0
Reviewed-by on v1 2/2
#2 lore raw

RE: [PATCH 2/2] wifi: rtl8xxxu: Fix assignment to bit field priv->cck_agc_report_type

Quoted 13 lines

-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, December 9, 2022 3:34 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
Subject: [PATCH 2/2] wifi: rtl8xxxu: Fix assignment to bit field priv->cck_agc_report_type

Just because priv->cck_agc_report_type is only one bit doesn't mean it works like a bool. The value assigned to it loses all bits except bit 0, so only assign 0 or 1 to it.

Quoted 5 lines

This affects the RTL8192EU, but rtl8xxxu already can't connect to any networks with this chip, so it probably didn't bother anyone.

Fixes 2ad2a813b803 ("wifi: rtl8xxxu: Fix the CCK RSSI calculation")
Quoted 28 lines
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +4 -3
index 3ed435401e57..799b03ec1980 100644
@@ -4208,10 +4208,12 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw)
 		 * should be equal or CCK RSSI report may be incorrect
 		 */
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_HSSI_PARM2);
-		priv->cck_agc_report_type = val32 & FPGA0_HSSI_PARM2_CCK_HIGH_PWR;
+		priv->cck_agc_report_type =
+			u32_get_bits(val32, FPGA0_HSSI_PARM2_CCK_HIGH_PWR);
 
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XB_HSSI_PARM2);
-		if (priv->cck_agc_report_type != (bool)(val32 & FPGA0_HSSI_PARM2_CCK_HIGH_PWR)) {
+		if (priv->cck_agc_report_type !=
+		    u32_get_bits(val32, FPGA0_HSSI_PARM2_CCK_HIGH_PWR)) {
 			if (priv->cck_agc_report_type)
 				val32 |= FPGA0_HSSI_PARM2_CCK_HIGH_PWR;
 			else
--

2.38.0

------Please consider the environment before printing this e-mail.

Reviewed-by on v1 1/2
#3 lore raw
In reply to Bitterblue Smith
Quoted 9 lines

-----Original Message-----
From: Bitterblue Smith <[email protected]>
Sent: Friday, December 9, 2022 3:32 AM
To: [email protected]
Cc: Jes Sorensen <[email protected]>; Ping-Ke Shih <[email protected]>
Subject: [PATCH 1/2] wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled

Quoted 6 lines

Just because priv->pi_enabled is only one bit doesn't mean it works like a bool. The value assigned to it loses all bits except bit 0, so only assign 0 or 1 to it.

This affects the RTL8188FU, but fixing the assignment didn't make a difference for my device.

The reason is the bit is always 0, I have similar review days ago [1].

[1] https://lore.kernel.org/linux-wireless/[email protected]/

Quoted 3 lines
Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
Quoted 22 lines
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +1 -2
index 2c4f403ba68f..97e7ff7289fa 100644
@@ -1122,7 +1122,7 @@ static void rtl8188fu_phy_iqcalibrate(struct rtl8xxxu_priv *priv,
 
 	if (t == 0) {
 		val32 = rtl8xxxu_read32(priv, REG_FPGA0_XA_HSSI_PARM1);
-		priv->pi_enabled = val32 & FPGA0_HSSI_PARM1_PI;
+		priv->pi_enabled = u32_get_bits(val32, FPGA0_HSSI_PARM1_PI);
 	}
 
 	/* save RF path */
--

2.38.0

------Please consider the environment before printing this e-mail.

#4 lore raw
In reply to Bitterblue Smith
Quoted 10 lines · Bitterblue Smith

Just because priv->pi_enabled is only one bit doesn't mean it works like a bool. The value assigned to it loses all bits except bit 0, so only assign 0 or 1 to it.

This affects the RTL8188FU, but fixing the assignment didn't make a difference for my device.

Fixes c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")

2 patches applied to wireless-next.git, thanks.

9e32b4a709f0 wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled 639c26faf9b1 wifi: rtl8xxxu: Fix assignment to bit field priv->cck_agc_report_type

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches