Re: [PATCH] checks: Fix detection of 'i2c-bus' node

David Gidson <[email protected]>
Newsgroups org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-tegra
Message-ID <aG-FPE9rBRqhq70h@zatzit>
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 <[email protected]>

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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIyBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmhvhSwACgkQzQJF27ox
2Gd26A/4i1INuUVnYIhUjSa7EnBNB+F6YLtDjjcc7ux8idax3svy4Nlv5dP9FYLD
tjcXfKYptZaKejhntmFIpUgKlGhquvH762/96A9KrYlFT3NaPAg1nQu9aEZFRCXz
meuoSgGZjVMUblzj2XwJ7g+wYb6fdMVal6STw+Jm6ExHJDrauCng1VKcOK1Shoec
aX1BvUlElLvSyoOOc41oBgxqgorNopVnj9rcFsY7AJ/EByBl1kRntnxfrlWktqV1
QTuajgId8dLZpU7PpSCHLEmofFyr2uqF1kmIoPq99KOuWRnpEXwZlWfb8D4K3a6V
MurHhDohFGa12KQrMS7xOoUi1ZD+NEB9ACkqsTX833bGGhmpXdkeY+VeAOHKbi9Y
hWXxVBS23hV7jZrc548zpdBvCXRw0xor5MerxgcYuNZ6eNXpE1XJfxWul3xfBOhD
GdF8uekdinN8A1MojAG0nXqYGppqL10SPYxCI/PjanKCsOcVQUPaQUo35Oeo5cJl
t2K1Nl/2ilDc/P4eiEuHlDx4G5Z3Rtx6TWa3iX5x307mxGwC+mzRF2/+ZVkocfsk
+CybUGCGY2vq2yUEgB1gUMg5xtXpx1XDHRJhgGeTBCGzGUvnJHX2UylOdal24oLE
sQ9RhZ+3bBc/tU2ayw9jgePl4gV/Kc/u0i7q5ibvjfUBDX5Ucg==
=ID+b
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.