* [PATCH] ASoC: codecs: aw88261: small cleanup in aw88261_set_tdm_slot()
@ 2026-10-01 6:51 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-10-01 6:51 UTC (permalink / raw)
To: Val Packett
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Luca Weiss, Charles Keepax, Kuninori Morimoto, linux-sound,
linux-kernel, kernel-janitors
This code triggers a Smatch false positive:
sound/soc/codecs/aw88261.c:858 aw88261_set_tdm_slot()
error: uninitialized symbol 'chan'.
This would only happen if both the tx and rx masks were zero which is
a nonsense scenario and reviewing the callers shows that it never
happens.
However, if the rx_mask is zero then we're comparing the mask from RX
against the chan from TX which is confusing:
if ((rx_mask & ~BIT(chan)) != 0) {
^^ rx ^^^^ tx chan
Of course, in that case the condition is going to be false because
the rx_mask is zero. So it's fine. But it would be more clear to move
the condition inside the if statement and it silences the static checker
warning as well.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
From code review. Untested.
sound/soc/codecs/aw88261.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/aw88261.c b/sound/soc/codecs/aw88261.c
index b8d06534bc8f..8671069f4c18 100644
--- a/sound/soc/codecs/aw88261.c
+++ b/sound/soc/codecs/aw88261.c
@@ -853,13 +853,13 @@ static int aw88261_set_tdm_slot(struct snd_soc_dai *dai,
return -EINVAL;
aw88261->rxl_slotvld_mask = chan << AW88261_I2S_RXL_SLOTVLD_START_BIT;
- }
- if ((rx_mask & ~BIT(chan)) != 0) {
- if ((chan = __ffs(rx_mask & ~BIT(chan))) > 16)
- return -EINVAL;
+ if ((rx_mask & ~BIT(chan)) != 0) {
+ if ((chan = __ffs(rx_mask & ~BIT(chan))) > 16)
+ return -EINVAL;
- aw88261->rxr_slotvld_mask = chan << AW88261_I2S_RXR_SLOTVLD_START_BIT;
+ aw88261->rxr_slotvld_mask = chan << AW88261_I2S_RXR_SLOTVLD_START_BIT;
+ }
}
return 0;
--
2.53.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-01 6:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 6:51 [PATCH] ASoC: codecs: aw88261: small cleanup in aw88261_set_tdm_slot() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®