From: Rob Herring <robh@kernel.org>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: "\"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>,
"Saravana Kannan" <saravanak@google.com>,
"Takashi Iwai" <tiwai@suse.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Tomi Valkeinen" <tomi.valkeinen@ideasonboard.com>,
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: Re: [PATCH v2 01/13] of: property: add port base loop
Date: Wed, 31 Jan 2024 12:52:19 -0600 [thread overview]
Message-ID: <20240131185219.GB1906672-robh@kernel.org> (raw)
In-Reply-To: <87ede1klgr.wl-kuninori.morimoto.gx@renesas.com>
On Mon, Jan 29, 2024 at 12:54:44AM +0000, Kuninori Morimoto wrote:
> We have endpoint base functions
> - of_graph_get_next_endpoint()
> - of_graph_get_endpoint_count()
> - for_each_endpoint_of_node()
>
> Here, for_each_endpoint_of_node() loop finds each endpoints
>
> ports {
> port@0 {
> (1) endpoint {...};
> };
> port@1 {
> (2) endpoint {...};
> };
> ...
> };
>
> In above case, for_each_endpoint_of_node() loop finds endpoint as
> (1) -> (2) -> ...
>
> Basically, user/driver knows which port is used for what, but not in
> all cases. For example on flexible/generic driver case, how many ports
> are used is not fixed.
>
> For example Sound Generic Card driver which is used from many venders
> can't know how many ports are used. Because the driver is very
> flexible/generic, it is impossible to know how many ports are used,
> it depends on each vender SoC and/or its used board.
>
> And more, the port can have multi endpoints. For example Generic Sound
> Card case, it supports many type of connection between CPU / Codec, and
> some of them uses multi endpoint in one port.
> Then, Generic Sound Card want to handle each connection via "port"
> instead of "endpoint".
> But, it is very difficult to handle each "port" by
> for_each_endpoint_of_node(). Getting "port" by using of_get_parent()
> from "endpoint" doesn't work. see below.
>
> ports {
> port@0 {
> (1) endpoint@0 {...};
> (2) endpoint@1 {...};
> };
> port@1 {
> (3) endpoint {...};
> };
> ...
> };
>
> Add "port" base functions.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> drivers/of/property.c | 48 ++++++++++++++++++++++++++++++++++++++++
> include/linux/of_graph.h | 21 ++++++++++++++++++
> 2 files changed, 69 insertions(+)
>
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index afdaefbd03f6..9e670e99dbbb 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -631,6 +631,42 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id)
> }
> EXPORT_SYMBOL(of_graph_get_port_by_id);
>
> +/**
> + * of_graph_get_next_port() - get next port node
> + * @parent: pointer to the parent device node
> + * @port: current port node, or NULL to get first
> + *
> + * Return: An 'port' node pointer with refcount incremented. Refcount
> + * of the passed @prev node is decremented.
> + */
> +struct device_node *of_graph_get_next_port(const struct device_node *parent,
> + struct device_node *port)
> +{
> + if (!parent)
> + return NULL;
> +
> + if (!port) {
> + struct device_node *node;
> +
> + node = of_get_child_by_name(parent, "ports");
> + if (node) {
> + parent = node;
> + of_node_put(node);
The original code had this right, but here you have it wrong.
You are releasing ports here, but then using it...
> + }
> +
> + return of_get_child_by_name(parent, "port");
...here. You have to get the child before you can put the parent.
> + }
> +
> + do {
> + port = of_get_next_child(parent, port);
> + if (!port)
> + break;
> + } while (!of_node_name_eq(port, "port"));
> +
> + return port;
> +}
> +EXPORT_SYMBOL(of_graph_get_next_port);
> +
next prev parent reply other threads:[~2024-01-31 18:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 0:54 [PATCH v2 00/13] of: property: add port base loop Kuninori Morimoto
2024-01-29 0:54 ` [PATCH v2 01/13] " Kuninori Morimoto
2024-01-29 12:16 ` Tomi Valkeinen
2024-01-31 18:52 ` Rob Herring [this message]
2024-01-31 23:25 ` Kuninori Morimoto
2024-01-31 18:59 ` Rob Herring
2024-01-29 0:54 ` [PATCH v2 02/13] of: property: use of_graph_get_next_port() on of_graph_get_next_endpoint() Kuninori Morimoto
2024-01-29 12:18 ` Tomi Valkeinen
2024-01-29 0:54 ` [PATCH v2 03/13] of: property: add of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-29 12:29 ` Tomi Valkeinen
2024-01-29 13:02 ` Laurent Pinchart
2024-01-30 0:08 ` Kuninori Morimoto
2024-01-31 18:43 ` Rob Herring
2024-02-01 0:43 ` Kuninori Morimoto
2024-02-01 1:48 ` Kuninori Morimoto
2024-01-29 13:37 ` Sakari Ailus
2024-01-30 0:37 ` Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 04/13] drm: omapdrm: use of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 05/13] media: xilinx-tpg: " Kuninori Morimoto
2024-01-30 13:35 ` kernel test robot
2024-01-29 0:55 ` [PATCH v2 06/13] ASoC: audio-graph-card: " Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 07/13] ASoC: audio-graph-card2: use of_graph_get_next_port() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 08/13] ASoC: audio-graph-card2: use of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 09/13] ASoC: test-component: use for_each_port_of_node() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 10/13] fbdev: omapfb: use of_graph_get_remote_port() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 11/13] fbdev: omapfb: use of_graph_get_next_port() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 12/13] fbdev: omapfb: use of_graph_get_next_endpoint_raw() Kuninori Morimoto
2024-01-29 0:55 ` [PATCH v2 13/13] fbdev: omapfb: use of_graph_get_next_endpoint() Kuninori Morimoto
2024-01-29 12:27 ` [PATCH v2 00/13] of: property: add port base loop Laurent Pinchart
2024-01-29 13:29 ` Sakari Ailus
2024-01-30 0:34 ` Kuninori Morimoto
2024-01-30 7:31 ` Sakari Ailus
2024-01-30 7:37 ` Tomi Valkeinen
2024-01-30 7:40 ` Sakari Ailus
2024-01-30 23:24 ` Kuninori Morimoto
2024-02-01 9:18 ` Sakari Ailus
2024-02-05 5:31 ` Kuninori Morimoto
2024-02-05 9:26 ` Laurent Pinchart
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=20240131185219.GB1906672-robh@kernel.org \
--to=robh@kernel.org \
--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=kuninori.morimoto.gx@renesas.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=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).