diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-05-01 10:29:19 +0400 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-07-20 07:29:51 +0400 |
commit | 0081cbc3731de8ad4744ba433af51f17bf27eb9c (patch) | |
tree | b03e5c4b7087ad78a230722850a29a72b2960663 /drivers/of | |
parent | 97e873e5c8ad8711ce4cca080cff4eb5d21b3aeb (diff) | |
download | linux-0081cbc3731de8ad4744ba433af51f17bf27eb9c.tar.xz |
Consolidate of_device_is_compatible
The only difference here is that Sparc uses strncmp to match compatibility
names while PowerPC uses strncasecmp.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 723d80d704e0..d6dc5e74c27c 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -63,3 +63,27 @@ const void *of_get_property(const struct device_node *np, const char *name, return pp ? pp->value : NULL; } EXPORT_SYMBOL(of_get_property); + +/** Checks if the given "compat" string matches one of the strings in + * the device's "compatible" property + */ +int of_device_is_compatible(const struct device_node *device, + const char *compat) +{ + const char* cp; + int cplen, l; + + cp = of_get_property(device, "compatible", &cplen); + if (cp == NULL) + return 0; + while (cplen > 0) { + if (of_compat_cmp(cp, compat, strlen(compat)) == 0) + return 1; + l = strlen(cp) + 1; + cp += l; + cplen -= l; + } + + return 0; +} +EXPORT_SYMBOL(of_device_is_compatible); |