diff mbox series

[1/5] wifi: b43: silence sparse warnings

Message ID 20240223114023.c64e2d348453.Iccc4ace1116721a044e5f31f40ea7709e72145f3@changeid (mailing list archive)
State Accepted
Commit 576b2015e7e02460a690769fb81a561cc748b877
Delegated to: Kalle Valo
Headers show
Series [1/5] wifi: b43: silence sparse warnings | expand

Commit Message

Johannes Berg Feb. 23, 2024, 10:40 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

sparse complains on this code about casts that lose bits
due to the usage of bitwise not, but really we do want
16 bits only, so clarify that by using masks.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 drivers/net/wireless/broadcom/b43/phy_ht.c | 6 +++---
 drivers/net/wireless/broadcom/b43/phy_n.c  | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Larry Finger Feb. 23, 2024, 3:58 p.m. UTC | #1
On 2/23/24 04:40, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> sparse complains on this code about casts that lose bits
> due to the usage of bitwise not, but really we do want
> 16 bits only, so clarify that by using masks.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>   drivers/net/wireless/broadcom/b43/phy_ht.c | 6 +++---
>   drivers/net/wireless/broadcom/b43/phy_n.c  | 4 ++--
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/b43/phy_ht.c b/drivers/net/wireless/broadcom/b43/phy_ht.c
> index d050971d150a..26a226126bc4 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_ht.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_ht.c
> @@ -322,8 +322,8 @@ static void b43_phy_ht_bphy_reset(struct b43_wldev *dev, bool reset)
>   			    B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX);
>   	else
>   		b43_phy_mask(dev, B43_PHY_B_BBCFG,
> -			     (u16)~(B43_PHY_B_BBCFG_RSTCCA |
> -				    B43_PHY_B_BBCFG_RSTRX));
> +			     0xffff & ~(B43_PHY_B_BBCFG_RSTCCA |
> +					B43_PHY_B_BBCFG_RSTRX));
>   
>   	b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp);
>   }
> @@ -551,7 +551,7 @@ static void b43_phy_ht_tx_power_ctl(struct b43_wldev *dev, bool enable)
>   				phy_ht->tx_pwr_idx[i] =
>   					b43_phy_read(dev, status_regs[i]);
>   		}
> -		b43_phy_mask(dev, B43_PHY_HT_TXPCTL_CMD_C1, ~en_bits);
> +		b43_phy_mask(dev, B43_PHY_HT_TXPCTL_CMD_C1, 0xffff & ~en_bits);
>   	} else {
>   		b43_phy_set(dev, B43_PHY_HT_TXPCTL_CMD_C1, en_bits);
>   
> diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
> index 2c0c019a815d..4bb005b93f2c 100644
> --- a/drivers/net/wireless/broadcom/b43/phy_n.c
> +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
> @@ -6246,7 +6246,7 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev,
>   		b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
>   		/* Take BPHY out of the reset */
>   		b43_phy_mask(dev, B43_PHY_B_BBCFG,
> -			     (u16)~(B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX));
> +			     ~(B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX) & 0xffff);
>   		b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
>   	}
>   
> @@ -6377,7 +6377,7 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
>   	} else if (channel_type == NL80211_CHAN_HT40MINUS) {
>   		b43_phy_mask(dev, B43_NPHY_RXCTL, ~B43_NPHY_RXCTL_BSELU20);
>   		if (phy->rev >= 7)
> -			b43_phy_mask(dev, 0x310, (u16)~0x8000);
> +			b43_phy_mask(dev, 0x310, 0x7fff);
>   	}
>   
>   	if (phy->rev >= 19) {


Acked_by: Larry Finger <Larry,Finger@lwfinger.net>

Thanks.

Larry
Kalle Valo Feb. 28, 2024, 11:37 a.m. UTC | #2
Johannes Berg <johannes@sipsolutions.net> wrote:

> From: Johannes Berg <johannes.berg@intel.com>
> 
> sparse complains on this code about casts that lose bits
> due to the usage of bitwise not, but really we do want
> 16 bits only, so clarify that by using masks.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

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

576b2015e7e0 wifi: b43: silence sparse warnings
17672ced7d73 wifi: brcmsmac: silence sparse warnings
e06324303662 wifi: rt2x00: silence sparse warnings
5a391813e7ef wifi: zd1211rw: silence sparse warnings
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/b43/phy_ht.c b/drivers/net/wireless/broadcom/b43/phy_ht.c
index d050971d150a..26a226126bc4 100644
--- a/drivers/net/wireless/broadcom/b43/phy_ht.c
+++ b/drivers/net/wireless/broadcom/b43/phy_ht.c
@@ -322,8 +322,8 @@  static void b43_phy_ht_bphy_reset(struct b43_wldev *dev, bool reset)
 			    B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX);
 	else
 		b43_phy_mask(dev, B43_PHY_B_BBCFG,
-			     (u16)~(B43_PHY_B_BBCFG_RSTCCA |
-				    B43_PHY_B_BBCFG_RSTRX));
+			     0xffff & ~(B43_PHY_B_BBCFG_RSTCCA |
+					B43_PHY_B_BBCFG_RSTRX));
 
 	b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp);
 }
@@ -551,7 +551,7 @@  static void b43_phy_ht_tx_power_ctl(struct b43_wldev *dev, bool enable)
 				phy_ht->tx_pwr_idx[i] =
 					b43_phy_read(dev, status_regs[i]);
 		}
-		b43_phy_mask(dev, B43_PHY_HT_TXPCTL_CMD_C1, ~en_bits);
+		b43_phy_mask(dev, B43_PHY_HT_TXPCTL_CMD_C1, 0xffff & ~en_bits);
 	} else {
 		b43_phy_set(dev, B43_PHY_HT_TXPCTL_CMD_C1, en_bits);
 
diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
index 2c0c019a815d..4bb005b93f2c 100644
--- a/drivers/net/wireless/broadcom/b43/phy_n.c
+++ b/drivers/net/wireless/broadcom/b43/phy_n.c
@@ -6246,7 +6246,7 @@  static void b43_nphy_channel_setup(struct b43_wldev *dev,
 		b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16 | 4);
 		/* Take BPHY out of the reset */
 		b43_phy_mask(dev, B43_PHY_B_BBCFG,
-			     (u16)~(B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX));
+			     ~(B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX) & 0xffff);
 		b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp16);
 	}
 
@@ -6377,7 +6377,7 @@  static int b43_nphy_set_channel(struct b43_wldev *dev,
 	} else if (channel_type == NL80211_CHAN_HT40MINUS) {
 		b43_phy_mask(dev, B43_NPHY_RXCTL, ~B43_NPHY_RXCTL_BSELU20);
 		if (phy->rev >= 7)
-			b43_phy_mask(dev, 0x310, (u16)~0x8000);
+			b43_phy_mask(dev, 0x310, 0x7fff);
 	}
 
 	if (phy->rev >= 19) {