summaryrefslogtreecommitdiff
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2016-08-28 21:31:21 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2016-08-28 21:31:21 +0000
commit24f4202df8ba19c09c248f190a6c1a94a26a74d4 (patch)
tree217226cc60fb1559c75c706b632d5821efc991ae /sys/dev/ofw
parent1fc157ae9102c6ac25199eb83230a1f78313ff76 (diff)
Notes
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c28
-rw-r--r--sys/dev/ofw/ofw_bus_subr.h1
2 files changed, 26 insertions, 3 deletions
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index d6a04d8f65e6..1c80106ceb61 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
#include "ofw_bus_if.h"
+#define OFW_COMPAT_LEN 255
+
int
ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd, phandle_t node)
{
@@ -178,7 +180,8 @@ ofw_bus_status_okay(device_t dev)
}
static int
-ofw_bus_node_is_compatible(const char *compat, int len, const char *onecompat)
+ofw_bus_node_is_compatible_int(const char *compat, int len,
+ const char *onecompat)
{
int onelen, l, ret;
@@ -203,6 +206,25 @@ ofw_bus_node_is_compatible(const char *compat, int len, const char *onecompat)
}
int
+ofw_bus_node_is_compatible(phandle_t node, const char *compatstr)
+{
+ char compat[OFW_COMPAT_LEN];
+ int len, rv;
+
+ if ((len = OF_getproplen(node, "compatible")) <= 0)
+ return (0);
+
+ bzero(compat, OFW_COMPAT_LEN);
+
+ if (OF_getprop(node, "compatible", compat, OFW_COMPAT_LEN) < 0)
+ return (0);
+
+ rv = ofw_bus_node_is_compatible_int(compat, len, compatstr);
+
+ return (rv);
+}
+
+int
ofw_bus_is_compatible(device_t dev, const char *onecompat)
{
phandle_t node;
@@ -219,7 +241,7 @@ ofw_bus_is_compatible(device_t dev, const char *onecompat)
if ((len = OF_getproplen(node, "compatible")) <= 0)
return (0);
- return (ofw_bus_node_is_compatible(compat, len, onecompat));
+ return (ofw_bus_node_is_compatible_int(compat, len, onecompat));
}
int
@@ -689,7 +711,7 @@ ofw_bus_find_compatible(phandle_t node, const char *onecompat)
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
len = OF_getprop_alloc(child, "compatible", 1, &compat);
if (len >= 0) {
- ret = ofw_bus_node_is_compatible(compat, len,
+ ret = ofw_bus_node_is_compatible_int(compat, len,
onecompat);
free(compat, M_OFWPROP);
if (ret != 0)
diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h
index 146009cac91b..6532a1661991 100644
--- a/sys/dev/ofw/ofw_bus_subr.h
+++ b/sys/dev/ofw/ofw_bus_subr.h
@@ -107,6 +107,7 @@ phandle_t ofw_bus_find_iparent(phandle_t);
/* Helper routine for checking compat prop */
int ofw_bus_is_compatible(device_t, const char *);
int ofw_bus_is_compatible_strict(device_t, const char *);
+int ofw_bus_node_is_compatible(phandle_t, const char *);
/*
* Helper routine to search a list of compat properties. The table is