diff mbox series

[v2,4/7] ASoC: soc-pcm: goto error after trying for_each_rtd_codec_dai

Message ID 87y2ts2wfj.wl-kuninori.morimoto.gx@renesas.com
State New
Headers show
Series ASoC: soc-pcm cleanup step2 | expand

Commit Message

Kuninori Morimoto Jan. 28, 2020, 1:37 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_pcm_open() might goto error process *during* for_each_rtd_codec_dai.
In such case, fallback process need to care about operated/non-operated
codec dai.

But, if it goto error process *after* loop even though error happen
during loop, it don't need to care about operated/non-operated.
In such case code can be more simple.
This patch do it. And this is prepare for soc_snd_open() cleanup

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

	- indicate error from inside loop

 sound/soc/soc-pcm.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index f11c15f..cf7c31f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -547,25 +547,27 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 		goto component_err;
 
 	for_each_rtd_codec_dai(rtd, i, codec_dai) {
-		ret = snd_soc_dai_startup(codec_dai, substream);
-		if (ret < 0) {
+		int r = snd_soc_dai_startup(codec_dai, substream);
+
+		if (r < 0)
 			dev_err(codec_dai->dev,
 				"ASoC: can't open codec %s: %d\n",
-				codec_dai->name, ret);
-			goto codec_dai_err;
-		}
+				codec_dai->name, r);
+		ret |= r;
 
 		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 			codec_dai->tx_mask = 0;
 		else
 			codec_dai->rx_mask = 0;
 	}
+	if (ret < 0)
+		goto codec_dai_err;
 
 	ret = soc_rtd_startup(rtd, substream);
 	if (ret < 0) {
 		pr_err("ASoC: %s startup failed: %d\n",
 		       rtd->dai_link->name, ret);
-		goto machine_err;
+		goto codec_dai_err;
 	}
 
 	/* Dynamic PCM DAI links compat checks use dynamic capabilities */
@@ -634,11 +636,8 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 config_err:
 	soc_rtd_shutdown(rtd, substream);
 
-machine_err:
-	i = rtd->num_codecs;
-
 codec_dai_err:
-	for_each_rtd_codec_dai_rollback(rtd, i, codec_dai)
+	for_each_rtd_codec_dai(rtd, i, codec_dai)
 		snd_soc_dai_shutdown(codec_dai, substream);
 
 component_err: