devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: "\"Uwe Kleine-König\"" <u.kleine-koenig@pengutronix.de>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@gmail.com>,
	"Frank Rowand" <frowand.list@gmail.com>,
	"Helge Deller" <deller@gmx.de>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Michal Simek" <michal.simek@amd.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Saravana Kannan" <saravanak@google.com>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>
Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-fbdev@vger.kernel.org, linux-media@vger.kernel.org,
	linux-sound@vger.kernel.org
Subject: [PATCH 07/13] ASoC: audio-graph-card2: use of_graph_get_next_port()
Date: Tue, 23 Jan 2024 00:04:32 +0000	[thread overview]
Message-ID: <87a5owud7z.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87jzo0uda2.wl-kuninori.morimoto.gx@renesas.com>

Now we can use of_graph_get_next_port() for port parsing.
Use it on audio-graph-card2 driver.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/audio-graph-card2.c | 29 ++++++++-------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 62606e20be9a..59a5db12bb5c 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -339,12 +339,7 @@ static struct device_node *graph_get_next_multi_ep(struct device_node **port)
 	 *	port@1 { rep1 };
 	 * };
 	 */
-	do {
-		*port = of_get_next_child(ports, *port);
-		if (!*port)
-			break;
-	} while (!of_node_name_eq(*port, "port"));
-
+	*port = of_graph_get_next_port(ports, *port);
 	if (*port) {
 		ep  = port_to_endpoint(*port);
 		rep = of_graph_get_remote_endpoint(ep);
@@ -539,7 +534,8 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link,
 	 */
 	struct device_node *mcpu_ep		= port_to_endpoint(mcpu_port);
 	struct device_node *mcpu_ep_n		= mcpu_ep;
-	struct device_node *mcpu_port_top	= of_get_next_child(of_get_parent(mcpu_port), NULL);
+	struct device_node *mcpu_ports		= of_get_parent(mcpu_port);
+	struct device_node *mcpu_port_top	= of_graph_get_next_port(mcpu_ports, NULL);
 	struct device_node *mcpu_ep_top		= port_to_endpoint(mcpu_port_top);
 	struct device_node *mcodec_ep_top	= of_graph_get_remote_endpoint(mcpu_ep_top);
 	struct device_node *mcodec_port_top	= of_get_parent(mcodec_ep_top);
@@ -572,12 +568,12 @@ static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link,
 			goto mcpu_err;
 
 		codec_idx = 0;
-		mcodec_port_i = of_get_next_child(mcodec_ports, NULL);
+		mcodec_port_i = of_graph_get_next_port(mcodec_ports, NULL);
 		while (1) {
 			if (codec_idx > dai_link->num_codecs)
 				goto mcodec_err;
 
-			mcodec_port_i = of_get_next_child(mcodec_ports, mcodec_port_i);
+			mcodec_port_i = of_graph_get_next_port(mcodec_ports, mcodec_port_i);
 
 			if (!mcodec_port_i)
 				goto mcodec_err;
@@ -967,7 +963,7 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv,
 	of_node_get(lnk);
 	port0 = lnk;
 	ports = of_get_parent(port0);
-	port1 = of_get_next_child(ports, lnk);
+	port1 = of_graph_get_next_port(ports, port0);
 
 	/*
 	 * Card2 can use original Codec2Codec settings if DT has.
@@ -1099,21 +1095,12 @@ static int graph_counter(struct device_node *lnk)
 	 */
 	if (graph_lnk_is_multi(lnk)) {
 		struct device_node *ports = of_get_parent(lnk);
-		struct device_node *port = NULL;
-		int cnt = 0;
 
 		/*
 		 * CPU/Codec = N:M case has many endpoints.
 		 * We can't use of_graph_get_endpoint_count() here
 		 */
-		while(1) {
-			port = of_get_next_child(ports, port);
-			if (!port)
-				break;
-			cnt++;
-		}
-
-		return cnt - 1;
+		return of_graph_get_port_count(ports) - 1;
 	}
 	/*
 	 * Single CPU / Codec
@@ -1197,7 +1184,7 @@ static int graph_count_c2c(struct simple_util_priv *priv,
 {
 	struct device_node *ports = of_get_parent(lnk);
 	struct device_node *port0 = lnk;
-	struct device_node *port1 = of_get_next_child(ports, lnk);
+	struct device_node *port1 = of_graph_get_next_port(ports, port0);
 	struct device_node *ep0 = port_to_endpoint(port0);
 	struct device_node *ep1 = port_to_endpoint(port1);
 	struct device_node *codec0 = of_graph_get_remote_port(ep0);
-- 
2.25.1


  parent reply	other threads:[~2024-01-23  0:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23  0:03 [PATCH 00/13] of: property: add port base loop Kuninori Morimoto
2024-01-23  0:03 ` [PATCH 01/13] " Kuninori Morimoto
2024-01-23  0:03 ` [PATCH 02/13] of: property: use of_graph_get_next_port() on of_graph_get_next_endpoint() Kuninori Morimoto
2024-01-23  0:04 ` [PATCH 03/13] of: property: add of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-25 16:27   ` kernel test robot
2024-01-23  0:04 ` [PATCH 04/13] drm: omapdrm: use of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-23  0:04 ` [PATCH 05/13] media: xilinx-tpg: " Kuninori Morimoto
2024-01-23  0:04 ` [PATCH 06/13] ASoC: audio-graph-card.c: " Kuninori Morimoto
2024-01-23  0:04 ` Kuninori Morimoto [this message]
2024-01-23  0:04 ` [PATCH 08/13] ASoC: audio-graph-card2.c: " Kuninori Morimoto
2024-01-23  0:04 ` [PATCH 09/13] ASoC: test-component: use for_each_port_of_node() Kuninori Morimoto
2024-01-23  0:04 ` [PATCH 10/13] fbdev: omapfb: use of_graph_get_remote_port() Kuninori Morimoto
2024-01-23  0:05 ` [PATCH 11/13] fbdev: omapfb: use of_graph_get_next_port() Kuninori Morimoto
2024-01-27 15:57   ` kernel test robot
2024-01-23  0:05 ` [PATCH 12/13] fbdev: omapfb: use of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-23  0:05 ` [PATCH 13/13] fbdev: omapfb: use of_graph_get_next_endpoint() 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=87a5owud7z.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=airlied@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mchehab@kernel.org \
    --cc=michal.simek@amd.com \
    --cc=mripard@kernel.org \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=saravanak@google.com \
    --cc=tiwai@suse.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=tzimmermann@suse.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).