use pmf again to register the shutdown handler, instead of

shutdownhook_establish()
This commit is contained in:
drochner 2008-02-28 14:40:17 +00:00
parent 0e748e633e
commit c0adcb9cf8
2 changed files with 10 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: wd.c,v 1.356 2008/02/21 21:52:06 drochner Exp $ */
/* $NetBSD: wd.c,v 1.357 2008/02/28 14:40:17 drochner Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.356 2008/02/21 21:52:06 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.357 2008/02/28 14:40:17 drochner Exp $");
#include "opt_ata.h"
@ -194,7 +194,7 @@ void wdrestart(void *);
void wddone(void *);
int wd_get_params(struct wd_softc *, u_int8_t, struct ataparams *);
int wd_flushcache(struct wd_softc *, int);
void wd_shutdown(void *);
bool wd_shutdown(device_t, int);
int wd_getcache(struct wd_softc *, int *);
int wd_setcache(struct wd_softc *, int);
@ -417,10 +417,6 @@ wdattach(struct device *parent, struct device *self, void *aux)
disk_init(&wd->sc_dk, wd->sc_dev.dv_xname, &wddkdriver);
disk_attach(&wd->sc_dk);
wd->sc_wdc_bio.lp = wd->sc_dk.dk_label;
wd->sc_sdhook = shutdownhook_establish(wd_shutdown, wd);
if (wd->sc_sdhook == NULL)
aprint_error("%s: WARNING: unable to establish shutdown hook\n",
wd->sc_dev.dv_xname);
#if NRND > 0
rnd_attach_source(&wd->rnd_source, wd->sc_dev.dv_xname,
RND_TYPE_DISK, 0);
@ -429,7 +425,7 @@ wdattach(struct device *parent, struct device *self, void *aux)
/* Discover wedges on this disk. */
dkwedge_discover(&wd->sc_dk);
if (!pmf_device_register(self, wd_suspend, NULL))
if (!pmf_device_register1(self, wd_suspend, NULL, wd_shutdown))
aprint_error_dev(self, "couldn't establish power handler\n");
}
@ -505,10 +501,6 @@ wddetach(struct device *self, int flags)
sc->sc_bscount = 0;
#endif
/* Get rid of the shutdown hook. */
if (sc->sc_sdhook != NULL)
shutdownhook_disestablish(sc->sc_sdhook);
pmf_device_deregister(self);
#if NRND > 0
@ -1948,14 +1940,15 @@ wd_flushcache(struct wd_softc *wd, int flags)
return 0;
}
void
wd_shutdown(void *arg)
bool
wd_shutdown(device_t dev, int how)
{
struct wd_softc *wd = arg;
struct wd_softc *wd = device_private(dev);
wd_flushcache(wd, AT_POLL);
if ((boothowto & RB_POWERDOWN) == RB_POWERDOWN)
if ((how & RB_POWERDOWN) == RB_POWERDOWN)
wd_standby(wd, AT_POLL);
return true;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdvar.h,v 1.34 2008/02/22 06:46:46 dogcow Exp $ */
/* $NetBSD: wdvar.h,v 1.35 2008/02/28 14:40:17 drochner Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -66,8 +66,6 @@ struct wd_softc {
int retries; /* number of xfer retry */
void *sc_sdhook; /* our shutdown hook */
#ifdef WD_SOFTBADSECT
SLIST_HEAD(, disk_badsectors) sc_bslist;
u_int sc_bscount;