[alsa-devel] [PATCH v3 08/18] ASoC: soc-pcm: use goto and remove multi return

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Mon Feb 17 03:16:09 CET 2020


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

When we use some kind of lock, we need to do unlock.
In that time, multi unlock/return is not good implementation.
This patch add label and use goto at dpcm_fe_dai_open()
to reduce such code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 sound/soc/soc-pcm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index fcebc327c0ef..bf1f74c42e1a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2733,8 +2733,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 
 	ret = dpcm_path_get(fe, stream, &list);
 	if (ret < 0) {
-		mutex_unlock(&fe->card->mutex);
-		return ret;
+		goto open_end;
 	} else if (ret == 0) {
 		dev_dbg(fe->dev, "ASoC: %s no valid %s route\n",
 			fe->dai_link->name, stream ? "capture" : "playback");
@@ -2755,6 +2754,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 
 	dpcm_clear_pending_state(fe, stream);
 	dpcm_path_put(&list);
+open_end:
 	mutex_unlock(&fe->card->mutex);
 	return ret;
 }
-- 
2.17.1



More information about the Alsa-devel mailing list