linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checks: Fix detection of 'i2c-bus' node
@ 2025-07-09 14:24 Jon Hunter
  2025-07-10  9:17 ` David Gidson
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Hunter @ 2025-07-09 14:24 UTC (permalink / raw)
  To: devicetree-compiler, David Gidson, Rob Herring; +Cc: linux-tegra, Jon Hunter

If an I2C controller has a 'i2c-bus' child node, then the function
check_i2c_bus_bridge() does not detect this as expected and warnings
such as the following are observed:

 Warning (i2c_bus_bridge): /example-0/i2c@7000c000: \
     incorrect #address-cells for I2C bus
 Warning (i2c_bus_bridge): /example-0/i2c@7000c000: \
     incorrect #size-cells for I2C bus

These warnings occur because the '#address-cells' and '#size-cells' are
not directly present under the I2C controller node but the 'i2c-bus'
child node. The function check_i2c_bus_bridge() does not detect this
because it is using the parent node's 'basenamelen' and not the child
node's 'basenamelen' when comparing the child node name with 'i2c-bus'.
The parent node's 'basenamelen' is shorter ('i2c') than 'i2c-bus' and so
the strprefixeq() test fails. Fix this by using the child node
'basenamelen' when comparing the child node name.

Fixes: 53a1bd546905 ("checks: add I2C bus checks")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 checks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/checks.c b/checks.c
index 123f2eb425f4..7e3fed5005b3 100644
--- a/checks.c
+++ b/checks.c
@@ -1024,7 +1024,7 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
 	} else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
 		struct node *child;
 		for_each_child(node, child) {
-			if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
+			if (strprefixeq(child->name, child->basenamelen, "i2c-bus"))
 				return;
 		}
 		node->bus = &i2c_bus;
-- 
2.43.0


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

* Re: [PATCH] checks: Fix detection of 'i2c-bus' node
  2025-07-09 14:24 [PATCH] checks: Fix detection of 'i2c-bus' node Jon Hunter
@ 2025-07-10  9:17 ` David Gidson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gidson @ 2025-07-10  9:17 UTC (permalink / raw)
  To: Jon Hunter; +Cc: devicetree-compiler, Rob Herring, linux-tegra

[-- Attachment #1: Type: text/plain, Size: 1962 bytes --]

On Wed, Jul 09, 2025 at 03:24:52PM +0100, Jon Hunter wrote:
> If an I2C controller has a 'i2c-bus' child node, then the function
> check_i2c_bus_bridge() does not detect this as expected and warnings
> such as the following are observed:
> 
>  Warning (i2c_bus_bridge): /example-0/i2c@7000c000: \
>      incorrect #address-cells for I2C bus
>  Warning (i2c_bus_bridge): /example-0/i2c@7000c000: \
>      incorrect #size-cells for I2C bus
> 
> These warnings occur because the '#address-cells' and '#size-cells' are
> not directly present under the I2C controller node but the 'i2c-bus'
> child node. The function check_i2c_bus_bridge() does not detect this
> because it is using the parent node's 'basenamelen' and not the child
> node's 'basenamelen' when comparing the child node name with 'i2c-bus'.
> The parent node's 'basenamelen' is shorter ('i2c') than 'i2c-bus' and so
> the strprefixeq() test fails. Fix this by using the child node
> 'basenamelen' when comparing the child node name.
> 
> Fixes: 53a1bd546905 ("checks: add I2C bus checks")
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>

Merged, thanks.

> ---
>  checks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/checks.c b/checks.c
> index 123f2eb425f4..7e3fed5005b3 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -1024,7 +1024,7 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
>  	} else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
>  		struct node *child;
>  		for_each_child(node, child) {
> -			if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
> +			if (strprefixeq(child->name, child->basenamelen, "i2c-bus"))
>  				return;
>  		}
>  		node->bus = &i2c_bus;

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2025-07-10  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 14:24 [PATCH] checks: Fix detection of 'i2c-bus' node Jon Hunter
2025-07-10  9:17 ` David Gidson

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