void fd_motor_timer(void) { if (motorct) { motorct--; if (motorct == 0) { fd_motor_off(); fd_selected = 0xFF; } } }
static int fddetach(device_t self, int flags) { struct fd_softc *fd = device_private(self); int bmaj, cmaj, i, mn; fd_motor_off(fd); /* locate the major number */ bmaj = bdevsw_lookup_major(&fd_bdevsw); cmaj = cdevsw_lookup_major(&fd_cdevsw); /* Nuke the vnodes for any open instances. */ for (i = 0; i < MAXPARTITIONS; i++) { mn = DISKMINOR(device_unit(self), i); vdevgone(bmaj, mn, mn, VBLK); vdevgone(cmaj, mn, mn, VCHR); } pmf_device_deregister(self); #if 0 /* XXX need to undo at detach? */ fd_set_properties(fd); #endif #if NRND > 0 rnd_detach_source(&fd->rnd_source); #endif disk_detach(&fd->sc_dk); disk_destroy(&fd->sc_dk); /* Kill off any queued buffers. */ bufq_drain(fd->sc_q); bufq_free(fd->sc_q); callout_destroy(&fd->sc_motoroff_ch); callout_destroy(&fd->sc_motoron_ch); return 0; }
int fdactivate(struct device *self, int act) { struct fd_softc *fd = (void *)self; struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; int rv = 0; switch (act) { case DVACT_SUSPEND: if (fdc->sc_state != DEVIDLE) { timeout_del(&fd->fd_motor_on_to); timeout_del(&fd->fd_motor_off_to); timeout_del(&fd->fdtimeout_to); fdc->sc_state = IOTIMEDOUT; fdc->sc_errors = 4; } break; case DVACT_POWERDOWN: fd_motor_off(self); break; } return (rv); }