diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-10-08 21:47:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-10-08 21:47:52 +0000 |
commit | 4a7a1f17c7d6f8e79f29d4fde2ba5faf09b7f5a8 (patch) | |
tree | fdc5670bf4d0a8cd810fe846698cb565f1f51cb9 /sys/dev/ata/wd.c | |
parent | c7f240fd53223122e6fe8cee52bb76b460263763 (diff) |
Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin
Diffstat (limited to 'sys/dev/ata/wd.c')
-rw-r--r-- | sys/dev/ata/wd.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 2e1c23b920b..7edd174a772 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.108 2011/07/06 04:49:36 matthew Exp $ */ +/* $OpenBSD: wd.c,v 1.109 2012/10/08 21:47:50 deraadt Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -142,7 +142,6 @@ void wdrestart(void *); int wd_get_params(struct wd_softc *, u_int8_t, struct ataparams *); void wd_flushcache(struct wd_softc *, int); void wd_standby(struct wd_softc *, int); -void wd_shutdown(void *); /* XXX: these should go elsewhere */ cdev_decl(wd); @@ -327,10 +326,6 @@ wdattach(struct device *parent, struct device *self, void *aux) */ wd->sc_dk.dk_name = wd->sc_dev.dv_xname; bufq_init(&wd->sc_bufq, BUFQ_DEFAULT); - wd->sc_sdhook = shutdownhook_establish(wd_shutdown, wd); - if (wd->sc_sdhook == NULL) - printf("%s: WARNING: unable to establish shutdown hook\n", - wd->sc_dev.dv_xname); timeout_set(&wd->sc_restart_timeout, wdrestart, wd); /* Attach disk. */ @@ -346,8 +341,11 @@ wdactivate(struct device *self, int act) switch (act) { case DVACT_SUSPEND: + break; + case DVACT_POWERDOWN: wd_flushcache(wd, AT_POLL); - wd_standby(wd, AT_POLL); + if (boothowto & RB_POWERDOWN) + wd_standby(wd, AT_POLL); break; case DVACT_RESUME: /* @@ -377,10 +375,6 @@ wddetach(struct device *self, int flags) disk_gone(wdopen, self->dv_unit); - /* Get rid of the shutdown hook. */ - if (sc->sc_sdhook != NULL) - shutdownhook_disestablish(sc->sc_sdhook); - /* Detach disk. */ bufq_destroy(&sc->sc_bufq); disk_detach(&sc->sc_dk); @@ -1142,13 +1136,3 @@ wd_standby(struct wd_softc *wd, int flags) * standby */ } - -void -wd_shutdown(void *arg) -{ - struct wd_softc *wd = arg; - - wd_flushcache(wd, AT_POLL); - if (boothowto & RB_POWERDOWN) - wd_standby(wd, AT_POLL); -} |