summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/fdt.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b17a9086cbf..5cdd958db9a 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,
} while (1);
}
+/**
+ * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
+ * @node: node to test
+ * @compat: compatible string to compare with compatible list.
+ */
+int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
+{
+ const char *cp;
+ unsigned long cplen, l;
+
+ cp = of_get_flat_dt_prop(node, "compatible", &cplen);
+ if (cp == NULL)
+ return 0;
+ while (cplen > 0) {
+ if (strncasecmp(cp, compat, strlen(compat)) == 0)
+ return 1;
+ l = strlen(cp) + 1;
+ cp += l;
+ cplen -= l;
+ }
+
+ return 0;
+}
+