fix of_flat_dt_is_compatible to match the full compatible string
PATCH 1/1 fix of_flat_dt_is_compatible to match the full compatible string
From: Stuart Yoder <[email protected]>
With the previous string comparison, a device tree compatible of "foo-bar" would match as compatible with a driver looking for "foo".
--- drivers/of/fdt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/of/fdt.c +1 -1
@@ -169,7 +169,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)if (cp ==NULL )return 0 ;while (cplen >0 ) { -if (strncasecmp (cp, compat,strlen (compat)) ==0 ) +if (!strcmp (cp, compat))return 1 ; l =strlen (cp) +1 ; cp += l;
Signature · 1 line
1.6.2.5
Quoted 7 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
With the previous string comparison, a device tree compatible of "foo-bar" would match as compatible with a driver looking for "foo".
Signed-off-by Stuart Yoder <[email protected]>
Beware you are doing two changes in one here and only documenting one...
You also removed the case insenstivity.
Now, those things are supposed to be case sensitive afaik, but we have enough legacy HW with more/less crap DTs and I'd be careful with changing that without a good reason (ie, it breaks not to do it ?).
No objection with fixing the partial match tho.
Cheers,
Ben.
Quoted 17 lines
--- drivers/of/fdt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/of/fdt.c +1
-1@@ -169,7 +169,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)if (cp ==NULL )return 0 ;while (cplen >0 ) { -if (strncasecmp (cp, compat,strlen (compat)) ==0 ) +if (!strcmp (cp, compat))return 1 ; l =strlen (cp) +1 ; cp += l;
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 7 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
With the previous string comparison, a device tree compatible of "foo-bar" would match as compatible with a driver looking for "foo".
Signed-off-by Stuart Yoder <[email protected]>Beware you are doing two changes in one here and only documenting one...
Quoted 7 lines
You also removed the case insenstivity.
Now, those things are supposed to be case sensitive afaik, but we have enough legacy HW with more/less crap DTs and I'd be careful with changing that without a good reason (ie, it breaks not to do it ?).
No objection with fixing the partial match tho.
On that note, for completeness, this code should be using the of_compat_cmp() to match up with other code. If SPARC ever uses this code, which davem said he might tp support kexec, then this macro will be important. I'll change it when I pick up the patch.
g.
Quoted 8 lines
Cheers,
Ben.Quoted 4 lines
---
=A0drivers/of/fdt.c | =A0 =A02 +-
=A01 files changed, 1 insertions(+), 1 deletions(-)
Quoted 5 lines
drivers/of/fdt.c int __init of_flat_dt_is_compatible(unsigned long no=
Quoted 5 lines
drivers/of/fdt.c +0
-0@@ -169,7 +169,7 @@ int __init of_flat_dt_is_compatible(unsigned long no=
de, const char *compat)
Quoted 4 lines
drivers/of/fdt.c int __init of_flat_dt_is_compatible(unsigned long no= · line 172
Quoted 4 lines
drivers/of/fdt.c +0
-1=A0 =A0 =A0 if (cp =3D=3D NULL) =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 while (cplen > 0) { - =A0 =A0 =A0 =A0 =A0 =A0 if (strncasecmp(cp, compat, strlen(compat)) =
=3D=3D 0)
Quoted 11 lines
drivers/of/fdt.c int __init of_flat_dt_is_compatible(unsigned long no= · line 175
Quoted 4 lines
drivers/of/fdt.c +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 if (!strcmp(cp, compat)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 l =3D strlen(cp) + 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 cp +=3D l;_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.