Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/36122b4c842f
branches:  trunk
changeset: 747680:36122b4c842f
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Sep 27 12:52:59 2009 +0000

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

diffstat:

 sys/dev/pci/if_dge.c |  24 ++++++++++++++----------
 sys/dev/pci/if_jme.c |  31 ++++++++++++++++++++-----------
 sys/dev/pci/if_ste.c |  25 ++++++++++++++-----------
 sys/dev/pci/if_ti.c  |  33 ++++++++++++++++++++-------------
 sys/dev/pci/if_txp.c |  22 ++++++++++++++--------
 5 files changed, 82 insertions(+), 53 deletions(-)

diffs (truncated from 354 to 300 lines):

diff -r 98d64565e017 -r 36122b4c842f sys/dev/pci/if_dge.c
--- a/sys/dev/pci/if_dge.c      Sun Sep 27 12:46:39 2009 +0000
+++ b/sys/dev/pci/if_dge.c      Sun Sep 27 12:52:59 2009 +0000
@@ -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;
 }
 
 /*
diff -r 98d64565e017 -r 36122b4c842f sys/dev/pci/if_jme.c
--- a/sys/dev/pci/if_jme.c      Sun Sep 27 12:46:39 2009 +0000
+++ b/sys/dev/pci/if_jme.c      Sun Sep 27 12:52:59 2009 +0000
@@ -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;
 
-       jme_stop(v, 1);
+       sc = device_private(self);
+       ifp = &sc->jme_if;
+       jme_stop(ifp, 1);
+
+       return true;
 }
 
 static void
diff -r 98d64565e017 -r 36122b4c842f sys/dev/pci/if_ste.c
--- a/sys/dev/pci/if_ste.c      Sun Sep 27 12:46:39 2009 +0000
+++ b/sys/dev/pci/if_ste.c      Sun Sep 27 12:52:59 2009 +0000
@@ -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
diff -r 98d64565e017 -r 36122b4c842f sys/dev/pci/if_ti.c
--- a/sys/dev/pci/if_ti.c       Sun Sep 27 12:46:39 2009 +0000
+++ b/sys/dev/pci/if_ti.c       Sun Sep 27 12:52:59 2009 +0000
@@ -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;
 }
diff -r 98d64565e017 -r 36122b4c842f sys/dev/pci/if_txp.c
--- a/sys/dev/pci/if_txp.c      Sun Sep 27 12:46:39 2009 +0000
+++ b/sys/dev/pci/if_txp.c      Sun Sep 27 12:52:59 2009 +0000
@@ -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 @@
  */



Home | Main Index | Thread Index | Old Index