Replace shutdownhook_establish(9) with pmf_device_register1(9).

Compile test only.
This commit is contained in:
tsutsui 2009-09-27 12:52:59 +00:00
parent 35a2c68409
commit 41bab1588b
5 changed files with 81 additions and 52 deletions

View File

@ -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 @@ struct dge_softc {
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_ioctl(struct ifnet *, u_long, void *);
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 @@ dge_attach(device_t parent, device_t self, void *aux)
/*
* 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 @@ dge_attach(device_t parent, device_t self, void *aux)
*
* 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;
}
/*

View File

@ -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_intr(void *);
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 *);
@ -459,11 +459,6 @@ jme_pci_attach(device_t parent, device_t self, void *aux)
return;
}
}
/*
* 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.
*
@ -517,6 +512,14 @@ jme_pci_attach(device_t parent, device_t self, void *aux)
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 @@ jme_reset(jme_softc_t *sc)
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;
jme_stop(v, 1);
sc = device_private(self);
ifp = &sc->jme_if;
jme_stop(ifp, 1);
return true;
}
static void

View File

@ -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 @@ struct ste_softc {
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_ioctl(struct ifnet *, u_long, void *);
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 @@ ste_attach(device_t parent, device_t self, void *aux)
/*
* 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 @@ ste_attach(device_t parent, device_t self, void *aux)
*
* 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

View File

@ -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_devs[] = {
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 @@ ti_attach(device_t parent, device_t self, void *aux)
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 @@ ti_attach(device_t parent, device_t self, void *aux)
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 @@ ti_stop(struct ti_softc *sc)
* 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;
}

View File

@ -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 @@ int txp_probe(device_t, cfdata_t, void *);
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 @@ txp_attach(device_t parent, device_t self, void *aux)
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 @@ txp_tx_reclaim(struct txp_softc *sc, struct txp_tx_ring *r, struct txp_dma_alloc
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_shutdown(void *vsc)
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