Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230617
b: refs/heads/master
c: 9f8a2c2
h: refs/heads/master
i:
  230615: b4dcc2f
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Dec 16, 2010
1 parent 34201bd commit d3f5c26
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 52 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 638428ece619495edc9579b1e21493eb00f9687c
refs/heads/master: 9f8a2c23c6c1140f515f601265c4dff7522110b7
13 changes: 1 addition & 12 deletions trunk/drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1984,8 +1984,7 @@ EXPORT_SYMBOL(scsi_mode_sense);
* in.
*
* Returns zero if unsuccessful or an error if TUR failed. For
* removable media, a return of NOT_READY or UNIT_ATTENTION is
* translated to success, with the ->changed flag updated.
* removable media, UNIT_ATTENTION sets ->changed flag.
**/
int
scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
Expand All @@ -2012,16 +2011,6 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
} while (scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION && --retries);

if (!sshdr)
/* could not allocate sense buffer, so can't process it */
return result;

if (sdev->removable && scsi_sense_valid(sshdr) &&
(sshdr->sense_key == UNIT_ATTENTION ||
sshdr->sense_key == NOT_READY)) {
sdev->changed = 1;
result = 0;
}
if (!sshdr_external)
kfree(sshdr);
return result;
Expand Down
10 changes: 1 addition & 9 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,15 +1045,7 @@ static int sd_media_changed(struct gendisk *disk)
sshdr);
}

/*
* Unable to test, unit probably not ready. This usually
* means there is no disc in the drive. Mark as changed,
* and we will figure it out later once the drive is
* available again.
*/
if (retval || (scsi_sense_valid(sshdr) &&
/* 0x3a is medium not present */
sshdr->asc == 0x3a)) {
if (retval) {
set_media_not_present(sdkp);
retval = 1;
goto out;
Expand Down
31 changes: 3 additions & 28 deletions trunk/drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,32 +165,6 @@ static void scsi_cd_put(struct scsi_cd *cd)
mutex_unlock(&sr_ref_mutex);
}

/* identical to scsi_test_unit_ready except that it doesn't
* eat the NOT_READY returns for removable media */
int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
{
int retries = MAX_RETRIES;
int the_result;
u8 cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0 };

/* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
* conditions are gone, or a timeout happens
*/
do {
the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL,
0, sshdr, SR_TIMEOUT,
retries--, NULL);
if (scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION)
sdev->changed = 1;

} while (retries > 0 &&
(!scsi_status_is_good(the_result) ||
(scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION)));
return the_result;
}

/*
* This function checks to see if the media has been changed in the
* CDROM drive. It is possible that we have already sensed a change,
Expand All @@ -213,7 +187,8 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
}

sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
retval = sr_test_unit_ready(cd->device, sshdr);
retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
sshdr);
/*
* Media is considered to be present if TUR succeeds or fails with
* sense data indicating something other than media-not-present
Expand Down Expand Up @@ -784,7 +759,7 @@ static void get_capabilities(struct scsi_cd *cd)
}

/* eat unit attentions */
sr_test_unit_ready(cd->device, &sshdr);
scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);

/* ask for mode page 0x2a */
rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/scsi/sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed);
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);

int sr_is_xa(Scsi_CD *);
int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr);

/* sr_vendor.c */
void sr_vendor_init(Scsi_CD *);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/sr_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
/* we have no changer support */
return -EINVAL;
}
if (0 == sr_test_unit_ready(cd->device, &sshdr))
if (!scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr))
return CDS_DISC_OK;

/* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */
Expand Down

0 comments on commit d3f5c26

Please sign in to comment.