Module Name:    src
Committed By:   tsutsui
Date:           Sun Sep  6 13:39:56 UTC 2009

Modified Files:
        src/sys/dev/pci: if_pcn.c

Log Message:
Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested Am79c973 PCnet-FAST III.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/dev/pci/if_pcn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_pcn.c
diff -u src/sys/dev/pci/if_pcn.c:1.47 src/sys/dev/pci/if_pcn.c:1.48
--- src/sys/dev/pci/if_pcn.c:1.47	Wed May  6 10:34:32 2009
+++ src/sys/dev/pci/if_pcn.c	Sun Sep  6 13:39:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_pcn.c,v 1.47 2009/05/06 10:34:32 cegger Exp $	*/
+/*	$NetBSD: if_pcn.c,v 1.48 2009/09/06 13:39:56 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.47 2009/05/06 10:34:32 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pcn.c,v 1.48 2009/09/06 13:39:56 tsutsui Exp $");
 
 #include "bpfilter.h"
 #include "rnd.h"
@@ -251,7 +251,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 */
 
 	/* Points to our media routines, etc. */
 	const struct pcn_variant *sc_variant;
@@ -398,7 +397,7 @@
 static int	pcn_init(struct ifnet *);
 static void	pcn_stop(struct ifnet *, int);
 
-static void	pcn_shutdown(void *);
+static bool	pcn_shutdown(device_t, int);
 
 static void	pcn_reset(struct pcn_softc *);
 static void	pcn_rxdrain(struct pcn_softc *);
@@ -862,11 +861,15 @@
 	    NULL, device_xname(self), "txcopy");
 #endif /* PCN_EVENT_COUNTERS */
 
-	/* Make sure the interface is shutdown during reboot. */
-	sc->sc_sdhook = shutdownhook_establish(pcn_shutdown, sc);
-	if (sc->sc_sdhook == NULL)
-		aprint_error_dev(self,
-		    "WARNING: unable to establish shutdown hook\n");
+	/*
+	 * Establish power handler with shutdown hook, to make sure
+	 * the interface is shutdown during reboot.
+	 */
+	if (pmf_device_register1(self, NULL, NULL, pcn_shutdown))
+		pmf_class_network_register(self, ifp);
+	else
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 
 	/*
@@ -902,14 +905,16 @@
  *
  *	Make sure the interface is stopped at reboot time.
  */
-static void
-pcn_shutdown(void *arg)
+static bool
+pcn_shutdown(device_t self, int howto)
 {
-	struct pcn_softc *sc = arg;
+	struct pcn_softc *sc = device_private(self);
 
 	pcn_stop(&sc->sc_ethercom.ec_if, 1);
 	/* explicitly reset the chip for some onboard one with lazy firmware */
 	pcn_reset(sc);
+
+	return true;
 }
 
 /*

Reply via email to