summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2008-03-09 19:25:56 +0000
committerjmcneill <jmcneill@NetBSD.org>2008-03-09 19:25:56 +0000
commit0bedbeef3af441ab33c21214ef655c3cdb30e7e4 (patch)
tree4fba22d84908cd4b04ec0794dfffa92baa092cb9 /sys/dev
parent47379c84582638fd8e866be8bd32eca6761d1472 (diff)
Convert from shutdownhook/powerhook to PMF.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/tulip.c82
-rw-r--r--sys/dev/ic/tulipvar.h4
2 files changed, 10 insertions, 76 deletions
diff --git a/sys/dev/ic/tulip.c b/sys/dev/ic/tulip.c
index 5136ef2d1f4..bb3dca6ce2f 100644
--- a/sys/dev/ic/tulip.c
+++ b/sys/dev/ic/tulip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tulip.c,v 1.157 2008/01/19 22:10:17 dyoung Exp $ */
+/* $NetBSD: tulip.c,v 1.158 2008/03/09 19:25:56 jmcneill Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.157 2008/01/19 22:10:17 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.158 2008/03/09 19:25:56 jmcneill Exp $");
#include "bpfilter.h"
@@ -101,8 +101,6 @@ static int tlp_ioctl(struct ifnet *, u_long, void *);
static int tlp_init(struct ifnet *);
static void tlp_stop(struct ifnet *, int);
-static void tlp_shutdown(void *);
-
static void tlp_rxdrain(struct tulip_softc *);
static int tlp_add_rxbuf(struct tulip_softc *, int);
static void tlp_srom_idle(struct tulip_softc *);
@@ -110,7 +108,6 @@ static int tlp_srom_size(struct tulip_softc *);
static int tlp_enable(struct tulip_softc *);
static void tlp_disable(struct tulip_softc *);
-static void tlp_power(int, void *);
static void tlp_filter_setup(struct tulip_softc *);
static void tlp_winb_filter_setup(struct tulip_softc *);
@@ -199,6 +196,7 @@ void
tlp_attach(struct tulip_softc *sc, const u_int8_t *enaddr)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
+ device_t self = &sc->sc_dev;
int i, error;
callout_init(&sc->sc_nway_callout, 0);
@@ -539,23 +537,11 @@ tlp_attach(struct tulip_softc *sc, const u_int8_t *enaddr)
RND_TYPE_NET, 0);
#endif
- /*
- * Make sure the interface is shutdown during reboot.
- */
- sc->sc_sdhook = shutdownhook_establish(tlp_shutdown, sc);
- if (sc->sc_sdhook == NULL)
- printf("%s: WARNING: unable to establish shutdown hook\n",
- sc->sc_dev.dv_xname);
+ if (!pmf_device_register(self, NULL, NULL))
+ aprint_error_dev(self, "couldn't establish power handler\n");
+ else
+ pmf_class_network_register(self, ifp);
- /*
- * Add a suspend hook to make sure we come back up after a
- * resume.
- */
- sc->sc_powerhook = powerhook_establish(sc->sc_dev.dv_xname,
- tlp_power, sc);
- if (sc->sc_powerhook == NULL)
- printf("%s: WARNING: unable to establish power hook\n",
- sc->sc_dev.dv_xname);
return;
/*
@@ -626,6 +612,7 @@ tlp_detach(struct tulip_softc *sc)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
struct tulip_rxsoft *rxs;
struct tulip_txsoft *txs;
+ device_t self = &sc->sc_dev;
int i;
/*
@@ -676,8 +663,7 @@ tlp_detach(struct tulip_softc *sc)
sizeof(struct tulip_control_data));
bus_dmamem_free(sc->sc_dmat, &sc->sc_cdseg, sc->sc_cdnseg);
- shutdownhook_disestablish(sc->sc_sdhook);
- powerhook_disestablish(sc->sc_powerhook);
+ pmf_device_deregister(self);
if (sc->sc_srom)
free(sc->sc_srom, M_DEVBUF);
@@ -686,19 +672,6 @@ tlp_detach(struct tulip_softc *sc)
}
/*
- * tlp_shutdown:
- *
- * Make sure the interface is stopped at reboot time.
- */
-static void
-tlp_shutdown(void *arg)
-{
- struct tulip_softc *sc = arg;
-
- tlp_stop(&sc->sc_ethercom.ec_if, 1);
-}
-
-/*
* tlp_start: [ifnet interface function]
*
* Start packet transmission on the interface.
@@ -2034,43 +2007,6 @@ tlp_disable(struct tulip_softc *sc)
}
/*
- * tlp_power:
- *
- * Power management (suspend/resume) hook.
- */
-static void
-tlp_power(int why, void *arg)
-{
- struct tulip_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_ethercom.ec_if;
- int s;
-
- s = splnet();
- switch (why) {
- case PWR_STANDBY:
- /* do nothing! */
- break;
- case PWR_SUSPEND:
- tlp_stop(ifp, 0);
- if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
- break;
- case PWR_RESUME:
- if (ifp->if_flags & IFF_UP) {
- if (sc->sc_power != NULL)
- (*sc->sc_power)(sc, why);
- tlp_init(ifp);
- }
- break;
- case PWR_SOFTSUSPEND:
- case PWR_SOFTSTANDBY:
- case PWR_SOFTRESUME:
- break;
- }
- splx(s);
-}
-
-/*
* tlp_rxdrain:
*
* Drain the receive queue.
diff --git a/sys/dev/ic/tulipvar.h b/sys/dev/ic/tulipvar.h
index bf7fcac418c..4ceccd749e5 100644
--- a/sys/dev/ic/tulipvar.h
+++ b/sys/dev/ic/tulipvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: tulipvar.h,v 1.58 2006/03/25 23:10:50 rpaulo Exp $ */
+/* $NetBSD: tulipvar.h,v 1.59 2008/03/09 19:25:56 jmcneill Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -342,8 +342,6 @@ struct tulip_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_powerhook; /* power management hook */
struct tulip_stats sc_stats; /* debugging stats */