diff options
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r-- | drivers/scsi/sr.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 7702681d93f9..896be4ab285d 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -179,18 +179,24 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot) | |||
179 | { | 179 | { |
180 | struct scsi_cd *cd = cdi->handle; | 180 | struct scsi_cd *cd = cdi->handle; |
181 | int retval; | 181 | int retval; |
182 | struct scsi_sense_hdr *sshdr; | ||
182 | 183 | ||
183 | if (CDSL_CURRENT != slot) { | 184 | if (CDSL_CURRENT != slot) { |
184 | /* no changer support */ | 185 | /* no changer support */ |
185 | return -EINVAL; | 186 | return -EINVAL; |
186 | } | 187 | } |
187 | 188 | ||
188 | retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES); | 189 | sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL); |
189 | if (retval) { | 190 | retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, |
190 | /* Unable to test, unit probably not ready. This usually | 191 | sshdr); |
191 | * means there is no disc in the drive. Mark as changed, | 192 | if (retval || (scsi_sense_valid(sshdr) && |
192 | * and we will figure it out later once the drive is | 193 | /* 0x3a is medium not present */ |
193 | * available again. */ | 194 | sshdr->asc == 0x3a)) { |
195 | /* Media not present or unable to test, unit probably not | ||
196 | * ready. This usually means there is no disc in the drive. | ||
197 | * Mark as changed, and we will figure it out later once | ||
198 | * the drive is available again. | ||
199 | */ | ||
194 | cd->device->changed = 1; | 200 | cd->device->changed = 1; |
195 | /* This will force a flush, if called from check_disk_change */ | 201 | /* This will force a flush, if called from check_disk_change */ |
196 | retval = 1; | 202 | retval = 1; |
@@ -213,6 +219,7 @@ out: | |||
213 | sdev_evt_send_simple(cd->device, SDEV_EVT_MEDIA_CHANGE, | 219 | sdev_evt_send_simple(cd->device, SDEV_EVT_MEDIA_CHANGE, |
214 | GFP_KERNEL); | 220 | GFP_KERNEL); |
215 | cd->previous_state = retval; | 221 | cd->previous_state = retval; |
222 | kfree(sshdr); | ||
216 | 223 | ||
217 | return retval; | 224 | return retval; |
218 | } | 225 | } |