2022-12-08 19:34:47

by Bitterblue Smith

[permalink] [raw]
Subject: [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")
Signed-off-by: Bitterblue Smith <[email protected]>
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
index 2c4f403ba68f..97e7ff7289fa 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
@@ -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


2022-12-08 19:40:43

by Bitterblue Smith

[permalink] [raw]
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.

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")
Signed-off-by: Bitterblue Smith <[email protected]>
---
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 3ed435401e57..799b03ec1980 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -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

2022-12-09 08:17:05

by Ping-Ke Shih

[permalink] [raw]
Subject: RE: [PATCH 1/2] wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled



> -----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
>
> 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]/

>
> Fixes: c888183b21f3 ("wifi: rtl8xxxu: Support new chip RTL8188FU")
> Signed-off-by: Bitterblue Smith <[email protected]>

Reviewed-by: Ping-Ke Shih <[email protected]>

> ---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> index 2c4f403ba68f..97e7ff7289fa 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c
> @@ -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.

2022-12-09 08:17:26

by Ping-Ke Shih

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



> -----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.
>
> 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")
> Signed-off-by: Bitterblue Smith <[email protected]>

Reviewed-by: Ping-Ke Shih <[email protected]>

> ---
> drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index 3ed435401e57..799b03ec1980 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -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.

2022-12-14 12:31:00

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/2] wifi: rtl8xxxu: Fix assignment to bit field priv->pi_enabled

Bitterblue Smith <[email protected]> wrote:

> 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")
> Signed-off-by: Bitterblue Smith <[email protected]>
> Reviewed-by: Ping-Ke Shih <[email protected]>

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

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

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