scsi: replace sr_test_unit_ready() with scsi_test_unit_ready()
The usage of TUR has been confusing involving several different commits updating different parts over time. Currently, the only differences between scsi_test_unit_ready() and sr_test_unit_ready() are, * scsi_test_unit_ready() also sets sdev->changed on NOT_READY. * scsi_test_unit_ready() returns 0 if TUR ended with UNIT_ATTENTION or NOT_READY. Due to the above two differences, sr is using its own sr_test_unit_ready(), but sd - the sole user of the above extra handling - doesn't even need them. Where scsi_test_unit_ready() is used in sd_media_changed(), the code is looking for device ready w/ media present state which is true iff TUR succeeds w/o sense data or UA, and when the device is not ready for whatever reason sd_media_changed() explicitly marks media as missing so there's no reason to set sdev->changed automatically from scsi_test_unit_ready() on NOT_READY. Drop both special handlings from scsi_test_unit_ready(), which makes it equivalant to sr_test_unit_ready(), and replace sr_test_unit_ready() with scsi_test_unit_ready(). Also, drop the unnecessary explicit NOT_READY check from sd_media_changed(). Checking return value is enough for testing device readiness. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
@@ -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,
|
||||
@@ -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;
|
||||
|
Reference in New Issue
Block a user