diff options
author | sos <sos@FreeBSD.org> | 2001-03-14 12:05:44 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2001-03-14 12:05:44 +0000 |
commit | 4659caa469c2dedd9d5063417c8da7cc4e37d7aa (patch) | |
tree | 871c965e909b58c956ea34692b952d392b3c58c1 /sys/dev/ata/atapi-all.c | |
parent | 045a83cd9229e8ab1171e7adf872e072644f8945 (diff) | |
download | FreeBSD-src-4659caa469c2dedd9d5063417c8da7cc4e37d7aa.zip FreeBSD-src-4659caa469c2dedd9d5063417c8da7cc4e37d7aa.tar.gz |
Refine the detach/attach code.
Proberly fail outstanding bio requests on devices that are detached.
This makes it possible to change between disk/cdrom/dvd/whathaveyou
in a notebook, just by suspending it, changing the device in the
bay (or what you model calls it), unsuspend and the ATA driver
will figure out what disappeared and properly fail those, and attach
any new devices found.
Diffstat (limited to 'sys/dev/ata/atapi-all.c')
-rw-r--r-- | sys/dev/ata/atapi-all.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index 5607569..4eec739 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -35,6 +35,7 @@ #include <sys/kernel.h> #include <sys/bus.h> #include <sys/malloc.h> +#include <sys/bio.h> #include <machine/bus.h> #include <sys/rman.h> #include <dev/ata/ata-all.h> @@ -114,13 +115,18 @@ notfound: free(atp, M_ATAPI); atp = NULL; } - /* store our softc */ + + /* store our softc signalling we are ready to go */ scp->dev_softc[ATA_DEV(device)] = atp; } void atapi_detach(struct atapi_softc *atp) { + struct atapi_request *request; + + atp->flags |= ATAPI_F_DETACHING; + switch (ATP_PARAM->device_type) { #ifdef DEV_ATAPICD case ATAPI_TYPE_CDROM: @@ -140,6 +146,21 @@ atapi_detach(struct atapi_softc *atp) default: return; } + TAILQ_FOREACH(request, &atp->controller->atapi_queue, chain) { + if (request->device != atp) + continue; + TAILQ_REMOVE(&atp->controller->atapi_queue, request, chain); + if (request->driver) { + struct bio *bp = (struct bio *) request->driver; + bp->bio_error = ENXIO; + bp->bio_flags |= BIO_ERROR; + biodone(bp); + } + if (request->dmatab) + free(request->dmatab, M_DEVBUF); + free(request, M_ATAPI); + } + atp->controller->dev_softc[ATA_DEV(atp->unit)] = NULL; free(atp, M_ATAPI); } |