All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>, Michael Walle <michael@walle.cc>,
	Guillaume Tucker <guillaume.tucker@collabora.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 4/4] ASoC: audio-graph: tidyup dai_name seting timing
Date: 10 May 2021 10:52:22 +0900	[thread overview]
Message-ID: <877dk7cq3t.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87cztzcq56.wl-kuninori.morimoto.gx@renesas.com>


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

audio-graph is using cpus->dai_name / codecs->dai_name
for dailink->name, but cpus->dai_name might be removed
under simple_parse_node() (= asoc_simple_canonicalize_cpu()).

Thus we need to get dai_name before calling simple_parse_node().
This patch fixup it.
To reduce future confusion, this patch follow same style
for similar parts too.

Fixes: 8859f809c7d5813 ("ASoC: audio-graph: add graph_parse_node()")
Fixes: e51237b8d305225 ("ASoC: audio-graph: add graph_link_init()")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 0159a4576e9c..f8fc3222710b 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -295,12 +295,13 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 		dai_link->dynamic		= 1;
 		dai_link->dpcm_merged_format	= 1;
 
+		snprintf(dai_name, sizeof(dai_name),
+			 "fe.%pOFP.%s", cpus->of_node, cpus->dai_name);
+
 		ret = graph_parse_node(priv, cpu_ep, li, 1);
 		if (ret)
 			return ret;
 
-		snprintf(dai_name, sizeof(dai_name),
-			 "fe.%pOFP.%s", cpus->of_node, cpus->dai_name);
 		/*
 		 * In BE<->BE connections it is not required to create
 		 * PCM devices at CPU end of the dai link and thus 'no_pcm'
@@ -325,13 +326,13 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 		dai_link->no_pcm		= 1;
 		dai_link->be_hw_params_fixup	= asoc_simple_be_hw_params_fixup;
 
+		snprintf(dai_name, sizeof(dai_name),
+			 "be.%pOFP.%s", codecs->of_node, codecs->dai_name);
+
 		ret = graph_parse_node(priv, codec_ep, li, 0);
 		if (ret < 0)
 			return ret;
 
-		snprintf(dai_name, sizeof(dai_name),
-			 "be.%pOFP.%s", codecs->of_node, codecs->dai_name);
-
 		/* check "prefix" from top node */
 		port = of_get_parent(ep);
 		ports = of_get_parent(port);
@@ -371,6 +372,13 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
 
 	dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
 
+	/*
+	 * next graph_parse_node() might remove cpus->dai_name.
+	 * get dai_name before it.
+	 */
+	snprintf(dai_name, sizeof(dai_name),
+		 "%s-%s", cpus->dai_name, codecs->dai_name);
+
 	ret = graph_parse_node(priv, cpu_ep, li, 1);
 	if (ret < 0)
 		return ret;
@@ -379,8 +387,6 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
 	if (ret < 0)
 		return ret;
 
-	snprintf(dai_name, sizeof(dai_name),
-		 "%s-%s", cpus->dai_name, codecs->dai_name);
 	ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
 	if (ret < 0)
 		return ret;
-- 
2.25.1


  parent reply	other threads:[~2021-05-10  1:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10  1:51 [PATCH 0/4] ASoC: simple-card / audio-graph re-cleanup Kuninori Morimoto
2021-05-10  1:52 ` [PATCH 1/4] ASoC: simple-card: add simple_parse_node() Kuninori Morimoto
2021-05-10  1:52 ` [PATCH 2/4] ASoC: simple-card: add simple_link_init() Kuninori Morimoto
2021-05-10  1:52 ` [PATCH 3/4] ASoC: audio-graph: tidyup graph_dai_link_of_dpcm() Kuninori Morimoto
2021-05-10  1:52 ` Kuninori Morimoto [this message]
2021-05-10 11:46 ` [PATCH 0/4] ASoC: simple-card / audio-graph re-cleanup Michael Walle
2021-05-10 12:27 ` Guillaume Tucker
2021-05-11 14:49   ` Mark Brown

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=877dk7cq3t.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=guillaume.tucker@collabora.com \
    --cc=michael@walle.cc \
    /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.