Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77091
b: refs/heads/master
c: 210ba1d
h: refs/heads/master
i:
  77089: 31c01f4
  77087: d9c6ab6
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Jan 12, 2008
1 parent a5c5cd2 commit 6822d3f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 32e8ae36b8f80372015b88b63c4358a376c9af0f
refs/heads/master: 210ba1d1724f5c4ed87a2ab1a21ca861a915f734
2 changes: 0 additions & 2 deletions trunk/drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);

#define SR_DISKS 256

#define MAX_RETRIES 3
#define SR_TIMEOUT (30 * HZ)
#define SR_CAPABILITIES \
(CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \
CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/scsi/sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <linux/genhd.h>
#include <linux/kref.h>

#define MAX_RETRIES 3
#define SR_TIMEOUT (30 * HZ)

struct scsi_device;

/* The CDROM is fairly slow, so we need a little extra time */
Expand Down
48 changes: 34 additions & 14 deletions trunk/drivers/scsi/sr_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,6 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
/* ---------------------------------------------------------------------- */
/* interface to cdrom.c */

static int test_unit_ready(Scsi_CD *cd)
{
struct packet_command cgc;

memset(&cgc, 0, sizeof(struct packet_command));
cgc.cmd[0] = GPCMD_TEST_UNIT_READY;
cgc.quiet = 1;
cgc.data_direction = DMA_NONE;
cgc.timeout = IOCTL_TIMEOUT;
return sr_do_ioctl(cd, &cgc);
}

int sr_tray_move(struct cdrom_device_info *cdi, int pos)
{
Scsi_CD *cd = cdi->handle;
Expand All @@ -310,14 +298,46 @@ int sr_lock_door(struct cdrom_device_info *cdi, int lock)

int sr_drive_status(struct cdrom_device_info *cdi, int slot)
{
struct scsi_cd *cd = cdi->handle;
struct scsi_sense_hdr sshdr;
struct media_event_desc med;

if (CDSL_CURRENT != slot) {
/* we have no changer support */
return -EINVAL;
}
if (0 == test_unit_ready(cdi->handle))
if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
&sshdr))
return CDS_DISC_OK;

return CDS_TRAY_OPEN;
if (!cdrom_get_media_event(cdi, &med)) {
if (med.media_present)
return CDS_DISC_OK;
else if (med.door_open)
return CDS_TRAY_OPEN;
else
return CDS_NO_DISC;
}

/*
* 0x04 is format in progress .. but there must be a disc present!
*/
if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04)
return CDS_DISC_OK;

/*
* If not using Mt Fuji extended media tray reports,
* just return TRAY_OPEN since ATAPI doesn't provide
* any other way to detect this...
*/
if (scsi_sense_valid(&sshdr) &&
/* 0x3a is medium not present */
sshdr.asc == 0x3a)
return CDS_NO_DISC;
else
return CDS_TRAY_OPEN;

return CDS_DRIVE_NOT_READY;
}

int sr_disk_status(struct cdrom_device_info *cdi)
Expand Down

0 comments on commit 6822d3f

Please sign in to comment.