diff mbox series

[v2,02/13] of: property: use of_graph_get_next_port() on of_graph_get_next_endpoint()

Message ID 87cytlklgl.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Not Applicable
Headers show
Series of: property: add port base loop | expand

Commit Message

Kuninori Morimoto Jan. 29, 2024, 12:54 a.m. UTC
We have of_graph_get_next_port(), use it on of_graph_get_next_endpoint().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/property.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Tomi Valkeinen Jan. 29, 2024, 12:18 p.m. UTC | #1
On 29/01/2024 02:54, Kuninori Morimoto wrote:
> We have of_graph_get_next_port(), use it on of_graph_get_next_endpoint().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   drivers/of/property.c | 18 ++++--------------
>   1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 9e670e99dbbb..14ffd199c9b1 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
> @@ -690,15 +690,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
>   	 * parent port node.
>   	 */
>   	if (!prev) {
> -		struct device_node *node;
> -
> -		node = of_get_child_by_name(parent, "ports");
> -		if (node)
> -			parent = node;
> -
> -		port = of_get_child_by_name(parent, "port");
> -		of_node_put(node);
> -
> +		port = of_graph_get_next_port(parent, NULL);
>   		if (!port) {
>   			pr_err("graph: no port node found in %pOF\n", parent);
>   			return NULL;
> @@ -725,11 +717,9 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
>   		/* No more endpoints under this port, try the next one. */
>   		prev = NULL;
>   
> -		do {
> -			port = of_get_next_child(parent, port);
> -			if (!port)
> -				return NULL;
> -		} while (!of_node_name_eq(port, "port"));
> +		port = of_graph_get_next_port(parent, port);
> +		if (!port)
> +			return NULL;
>   	}
>   }
>   EXPORT_SYMBOL(of_graph_get_next_endpoint);

Reviewed-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

  Tomi
diff mbox series

Patch

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 9e670e99dbbb..14ffd199c9b1 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -690,15 +690,7 @@  struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 	 * parent port node.
 	 */
 	if (!prev) {
-		struct device_node *node;
-
-		node = of_get_child_by_name(parent, "ports");
-		if (node)
-			parent = node;
-
-		port = of_get_child_by_name(parent, "port");
-		of_node_put(node);
-
+		port = of_graph_get_next_port(parent, NULL);
 		if (!port) {
 			pr_err("graph: no port node found in %pOF\n", parent);
 			return NULL;
@@ -725,11 +717,9 @@  struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 		/* No more endpoints under this port, try the next one. */
 		prev = NULL;
 
-		do {
-			port = of_get_next_child(parent, port);
-			if (!port)
-				return NULL;
-		} while (!of_node_name_eq(port, "port"));
+		port = of_graph_get_next_port(parent, port);
+		if (!port)
+			return NULL;
 	}
 }
 EXPORT_SYMBOL(of_graph_get_next_endpoint);