From: Kuninori Morimoto Date: Tue, 30 May 2023 00:49:43 +0000 (+0000) Subject: ASoC: soc-pcm.c: indicate error if stream has no playback no capture X-Git-Tag: v6.6.7~1940^2~32^2~123^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=092830cf550667d5fa6286605167d232f2c1f61e;p=platform%2Fkernel%2Flinux-starfive.git ASoC: soc-pcm.c: indicate error if stream has no playback no capture soc_get_playback_capture() (A) returns number of substreams for playback/capture (B). ASoC will probe the Sound Card and mapps CPU<->Codec pair. (A) static int soc_get_playback_capture(..., (B) int *playback, int *capture) { ... if (rtd->dai_link->playback_only) { *playback = 1; *capture = 0; } if (rtd->dai_link->capture_only) { *playback = 0; *capture = 1; } (C) return 0; } But it might be no playback no capture if it returns playback=0, capture=0. It is very difficult to notice about it. This patch indicates error at (C) then. Signed-off-by: Kuninori Morimoto Reviewed-by: Amadeusz Sławiński Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/87y1l6zlqx.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 6365ad8..f3ce825 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2814,6 +2814,13 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, *capture = 1; } + if (!*playback && !*capture) { + dev_err(rtd->dev, "substream %s has no playback, no capture\n", + rtd->dai_link->stream_name); + + return -EINVAL; + } + return 0; }