devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent()
       [not found] <cover.6800d0e1b9b578b82f68dec1b99b3a601d6e54ca.1495032810.git-series.kieran.bingham+renesas@ideasonboard.com>
@ 2017-05-17 15:03 ` Kieran Bingham
       [not found]   ` <56c9c74fa9e2879aea9e008d54d8b8d7b450b8ae.1495032810.git-series.kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Kieran Bingham @ 2017-05-17 15:03 UTC (permalink / raw)
  To: linux-renesas-soc, linux-media, sakari.ailus, niklas.soderlund,
	laurent.pinchart
  Cc: Kieran Bingham, Rob Herring, Frank Rowand,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

When handling endpoints, the v4l2 async framework needs to identify the
parent device of a port endpoint.

Adapt the existing of_graph_get_remote_port_parent() such that a caller
can obtain the parent of a port without parsing the remote-endpoint
first.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
 drivers/of/base.c        | 30 ++++++++++++++++++++++--------
 include/linux/of_graph.h |  1 +
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d7c4629a3a2d..f81100500999 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2455,6 +2455,27 @@ struct device_node *of_graph_get_endpoint_by_regs(
 EXPORT_SYMBOL(of_graph_get_endpoint_by_regs);
 
 /**
+ * of_graph_get_port_parent() - get port's parent node
+ * @node: pointer to a local endpoint device_node
+ *
+ * Return: device node associated with endpoint @node.
+ *	   Use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_port_parent(struct device_node *node)
+{
+	unsigned int depth;
+
+	/* Walk 3 levels up only if there is 'ports' node. */
+	for (depth = 3; depth && node; depth--) {
+		node = of_get_next_parent(node);
+		if (depth == 2 && of_node_cmp(node->name, "ports"))
+			break;
+	}
+	return node;
+}
+EXPORT_SYMBOL(of_graph_get_port_parent);
+
+/**
  * of_graph_get_remote_port_parent() - get remote port's parent node
  * @node: pointer to a local endpoint device_node
  *
@@ -2465,18 +2486,11 @@ struct device_node *of_graph_get_remote_port_parent(
 			       const struct device_node *node)
 {
 	struct device_node *np;
-	unsigned int depth;
 
 	/* Get remote endpoint node. */
 	np = of_parse_phandle(node, "remote-endpoint", 0);
 
-	/* Walk 3 levels up only if there is 'ports' node. */
-	for (depth = 3; depth && np; depth--) {
-		np = of_get_next_parent(np);
-		if (depth == 2 && of_node_cmp(np->name, "ports"))
-			break;
-	}
-	return np;
+	return of_graph_get_port_parent(np);
 }
 EXPORT_SYMBOL(of_graph_get_remote_port_parent);
 
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index abdb02eaef06..49bf34880ebc 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -48,6 +48,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
 struct device_node *of_graph_get_endpoint_by_regs(
 		const struct device_node *parent, int port_reg, int reg);
+struct device_node *of_graph_get_port_parent(struct device_node *node);
 struct device_node *of_graph_get_remote_port_parent(
 					const struct device_node *node);
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
-- 
git-series 0.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent()
       [not found]   ` <56c9c74fa9e2879aea9e008d54d8b8d7b450b8ae.1495032810.git-series.kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2017-05-17 16:36     ` Rob Herring
       [not found]       ` <CAL_JsqLvXH3kKV-DxWuNrAYGh8=L8Mdg5zcm2RsHZTpmi_8g-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2017-05-17 16:36 UTC (permalink / raw)
  To: Kieran Bingham
  Cc: open list:MEDIA DRIVERS FOR RENESAS - FCP,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Sakari Ailus,
	Niklas Söderlund, Laurent Pinchart, Kieran Bingham,
	Frank Rowand, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
	open list

On Wed, May 17, 2017 at 10:03 AM, Kieran Bingham <kbingham-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> From: Kieran Bingham <kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
>
> When handling endpoints, the v4l2 async framework needs to identify the
> parent device of a port endpoint.
>
> Adapt the existing of_graph_get_remote_port_parent() such that a caller
> can obtain the parent of a port without parsing the remote-endpoint
> first.

A similar patch is already applied as part of the ASoC graph card support.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent()
       [not found]       ` <CAL_JsqLvXH3kKV-DxWuNrAYGh8=L8Mdg5zcm2RsHZTpmi_8g-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-05-17 20:02         ` Kieran Bingham
       [not found]           ` <61138419-5781-bbec-7ac5-44524ad501ce-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
  2017-05-18 13:18           ` Laurent Pinchart
  0 siblings, 2 replies; 5+ messages in thread
From: Kieran Bingham @ 2017-05-17 20:02 UTC (permalink / raw)
  To: Rob Herring, Kieran Bingham, Kuninori Morimoto
  Cc: open list:MEDIA DRIVERS FOR RENESAS - FCP,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Sakari Ailus,
	Niklas Söderlund, Laurent Pinchart, Frank Rowand,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

On 17/05/17 17:36, Rob Herring wrote:
> On Wed, May 17, 2017 at 10:03 AM, Kieran Bingham <kbingham-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>> From: Kieran Bingham <kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
>>
>> When handling endpoints, the v4l2 async framework needs to identify the
>> parent device of a port endpoint.
>>
>> Adapt the existing of_graph_get_remote_port_parent() such that a caller
>> can obtain the parent of a port without parsing the remote-endpoint
>> first.
> 
> A similar patch is already applied as part of the ASoC graph card support.
> 
> Rob

Ah yes, a quick google finds it...
:  https://patchwork.kernel.org/patch/9658907/

Surprisingly similar patch ... and a familiar name.

Morimoto-san - you beat me to it :D !

Thanks Rob, (And Morimoto!)

--
Kieran
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent()
       [not found]           ` <61138419-5781-bbec-7ac5-44524ad501ce-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2017-05-17 23:53             ` Kuninori Morimoto
  0 siblings, 0 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2017-05-17 23:53 UTC (permalink / raw)
  To: kieran.bingham-ryLnwIuWjnjg/C1BVhZhaw, Kieran Bingham
  Cc: Rob Herring, Kieran Bingham,
	open list:MEDIA DRIVERS FOR RENESAS - FCP,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Sakari Ailus,
	Niklas Söderlund, Laurent Pinchart, Frank Rowand,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list


Hi Kieran

> >> From: Kieran Bingham <kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> >>
> >> When handling endpoints, the v4l2 async framework needs to identify the
> >> parent device of a port endpoint.
> >>
> >> Adapt the existing of_graph_get_remote_port_parent() such that a caller
> >> can obtain the parent of a port without parsing the remote-endpoint
> >> first.
> > 
> > A similar patch is already applied as part of the ASoC graph card support.
> > 
> > Rob
> 
> Ah yes, a quick google finds it...
> :  https://patchwork.kernel.org/patch/9658907/
> 
> Surprisingly similar patch ... and a familiar name.
> 
> Morimoto-san - you beat me to it :D !

Interesting.
It was applies today to Mark's (= ALSA SoC Maintainer) branch !
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/?h=topic/of-graph&id=0ef472a973ebbfc20f2f12769e77a8cfd3612778


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent()
  2017-05-17 20:02         ` Kieran Bingham
       [not found]           ` <61138419-5781-bbec-7ac5-44524ad501ce-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2017-05-18 13:18           ` Laurent Pinchart
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2017-05-18 13:18 UTC (permalink / raw)
  To: kieran.bingham
  Cc: Rob Herring, Kieran Bingham, Kuninori Morimoto,
	open list:MEDIA DRIVERS FOR RENESAS - FCP,
	linux-media@vger.kernel.org, Sakari Ailus, Niklas Söderlund,
	Frank Rowand, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
	open list

Hi Kieran,

On Wednesday 17 May 2017 21:02:42 Kieran Bingham wrote:
> On 17/05/17 17:36, Rob Herring wrote:
> > On Wed, May 17, 2017 at 10:03 AM, Kieran Bingham wrote:
> >> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> >> 
> >> When handling endpoints, the v4l2 async framework needs to identify the
> >> parent device of a port endpoint.
> >> 
> >> Adapt the existing of_graph_get_remote_port_parent() such that a caller
> >> can obtain the parent of a port without parsing the remote-endpoint
> >> first.
> > 
> > A similar patch is already applied as part of the ASoC graph card support.
> > 
> > Rob
> 
> Ah yes, a quick google finds it...
> 
> :  https://patchwork.kernel.org/patch/9658907/
> 
> Surprisingly similar patch ... and a familiar name.

Very similar indeed, down to identical problems ;-) Quoting your patch,

>  /**
> + * of_graph_get_port_parent() - get port's parent node
> + * @node: pointer to a local endpoint device_node
> + *
> + * Return: device node associated with endpoint @node.
> + *	   Use of_node_put() on it when done.
> + */

The documentation of the return value is a bit confusing to me. I assume that, 
by device node, you meant the DT node corresponding to the device of the 
endpoint which is passed as an argument. However, device node cal also refer 
to struct device_node. Should this be clarified ?

> Morimoto-san - you beat me to it :D !
> 
> Thanks Rob, (And Morimoto!)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-18 13:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.6800d0e1b9b578b82f68dec1b99b3a601d6e54ca.1495032810.git-series.kieran.bingham+renesas@ideasonboard.com>
2017-05-17 15:03 ` [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent() Kieran Bingham
     [not found]   ` <56c9c74fa9e2879aea9e008d54d8b8d7b450b8ae.1495032810.git-series.kieran.bingham+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2017-05-17 16:36     ` Rob Herring
     [not found]       ` <CAL_JsqLvXH3kKV-DxWuNrAYGh8=L8Mdg5zcm2RsHZTpmi_8g-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-17 20:02         ` Kieran Bingham
     [not found]           ` <61138419-5781-bbec-7ac5-44524ad501ce-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2017-05-17 23:53             ` Kuninori Morimoto
2017-05-18 13:18           ` Laurent Pinchart

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).