devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Rob Herring <robh+dt@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>, devicetree@vger.kernel.org
Subject: [PATCH 2/5] ASoC: rsnd: cleanup rsnd_dai_of_node()
Date: Mon, 24 Jul 2023 00:21:31 +0000	[thread overview]
Message-ID: <87v8eab1md.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87y1j6b1ne.wl-kuninori.morimoto.gx@renesas.com>

It calls rsnd_dai_of_node() to know it was called from Audio Graph
Card/Card2, or from Simple Audio Card. And after that, it gets
number of related DAIs.

To be more simple code, this patch merges these.
This is prepare for multi Component support.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/core.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index f3f17b784025..a87d7fa55f7b 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1261,7 +1261,7 @@ int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name
 }
 
 static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv,
-					    int *is_graph)
+					    int *nr, int *is_graph)
 {
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct device_node *np = dev->of_node;
@@ -1274,22 +1274,30 @@ static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv,
 	 * parse both previous dai (= rcar_sound,dai), and
 	 * graph dai (= ports/port)
 	 */
+
+	/*
+	 * Simple-Card
+	 */
 	dai_node = of_get_child_by_name(np, RSND_NODE_DAI);
 	if (dai_node) {
+		*nr = of_get_child_count(dai_node);
 		ret = dai_node;
 		goto of_node_compatible;
 	}
 
-	ret = np;
-
+	/*
+	 * Audio-Graph-Card
+	 */
 	dai_node = of_graph_get_next_endpoint(np, NULL);
-	if (dai_node)
-		goto of_node_graph;
+	if (dai_node) {
+		*nr = of_graph_get_endpoint_count(np);
+		*is_graph = 1;
+		ret = np;
+		goto of_node_compatible;
+	}
 
 	return NULL;
 
-of_node_graph:
-	*is_graph = 1;
 of_node_compatible:
 	of_node_put(dai_node);
 
@@ -1447,16 +1455,11 @@ static int rsnd_dai_probe(struct rsnd_priv *priv)
 	struct snd_soc_dai_driver *rdrv;
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct rsnd_dai *rdai;
-	int nr;
+	int nr = 0;
 	int is_graph;
 	int dai_i;
 
-	dai_node = rsnd_dai_of_node(priv, &is_graph);
-	if (is_graph)
-		nr = of_graph_get_endpoint_count(dai_node);
-	else
-		nr = of_get_child_count(dai_node);
-
+	dai_node = rsnd_dai_of_node(priv, &nr, &is_graph);
 	if (!nr)
 		return -EINVAL;
 
-- 
2.25.1


  parent reply	other threads:[~2023-07-24  0:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24  0:20 [PATCH 0/5] ASoC: rsnd: add multi Component support Kuninori Morimoto
2023-07-24  0:21 ` [PATCH 1/5] ASoC: rsnd: use DAI driver ID instead of DAI ID Kuninori Morimoto
2023-07-24  0:21 ` Kuninori Morimoto [this message]
2023-07-24  0:21 ` [PATCH 3/5] ASoC: rsnd: enable multi Component support for Audio Graph Card/Card2 Kuninori Morimoto
2023-07-24  0:21 ` [PATCH 4/5] ASoC: dt-bindings: renesas,rsnd.yaml: add common port-def Kuninori Morimoto
2023-07-24  0:22 ` [PATCH 5/5] ASoC: dt-bindings: renesas,rsnd.yaml: enable multi ports for multi Component support Kuninori Morimoto
2023-07-31 16:58 ` [PATCH 0/5] ASoC: rsnd: add " 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=87v8eab1md.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).