Module Name:    src
Committed By:   tsutsui
Date:           Sun Sep 27 12:52:59 UTC 2009

Modified Files:
        src/sys/dev/pci: if_dge.c if_jme.c if_ste.c if_ti.c if_txp.c

Log Message:
Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/pci/if_dge.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/if_jme.c
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/pci/if_ste.c
cvs rdiff -u -r1.85 -r1.86 src/sys/dev/pci/if_ti.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/if_txp.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/pci/if_dge.c
diff -u src/sys/dev/pci/if_dge.c:1.26 src/sys/dev/pci/if_dge.c:1.27
--- src/sys/dev/pci/if_dge.c:1.26	Tue May 12 08:23:00 2009
+++ src/sys/dev/pci/if_dge.c	Sun Sep 27 12:52:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_dge.c,v 1.26 2009/05/12 08:23:00 cegger Exp $ */
+/*	$NetBSD: if_dge.c,v 1.27 2009/09/27 12:52:59 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2004, SUNET, Swedish University Computer Network.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.26 2009/05/12 08:23:00 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.27 2009/09/27 12:52:59 tsutsui Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -258,7 +258,6 @@
 	bus_space_handle_t sc_sh;	/* bus space handle */
 	bus_dma_tag_t sc_dmat;		/* bus DMA tag */
 	struct ethercom sc_ethercom;	/* ethernet common data */
-	void *sc_sdhook;		/* shutdown hook */
 
 	int sc_flags;			/* flags; see below */
 	int sc_bus_speed;		/* PCI/PCIX bus speed */
@@ -618,7 +617,7 @@
 static int	dge_init(struct ifnet *);
 static void	dge_stop(struct ifnet *, int);
 
-static void	dge_shutdown(void *);
+static bool	dge_shutdown(device_t, int);
 
 static void	dge_reset(struct dge_softc *);
 static void	dge_rxdrain(struct dge_softc *);
@@ -963,9 +962,11 @@
 	/*
 	 * Make sure the interface is shutdown during reboot.
 	 */
-	sc->sc_sdhook = shutdownhook_establish(dge_shutdown, sc);
-	if (sc->sc_sdhook == NULL)
-		aprint_error_dev(&sc->sc_dev, "WARNING: unable to establish shutdown hook\n");
+	if (pmf_device_register1(self, NULL, NULL, dge_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 
 	/*
@@ -1001,12 +1002,15 @@
  *
  *	Make sure the interface is stopped at reboot time.
  */
-static void
-dge_shutdown(void *arg)
+static bool
+dge_shutdown(device_t self, int howto)
 {
-	struct dge_softc *sc = arg;
+	struct dge_softc *sc;
 
+	sc = device_private(self);
 	dge_stop(&sc->sc_ethercom.ec_if, 1);
+
+	return true;
 }
 
 /*

Index: src/sys/dev/pci/if_jme.c
diff -u src/sys/dev/pci/if_jme.c:1.10 src/sys/dev/pci/if_jme.c:1.11
--- src/sys/dev/pci/if_jme.c:1.10	Fri Jun 26 00:24:18 2009
+++ src/sys/dev/pci/if_jme.c	Sun Sep 27 12:52:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_jme.c,v 1.10 2009/06/26 00:24:18 dyoung Exp $	*/
+/*	$NetBSD: if_jme.c,v 1.11 2009/09/27 12:52:59 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2008 Manuel Bouyer.  All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.10 2009/06/26 00:24:18 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_jme.c,v 1.11 2009/09/27 12:52:59 tsutsui Exp $");
 
 
 #include <sys/param.h>
@@ -205,7 +205,7 @@
 static int jme_ifioctl(struct ifnet *, ioctl_cmd_t, void *);
 static int jme_mediachange(struct ifnet *);
 static void jme_ifwatchdog(struct ifnet *);
-static void jme_shutdown(void *);
+static bool jme_shutdown(device_t, int);
 
 static void jme_txeof(struct jme_softc *);
 static void jme_ifstart(struct ifnet *);
@@ -460,11 +460,6 @@
 		}
 	}
 	/*
-	 * Add shutdown hook so that DMA is disabled prior to reboot.
-	 */
-	(void)shutdownhook_establish(jme_shutdown, ifp);
-
-	/*
 	 * Initialize our media structures and probe the MII.
 	 *
 	 * Note that we don't care about the media instance.  We
@@ -517,6 +512,14 @@
 	if_attach(ifp);
 	ether_ifattach(&(sc)->jme_if, (sc)->jme_enaddr);
 
+	/*
+	 * Add shutdown hook so that DMA is disabled prior to reboot.
+	 */
+	if (pmf_device_register1(self, NULL, NULL, jme_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 #if NRND > 0
 	rnd_attach_source(&sc->rnd_source, device_xname(self),
 	    RND_TYPE_NET, 0);
@@ -630,11 +633,17 @@
 	bus_space_write_4(sc->jme_bt_mac, sc->jme_bh_mac, JME_GHC, 0);
 }
 
-static void
-jme_shutdown(void *v)
+static bool
+jme_shutdown(device_t self, int howto)
 {
+	jme_softc_t *sc;
+	struct ifnet *ifp;
+
+	sc = device_private(self);
+	ifp = &sc->jme_if;
+	jme_stop(ifp, 1);
 
-	jme_stop(v, 1);
+	return true;
 }
 
 static void

Index: src/sys/dev/pci/if_ste.c
diff -u src/sys/dev/pci/if_ste.c:1.37 src/sys/dev/pci/if_ste.c:1.38
--- src/sys/dev/pci/if_ste.c:1.37	Wed May  6 09:25:16 2009
+++ src/sys/dev/pci/if_ste.c	Sun Sep 27 12:52:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ste.c,v 1.37 2009/05/06 09:25:16 cegger Exp $	*/
+/*	$NetBSD: if_ste.c,v 1.38 2009/09/27 12:52:59 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.37 2009/05/06 09:25:16 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ste.c,v 1.38 2009/09/27 12:52:59 tsutsui Exp $");
 
 #include "bpfilter.h"
 
@@ -127,7 +127,6 @@
 	bus_space_handle_t sc_sh;	/* bus space handle */
 	bus_dma_tag_t sc_dmat;		/* bus DMA tag */
 	struct ethercom sc_ethercom;	/* ethernet common data */
-	void *sc_sdhook;		/* shutdown hook */
 
 	void *sc_ih;			/* interrupt cookie */
 
@@ -203,7 +202,7 @@
 static int	ste_init(struct ifnet *);
 static void	ste_stop(struct ifnet *, int);
 
-static void	ste_shutdown(void *);
+static bool	ste_shutdown(device_t, int);
 
 static void	ste_reset(struct ste_softc *, u_int32_t);
 static void	ste_setthresh(struct ste_softc *);
@@ -510,10 +509,11 @@
 	/*
 	 * Make sure the interface is shutdown during reboot.
 	 */
-	sc->sc_sdhook = shutdownhook_establish(ste_shutdown, sc);
-	if (sc->sc_sdhook == NULL)
-		printf("%s: WARNING: unable to establish shutdown hook\n",
-		    device_xname(&sc->sc_dev));
+	if (pmf_device_register1(self, NULL, NULL, ste_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 
 	/*
@@ -549,12 +549,15 @@
  *
  *	Make sure the interface is stopped at reboot time.
  */
-static void
-ste_shutdown(void *arg)
+static bool
+ste_shutdown(device_t self, int howto)
 {
-	struct ste_softc *sc = arg;
+	struct ste_softc *sc;
 
+	sc = device_private(self);
 	ste_stop(&sc->sc_ethercom.ec_if, 1);
+
+	return true;
 }
 
 static void

Index: src/sys/dev/pci/if_ti.c
diff -u src/sys/dev/pci/if_ti.c:1.85 src/sys/dev/pci/if_ti.c:1.86
--- src/sys/dev/pci/if_ti.c:1.85	Tue May 12 08:23:01 2009
+++ src/sys/dev/pci/if_ti.c	Sun Sep 27 12:52:59 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.85 2009/05/12 08:23:01 cegger Exp $ */
+/* $NetBSD: if_ti.c,v 1.86 2009/09/27 12:52:59 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.85 2009/05/12 08:23:01 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.86 2009/09/27 12:52:59 tsutsui Exp $");
 
 #include "bpfilter.h"
 #include "opt_inet.h"
@@ -151,7 +151,7 @@
 static const struct ti_type *ti_type_match(struct pci_attach_args *);
 static int ti_probe(device_t, cfdata_t, void *);
 static void ti_attach(device_t, device_t, void *);
-static void ti_shutdown(void *);
+static bool ti_shutdown(device_t, int);
 static void ti_txeof_tigon1(struct ti_softc *);
 static void ti_txeof_tigon2(struct ti_softc *);
 static void ti_rxeof(struct ti_softc *);
@@ -1678,12 +1678,6 @@
 		return;
 	}
 	printf("%s: interrupting at %s\n", device_xname(&sc->sc_dev), intrstr);
-	/*
-	 * Add shutdown hook so that DMA is disabled prior to reboot. Not
-	 * doing do could allow DMA to corrupt kernel memory during the
-	 * reboot before the driver initializes.
-	 */
-	(void) shutdownhook_establish(ti_shutdown, sc);
 
 	if (ti_chipinit(sc)) {
 		aprint_error_dev(self, "chip initialization failed\n");
@@ -1879,6 +1873,16 @@
 	if_attach(ifp);
 	ether_ifattach(ifp, eaddr);
 
+	/*
+	 * Add shutdown hook so that DMA is disabled prior to reboot. Not
+	 * doing do could allow DMA to corrupt kernel memory during the
+	 * reboot before the driver initializes.
+	 */
+	if (pmf_device_register1(self, NULL, NULL, ti_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 fail2:
 	pci_intr_disestablish(pc, sc->sc_ih);
@@ -2866,10 +2870,13 @@
  * Stop all chip I/O so that the kernel's probe routines don't
  * get confused by errant DMAs when rebooting.
  */
-static void
-ti_shutdown(void *v)
+static bool
+ti_shutdown(device_t self, int howto)
 {
-	struct ti_softc		*sc = v;
+	struct ti_softc *sc;
 
+	sc = device_private(self);
 	ti_chipinit(sc);
+
+	return true;
 }

Index: src/sys/dev/pci/if_txp.c
diff -u src/sys/dev/pci/if_txp.c:1.34 src/sys/dev/pci/if_txp.c:1.35
--- src/sys/dev/pci/if_txp.c:1.34	Sat Apr 18 14:58:03 2009
+++ src/sys/dev/pci/if_txp.c	Sun Sep 27 12:52:59 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_txp.c,v 1.34 2009/04/18 14:58:03 tsutsui Exp $ */
+/* $NetBSD: if_txp.c,v 1.35 2009/09/27 12:52:59 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2001
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.34 2009/04/18 14:58:03 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.35 2009/09/27 12:52:59 tsutsui Exp $");
 
 #include "bpfilter.h"
 #include "opt_inet.h"
@@ -91,7 +91,7 @@
 void txp_attach(device_t, device_t, void *);
 int txp_intr(void *);
 void txp_tick(void *);
-void txp_shutdown(void *);
+bool txp_shutdown(device_t, int);
 int txp_ioctl(struct ifnet *, u_long, void *);
 void txp_start(struct ifnet *);
 void txp_stop(struct txp_softc *);
@@ -345,8 +345,10 @@
 	if_attach(ifp);
 	ether_ifattach(ifp, enaddr);
 
-	shutdownhook_establish(txp_shutdown, sc);
-
+	if (pmf_device_register1(self, NULL, NULL, txp_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	return;
 
@@ -907,10 +909,12 @@
 		ifp->if_timer = 0;
 }
 
-void
-txp_shutdown(void *vsc)
+bool
+txp_shutdown(device_t self, int howto)
 {
-	struct txp_softc *sc = (struct txp_softc *)vsc;
+	struct txp_softc *sc;
+
+	sc = device_private(self);
 
 	/* mask all interrupts */
 	WRITE_REG(sc, TXP_IMR,
@@ -921,6 +925,8 @@
 	txp_command(sc, TXP_CMD_TX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 0);
 	txp_command(sc, TXP_CMD_RX_DISABLE, 0, 0, 0, NULL, NULL, NULL, 0);
 	txp_command(sc, TXP_CMD_HALT, 0, 0, 0, NULL, NULL, NULL, 0);
+
+	return true;
 }
 
 int

Reply via email to