svn commit: r291648 - head/sys/dev/ofw
Michal Meloun
mmel at FreeBSD.org
Wed Dec 2 14:21:17 UTC 2015
Author: mmel
Date: Wed Dec 2 14:21:16 2015
New Revision: 291648
URL: https://svnweb.freebsd.org/changeset/base/291648
Log:
OFW: Move code for searching interrupt parent into separate function.
It can be used by interrupt controller drivers.
Approved by: kib (mentor)
Modified:
head/sys/dev/ofw/ofw_bus_subr.c
head/sys/dev/ofw/ofw_bus_subr.h
Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c Wed Dec 2 12:58:20 2015 (r291647)
+++ head/sys/dev/ofw/ofw_bus_subr.c Wed Dec 2 14:21:16 2015 (r291648)
@@ -430,6 +430,27 @@ ofw_bus_reg_to_rl(device_t dev, phandle_
return (0);
}
+/*
+ * Get interrupt parent for given node.
+ * Returns 0 if interrupt parent doesn't exist.
+ */
+phandle_t
+ofw_bus_find_iparent(phandle_t node)
+{
+ phandle_t iparent;
+
+ if (OF_searchencprop(node, "interrupt-parent", &iparent,
+ sizeof(iparent)) == -1) {
+ for (iparent = node; iparent != 0;
+ iparent = OF_parent(iparent)) {
+ if (OF_hasprop(iparent, "interrupt-controller"))
+ break;
+ }
+ iparent = OF_xref_from_node(iparent);
+ }
+ return (iparent);
+}
+
int
ofw_bus_intr_to_rl(device_t dev, phandle_t node,
struct resource_list *rl, int *rlen)
@@ -442,18 +463,11 @@ ofw_bus_intr_to_rl(device_t dev, phandle
nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
(void **)&intr);
if (nintr > 0) {
- if (OF_searchencprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == -1) {
- for (iparent = node; iparent != 0;
- iparent = OF_parent(iparent)) {
- if (OF_hasprop(iparent, "interrupt-controller"))
- break;
- }
- if (iparent == 0) {
- device_printf(dev, "No interrupt-parent found, "
- "assuming direct parent\n");
- iparent = OF_parent(node);
- }
+ iparent = ofw_bus_find_iparent(node);
+ if (iparent == 0) {
+ device_printf(dev, "No interrupt-parent found, "
+ "assuming direct parent\n");
+ iparent = OF_parent(node);
iparent = OF_xref_from_node(iparent);
}
if (OF_searchencprop(OF_node_from_xref(iparent),
Modified: head/sys/dev/ofw/ofw_bus_subr.h
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.h Wed Dec 2 12:58:20 2015 (r291647)
+++ head/sys/dev/ofw/ofw_bus_subr.h Wed Dec 2 14:21:16 2015 (r291648)
@@ -82,7 +82,7 @@ const char *ofw_bus_get_status(device_t
int ofw_bus_status_okay(device_t dev);
/* Helper to get node's interrupt parent */
-void ofw_bus_find_iparent(phandle_t);
+phandle_t ofw_bus_find_iparent(phandle_t);
/* Helper routine for checking compat prop */
int ofw_bus_is_compatible(device_t, const char *);
More information about the svn-src-head
mailing list