diff mbox series

[1/3] wifi: ath9k: ath9k_set_moredata(): fix sparse warnings

Message ID 20240320170656.3534265-2-kvalo@kernel.org
State New
Headers show
Series [1/3] wifi: ath9k: ath9k_set_moredata(): fix sparse warnings | expand

Commit Message

Kalle Valo March 20, 2024, 5:06 p.m. UTC
From: Kalle Valo <quic_kvalo@quicinc.com>

Sparse warns:

drivers/net/wireless/ath/ath9k/xmit.c:1677:20: warning: incorrect type in initializer (different base types)
drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    expected unsigned short [usertype] mask
drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    got restricted __le16 [usertype]
drivers/net/wireless/ath/ath9k/xmit.c:1681:17: warning: restricted __le16 degrades to integer
drivers/net/wireless/ath/ath9k/xmit.c:1682:42: warning: restricted __le16 degrades to integer
drivers/net/wireless/ath/ath9k/xmit.c:1682:36: warning: incorrect type in assignment (different base types)
drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    expected restricted __le16 [usertype] frame_control
drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    got int

Fix ath9k_set_moredata() to use __le16 with masks and use if statement instead
of multiply operator.

Compile tested only.

Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
---
 drivers/net/wireless/ath/ath9k/xmit.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Toke Høiland-Jørgensen March 21, 2024, 6:37 p.m. UTC | #1
Kalle Valo <kvalo@kernel.org> writes:

> From: Kalle Valo <quic_kvalo@quicinc.com>
>
> Sparse warns:
>
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20: warning: incorrect type in initializer (different base types)
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    expected unsigned short [usertype] mask
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    got restricted __le16 [usertype]
> drivers/net/wireless/ath/ath9k/xmit.c:1681:17: warning: restricted __le16 degrades to integer
> drivers/net/wireless/ath/ath9k/xmit.c:1682:42: warning: restricted __le16 degrades to integer
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36: warning: incorrect type in assignment (different base types)
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    expected restricted __le16 [usertype] frame_control
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    got int
>
> Fix ath9k_set_moredata() to use __le16 with masks and use if statement instead
> of multiply operator.
>
> Compile tested only.
>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Kalle Valo March 25, 2024, 10:51 a.m. UTC | #2
Kalle Valo <kvalo@kernel.org> wrote:

> Sparse warns:
> 
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20: warning: incorrect type in initializer (different base types)
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    expected unsigned short [usertype] mask
> drivers/net/wireless/ath/ath9k/xmit.c:1677:20:    got restricted __le16 [usertype]
> drivers/net/wireless/ath/ath9k/xmit.c:1681:17: warning: restricted __le16 degrades to integer
> drivers/net/wireless/ath/ath9k/xmit.c:1682:42: warning: restricted __le16 degrades to integer
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36: warning: incorrect type in assignment (different base types)
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    expected restricted __le16 [usertype] frame_control
> drivers/net/wireless/ath/ath9k/xmit.c:1682:36:    got int
> 
> Fix ath9k_set_moredata() to use __le16 with masks and use if statement instead
> of multiply operator.
> 
> Compile tested only.
> 
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
> Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

3 patches applied to ath-next branch of ath.git, thanks.

e5f6c85ac16f wifi: ath9k: ath9k_set_moredata(): fix sparse warnings
a854028e7bd8 wifi: ath9k: fix ath9k_use_msi declaration
f09e3b774fe8 wifi: ath9k: eeprom: fix sparse endian warnings
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index d519b676a109..35aa47a9db90 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1674,8 +1674,14 @@  static void
 ath9k_set_moredata(struct ath_softc *sc, struct ath_buf *bf, bool val)
 {
 	struct ieee80211_hdr *hdr;
-	u16 mask = cpu_to_le16(IEEE80211_FCTL_MOREDATA);
-	u16 mask_val = mask * val;
+	__le16 mask, mask_val;
+
+	mask = cpu_to_le16(IEEE80211_FCTL_MOREDATA);
+
+	if (val)
+		mask_val = mask;
+	else
+		mask_val = 0;
 
 	hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
 	if ((hdr->frame_control & mask) != mask_val) {