summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2008-03-09 19:15:01 +0000
committerjmcneill <jmcneill@NetBSD.org>2008-03-09 19:15:01 +0000
commitfdf8cc971847d61c577dceb43ee8f64b825dc1ec (patch)
treef924618e82164401026570f760eab4bb09bfe990 /sys/dev
parent80e26751e9414d933eb02afe807f44f7780ce2b7 (diff)
Replace shutdownhook with PMF power handler.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ld.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/sys/dev/ld.c b/sys/dev/ld.c
index c9b0e16f808..9c17a99daeb 100644
--- a/sys/dev/ld.c
+++ b/sys/dev/ld.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ld.c,v 1.54 2008/01/04 21:17:48 ad Exp $ */
+/* $NetBSD: ld.c,v 1.55 2008/03/09 19:15:01 jmcneill Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.54 2008/01/04 21:17:48 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.55 2008/03/09 19:15:01 jmcneill Exp $");
#include "rnd.h"
@@ -74,7 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.54 2008/01/04 21:17:48 ad Exp $");
static void ldgetdefaultlabel(struct ld_softc *, struct disklabel *);
static void ldgetdisklabel(struct ld_softc *);
static void ldminphys(struct buf *bp);
-static void ldshutdown(void *);
+static bool ld_shutdown(device_t, int);
static void ldstart(struct ld_softc *, struct buf *);
static void ld_set_properties(struct ld_softc *);
static void ld_config_interrupts (struct device *);
@@ -100,7 +100,6 @@ const struct cdevsw ld_cdevsw = {
};
static struct dkdriver lddkdriver = { ldstrategy, ldminphys };
-static void *ld_sdh;
void
ldattach(struct ld_softc *sc)
@@ -159,9 +158,11 @@ ldattach(struct ld_softc *sc)
RND_TYPE_DISK, 0);
#endif
- /* Set the `shutdownhook'. */
- if (ld_sdh == NULL)
- ld_sdh = shutdownhook_establish(ldshutdown, NULL);
+ /* Register with PMF */
+ if (!pmf_device_register1(&sc->sc_dv, NULL, NULL, ld_shutdown))
+ aprint_error_dev(&sc->sc_dv,
+ "couldn't establish power handler\n");
+
bufq_alloc(&sc->sc_bufq, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
/* Discover wedges on this disk. */
@@ -263,19 +264,17 @@ ldenddetach(struct ld_softc *sc)
}
/* ARGSUSED */
-static void
-ldshutdown(void *cookie)
+static bool
+ld_shutdown(device_t dev, int flags)
{
- struct ld_softc *sc;
- int i;
+ struct ld_softc *sc = device_private(dev);
- for (i = 0; i < ld_cd.cd_ndevs; i++) {
- if ((sc = device_lookup(&ld_cd, i)) == NULL)
- continue;
- if (sc->sc_flush != NULL && (*sc->sc_flush)(sc) != 0)
- printf("%s: unable to flush cache\n",
- sc->sc_dv.dv_xname);
+ if (sc->sc_flush != NULL && (*sc->sc_flush)(sc) != 0) {
+ printf("%s: unable to flush cache\n", device_xname(dev));
+ return false;
}
+
+ return true;
}
/* ARGSUSED */