aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-12-08 14:57:40 -0500
committerJens Axboe <jaxboe@fusionio.com>2010-12-16 11:53:39 -0500
commit9f8a2c23c6c1140f515f601265c4dff7522110b7 (patch)
tree6defb41e4b129c3772e0c6d40b5e8e9a29bea7f0 /drivers/scsi/scsi_lib.c
parent638428ece619495edc9579b1e21493eb00f9687c (diff)
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>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index eafeeda6e194..13bf89145b18 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1984,8 +1984,7 @@ EXPORT_SYMBOL(scsi_mode_sense);
1984 * in. 1984 * in.
1985 * 1985 *
1986 * Returns zero if unsuccessful or an error if TUR failed. For 1986 * Returns zero if unsuccessful or an error if TUR failed. For
1987 * removable media, a return of NOT_READY or UNIT_ATTENTION is 1987 * removable media, UNIT_ATTENTION sets ->changed flag.
1988 * translated to success, with the ->changed flag updated.
1989 **/ 1988 **/
1990int 1989int
1991scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, 1990scsi_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,
2012 } while (scsi_sense_valid(sshdr) && 2011 } while (scsi_sense_valid(sshdr) &&
2013 sshdr->sense_key == UNIT_ATTENTION && --retries); 2012 sshdr->sense_key == UNIT_ATTENTION && --retries);
2014 2013
2015 if (!sshdr)
2016 /* could not allocate sense buffer, so can't process it */
2017 return result;
2018
2019 if (sdev->removable && scsi_sense_valid(sshdr) &&
2020 (sshdr->sense_key == UNIT_ATTENTION ||
2021 sshdr->sense_key == NOT_READY)) {
2022 sdev->changed = 1;
2023 result = 0;
2024 }
2025 if (!sshdr_external) 2014 if (!sshdr_external)
2026 kfree(sshdr); 2015 kfree(sshdr);
2027 return result; 2016 return result;