diff mbox series

wifi: mt76: mt7915: workaround dubious x | !y warning

Message ID 20240321153437.403259-1-kvalo@kernel.org
State Superseded
Headers show
Series wifi: mt76: mt7915: workaround dubious x | !y warning | expand

Commit Message

Kalle Valo March 21, 2024, 3:34 p.m. UTC
Sparse warns:

drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c:526:9: warning: dubious: x | !y

Workaround it by using the '?' operator. Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
---
 drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 61cdb09ff760dd32439cde1200a1a8bd208807cd

Comments

Nicolas Cavallari March 21, 2024, 3:51 p.m. UTC | #1
On 21/03/2024 16:34, Kalle Valo wrote:
> Sparse warns:
> 
> drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c:526:9: warning: dubious: x | !y
> 
> Workaround it by using the '?' operator. Compile tested only.
> 
> Signed-off-by: Kalle Valo <kvalo@kernel.org>
> ---
>   drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> index 450f4d221184..3f47aafb1a6c 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
> @@ -523,7 +523,7 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
>   
>   	/* WM CPU info record control */
>   	mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
> -	mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | !dev->fw.debug_wm);
> +	mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | dev->fw.debug_wm ? 0 : BIT(0));

clang says "bitwise or with non-zero value always evaluates to true 
[-Wtautological-bitwise-compare]"

It needs some parenthesis.
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
index 450f4d221184..3f47aafb1a6c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c
@@ -523,7 +523,7 @@  mt7915_fw_debug_wm_set(void *data, u64 val)
 
 	/* WM CPU info record control */
 	mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
-	mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | !dev->fw.debug_wm);
+	mt76_wr(dev, MT_DIC_CMD_REG_CMD, BIT(2) | BIT(13) | dev->fw.debug_wm ? 0 : BIT(0));
 	mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
 	mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));