Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Replace shutdownhook_establish(9) with pmf_device_re...



details:   https://anonhg.NetBSD.org/src/rev/eb3723e32477
branches:  trunk
changeset: 747195:eb3723e32477
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Sep 05 12:30:59 2009 +0000

description:
Replace shutdownhook_establish(9) with pmf_device_register1(9) in
MI epconfig() and ep_detach(), and remove pmf(9) calls in pcmcia attachment.
Tested on ep0 at pci, but pcmcia attachment is untested.

diffstat:

 sys/dev/ic/elink3.c           |  22 ++++++++++++++--------
 sys/dev/ic/elink3var.h        |   4 +---
 sys/dev/pcmcia/if_ep_pcmcia.c |  11 ++---------
 3 files changed, 17 insertions(+), 20 deletions(-)

diffs (129 lines):

diff -r 8f8f3b19c6c9 -r eb3723e32477 sys/dev/ic/elink3.c
--- a/sys/dev/ic/elink3.c       Sat Sep 05 12:00:25 2009 +0000
+++ b/sys/dev/ic/elink3.c       Sat Sep 05 12:30:59 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3.c,v 1.127 2008/08/27 05:33:47 christos Exp $    */
+/*     $NetBSD: elink3.c,v 1.128 2009/09/05 12:30:59 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.127 2008/08/27 05:33:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.128 2009/09/05 12:30:59 tsutsui Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -192,7 +192,7 @@
 void   epstart(struct ifnet *);
 void   epwatchdog(struct ifnet *);
 void   epreset(struct ep_softc *);
-static void epshutdown(void *);
+static bool epshutdown(device_t, int);
 void   epread(struct ep_softc *);
 struct mbuf *epget(struct ep_softc *, int);
 void   epmbuffill(void *);
@@ -501,7 +501,11 @@
        sc->tx_start_thresh = 20;       /* probably a good starting point. */
 
        /*  Establish callback to reset card when we reboot. */
-       sc->sd_hook = shutdownhook_establish(epshutdown, sc);
+       if (pmf_device_register1(sc->sc_dev, NULL, NULL, epshutdown))
+               pmf_class_network_register(sc->sc_dev, ifp);
+       else
+               aprint_error_dev(sc->sc_dev,
+                   "couldn't establish power handler\n");
 
        ep_reset_cmd(sc, ELINK_COMMAND, RX_RESET);
        ep_reset_cmd(sc, ELINK_COMMAND, TX_RESET);
@@ -1798,10 +1802,10 @@
 /*
  * Before reboots, reset card completely.
  */
-static void
-epshutdown(void *arg)
+static bool
+epshutdown(device_t self, int howto)
 {
-       struct ep_softc *sc = arg;
+       struct ep_softc *sc = device_private(self);
        int s = splnet();
 
        if (sc->enabled) {
@@ -1811,6 +1815,8 @@
                sc->enabled = 0;
        }
        splx(s);
+
+       return true;
 }
 
 /*
@@ -2050,7 +2056,7 @@
        ether_ifdetach(ifp);
        if_detach(ifp);
 
-       shutdownhook_disestablish(sc->sd_hook);
+       pmf_device_deregister(sc->sc_dev);
 
        return (0);
 }
diff -r 8f8f3b19c6c9 -r eb3723e32477 sys/dev/ic/elink3var.h
--- a/sys/dev/ic/elink3var.h    Sat Sep 05 12:00:25 2009 +0000
+++ b/sys/dev/ic/elink3var.h    Sat Sep 05 12:30:59 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3var.h,v 1.35 2008/08/27 05:33:47 christos Exp $  */
+/*     $NetBSD: elink3var.h,v 1.36 2009/09/05 12:30:59 tsutsui Exp $   */
 
 /*
  * Copyright (c) 1994 Herb Peyerl <hpeyerl%beer.org@localhost>
@@ -105,8 +105,6 @@
        rndsource_element_t rnd_source;
 #endif
 
-       void *sd_hook;
-
        /* power management hooks */
        int (*enable)(struct ep_softc *);
        void (*disable)(struct ep_softc *);
diff -r 8f8f3b19c6c9 -r eb3723e32477 sys/dev/pcmcia/if_ep_pcmcia.c
--- a/sys/dev/pcmcia/if_ep_pcmcia.c     Sat Sep 05 12:00:25 2009 +0000
+++ b/sys/dev/pcmcia/if_ep_pcmcia.c     Sat Sep 05 12:30:59 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ep_pcmcia.c,v 1.62 2008/08/27 05:33:47 christos Exp $       */
+/*     $NetBSD: if_ep_pcmcia.c,v 1.63 2009/09/05 12:31:00 tsutsui Exp $        */
 
 /*-
  * Copyright (c) 1998, 2000, 2004 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.62 2008/08/27 05:33:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ep_pcmcia.c,v 1.63 2009/09/05 12:31:00 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -322,11 +322,6 @@
        if (epconfig(sc, epp->epp_chipset, enaddr))
                aprint_error_dev(self, "couldn't configure controller\n");
 
-       if (!pmf_device_register(self, NULL, NULL))
-               aprint_error_dev(self, "couldn't establish power handler\n");
-       else
-               pmf_class_network_register(self, &sc->sc_ethercom.ec_if);
-
        sc->enabled = 0;
        ep_pcmcia_disable(sc);
        return;
@@ -349,8 +344,6 @@
                /* Nothing to detach. */
                return 0;
 
-       pmf_device_deregister(self);
-
        rv = ep_detach(self, flags);
        if (rv != 0)
                return rv;



Home | Main Index | Thread Index | Old Index