diff mbox series

[v3,01/21] ASoC: soc-pcm.c: indicate error if stream has no playback no capture

Message ID 87mt1olzk4.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit 092830cf550667d5fa6286605167d232f2c1f61e
Headers show
Series ASoC: replace dpcm_playback/capture to playback/capture_only | expand

Commit Message

Kuninori Morimoto May 29, 2023, 1:02 a.m. UTC
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 <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
---
 sound/soc/soc-pcm.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7247f44faa1c..fe65994485f8 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2815,6 +2815,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;
 }