Skip to content

Commit d61a806

Browse files
committed
ASoC: soc-dai: tidyup return value of snd_soc_xlate_tdm_slot_mask()
JIRA: https://issues.redhat.com/browse/RHEL-101627 commit f4c77d5 Author: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Date: Fri Jun 6 01:59:15 2025 +0000 ASoC: soc-dai: tidyup return value of snd_soc_xlate_tdm_slot_mask() commit 7f1186a ("ASoC: soc-dai: check return value at snd_soc_dai_set_tdm_slot()") checks return value of xlate_tdm_slot_mask() (A1)(A2). /* * ... (Y) * TDM mode can be disabled by passing 0 for @Slots. In this case @tx_mask, * @rx_mask and @slot_width will be ignored. * ... */ int snd_soc_dai_set_tdm_slot(...) { ... if (...) (A1) ret = dai->driver->ops->xlate_tdm_slot_mask(...); else (A2) ret = snd_soc_xlate_tdm_slot_mask(...); if (ret) goto err; ... } snd_soc_xlate_tdm_slot_mask() (A2) will return -EINVAL if slots was 0 (X), but snd_soc_dai_set_tdm_slot() allow to use it (Y). (A) static int snd_soc_xlate_tdm_slot_mask(...) { ... if (!slots) (X) return -EINVAL; ... } Call xlate_tdm_slot_mask() only if slots was non zero. Reported-by: Giedrius Trainavičius <giedrius@blokas.io> Closes: https://lore.kernel.org/r/CAMONXLtSL7iKyvH6w=CzPTxQdBECf++hn8RKL6Y4=M_ou2YHow@mail.gmail.com Fixes: 7f1186a ("ASoC: soc-dai: check return value at snd_soc_dai_set_tdm_slot()") Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/8734cdfx59.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
1 parent a2c9fc9 commit d61a806

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sound/soc/soc-dai.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,15 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
259259
&rx_mask,
260260
};
261261

262-
if (dai->driver->ops &&
263-
dai->driver->ops->xlate_tdm_slot_mask)
264-
ret = dai->driver->ops->xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
265-
else
266-
ret = snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
267-
if (ret)
268-
goto err;
262+
if (slots) {
263+
if (dai->driver->ops &&
264+
dai->driver->ops->xlate_tdm_slot_mask)
265+
ret = dai->driver->ops->xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
266+
else
267+
ret = snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
268+
if (ret)
269+
goto err;
270+
}
269271

270272
for_each_pcm_streams(stream)
271273
snd_soc_dai_tdm_mask_set(dai, stream, *tdm_mask[stream]);

0 commit comments

Comments
 (0)