summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ofw/fdt.c21
-rw-r--r--sys/dev/ofw/openfirm.h3
2 files changed, 22 insertions, 2 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
index cdb588b3f5c..988cdbb8030 100644
--- a/sys/dev/ofw/fdt.c
+++ b/sys/dev/ofw/fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.c,v 1.8 2016/04/06 12:10:04 patrick Exp $ */
+/* $OpenBSD: fdt.c,v 1.9 2016/05/16 21:12:17 kettenis Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@@ -701,3 +701,22 @@ OF_getprop(int handle, char *prop, void *buf, int buflen)
memcpy(buf, data, min(len, buflen));
return len;
}
+
+int
+OF_is_compatible(int handle, const char *name)
+{
+ void *node = (char *)tree.header + handle;
+ char *data;
+ int len;
+
+ len = fdt_node_property(node, "compatible", &data);
+ while (len > 0) {
+ if (strcmp(data, name) == 0)
+ return 1;
+ len -= strlen(data) + 1;
+ data += strlen(data) + 1;
+ }
+
+ return 0;
+}
+
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 5affb5fcfa4..4b9c3cf0976 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: openfirm.h,v 1.10 2007/10/14 17:26:59 kettenis Exp $ */
+/* $OpenBSD: openfirm.h,v 1.11 2016/05/16 21:12:17 kettenis Exp $ */
/* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */
/*
@@ -51,6 +51,7 @@ int OF_getprop(int handle, char *prop, void *buf, int buflen);
int OF_setprop(int, char *, const void *, int);
int OF_nextprop(int, char *, void *);
int OF_finddevice(char *name);
+int OF_is_compatible(int, const char *);
int OF_instance_to_path(int ihandle, char *buf, int buflen);
int OF_package_to_path(int phandle, char *buf, int buflen);
int OF_call_method_1(char *method, int ihandle, int nargs, ...);