Skip to content
Permalink
Browse files
ide: Inline struct scsi_request into struct ide_request
Inline all struct scsi_request members into struct ide_request except
'retries'. Rename BLK_MAX_CDB into IDE_MAX_CDB.

Cc: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
  • Loading branch information
bvanassche committed Apr 11, 2021
1 parent e412ce4 commit 87c32e7e1cf663904d348a5b1ce8d6d4f015967d
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 164 deletions.
@@ -11,8 +11,6 @@
#include <linux/scatterlist.h>
#include <linux/gfp.h>

#include <scsi/scsi.h>

#define DRV_NAME "ide-atapi"
#define PFX DRV_NAME ": "

@@ -91,11 +89,13 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
struct ide_atapi_pc *pc, void *buf, unsigned int bufflen)
{
struct request *rq;
struct ide_request *req;
int error;

rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, 0);
ide_req(rq)->type = ATA_PRIV_MISC;
ide_req(rq)->special = pc;
req = ide_req(rq);
req->type = ATA_PRIV_MISC;
req->special = pc;

if (buf && bufflen) {
error = blk_rq_map_kern(drive->queue, rq, buf, bufflen,
@@ -104,11 +104,11 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
goto put_req;
}

memcpy(scsi_req(rq)->cmd, pc->c, 12);
memcpy(req->cmd, pc->c, 12);
if (drive->media == ide_tape)
scsi_req(rq)->cmd[13] = REQ_IDETAPE_PC1;
req->cmd[13] = REQ_IDETAPE_PC1;
blk_execute_rq(disk, rq, 0);
error = scsi_req(rq)->result ? -EIO : 0;
error = req->result ? -EIO : 0;
put_req:
blk_put_request(rq);
return error;
@@ -174,7 +174,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
{
struct request_sense *sense = &drive->sense_data;
struct request *sense_rq;
struct scsi_request *req;
struct ide_request *req;
unsigned int cmd_len, sense_len;
int err;

@@ -203,7 +203,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
drive->sense_rq = sense_rq;
}
req = scsi_req(sense_rq);
req = ide_req(sense_rq);

memset(sense, 0, sizeof(*sense));

@@ -276,7 +276,7 @@ void ide_retry_pc(ide_drive_t *drive)

/* init pc from sense_rq */
ide_init_pc(pc);
memcpy(pc->c, scsi_req(sense_rq)->cmd, 12);
memcpy(pc->c, ide_req(sense_rq)->cmd, 12);

if (drive->media == ide_tape)
drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC;
@@ -296,17 +296,18 @@ EXPORT_SYMBOL_GPL(ide_retry_pc);
int ide_cd_expiry(ide_drive_t *drive)
{
struct request *rq = drive->hwif->rq;
struct ide_request *req = ide_req(rq);
unsigned long wait = 0;

debug_log("%s: scsi_req(rq)->cmd[0]: 0x%x\n", __func__, scsi_req(rq)->cmd[0]);
debug_log("%s: req->cmd[0]: 0x%x\n", __func__, req->cmd[0]);

/*
* Some commands are *slow* and normally take a long time to complete.
* Usually we can use the ATAPI "disconnect" to bypass this, but not all
* commands/drives support that. Let ide_timer_expiry keep polling us
* for these.
*/
switch (scsi_req(rq)->cmd[0]) {
switch (req->cmd[0]) {
case GPCMD_BLANK:
case GPCMD_FORMAT_UNIT:
case GPCMD_RESERVE_RZONE_TRACK:
@@ -317,7 +318,7 @@ int ide_cd_expiry(ide_drive_t *drive)
default:
if (!(rq->rq_flags & RQF_QUIET))
printk(KERN_INFO PFX "cmd 0x%x timed out\n",
scsi_req(rq)->cmd[0]);
req->cmd[0]);
wait = 0;
break;
}
@@ -446,7 +447,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
? "write" : "read");
pc->flags |= PC_FLAG_DMA_ERROR;
} else
scsi_req(rq)->resid_len = 0;
ide_req(rq)->resid_len = 0;
debug_log("%s: DMA finished\n", drive->name);
}

@@ -463,23 +464,23 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
local_irq_enable_in_hardirq();

if (drive->media == ide_tape &&
(stat & ATA_ERR) && scsi_req(rq)->cmd[0] == REQUEST_SENSE)
(stat & ATA_ERR) && ide_req(rq)->cmd[0] == REQUEST_SENSE)
stat &= ~ATA_ERR;

if ((stat & ATA_ERR) || (pc->flags & PC_FLAG_DMA_ERROR)) {
/* Error detected */
debug_log("%s: I/O error\n", drive->name);

if (drive->media != ide_tape)
scsi_req(pc->rq)->result++;
ide_req(pc->rq)->result++;

if (scsi_req(rq)->cmd[0] == REQUEST_SENSE) {
if (ide_req(rq)->cmd[0] == REQUEST_SENSE) {
printk(KERN_ERR PFX "%s: I/O error in request "
"sense command\n", drive->name);
return ide_do_reset(drive);
}

debug_log("[cmd %x]: check condition\n", scsi_req(rq)->cmd[0]);
debug_log("[cmd %x]: check condition\n", ide_req(rq)->cmd[0]);

/* Retry operation */
ide_retry_pc(drive);
@@ -505,13 +506,13 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
drive->failed_pc = NULL;

if (ata_misc_request(rq)) {
scsi_req(rq)->result = 0;
ide_req(rq)->result = 0;
error = BLK_STS_OK;
} else {

if (blk_rq_is_passthrough(rq) && uptodate <= 0) {
if (scsi_req(rq)->result == 0)
scsi_req(rq)->result = -EIO;
if (ide_req(rq)->result == 0)
ide_req(rq)->result = -EIO;
}

error = uptodate ? BLK_STS_OK : BLK_STS_IOERR;
@@ -539,15 +540,15 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
ide_pio_bytes(drive, cmd, write, done);

/* Update transferred byte count */
scsi_req(rq)->resid_len -= done;
ide_req(rq)->resid_len -= done;

bcount -= done;

if (bcount)
ide_pad_transfer(drive, write, bcount);

debug_log("[cmd %x] transferred %d bytes, padded %d bytes, resid: %u\n",
scsi_req(rq)->cmd[0], done, bcount, scsi_req(rq)->resid_len);
ide_req(rq)->cmd[0], done, bcount, ide_req(rq)->resid_len);

/* And set the interrupt handler again */
ide_set_handler(drive, ide_pc_intr, timeout);
@@ -630,7 +631,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)

if (dev_is_idecd(drive)) {
/* ATAPI commands get padded out to 12 bytes minimum */
cmd_len = COMMAND_SIZE(scsi_req(rq)->cmd[0]);
cmd_len = COMMAND_SIZE(ide_req(rq)->cmd[0]);
if (cmd_len < ATAPI_MIN_CDB_BYTES)
cmd_len = ATAPI_MIN_CDB_BYTES;

@@ -677,7 +678,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)

/* Send the actual packet */
if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0)
hwif->tp_ops->output_data(drive, NULL, scsi_req(rq)->cmd, cmd_len);
hwif->tp_ops->output_data(drive, NULL, ide_req(rq)->cmd, cmd_len);

/* Begin DMA, if necessary */
if (dev_is_idecd(drive)) {
@@ -722,7 +723,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
bytes, 63 * 1024));

/* We haven't transferred any data yet */
scsi_req(rq)->resid_len = bcount;
ide_req(rq)->resid_len = bcount;

if (pc->flags & PC_FLAG_DMA_ERROR) {
pc->flags &= ~PC_FLAG_DMA_ERROR;

0 comments on commit 87c32e7

Please sign in to comment.