Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84419
b: refs/heads/master
c: 38582a6
h: refs/heads/master
i:
  84417: 671ad69
  84415: 7cabf65
v: v3
  • Loading branch information
James Bottomley authored and James Bottomley committed Feb 8, 2008
1 parent de47f9b commit b8e4f6d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 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: d6a451dd4d7ec805f9a21bb1994ce8ceaecc8fe6
refs/heads/master: 38582a62ecd337de4212004c7d4844899dc57890
49 changes: 27 additions & 22 deletions trunk/drivers/scsi/sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,29 @@ static void scsi_cd_put(struct scsi_cd *cd)
mutex_unlock(&sr_ref_mutex);
}

/* identical to scsi_test_unit_ready except that it doesn't
* eat the NOT_READY returns for removable media */
int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr)
{
int retries = MAX_RETRIES;
int the_result;
u8 cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0 };

/* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
* conditions are gone, or a timeout happens
*/
do {
the_result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL,
0, sshdr, SR_TIMEOUT,
retries--);

} while (retries > 0 &&
(!scsi_status_is_good(the_result) ||
(scsi_sense_valid(sshdr) &&
sshdr->sense_key == UNIT_ATTENTION)));
return the_result;
}

/*
* This function checks to see if the media has been changed in the
* CDROM drive. It is possible that we have already sensed a change,
Expand All @@ -185,8 +208,7 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
}

sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
retval = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
sshdr);
retval = sr_test_unit_ready(cd->device, sshdr);
if (retval || (scsi_sense_valid(sshdr) &&
/* 0x3a is medium not present */
sshdr->asc == 0x3a)) {
Expand Down Expand Up @@ -733,10 +755,8 @@ static void get_capabilities(struct scsi_cd *cd)
{
unsigned char *buffer;
struct scsi_mode_data data;
unsigned char cmd[MAX_COMMAND_SIZE];
struct scsi_sense_hdr sshdr;
unsigned int the_result;
int retries, rc, n;
int rc, n;

static const char *loadmech[] =
{
Expand All @@ -758,23 +778,8 @@ static void get_capabilities(struct scsi_cd *cd)
return;
}

/* issue TEST_UNIT_READY until the initial startup UNIT_ATTENTION
* conditions are gone, or a timeout happens
*/
retries = 0;
do {
memset((void *)cmd, 0, MAX_COMMAND_SIZE);
cmd[0] = TEST_UNIT_READY;

the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
0, &sshdr, SR_TIMEOUT,
MAX_RETRIES);

retries++;
} while (retries < 5 &&
(!scsi_status_is_good(the_result) ||
(scsi_sense_valid(&sshdr) &&
sshdr.sense_key == UNIT_ATTENTION)));
/* eat unit attentions */
sr_test_unit_ready(cd->device, &sshdr);

/* ask for mode page 0x2a */
rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/scsi/sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed);
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);

int sr_is_xa(Scsi_CD *);
int sr_test_unit_ready(struct scsi_device *sdev, struct scsi_sense_hdr *sshdr);

/* sr_vendor.c */
void sr_vendor_init(Scsi_CD *);
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/scsi/sr_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)
/* we have no changer support */
return -EINVAL;
}
if (0 == scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES,
&sshdr))
if (0 == sr_test_unit_ready(cd->device, &sshdr))
return CDS_DISC_OK;

if (!cdrom_get_media_event(cdi, &med)) {
Expand Down

0 comments on commit b8e4f6d

Please sign in to comment.