Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/330be95bbdd8
branches:  trunk
changeset: 747158:330be95bbdd8
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Sep 04 16:21:24 2009 +0000

description:
Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested on sun3x.

diffstat:

 sys/dev/ic/lance.c    |  25 ++++++++++++++++---------
 sys/dev/ic/lancevar.h |   4 +---
 2 files changed, 17 insertions(+), 12 deletions(-)

diffs (80 lines):

diff -r 3773ed699cc3 -r 330be95bbdd8 sys/dev/ic/lance.c
--- a/sys/dev/ic/lance.c        Fri Sep 04 16:18:34 2009 +0000
+++ b/sys/dev/ic/lance.c        Fri Sep 04 16:21:24 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lance.c,v 1.42 2008/11/07 00:20:02 dyoung Exp $        */
+/*     $NetBSD: lance.c,v 1.43 2009/09/04 16:21:24 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.42 2008/11/07 00:20:02 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.43 2009/09/04 16:21:24 tsutsui Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -111,7 +111,7 @@
 
 integrate struct mbuf *lance_get(struct lance_softc *, int, int);
 
-hide void lance_shutdown(void *);
+hide bool lance_shutdown(device_t, int);
 
 int lance_mediachange(struct ifnet *);
 void lance_mediastatus(struct ifnet *, struct ifmediareq *);
@@ -250,9 +250,12 @@
        if_attach(ifp);
        ether_ifattach(ifp, sc->sc_enaddr);
 
-       sc->sc_sh = shutdownhook_establish(lance_shutdown, ifp);
-       if (sc->sc_sh == NULL)
-               panic("lance_config: can't establish shutdownhook");
+       if (pmf_device_register1(sc->sc_dev, NULL, NULL, lance_shutdown))
+               pmf_class_network_register(sc->sc_dev, ifp);
+       else
+               aprint_error_dev(sc->sc_dev,
+                   "couldn't establish power handler\n");
+
        sc->sc_rbufaddr = malloc(sc->sc_nrbuf * sizeof(int), M_DEVBUF,
                                        M_WAITOK);
        sc->sc_tbufaddr = malloc(sc->sc_ntbuf * sizeof(int), M_DEVBUF,
@@ -568,11 +571,15 @@
        return (error);
 }
 
-hide void
-lance_shutdown(void *arg)
+hide bool
+lance_shutdown(device_t self, int howto)
 {
+       struct lance_softc *sc = device_private(self);
+       struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 
-       lance_stop((struct ifnet *)arg, 0);
+       lance_stop(ifp, 0);
+
+       return true;
 }
 
 /*
diff -r 3773ed699cc3 -r 330be95bbdd8 sys/dev/ic/lancevar.h
--- a/sys/dev/ic/lancevar.h     Fri Sep 04 16:18:34 2009 +0000
+++ b/sys/dev/ic/lancevar.h     Fri Sep 04 16:21:24 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lancevar.h,v 1.12 2008/04/28 20:23:50 martin Exp $     */
+/*     $NetBSD: lancevar.h,v 1.13 2009/09/04 16:21:24 tsutsui Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -91,8 +91,6 @@
 
        int     sc_havecarrier; /* carrier status */
 
-       void    *sc_sh;         /* shutdownhook cookie */
-
        uint16_t sc_conf3;      /* CSR3 value */
        uint16_t sc_saved_csr0;/* Value of csr0 at time of interrupt */
 



Home | Main Index | Thread Index | Old Index