summaryrefslogtreecommitdiff
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c91
1 files changed, 43 insertions, 48 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 9cbd217bc0c9..6eb98725e194 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -121,7 +121,7 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq)
* don't log START_STOP unit with LoEj set, since we cannot
* reliably check if drive can auto-close
*/
- if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
+ if (scsi_req(rq)->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
break;
log = 1;
break;
@@ -163,7 +163,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
* toc has not been recorded yet, it will fail with 05/24/00 (which is a
* confusing error)
*/
- if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP)
+ if (failed_command && scsi_req(failed_command)->cmd[0] == GPCMD_READ_TOC_PMA_ATIP)
if (sense->sense_key == 0x05 && sense->asc == 0x24)
return;
@@ -219,15 +219,12 @@ static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
void *sense = bio_data(rq->bio);
if (failed) {
- if (failed->sense) {
- /*
- * Sense is always read into drive->sense_data.
- * Copy back if the failed request has its
- * sense pointer set.
- */
- memcpy(failed->sense, sense, 18);
- failed->sense_len = rq->sense_len;
- }
+ /*
+ * Sense is always read into drive->sense_data, copy back to the
+ * original request.
+ */
+ memcpy(scsi_req(failed)->sense, sense, 18);
+ scsi_req(failed)->sense_len = scsi_req(rq)->sense_len;
cdrom_analyze_sense_data(drive, failed);
if (ide_end_rq(drive, failed, -EIO, blk_rq_bytes(failed)))
@@ -338,7 +335,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
*
* cdrom_log_sense() knows this!
*/
- if (rq->cmd[0] == GPCMD_START_STOP_UNIT)
+ if (scsi_req(rq)->cmd[0] == GPCMD_START_STOP_UNIT)
break;
/* fall-through */
case DATA_PROTECT:
@@ -414,7 +411,7 @@ static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd)
* Some of the trailing request sense fields are optional,
* and some drives don't send them. Sigh.
*/
- if (rq->cmd[0] == GPCMD_REQUEST_SENSE &&
+ if (scsi_req(rq)->cmd[0] == GPCMD_REQUEST_SENSE &&
cmd->nleft > 0 && cmd->nleft <= 5)
cmd->nleft = 0;
}
@@ -425,12 +422,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
req_flags_t rq_flags)
{
struct cdrom_info *info = drive->driver_data;
- struct request_sense local_sense;
int retries = 10;
- req_flags_t flags = 0;
-
- if (!sense)
- sense = &local_sense;
+ bool failed;
ide_debug_log(IDE_DBG_PC, "cmd[0]: 0x%x, write: 0x%x, timeout: %d, "
"rq_flags: 0x%x",
@@ -440,12 +433,12 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
do {
struct request *rq;
int error;
+ bool delay = false;
rq = blk_get_request(drive->queue, write, __GFP_RECLAIM);
-
- memcpy(rq->cmd, cmd, BLK_MAX_CDB);
+ scsi_req_init(rq);
+ memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
rq->cmd_type = REQ_TYPE_ATA_PC;
- rq->sense = sense;
rq->rq_flags |= rq_flags;
rq->timeout = timeout;
if (buffer) {
@@ -460,21 +453,21 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
error = blk_execute_rq(drive->queue, info->disk, rq, 0);
if (buffer)
- *bufflen = rq->resid_len;
-
- flags = rq->rq_flags;
- blk_put_request(rq);
+ *bufflen = scsi_req(rq)->resid_len;
+ if (sense)
+ memcpy(sense, scsi_req(rq)->sense, sizeof(*sense));
/*
* FIXME: we should probably abort/retry or something in case of
* failure.
*/
- if (flags & RQF_FAILED) {
+ failed = (rq->rq_flags & RQF_FAILED) != 0;
+ if (failed) {
/*
* The request failed. Retry if it was due to a unit
* attention status (usually means media was changed).
*/
- struct request_sense *reqbuf = sense;
+ struct request_sense *reqbuf = scsi_req(rq)->sense;
if (reqbuf->sense_key == UNIT_ATTENTION)
cdrom_saw_media_change(drive);
@@ -485,19 +478,20 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
* a disk. Retry, but wait a little to give
* the drive time to complete the load.
*/
- ssleep(2);
+ delay = true;
} else {
/* otherwise, don't retry */
retries = 0;
}
--retries;
}
-
- /* end of retry loop */
- } while ((flags & RQF_FAILED) && retries >= 0);
+ blk_put_request(rq);
+ if (delay)
+ ssleep(2);
+ } while (failed && retries >= 0);
/* return an error if the command failed */
- return (flags & RQF_FAILED) ? -EIO : 0;
+ return failed ? -EIO : 0;
}
/*
@@ -636,7 +630,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
len -= blen;
if (sense && write == 0)
- rq->sense_len += blen;
+ scsi_req(rq)->sense_len += blen;
}
/* pad, if necessary */
@@ -664,7 +658,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
out_end:
if (rq->cmd_type == REQ_TYPE_BLOCK_PC && rc == 0) {
- rq->resid_len = 0;
+ scsi_req(rq)->resid_len = 0;
blk_end_request_all(rq, 0);
hwif->rq = NULL;
} else {
@@ -685,9 +679,9 @@ out_end:
/* make sure it's fully ended */
if (rq->cmd_type != REQ_TYPE_FS) {
- rq->resid_len -= cmd->nbytes - cmd->nleft;
+ scsi_req(rq)->resid_len -= cmd->nbytes - cmd->nleft;
if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
- rq->resid_len += cmd->last_xfer_len;
+ scsi_req(rq)->resid_len += cmd->last_xfer_len;
}
ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq));
@@ -1312,28 +1306,29 @@ static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
int hard_sect = queue_logical_block_size(q);
long block = (long)blk_rq_pos(rq) / (hard_sect >> 9);
unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9);
+ struct scsi_request *req = scsi_req(rq);
- memset(rq->cmd, 0, BLK_MAX_CDB);
+ memset(req->cmd, 0, BLK_MAX_CDB);
if (rq_data_dir(rq) == READ)
- rq->cmd[0] = GPCMD_READ_10;
+ req->cmd[0] = GPCMD_READ_10;
else
- rq->cmd[0] = GPCMD_WRITE_10;
+ req->cmd[0] = GPCMD_WRITE_10;
/*
* fill in lba
*/
- rq->cmd[2] = (block >> 24) & 0xff;
- rq->cmd[3] = (block >> 16) & 0xff;
- rq->cmd[4] = (block >> 8) & 0xff;
- rq->cmd[5] = block & 0xff;
+ req->cmd[2] = (block >> 24) & 0xff;
+ req->cmd[3] = (block >> 16) & 0xff;
+ req->cmd[4] = (block >> 8) & 0xff;
+ req->cmd[5] = block & 0xff;
/*
* and transfer length
*/
- rq->cmd[7] = (blocks >> 8) & 0xff;
- rq->cmd[8] = blocks & 0xff;
- rq->cmd_len = 10;
+ req->cmd[7] = (blocks >> 8) & 0xff;
+ req->cmd[8] = blocks & 0xff;
+ req->cmd_len = 10;
return BLKPREP_OK;
}
@@ -1343,7 +1338,7 @@ static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
*/
static int ide_cdrom_prep_pc(struct request *rq)
{
- u8 *c = rq->cmd;
+ u8 *c = scsi_req(rq)->cmd;
/* transform 6-byte read/write commands to the 10-byte version */
if (c[0] == READ_6 || c[0] == WRITE_6) {
@@ -1354,7 +1349,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
c[2] = 0;
c[1] &= 0xe0;
c[0] += (READ_10 - READ_6);
- rq->cmd_len = 10;
+ scsi_req(rq)->cmd_len = 10;
return BLKPREP_OK;
}