diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2009-11-23 22:07:00 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2009-11-23 22:07:00 -0500 |
commit | 00e38efd90f27518ec96b37b1c7773e3ac529966 (patch) | |
tree | 20980561a5187ac81b79a7badc9c473802ad9829 /drivers/of | |
parent | ca900cfa2944448bdb76e1246f282e59bc65f472 (diff) |
of/flattree: Merge of_flat_dt_is_compatible
Merge common code between PowerPC and Microblaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/fdt.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index b17a9086cbfc..5cdd958db9af 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
@@ -142,3 +142,27 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name, | |||
142 | } while (1); | 142 | } while (1); |
143 | } | 143 | } |
144 | 144 | ||
145 | /** | ||
146 | * of_flat_dt_is_compatible - Return true if given node has compat in compatible list | ||
147 | * @node: node to test | ||
148 | * @compat: compatible string to compare with compatible list. | ||
149 | */ | ||
150 | int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) | ||
151 | { | ||
152 | const char *cp; | ||
153 | unsigned long cplen, l; | ||
154 | |||
155 | cp = of_get_flat_dt_prop(node, "compatible", &cplen); | ||
156 | if (cp == NULL) | ||
157 | return 0; | ||
158 | while (cplen > 0) { | ||
159 | if (strncasecmp(cp, compat, strlen(compat)) == 0) | ||
160 | return 1; | ||
161 | l = strlen(cp) + 1; | ||
162 | cp += l; | ||
163 | cplen -= l; | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||