diff mbox series

wifi: brcmsmac: simplify wlc_phy_rxcal_radio_setup_nphy()

Message ID 20241029114912.1534179-1-dmantipov@yandex.ru (mailing list archive)
State Deferred
Delegated to: Kalle Valo
Headers show
Series wifi: brcmsmac: simplify wlc_phy_rxcal_radio_setup_nphy() | expand

Commit Message

Dmitry Antipov Oct. 29, 2024, 11:49 a.m. UTC
Since 'tx_rx_cal_radio_saveregs[]' of 'struct brcms_phy' is 'u16',
'pi->tx_rx_cal_radio_saveregs[2] & 0xF0) >> 8' is always zero, so
a few duplicated snippets in 'wlc_phy_rxcal_radio_setup_nphy()'
may be reduced to compile-time constant (in fact, the same thing is
actually done by both gcc and clang I've tried). Compile tested only.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 .../broadcom/brcm80211/brcmsmac/phy/phy_n.c   | 44 ++-----------------
 1 file changed, 4 insertions(+), 40 deletions(-)

Comments

Arend van Spriel Oct. 30, 2024, 11:13 a.m. UTC | #1
On 10/29/2024 12:49 PM, Dmitry Antipov wrote:
> Since 'tx_rx_cal_radio_saveregs[]' of 'struct brcms_phy' is 'u16',
> 'pi->tx_rx_cal_radio_saveregs[2] & 0xF0) >> 8' is always zero, so
> a few duplicated snippets in 'wlc_phy_rxcal_radio_setup_nphy()'
> may be reduced to compile-time constant (in fact, the same thing is
> actually done by both gcc and clang I've tried). Compile tested only.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

Thanks, Dmitry

This was already reported earlier bij Colin (Ian) King. Can you agree to 
add a Reported-by: tag?

As for the change it is true that it boils down to a constant, but I 
doubt is that would be the intended behavior. I have to consult my 
co-workers in radio/phy team.

Regards,
Arend

> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>   .../broadcom/brcm80211/brcmsmac/phy/phy_n.c   | 44 ++-----------------
>   1 file changed, 4 insertions(+), 40 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index d69879e1bd87..48343c820422 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -26201,7 +26201,6 @@  static void wlc_phy_calc_rx_iq_comp_nphy(struct brcms_phy *pi, u8 core_mask)
 
 static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core)
 {
-	u16 offtune_val;
 	u16 bias_g = 0;
 	u16 bias_a = 0;
 
@@ -26322,17 +26321,9 @@  static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core)
 						read_radio_reg(pi,
 							RADIO_2056_RX_LNAA_TUNE
 							| RADIO_2056_RX0);
-
-					offtune_val =
-						(pi->tx_rx_cal_radio_saveregs
-						 [2] & 0xF0) >> 8;
-					offtune_val =
-						(offtune_val <= 0x7) ? 0xF : 0;
-
 					mod_radio_reg(pi,
 						      RADIO_2056_RX_LNAA_TUNE |
-						      RADIO_2056_RX0, 0xF0,
-						      (offtune_val << 8));
+						      RADIO_2056_RX0, 0xF0, 0xF00);
 				}
 
 				write_radio_reg(pi,
@@ -26372,18 +26363,9 @@  static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core)
 							pi,
 							RADIO_2056_RX_LNAG_TUNE
 							| RADIO_2056_RX0);
-
-					offtune_val =
-						(pi->
-						 tx_rx_cal_radio_saveregs[2] &
-						 0xF0) >> 8;
-					offtune_val =
-						(offtune_val <= 0x7) ? 0xF : 0;
-
 					mod_radio_reg(pi,
 						      RADIO_2056_RX_LNAG_TUNE |
-						      RADIO_2056_RX0, 0xF0,
-						      (offtune_val << 8));
+						      RADIO_2056_RX0, 0xF0, 0xF00);
 				}
 
 				write_radio_reg(pi,
@@ -26446,18 +26428,9 @@  static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core)
 							pi,
 							RADIO_2056_RX_LNAA_TUNE
 							| RADIO_2056_RX1);
-
-					offtune_val =
-						(pi->
-						 tx_rx_cal_radio_saveregs[2] &
-						 0xF0) >> 8;
-					offtune_val =
-						(offtune_val <= 0x7) ? 0xF : 0;
-
 					mod_radio_reg(pi,
 						      RADIO_2056_RX_LNAA_TUNE |
-						      RADIO_2056_RX1, 0xF0,
-						      (offtune_val << 8));
+						      RADIO_2056_RX1, 0xF0, 0xF00);
 				}
 
 				write_radio_reg(pi,
@@ -26496,18 +26469,9 @@  static void wlc_phy_rxcal_radio_setup_nphy(struct brcms_phy *pi, u8 rx_core)
 							pi,
 							RADIO_2056_RX_LNAG_TUNE
 							| RADIO_2056_RX1);
-
-					offtune_val =
-						(pi->
-						 tx_rx_cal_radio_saveregs[2] &
-						 0xF0) >> 8;
-					offtune_val =
-						(offtune_val <= 0x7) ? 0xF : 0;
-
 					mod_radio_reg(pi,
 						      RADIO_2056_RX_LNAG_TUNE |
-						      RADIO_2056_RX1, 0xF0,
-						      (offtune_val << 8));
+						      RADIO_2056_RX1, 0xF0, 0xF00);
 				}
 
 				write_radio_reg(pi,