summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-cd.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2002-09-12 13:55:24 +0000
committersos <sos@FreeBSD.org>2002-09-12 13:55:24 +0000
commitd0ac6e69919c8c2155ef5086e78b622f9570e4b3 (patch)
treeab82794197ffa01634574536fa7f496c39cc4e9b /sys/dev/ata/atapi-cd.c
parent8a7241d8c2af8571ec8faa3fff4b41668c4b6435 (diff)
downloadFreeBSD-src-d0ac6e69919c8c2155ef5086e78b622f9570e4b3.zip
FreeBSD-src-d0ac6e69919c8c2155ef5086e78b622f9570e4b3.tar.gz
Wait for drive to become ready if its in progress of loading..
Based on patch in PR-42659, but done somewhat differently. PR: 42659
Diffstat (limited to 'sys/dev/ata/atapi-cd.c')
-rw-r--r--sys/dev/ata/atapi-cd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index c209065..b427d32 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -509,6 +509,7 @@ static int
acdopen(dev_t dev, int flags, int fmt, struct thread *td)
{
struct acd_softc *cdp = dev->si_drv1;
+ int timeout = 60;
if (!cdp)
return ENXIO;
@@ -517,6 +518,19 @@ acdopen(dev_t dev, int flags, int fmt, struct thread *td)
if (count_dev(dev) > 1)
return EBUSY;
}
+
+ /* wait if drive is not finished loading the medium */
+ while (timeout--) {
+ struct atapi_reqsense *sense = cdp->device->result;
+
+ if (!atapi_test_ready(cdp->device))
+ break;
+ if (sense->sense_key == 2 && sense->asc == 4 && sense->ascq == 1)
+ tsleep(&timeout, PRIBIO, "acdld", hz / 2);
+ else
+ break;
+ }
+
if (count_dev(dev) == 1) {
if (cdp->changer_info && cdp->slot != cdp->changer_info->current_slot) {
acd_select_slot(cdp);
OpenPOWER on IntegriCloud