Module Name:    src
Committed By:   dyoung
Date:           Mon Aug 29 22:41:52 UTC 2011

Modified Files:
        src/sys/arch/x86/pci: pci_intr_machdep.c

Log Message:
Use a loop instead of tail-recursion for the pci_intr(9) overrides.
This is the same change that I just made to the pci(9) overrides.  While
I am here, fix a bug: use PCI_OVERRIDE_INTR_DISESTABLISH instead of
PCI_OVERRIDE_INTR_ESTABLISH for the pci_intr_disestablish(9) override.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/pci/pci_intr_machdep.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/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.22 src/sys/arch/x86/pci/pci_intr_machdep.c:1.23
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.22	Wed Aug 17 14:56:55 2011
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Mon Aug 29 22:41:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.22 2011/08/17 14:56:55 dyoung Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.23 2011/08/29 22:41:52 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.22 2011/08/17 14:56:55 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.23 2011/08/29 22:41:52 dyoung Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -115,20 +115,16 @@
 {
 	int pin = pa->pa_intrpin;
 	int line = pa->pa_intrline;
-	pci_chipset_tag_t pc;
+	pci_chipset_tag_t ipc, pc = pa->pa_pc;
 #if NIOAPIC > 0 || NACPICA > 0
 	int rawpin = pa->pa_rawintrpin;
 	int bus, dev, func;
 #endif
 
-	if ((pc = pa->pa_pc) != NULL) {
-		if ((pc->pc_present & PCI_OVERRIDE_INTR_MAP) != 0)
-			return (*pc->pc_ov->ov_intr_map)(pc->pc_ctx, pa, ihp);
-		if (pc->pc_super != NULL) {
-			struct pci_attach_args paclone = *pa;
-			paclone.pa_pc = pc->pc_super;
-			return pci_intr_map(&paclone, ihp);
-		}
+	for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) {
+		if ((ipc->pc_present & PCI_OVERRIDE_INTR_MAP) == 0)
+			continue;
+		return (*ipc->pc_ov->ov_intr_map)(ipc->pc_ctx, pa, ihp);
 	}
 
 	if (pin == 0) {
@@ -217,12 +213,12 @@
 const char *
 pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
 {
+	pci_chipset_tag_t ipc;
 
-	if (pc != NULL) {
-		if ((pc->pc_present & PCI_OVERRIDE_INTR_STRING) != 0)
-			return (*pc->pc_ov->ov_intr_string)(pc->pc_ctx, pc, ih);
-		if (pc->pc_super != NULL)
-			return pci_intr_string(pc->pc_super, ih);
+	for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) {
+		if ((ipc->pc_present & PCI_OVERRIDE_INTR_STRING) == 0)
+			continue;
+		return (*ipc->pc_ov->ov_intr_string)(ipc->pc_ctx, pc, ih);
 	}
 
 	return intr_string(ih & ~MPSAFE_MASK);
@@ -232,12 +228,12 @@
 const struct evcnt *
 pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
 {
+	pci_chipset_tag_t ipc;
 
-	if (pc != NULL) {
-		if ((pc->pc_present & PCI_OVERRIDE_INTR_EVCNT) != 0)
-			return (*pc->pc_ov->ov_intr_evcnt)(pc->pc_ctx, pc, ih);
-		if (pc->pc_super != NULL)
-			return pci_intr_evcnt(pc->pc_super, ih);
+	for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) {
+		if ((ipc->pc_present & PCI_OVERRIDE_INTR_EVCNT) == 0)
+			continue;
+		return (*ipc->pc_ov->ov_intr_evcnt)(ipc->pc_ctx, pc, ih);
 	}
 
 	/* XXX for now, no evcnt parent reported */
@@ -273,16 +269,13 @@
 	struct ioapic_softc *ioapic;
 #endif
 	bool mpsafe;
+	pci_chipset_tag_t ipc;
 
-	if (pc != NULL) {
-		if ((pc->pc_present & PCI_OVERRIDE_INTR_ESTABLISH) != 0) {
-			return (*pc->pc_ov->ov_intr_establish)(pc->pc_ctx,
-			    pc, ih, level, func, arg);
-		}
-		if (pc->pc_super != NULL) {
-			return pci_intr_establish(pc->pc_super, ih, level, func,
-			    arg);
-		}
+	for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) {
+		if ((ipc->pc_present & PCI_OVERRIDE_INTR_ESTABLISH) == 0)
+			continue;
+		return (*ipc->pc_ov->ov_intr_establish)(ipc->pc_ctx,
+		    pc, ih, level, func, arg);
 	}
 
 	pic = &i8259_pic;
@@ -312,17 +305,13 @@
 void
 pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
 {
+	pci_chipset_tag_t ipc;
 
-	if (pc != NULL) {
-		if ((pc->pc_present & PCI_OVERRIDE_INTR_ESTABLISH) != 0) {
-			(*pc->pc_ov->ov_intr_disestablish)(pc->pc_ctx,
-			    pc, cookie);
-			return;
-		}
-		if (pc->pc_super != NULL) {
-			pci_intr_disestablish(pc->pc_super, cookie);
-			return;
-		}
+	for (ipc = pc; ipc != NULL; ipc = ipc->pc_super) {
+		if ((ipc->pc_present & PCI_OVERRIDE_INTR_DISESTABLISH) == 0)
+			continue;
+		(*ipc->pc_ov->ov_intr_disestablish)(ipc->pc_ctx, pc, cookie);
+		return;
 	}
 
 	intr_disestablish(cookie);

Reply via email to