]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix up scsi_test_unit_ready() to work correctly with CD-ROMs
authorJames Bottomley <james.bottomley@steeleye.com>
Fri, 10 Sep 2004 13:52:44 +0000 (09:52 -0400)
committerJames Bottomley <jejb@raven.il.steeleye.com>
Fri, 10 Sep 2004 13:52:44 +0000 (09:52 -0400)
Olaf Hering noticed that SG_IO was no-longer working correctly on some
CD-ROMS.  The reason is a change in behaviour induced by switching to
the new scsi_test_unit_ready() API.

Apparently the CD-ROM special case needs to ignore both UNIT_ATTENTION
and NOT_READY for removable media.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/scsi_lib.c

index ac16f21dc3a12d405dc4a1c9369f66f7c177b6bd..47bf354d2957916de469f3c33a6c5ac3b9d7b8ae 100644 (file)
@@ -1585,11 +1585,12 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries)
        if (!sreq)
                return -ENOMEM;
 
-               sreq->sr_data_direction = DMA_NONE;
-        scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
+       sreq->sr_data_direction = DMA_NONE;
+       scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
 
        if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
-           (sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION &&
+           ((sreq->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION ||
+            (sreq->sr_sense_buffer[2] & 0x0f) == NOT_READY) &&
            sdev->removable) {
                sdev->changed = 1;
                sreq->sr_result = 0;