diff mbox

fix of_flat_dt_is_compatible to match the full compatible string

Message ID 1279841330-28695-1-git-send-email-stuart.yoder@freescale.com (mailing list archive)
State Accepted, archived
Delegated to: Grant Likely
Headers show

Commit Message

Stuart Yoder July 22, 2010, 11:28 p.m. UTC
From: Stuart Yoder <stuart.yoder@freescale.com>

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 <stuart.yoder@freescale.com>
---
 drivers/of/fdt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Benjamin Herrenschmidt July 23, 2010, 2:45 a.m. UTC | #1
On Thu, 2010-07-22 at 18:28 -0500, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder@freescale.com>
> 
> 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 <stuart.yoder@freescale.com>

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.

> ---
>  drivers/of/fdt.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index dee4fb5..f5239c0 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -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;
Grant Likely July 24, 2010, 10 p.m. UTC | #2
On Thu, Jul 22, 2010 at 8:45 PM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Thu, 2010-07-22 at 18:28 -0500, Stuart Yoder wrote:
>> From: Stuart Yoder <stuart.yoder@freescale.com>
>>
>> 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 <stuart.yoder@freescale.com>
>
> 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.

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.

>
> Cheers,
> Ben.
>
>> ---
>>  drivers/of/fdt.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index dee4fb5..f5239c0 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -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;
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
diff mbox

Patch

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index dee4fb5..f5239c0 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -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;