All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checks: Remove check for graph child addresses
@ 2025-07-08 16:02 Niklas Söderlund
  2025-07-08 16:18 ` Niklas Söderlund
  0 siblings, 1 reply; 3+ messages in thread
From: Niklas Söderlund @ 2025-07-08 16:02 UTC (permalink / raw)
  To: Rob Herring, David Gibson, Saravana Kannan, Geert Uytterhoeven,
	devicetree
  Cc: linux-renesas-soc, Niklas Söderlund

The dtc graph_child_address check can't distinguish between bindings
where there can only be a single endpoint, and cases where there can be
multiple endpoints.

In cases where the bindings allow for multiple endpoints but only one is
described false warnings about unnecessary #address-cells/#size-cells
can be generated, but only if the endpoint described have an address of
0 (A), for single endpoints with a non-zero address (B) no warnings are
generated.

A)
    ports {
	#address-cells = <1>;
	#size-cells = <0>;

	port@0 {
	    #address-cells = <1>;
	    #size-cells = <0>;

	    sourceA: endpoint@0 {
		reg = <0>
	    };
	};
    };

B)
    ports {
	#address-cells = <1>;
	#size-cells = <0>;

	port@0 {
	    #address-cells = <1>;
	    #size-cells = <0>;

	    sourceB: endpoint@1 {
		reg = <1>
	    };
	};
    };

Remove the check as it is somewhat redundant now that we can use schemas
to validate the full node.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Hello,

This started as an effort to demote this check to W=2 [1] and have then
moved on from there to completely remove the check in this patch per
David and Rob's suggestion.

This patch supersedes all other patches for my me in this area.

If this change is accepted in dtc and later checks.c synced to
linux/scripts/dtc/checks.c one must also drop "-Wno-graph_child_address"
from Documentation/devicetree/bindings/Makefile and
scripts/Makefile.dtbs.

1.  https://lore.kernel.org/all/20250702085008.689727-1-niklas.soderlund%2Brenesas@ragnatech.se/
---
 checks.c | 27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/checks.c b/checks.c
index 123f2eb425f4..0b1fd9f13cb4 100644
--- a/checks.c
+++ b/checks.c
@@ -1894,31 +1894,6 @@ static void check_graph_endpoint(struct check *c, struct dt_info *dti,
 }
 WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes);
 
-static void check_graph_child_address(struct check *c, struct dt_info *dti,
-				      struct node *node)
-{
-	int cnt = 0;
-	struct node *child;
-
-	if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
-		return;
-
-	for_each_child(node, child) {
-		struct property *prop = get_property(child, "reg");
-
-		/* No error if we have any non-zero unit address */
-                if (prop && propval_cell(prop) != 0 )
-			return;
-
-		cnt++;
-	}
-
-	if (cnt == 1 && node->addr_cells != -1)
-		FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
-		     node->children->name);
-}
-WARNING(graph_child_address, check_graph_child_address, NULL, &graph_nodes, &graph_port, &graph_endpoint);
-
 static struct check *check_table[] = {
 	&duplicate_node_names, &duplicate_property_names,
 	&node_name_chars, &node_name_format, &property_name_chars,
@@ -2005,7 +1980,7 @@ static struct check *check_table[] = {
 
 	&alias_paths,
 
-	&graph_nodes, &graph_child_address, &graph_port, &graph_endpoint,
+	&graph_nodes, &graph_port, &graph_endpoint,
 
 	&always_fail,
 };
-- 
2.50.0


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

* [PATCH] checks: Remove check for graph child addresses
@ 2025-07-08 16:15 Niklas Söderlund
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2025-07-08 16:15 UTC (permalink / raw)
  To: Rob Herring, David Gibson, Saravana Kannan, Geert Uytterhoeven,
	devicetree-compiler
  Cc: linux-renesas-soc, Niklas Söderlund

The dtc graph_child_address check can't distinguish between bindings
where there can only be a single endpoint, and cases where there can be
multiple endpoints.

In cases where the bindings allow for multiple endpoints but only one is
described false warnings about unnecessary #address-cells/#size-cells
can be generated, but only if the endpoint described have an address of
0 (A), for single endpoints with a non-zero address (B) no warnings are
generated.

A)
    ports {
	#address-cells = <1>;
	#size-cells = <0>;

	port@0 {
	    #address-cells = <1>;
	    #size-cells = <0>;

	    sourceA: endpoint@0 {
		reg = <0>
	    };
	};
    };

B)
    ports {
	#address-cells = <1>;
	#size-cells = <0>;

	port@0 {
	    #address-cells = <1>;
	    #size-cells = <0>;

	    sourceB: endpoint@1 {
		reg = <1>
	    };
	};
    };

Remove the check as it is somewhat redundant now that we can use schemas
to validate the full node.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Hello,

This started as an effort to demote this check to W=2 [1] and have then
moved on from there to completely remove the check in this patch per
David and Rob's suggestion.

This patch supersedes all other patches for my me in this area.

If this change is accepted in dtc and later checks.c synced to
linux/scripts/dtc/checks.c one must also drop "-Wno-graph_child_address"
from Documentation/devicetree/bindings/Makefile and
scripts/Makefile.dtbs.

1.  https://lore.kernel.org/all/20250702085008.689727-1-niklas.soderlund%2Brenesas@ragnatech.se/
---
 checks.c | 27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/checks.c b/checks.c
index 123f2eb425f4..0b1fd9f13cb4 100644
--- a/checks.c
+++ b/checks.c
@@ -1894,31 +1894,6 @@ static void check_graph_endpoint(struct check *c, struct dt_info *dti,
 }
 WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes);
 
-static void check_graph_child_address(struct check *c, struct dt_info *dti,
-				      struct node *node)
-{
-	int cnt = 0;
-	struct node *child;
-
-	if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
-		return;
-
-	for_each_child(node, child) {
-		struct property *prop = get_property(child, "reg");
-
-		/* No error if we have any non-zero unit address */
-                if (prop && propval_cell(prop) != 0 )
-			return;
-
-		cnt++;
-	}
-
-	if (cnt == 1 && node->addr_cells != -1)
-		FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
-		     node->children->name);
-}
-WARNING(graph_child_address, check_graph_child_address, NULL, &graph_nodes, &graph_port, &graph_endpoint);
-
 static struct check *check_table[] = {
 	&duplicate_node_names, &duplicate_property_names,
 	&node_name_chars, &node_name_format, &property_name_chars,
@@ -2005,7 +1980,7 @@ static struct check *check_table[] = {
 
 	&alias_paths,
 
-	&graph_nodes, &graph_child_address, &graph_port, &graph_endpoint,
+	&graph_nodes, &graph_port, &graph_endpoint,
 
 	&always_fail,
 };
-- 
2.50.0


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

* Re: [PATCH] checks: Remove check for graph child addresses
  2025-07-08 16:02 [PATCH] checks: Remove check for graph child addresses Niklas Söderlund
@ 2025-07-08 16:18 ` Niklas Söderlund
  0 siblings, 0 replies; 3+ messages in thread
From: Niklas Söderlund @ 2025-07-08 16:18 UTC (permalink / raw)
  To: Rob Herring, David Gibson, Saravana Kannan, Geert Uytterhoeven,
	devicetree
  Cc: linux-renesas-soc

Hello,

This was sent to the wrong list, please ignore it. I have resent it to 
the correct devicetree-compiler@vger.kernel.org list.

Sorry for the noise.

On 2025-07-08 18:02:01 +0200, Niklas Söderlund wrote:
> The dtc graph_child_address check can't distinguish between bindings
> where there can only be a single endpoint, and cases where there can be
> multiple endpoints.
> 
> In cases where the bindings allow for multiple endpoints but only one is
> described false warnings about unnecessary #address-cells/#size-cells
> can be generated, but only if the endpoint described have an address of
> 0 (A), for single endpoints with a non-zero address (B) no warnings are
> generated.
> 
> A)
>     ports {
> 	#address-cells = <1>;
> 	#size-cells = <0>;
> 
> 	port@0 {
> 	    #address-cells = <1>;
> 	    #size-cells = <0>;
> 
> 	    sourceA: endpoint@0 {
> 		reg = <0>
> 	    };
> 	};
>     };
> 
> B)
>     ports {
> 	#address-cells = <1>;
> 	#size-cells = <0>;
> 
> 	port@0 {
> 	    #address-cells = <1>;
> 	    #size-cells = <0>;
> 
> 	    sourceB: endpoint@1 {
> 		reg = <1>
> 	    };
> 	};
>     };
> 
> Remove the check as it is somewhat redundant now that we can use schemas
> to validate the full node.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> Hello,
> 
> This started as an effort to demote this check to W=2 [1] and have then
> moved on from there to completely remove the check in this patch per
> David and Rob's suggestion.
> 
> This patch supersedes all other patches for my me in this area.
> 
> If this change is accepted in dtc and later checks.c synced to
> linux/scripts/dtc/checks.c one must also drop "-Wno-graph_child_address"
> from Documentation/devicetree/bindings/Makefile and
> scripts/Makefile.dtbs.
> 
> 1.  https://lore.kernel.org/all/20250702085008.689727-1-niklas.soderlund%2Brenesas@ragnatech.se/
> ---
>  checks.c | 27 +--------------------------
>  1 file changed, 1 insertion(+), 26 deletions(-)
> 
> diff --git a/checks.c b/checks.c
> index 123f2eb425f4..0b1fd9f13cb4 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -1894,31 +1894,6 @@ static void check_graph_endpoint(struct check *c, struct dt_info *dti,
>  }
>  WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes);
>  
> -static void check_graph_child_address(struct check *c, struct dt_info *dti,
> -				      struct node *node)
> -{
> -	int cnt = 0;
> -	struct node *child;
> -
> -	if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus)
> -		return;
> -
> -	for_each_child(node, child) {
> -		struct property *prop = get_property(child, "reg");
> -
> -		/* No error if we have any non-zero unit address */
> -                if (prop && propval_cell(prop) != 0 )
> -			return;
> -
> -		cnt++;
> -	}
> -
> -	if (cnt == 1 && node->addr_cells != -1)
> -		FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary",
> -		     node->children->name);
> -}
> -WARNING(graph_child_address, check_graph_child_address, NULL, &graph_nodes, &graph_port, &graph_endpoint);
> -
>  static struct check *check_table[] = {
>  	&duplicate_node_names, &duplicate_property_names,
>  	&node_name_chars, &node_name_format, &property_name_chars,
> @@ -2005,7 +1980,7 @@ static struct check *check_table[] = {
>  
>  	&alias_paths,
>  
> -	&graph_nodes, &graph_child_address, &graph_port, &graph_endpoint,
> +	&graph_nodes, &graph_port, &graph_endpoint,
>  
>  	&always_fail,
>  };
> -- 
> 2.50.0
> 

-- 
Kind Regards,
Niklas Söderlund

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

end of thread, other threads:[~2025-07-08 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 16:02 [PATCH] checks: Remove check for graph child addresses Niklas Söderlund
2025-07-08 16:18 ` Niklas Söderlund
  -- strict thread matches above, loose matches on Subject: below --
2025-07-08 16:15 Niklas Söderlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.