All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [alsa-devel] [PATCH 5/7] ASoC: soc-pcm: goto error after trying all component open
Date: 27 Jan 2020 10:49:28 +0900	[thread overview]
Message-ID: <87zhe9mzx3.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <877e1doeis.wl-kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_pcm_components_open() might goto error process *during* opening
component loop.
In such case, fallback process need to care about operated/non-operated
component.

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>
---
 sound/soc/soc-pcm.c | 41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 57d2f00..1e370ef 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -463,47 +463,32 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream)
 	hw->rate_max = min_not_zero(hw->rate_max, rate_max);
 }
 
-static int soc_pcm_components_open(struct snd_pcm_substream *substream,
-				   struct snd_soc_component **last)
+static int soc_pcm_components_open(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_component *component;
 	int i, ret = 0;
 
 	for_each_rtd_components(rtd, i, component) {
-		*last = component;
+		ret |= snd_soc_component_module_get_when_open(component);
+		ret |= snd_soc_component_open(component, substream);
+	}
 
-		ret = snd_soc_component_module_get_when_open(component);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"ASoC: can't get module %s\n",
-				component->name);
-			return ret;
-		}
+	if (ret < 0)
+		dev_err(component->dev,
+			"ASoC: error happen during open component %s: %d\n",
+			component->name, ret);
 
-		ret = snd_soc_component_open(component, substream);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"ASoC: can't open component %s: %d\n",
-				component->name, ret);
-			return ret;
-		}
-	}
-	*last = NULL;
-	return 0;
+	return ret;
 }
 
-static int soc_pcm_components_close(struct snd_pcm_substream *substream,
-				    struct snd_soc_component *last)
+static int soc_pcm_components_close(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_component *component;
 	int i, ret = 0;
 
 	for_each_rtd_components(rtd, i, component) {
-		if (component == last)
-			break;
-
 		ret |= snd_soc_component_close(component, substream);
 		snd_soc_component_module_put_when_close(component);
 	}
@@ -542,7 +527,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 		goto out;
 	}
 
-	ret = soc_pcm_components_open(substream, &component);
+	ret = soc_pcm_components_open(substream);
 	if (ret < 0)
 		goto component_err;
 
@@ -638,7 +623,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 		snd_soc_dai_shutdown(codec_dai, substream);
 
 component_err:
-	soc_pcm_components_close(substream, component);
+	soc_pcm_components_close(substream);
 
 	snd_soc_dai_shutdown(cpu_dai, substream);
 out:
@@ -692,7 +677,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	soc_rtd_shutdown(rtd, substream);
 
-	soc_pcm_components_close(substream, NULL);
+	soc_pcm_components_close(substream);
 
 	snd_soc_dapm_stream_stop(rtd, substream->stream);
 
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2020-01-27  1:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27  1:48 [alsa-devel] [PATCH 0/7] ASoC: soc-pcm cleanup step2 Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 1/7] ASoC: soc-pcm: add snd_soc_runtime_action() Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 2/7] ASoC: soc-pcm: adjustment for DAI member 0 reset Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 3/7] ASoC: soc-pcm: add for_each_dapm_widgets() macro Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 4/7] ASoC: soc-pcm: goto error after trying for_each_rtd_codec_dai Kuninori Morimoto
2020-01-28  7:01   ` Takashi Iwai
2020-01-28  7:30     ` Kuninori Morimoto
2020-01-28 16:31       ` Pierre-Louis Bossart
2020-01-28 16:44         ` Takashi Iwai
2020-01-29  0:15           ` Kuninori Morimoto
2020-01-27  1:49 ` Kuninori Morimoto [this message]
2020-01-27 18:34   ` [alsa-devel] [PATCH 5/7] ASoC: soc-pcm: goto error after trying all component open Sridharan, Ranjani
2020-01-28  0:31     ` Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 6/7] ASoC: soc-pcm: move soc_pcm_close() next to soc_pcm_open() Kuninori Morimoto
2020-01-27  1:49 ` [alsa-devel] [PATCH 7/7] ASoC: soc-pcm: tidyup soc_pcm_open() order Kuninori Morimoto
2020-02-25  1:22   ` Pierre-Louis Bossart
2020-02-25  1:40     ` Mark Brown
2020-02-25  4:20       ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhe9mzx3.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.