|
@@ -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);
|