aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sr_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sr_ioctl.c')
-rw-r--r--drivers/scsi/sr_ioctl.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index e1589f91706a..d5cebff1d646 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -275,18 +275,6 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
275/* ---------------------------------------------------------------------- */ 275/* ---------------------------------------------------------------------- */
276/* interface to cdrom.c */ 276/* interface to cdrom.c */
277 277
278static int test_unit_ready(Scsi_CD *cd)
279{
280 struct packet_command cgc;
281
282 memset(&cgc, 0, sizeof(struct packet_command));
283 cgc.cmd[0] = GPCMD_TEST_UNIT_READY;
284 cgc.quiet = 1;
285 cgc.data_direction = DMA_NONE;
286 cgc.timeout = IOCTL_TIMEOUT;
287 return sr_do_ioctl(cd, &cgc);
288}
289
290int sr_tray_move(struct cdrom_device_info *cdi, int pos) 278int sr_tray_move(struct cdrom_device_info *cdi, int pos)
291{ 279{
292 Scsi_CD *cd = cdi->handle; 280 Scsi_CD *cd = cdi->handle;
@@ -310,14 +298,46 @@ int sr_lock_door(struct cdrom_device_info *cdi, int lock)
310 298
311int sr_drive_status(struct cdrom_device_info *cdi, int slot) 299int sr_drive_status(struct cdrom_device_info *cdi, int slot)
312{ 300{
301 struct scsi_cd *cd = cdi->handle;
302 struct scsi_sense_hdr sshdr;
303 struct media_event_desc med;
304
313 if (CDSL_CURRENT != slot) { 305 if (CDSL_CURRENT != slot) {
314 /* we have no changer support */ 306 /* we have no changer support */
315 return -EINVAL; 307 return -EINVAL;
316 } 308 }
317 if (0 == test_unit_ready(cdi->handle)) 309 if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
310 &sshdr))
318 return CDS_DISC_OK; 311 return CDS_DISC_OK;
319 312
320 return CDS_TRAY_OPEN; 313 if (!cdrom_get_media_event(cdi, &med)) {
314 if (med.media_present)
315 return CDS_DISC_OK;
316 else if (med.door_open)
317 return CDS_TRAY_OPEN;
318 else
319 return CDS_NO_DISC;
320 }
321
322 /*
323 * 0x04 is format in progress .. but there must be a disc present!
324 */
325 if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04)
326 return CDS_DISC_OK;
327
328 /*
329 * If not using Mt Fuji extended media tray reports,
330 * just return TRAY_OPEN since ATAPI doesn't provide
331 * any other way to detect this...
332 */
333 if (scsi_sense_valid(&sshdr) &&
334 /* 0x3a is medium not present */
335 sshdr.asc == 0x3a)
336 return CDS_NO_DISC;
337 else
338 return CDS_TRAY_OPEN;
339
340 return CDS_DRIVE_NOT_READY;
321} 341}
322 342
323int sr_disk_status(struct cdrom_device_info *cdi) 343int sr_disk_status(struct cdrom_device_info *cdi)