From: Alan Stern This patch (as696) moves the check for medium not present a bit earlier in the sd_spinup_disk() routine. The existing code will happily continue probing even after the device has told it there is no media. Signed-off-by: Alan Stern Cc: James Bottomley Cc: Jens Axboe Signed-off-by: Andrew Morton --- drivers/scsi/sd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff -puN drivers/scsi/sd.c~sd-early-detection-of-medium-not-present drivers/scsi/sd.c --- a/drivers/scsi/sd.c~sd-early-detection-of-medium-not-present +++ a/drivers/scsi/sd.c @@ -1050,6 +1050,14 @@ sd_spinup_disk(struct scsi_disk *sdkp, c &sshdr, SD_TIMEOUT, SD_MAX_RETRIES); + /* + * If the drive has indicated to us that it + * doesn't have any media in it, don't bother + * with any of the rest of this crap. + */ + if (media_not_present(sdkp, &sshdr)) + return; + if (the_result) sense_valid = scsi_sense_valid(&sshdr); retries++; @@ -1058,14 +1066,6 @@ sd_spinup_disk(struct scsi_disk *sdkp, c ((driver_byte(the_result) & DRIVER_SENSE) && sense_valid && sshdr.sense_key == UNIT_ATTENTION))); - /* - * If the drive has indicated to us that it doesn't have - * any media in it, don't bother with any of the rest of - * this crap. - */ - if (media_not_present(sdkp, &sshdr)) - return; - if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { /* no sense, TUR either succeeded or failed * with a status error */ _