Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt When searching for interrupt parent, stop as soo...
details: https://anonhg.NetBSD.org/src/rev/dcaa9c8e958c
branches: trunk
changeset: 320355:dcaa9c8e958c
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon Jul 02 17:50:02 2018 +0000
description:
When searching for interrupt parent, stop as soon as we see an
interrupt-controller property on a node other than the starting node.
diffstat:
sys/dev/fdt/fdt_intr.c | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diffs (64 lines):
diff -r da363084f112 -r dcaa9c8e958c sys/dev/fdt/fdt_intr.c
--- a/sys/dev/fdt/fdt_intr.c Mon Jul 02 17:13:15 2018 +0000
+++ b/sys/dev/fdt/fdt_intr.c Mon Jul 02 17:50:02 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.14 2018/07/02 16:06:50 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.15 2018/07/02 17:50:02 jmcneill Exp $ */
/*-
* Copyright (c) 2015-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.14 2018/07/02 16:06:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.15 2018/07/02 17:50:02 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -56,18 +56,42 @@
static u_int * get_specifier_by_index(int, int, int *);
static u_int * get_specifier_from_map(int, const u_int *, int *);
+/*
+ * Find the interrupt controller for a given node. This function will either
+ * return the phandle of the interrupt controller for this node, or the phandle
+ * of a node containing an interrupt-map table that can be used to find the
+ * real interrupt controller.
+ */
static int
fdtbus_get_interrupt_parent(int phandle)
{
int iparent = phandle;
do {
+ /*
+ * If the node is an interrupt-controller, we are done. Note that
+ * a node cannot be an interrupt-controller for itself, so we skip
+ * the leaf node here.
+ */
+ if (phandle != iparent && of_hasprop(iparent, "interrupt-controller"))
+ return iparent;
+
+ /*
+ * If the node has an explicit interrupt-parent, follow the reference.
+ */
if (of_hasprop(iparent, "interrupt-parent"))
return fdtbus_get_phandle(iparent, "interrupt-parent");
- else if (of_hasprop(iparent, "interrupt-controller"))
+
+ /*
+ * If the node has an interrupt-map, use it. The caller is responsible
+ * for parsing the interrupt-map and finding the real interrupt parent.
+ */
+ if (of_hasprop(iparent, "interrupt-map"))
return iparent;
- else if (of_hasprop(iparent, "interrupt-map"))
- return iparent;
+
+ /*
+ * Continue searching up the tree.
+ */
iparent = OF_parent(iparent);
} while (iparent > 0);
Home |
Main Index |
Thread Index |
Old Index