aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ofw/openfirm.c
diff options
context:
space:
mode:
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>2009-01-03 19:38:47 +0000
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>2009-01-03 19:38:47 +0000
commitacb97117e373cd585ffae39245eb16f1dfcff33e (patch)
tree098db494b106fc2ba6859a08899f153876ecd41f /sys/dev/ofw/openfirm.c
parenta79bdfef68e10bdcb6541da207462197f482d81a (diff)
Fix the OFW interrupt map parser to use its own idea of the number of interrupt
cells in the map, instead of using a value passed to it and then panicing if it disagrees. This fixes interrupt map parsing for PCI bridges on some Apple Uninorth PCI controllers. Reported by: marcel Tested on: G4 iBook, Sun Ultra 5
Notes
Notes: svn path=/head/; revision=186728
Diffstat (limited to 'sys/dev/ofw/openfirm.c')
-rw-r--r--sys/dev/ofw/openfirm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index c7b220358aad..4c33c9f87b50 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -220,6 +220,23 @@ OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
}
/*
+ * Resursively search the node and its parent for the given property, working
+ * downward from the node to the device tree root. Returns the value of the
+ * first match.
+ */
+ssize_t
+OF_searchprop(phandle_t node, char *propname, void *buf, size_t len)
+{
+ ssize_t rv;
+
+ for (; node != 0; node = OF_parent(node)) {
+ if ((rv = OF_getprop(node, propname, buf, len)) != -1)
+ return (rv);
+ }
+ return (-1);
+}
+
+/*
* Store the value of a property of a package into newly allocated memory
* (using the M_OFWPROP malloc pool and M_WAITOK). elsz is the size of a
* single element, the number of elements is return in number.