]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: soc-dai: tidyup return value of snd_soc_xlate_tdm_slot_mask()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 6 Jun 2025 01:59:15 +0000 (01:59 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 8 Jun 2025 22:34:50 +0000 (23:34 +0100)
commit 7f1186a8d738661 ("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: 7f1186a8d738661 ("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>
sound/soc/soc-dai.c

index a210089747d0044b4e4b235ad0cde2b20ec5b323..32f46a38682b798931702e88bc1738ad23e64769 100644 (file)
@@ -259,13 +259,15 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
                &rx_mask,
        };
 
-       if (dai->driver->ops &&
-           dai->driver->ops->xlate_tdm_slot_mask)
-               ret = dai->driver->ops->xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
-       else
-               ret = snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
-       if (ret)
-               goto err;
+       if (slots) {
+               if (dai->driver->ops &&
+                   dai->driver->ops->xlate_tdm_slot_mask)
+                       ret = dai->driver->ops->xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
+               else
+                       ret = snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
+               if (ret)
+                       goto err;
+       }
 
        for_each_pcm_streams(stream)
                snd_soc_dai_tdm_mask_set(dai, stream, *tdm_mask[stream]);