Module Name:    src
Committed By:   jmcneill
Date:           Mon Jul  2 16:06:50 UTC 2018

Modified Files:
        src/sys/dev/fdt: fdt_intr.c

Log Message:
Fix a regression with interrupt-map handling in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/fdt/fdt_intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/fdt/fdt_intr.c
diff -u src/sys/dev/fdt/fdt_intr.c:1.13 src/sys/dev/fdt/fdt_intr.c:1.14
--- src/sys/dev/fdt/fdt_intr.c:1.13	Mon Jul  2 12:17:05 2018
+++ src/sys/dev/fdt/fdt_intr.c	Mon Jul  2 16:06:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.13 2018/07/02 12:17:05 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.14 2018/07/02 16:06:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.13 2018/07/02 12:17:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.14 2018/07/02 16:06:50 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -59,29 +59,19 @@ static u_int *	get_specifier_from_map(in
 static int
 fdtbus_get_interrupt_parent(int phandle)
 {
-	u_int interrupt_parent;
+	int iparent = phandle;
 
-	while (phandle >= 0) {
-		if (of_getprop_uint32(phandle, "interrupt-parent",
-		    &interrupt_parent) == 0) {
-			break;
-		}
-		if (phandle == 0) {
-			return -1;
-		}
-		phandle = OF_parent(phandle);
-	}
-	if (phandle < 0) {
-		return -1;
-	}
-
-	const void *data = fdtbus_get_data();
-	const int off = fdt_node_offset_by_phandle(data, interrupt_parent);
-	if (off < 0) {
-		return -1;
-	}
+	do {
+		if (of_hasprop(iparent, "interrupt-parent"))
+			return fdtbus_get_phandle(iparent, "interrupt-parent");
+		else if (of_hasprop(iparent, "interrupt-controller"))
+			return iparent;
+		else if (of_hasprop(iparent, "interrupt-map"))
+			return iparent;
+		iparent = OF_parent(iparent);
+	} while (iparent > 0);
 
-	return fdtbus_offset2phandle(off);
+	return 0;
 }
 
 static struct fdtbus_interrupt_controller *

Reply via email to