diff options
author | Tejun Heo <tj@kernel.org> | 2010-12-09 05:18:42 -0500 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-12-16 11:53:39 -0500 |
commit | 638428ece619495edc9579b1e21493eb00f9687c (patch) | |
tree | 08fec48e5218977d0d2db5b0a0a205c76b38f07e /drivers/scsi | |
parent | 2d9217296bfa6fdc0d3707264076e5296faffdbd (diff) |
scsi: fix TUR error handling in sr_media_change()
sr_test_unit_ready() returns 0 iff TUR succeeded - IOW, when media is
present and the device is actually ready, so the return value wouldn't
be zero when TUR ends with sense data. sr_media_change() incorrectly
tests (retval || (scsi_sense_valid(sshdr)...)) when it tries to test
whether TUR failed without sense data or with sense data indicating
media-not-present.
Fix the test using scsi_status_is_good() and update comments.
- Fixed a comment typo spotted by Eike.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rolf Eike Beer <eike-kernel@sf-tec.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sr.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index d7b383c96d5d..c7e29bdec2cd 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -214,13 +214,17 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot) | |||
214 | 214 | ||
215 | sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL); | 215 | sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL); |
216 | retval = sr_test_unit_ready(cd->device, sshdr); | 216 | retval = sr_test_unit_ready(cd->device, sshdr); |
217 | if (retval || (scsi_sense_valid(sshdr) && | 217 | /* |
218 | /* 0x3a is medium not present */ | 218 | * Media is considered to be present if TUR succeeds or fails with |
219 | sshdr->asc == 0x3a)) { | 219 | * sense data indicating something other than media-not-present |
220 | /* Media not present or unable to test, unit probably not | 220 | * (ASC 0x3a). |
221 | * ready. This usually means there is no disc in the drive. | 221 | */ |
222 | * Mark as changed, and we will figure it out later once | 222 | if (!scsi_status_is_good(retval) && |
223 | * the drive is available again. | 223 | (!scsi_sense_valid(sshdr) || sshdr->asc == 0x3a)) { |
224 | /* | ||
225 | * Probably no media in the device. Mark as changed, and | ||
226 | * we will figure it out later once the drive is available | ||
227 | * again. | ||
224 | */ | 228 | */ |
225 | cd->device->changed = 1; | 229 | cd->device->changed = 1; |
226 | /* This will force a flush, if called from check_disk_change */ | 230 | /* This will force a flush, if called from check_disk_change */ |