diff options
Diffstat (limited to 'drivers/of/base.c')
-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, | |||
63 | return pp ? pp->value : NULL; | 63 | return pp ? pp->value : NULL; |
64 | } | 64 | } |
65 | EXPORT_SYMBOL(of_get_property); | 65 | EXPORT_SYMBOL(of_get_property); |
66 | |||
67 | /** Checks if the given "compat" string matches one of the strings in | ||
68 | * the device's "compatible" property | ||
69 | */ | ||
70 | int of_device_is_compatible(const struct device_node *device, | ||
71 | const char *compat) | ||
72 | { | ||
73 | const char* cp; | ||
74 | int cplen, l; | ||
75 | |||
76 | cp = of_get_property(device, "compatible", &cplen); | ||
77 | if (cp == NULL) | ||
78 | return 0; | ||
79 | while (cplen > 0) { | ||
80 | if (of_compat_cmp(cp, compat, strlen(compat)) == 0) | ||
81 | return 1; | ||
82 | l = strlen(cp) + 1; | ||
83 | cp += l; | ||
84 | cplen -= l; | ||
85 | } | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | EXPORT_SYMBOL(of_device_is_compatible); | ||