Module Name:    src
Committed By:   thorpej
Date:           Sat Jun 19 16:29:04 UTC 2021

Modified Files:
        src/sys/arch/alpha/pci: dwlpx.c pci_kn8ae.c pci_kn8ae.h

Log Message:
Remove the "first" argument from pci_kn8ae_pickintr(), instead using
a real once control in that function. Removes a needless divergence from
other "pickintr" routines.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/pci/dwlpx.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/alpha/pci/pci_kn8ae.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/pci/pci_kn8ae.h

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/alpha/pci/dwlpx.c
diff -u src/sys/arch/alpha/pci/dwlpx.c:1.40 src/sys/arch/alpha/pci/dwlpx.c:1.41
--- src/sys/arch/alpha/pci/dwlpx.c:1.40	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/dwlpx.c	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx.c,v 1.40 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.40 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -106,7 +106,6 @@ dwlpxmatch(device_t parent, cfdata_t cf,
 static void
 dwlpxattach(device_t parent, device_t self, void *aux)
 {
-	static int once = 0;
 	struct dwlpx_softc *sc = device_private(self);
 	struct dwlpx_config *ccp = &sc->dwlpx_cc;
 	struct kft_dev_attach_args *ka = aux;
@@ -158,15 +157,10 @@ dwlpxattach(device_t parent, device_t se
 	}
 #endif
 
-	if (once == 0) {
-		/*
-		 * Set up interrupts
-		 */
-		pci_kn8ae_pickintr(&sc->dwlpx_cc, 1);
-		once++;
-	} else {
-		pci_kn8ae_pickintr(&sc->dwlpx_cc, 0);
-	}
+	/*
+	 * Set up interrupts
+	 */
+	pci_kn8ae_pickintr(&sc->dwlpx_cc);
 
 	/*
 	 * Attach PCI bus

Index: src/sys/arch/alpha/pci/pci_kn8ae.c
diff -u src/sys/arch/alpha/pci/pci_kn8ae.c:1.31 src/sys/arch/alpha/pci/pci_kn8ae.c:1.32
--- src/sys/arch/alpha/pci/pci_kn8ae.c:1.31	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/pci/pci_kn8ae.c	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn8ae.c,v 1.31 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: pci_kn8ae.c,v 1.32 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,v 1.31 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,v 1.32 2021/06/19 16:29:03 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,
 #include <sys/device.h>
 #include <sys/cpu.h>
 #include <sys/syslog.h>
+#include <sys/once.h>
 
 #include <machine/autoconf.h>
 
@@ -87,10 +88,27 @@ kn8ae_intr_wrapper(void *arg, u_long vec
 	KERNEL_UNLOCK_ONE(NULL);
 }
 
-void
-pci_kn8ae_pickintr(struct dwlpx_config *ccp, int first)
+static ONCE_DECL(pci_kn8ae_once);
+
+static int
+pci_kn8ae_init_imaskcache(void)
 {
 	int io, hose, dev;
+
+	for (io = 0; io < DWLPX_NIONODE; io++) {
+		for (hose = 0; hose < DWLPX_NHOSE; hose++) {
+			for (dev = 0; dev < NHPC; dev++) {
+				imaskcache[io][hose][dev] = DWLPX_IMASK_DFLT;
+			}
+		}
+	}
+
+	return 0;
+}
+
+void
+pci_kn8ae_pickintr(struct dwlpx_config *ccp)
+{
 	pci_chipset_tag_t pc = &ccp->cc_pc;
 
 	pc->pc_intr_v = ccp;
@@ -103,17 +121,7 @@ pci_kn8ae_pickintr(struct dwlpx_config *
 	/* Not supported on KN8AE. */
 	pc->pc_pciide_compat_intr_establish = NULL;
 
-	if (!first) {
-		return;
-	}
-
-	for (io = 0; io < DWLPX_NIONODE; io++) {
-		for (hose = 0; hose < DWLPX_NHOSE; hose++) {
-			for (dev = 0; dev < NHPC; dev++) {
-				imaskcache[io][hose][dev] = DWLPX_IMASK_DFLT;
-			}
-		}
-	}
+	RUN_ONCE(&pci_kn8ae_once, pci_kn8ae_init_imaskcache);
 }
 
 #define	IH_MAKE(vec, dev, pin)						\

Index: src/sys/arch/alpha/pci/pci_kn8ae.h
diff -u src/sys/arch/alpha/pci/pci_kn8ae.h:1.5 src/sys/arch/alpha/pci/pci_kn8ae.h:1.6
--- src/sys/arch/alpha/pci/pci_kn8ae.h:1.5	Sat Mar 14 14:45:53 2009
+++ src/sys/arch/alpha/pci/pci_kn8ae.h	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn8ae.h,v 1.5 2009/03/14 14:45:53 dsl Exp $ */
+/* $NetBSD: pci_kn8ae.h,v 1.6 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -30,4 +30,4 @@
  * SUCH DAMAGE.
  */
 
-void	pci_kn8ae_pickintr(struct dwlpx_config *, int);
+void	pci_kn8ae_pickintr(struct dwlpx_config *);

Reply via email to