提交 2f5a8e80 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

ide: don't abuse cmd_type

Currently the legacy ide driver defines several request types of it's own,
which is in the way of removing that field entirely.

Instead add a type field to struct ide_request and use that to distinguish
the different types of IDE-internal requests.

It's a bit of a mess, but so is the surrounding code..
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Acked-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 57292b58
...@@ -95,6 +95,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, ...@@ -95,6 +95,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
rq->special = (char *)pc; rq->special = (char *)pc;
if (buf && bufflen) { if (buf && bufflen) {
...@@ -193,7 +194,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) ...@@ -193,7 +194,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
BUG_ON(sense_len > sizeof(*sense)); BUG_ON(sense_len > sizeof(*sense));
if (rq->cmd_type == REQ_TYPE_ATA_SENSE || drive->sense_rq_armed) if (ata_sense_request(rq) || drive->sense_rq_armed)
return; return;
memset(sense, 0, sizeof(*sense)); memset(sense, 0, sizeof(*sense));
...@@ -211,7 +212,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) ...@@ -211,7 +212,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
} }
sense_rq->rq_disk = rq->rq_disk; sense_rq->rq_disk = rq->rq_disk;
sense_rq->cmd_type = REQ_TYPE_ATA_SENSE; sense_rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(sense_rq)->type = ATA_PRIV_SENSE;
sense_rq->rq_flags |= RQF_PREEMPT; sense_rq->rq_flags |= RQF_PREEMPT;
req->cmd[0] = GPCMD_REQUEST_SENSE; req->cmd[0] = GPCMD_REQUEST_SENSE;
...@@ -313,10 +315,14 @@ int ide_cd_get_xferlen(struct request *rq) ...@@ -313,10 +315,14 @@ int ide_cd_get_xferlen(struct request *rq)
switch (rq->cmd_type) { switch (rq->cmd_type) {
case REQ_TYPE_FS: case REQ_TYPE_FS:
return 32768; return 32768;
case REQ_TYPE_ATA_SENSE:
case REQ_TYPE_BLOCK_PC: case REQ_TYPE_BLOCK_PC:
case REQ_TYPE_ATA_PC:
return blk_rq_bytes(rq); return blk_rq_bytes(rq);
case REQ_TYPE_DRV_PRIV:
switch (ide_req(rq)->type) {
case ATA_PRIV_PC:
case ATA_PRIV_SENSE:
return blk_rq_bytes(rq);
}
default: default:
return 0; return 0;
} }
...@@ -377,7 +383,7 @@ int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len, ...@@ -377,7 +383,7 @@ int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len,
drive->name, __func__, ireason); drive->name, __func__, ireason);
} }
if (dev_is_idecd(drive) && rq->cmd_type == REQ_TYPE_ATA_PC) if (dev_is_idecd(drive) && ata_pc_request(rq))
rq->rq_flags |= RQF_FAILED; rq->rq_flags |= RQF_FAILED;
return 1; return 1;
...@@ -480,7 +486,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) ...@@ -480,7 +486,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
if (uptodate == 0) if (uptodate == 0)
drive->failed_pc = NULL; drive->failed_pc = NULL;
if (rq->cmd_type == REQ_TYPE_DRV_PRIV) { if (ata_misc_request(rq)) {
rq->errors = 0; rq->errors = 0;
error = 0; error = 0;
} else { } else {
......
...@@ -210,7 +210,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, ...@@ -210,7 +210,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
{ {
/* /*
* For REQ_TYPE_ATA_SENSE, "rq->special" points to the original * For ATA_PRIV_SENSE, "rq->special" points to the original
* failed request. Also, the sense data should be read * failed request. Also, the sense data should be read
* directly from rq which might be different from the original * directly from rq which might be different from the original
* sense buffer if it got copied during mapping. * sense buffer if it got copied during mapping.
...@@ -282,7 +282,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat) ...@@ -282,7 +282,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
"stat 0x%x", "stat 0x%x",
rq->cmd[0], rq->cmd_type, err, stat); rq->cmd[0], rq->cmd_type, err, stat);
if (rq->cmd_type == REQ_TYPE_ATA_SENSE) { if (ata_sense_request(rq)) {
/* /*
* We got an error trying to get sense info from the drive * We got an error trying to get sense info from the drive
* (probably while trying to recover from a former error). * (probably while trying to recover from a former error).
...@@ -438,7 +438,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, ...@@ -438,7 +438,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
rq = blk_get_request(drive->queue, write, __GFP_RECLAIM); rq = blk_get_request(drive->queue, write, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB); memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
rq->cmd_type = REQ_TYPE_ATA_PC; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_PC;
rq->rq_flags |= rq_flags; rq->rq_flags |= rq_flags;
rq->timeout = timeout; rq->timeout = timeout;
if (buffer) { if (buffer) {
...@@ -520,7 +521,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -520,7 +521,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
ide_expiry_t *expiry = NULL; ide_expiry_t *expiry = NULL;
int dma_error = 0, dma, thislen, uptodate = 0; int dma_error = 0, dma, thislen, uptodate = 0;
int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0; int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
int sense = (rq->cmd_type == REQ_TYPE_ATA_SENSE); int sense = ata_sense_request(rq);
unsigned int timeout; unsigned int timeout;
u16 len; u16 len;
u8 ireason, stat; u8 ireason, stat;
...@@ -785,18 +786,22 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, ...@@ -785,18 +786,22 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
if (cdrom_start_rw(drive, rq) == ide_stopped) if (cdrom_start_rw(drive, rq) == ide_stopped)
goto out_end; goto out_end;
break; break;
case REQ_TYPE_ATA_SENSE:
case REQ_TYPE_BLOCK_PC: case REQ_TYPE_BLOCK_PC:
case REQ_TYPE_ATA_PC: handle_pc:
if (!rq->timeout) if (!rq->timeout)
rq->timeout = ATAPI_WAIT_PC; rq->timeout = ATAPI_WAIT_PC;
cdrom_do_block_pc(drive, rq); cdrom_do_block_pc(drive, rq);
break; break;
case REQ_TYPE_DRV_PRIV: case REQ_TYPE_DRV_PRIV:
switch (ide_req(rq)->type) {
case ATA_PRIV_MISC:
/* right now this can only be a reset... */ /* right now this can only be a reset... */
uptodate = 1; uptodate = 1;
goto out_end; goto out_end;
case ATA_PRIV_SENSE:
case ATA_PRIV_PC:
goto handle_pc;
}
default: default:
BUG(); BUG();
} }
......
...@@ -306,6 +306,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi) ...@@ -306,6 +306,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
rq->rq_flags = RQF_QUIET; rq->rq_flags = RQF_QUIET;
ret = blk_execute_rq(drive->queue, cd->disk, rq, 0); ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
blk_put_request(rq); blk_put_request(rq);
......
...@@ -168,6 +168,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, ...@@ -168,6 +168,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
rq = blk_get_request(q, READ, __GFP_RECLAIM); rq = blk_get_request(q, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
scsi_req(rq)->cmd_len = 5; scsi_req(rq)->cmd_len = 5;
scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC; scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC;
*(int *)&scsi_req(rq)->cmd[1] = arg; *(int *)&scsi_req(rq)->cmd[1] = arg;
......
...@@ -453,7 +453,8 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq) ...@@ -453,7 +453,8 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
cmd->tf_flags = IDE_TFLAG_DYN; cmd->tf_flags = IDE_TFLAG_DYN;
cmd->protocol = ATA_PROT_NODATA; cmd->protocol = ATA_PROT_NODATA;
rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_TASKFILE;
rq->special = cmd; rq->special = cmd;
cmd->rq = rq; cmd->rq = rq;
...@@ -479,7 +480,8 @@ static int set_multcount(ide_drive_t *drive, int arg) ...@@ -479,7 +480,8 @@ static int set_multcount(ide_drive_t *drive, int arg)
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_TASKFILE;
drive->mult_req = arg; drive->mult_req = arg;
drive->special_flags |= IDE_SFLAG_SET_MULTMODE; drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
......
...@@ -124,7 +124,7 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat) ...@@ -124,7 +124,7 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
/* retry only "normal" I/O: */ /* retry only "normal" I/O: */
if (rq->cmd_type != REQ_TYPE_FS) { if (rq->cmd_type != REQ_TYPE_FS) {
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { if (ata_taskfile_request(rq)) {
struct ide_cmd *cmd = rq->special; struct ide_cmd *cmd = rq->special;
if (cmd) if (cmd)
...@@ -147,7 +147,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) ...@@ -147,7 +147,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
{ {
struct request *rq = drive->hwif->rq; struct request *rq = drive->hwif->rq;
if (rq && rq->cmd_type == REQ_TYPE_DRV_PRIV && if (rq && ata_misc_request(rq) &&
scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) { scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) {
if (err <= 0 && rq->errors == 0) if (err <= 0 && rq->errors == 0)
rq->errors = -EIO; rq->errors = -EIO;
......
...@@ -97,7 +97,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc) ...@@ -97,7 +97,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
"Aborting request!\n"); "Aborting request!\n");
} }
if (rq->cmd_type == REQ_TYPE_DRV_PRIV) if (ata_misc_request(rq))
rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
return uptodate; return uptodate;
...@@ -246,7 +246,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, ...@@ -246,7 +246,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
} else } else
printk(KERN_ERR PFX "%s: I/O error\n", drive->name); printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
if (rq->cmd_type == REQ_TYPE_DRV_PRIV) { if (ata_misc_request(rq)) {
rq->errors = 0; rq->errors = 0;
ide_complete_rq(drive, 0, blk_rq_bytes(rq)); ide_complete_rq(drive, 0, blk_rq_bytes(rq));
return ide_stopped; return ide_stopped;
...@@ -265,14 +265,20 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, ...@@ -265,14 +265,20 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
pc = &floppy->queued_pc; pc = &floppy->queued_pc;
idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
break; break;
case REQ_TYPE_DRV_PRIV:
case REQ_TYPE_ATA_SENSE:
pc = (struct ide_atapi_pc *)rq->special;
break;
case REQ_TYPE_BLOCK_PC: case REQ_TYPE_BLOCK_PC:
pc = &floppy->queued_pc; pc = &floppy->queued_pc;
idefloppy_blockpc_cmd(floppy, pc, rq); idefloppy_blockpc_cmd(floppy, pc, rq);
break; break;
case REQ_TYPE_DRV_PRIV:
switch (ide_req(rq)->type) {
case ATA_PRIV_MISC:
case ATA_PRIV_SENSE:
pc = (struct ide_atapi_pc *)rq->special;
break;
default:
BUG();
}
break;
default: default:
BUG(); BUG();
} }
......
...@@ -102,7 +102,7 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) ...@@ -102,7 +102,7 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
drive->dev_flags |= IDE_DFLAG_PARKED; drive->dev_flags |= IDE_DFLAG_PARKED;
} }
if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { if (rq && ata_taskfile_request(rq)) {
struct ide_cmd *orig_cmd = rq->special; struct ide_cmd *orig_cmd = rq->special;
if (cmd->tf_flags & IDE_TFLAG_DYN) if (cmd->tf_flags & IDE_TFLAG_DYN)
...@@ -135,7 +135,7 @@ EXPORT_SYMBOL(ide_complete_rq); ...@@ -135,7 +135,7 @@ EXPORT_SYMBOL(ide_complete_rq);
void ide_kill_rq(ide_drive_t *drive, struct request *rq) void ide_kill_rq(ide_drive_t *drive, struct request *rq)
{ {
u8 drv_req = (rq->cmd_type == REQ_TYPE_DRV_PRIV) && rq->rq_disk; u8 drv_req = ata_misc_request(rq) && rq->rq_disk;
u8 media = drive->media; u8 media = drive->media;
drive->failed_pc = NULL; drive->failed_pc = NULL;
...@@ -340,7 +340,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ...@@ -340,7 +340,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
if (drive->current_speed == 0xff) if (drive->current_speed == 0xff)
ide_config_drive_speed(drive, drive->desired_speed); ide_config_drive_speed(drive, drive->desired_speed);
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) if (ata_taskfile_request(rq))
return execute_drive_cmd(drive, rq); return execute_drive_cmd(drive, rq);
else if (ata_pm_request(rq)) { else if (ata_pm_request(rq)) {
struct ide_pm_state *pm = rq->special; struct ide_pm_state *pm = rq->special;
...@@ -353,7 +353,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ...@@ -353,7 +353,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
pm->pm_step == IDE_PM_COMPLETED) pm->pm_step == IDE_PM_COMPLETED)
ide_complete_pm_rq(drive, rq); ide_complete_pm_rq(drive, rq);
return startstop; return startstop;
} else if (!rq->rq_disk && rq->cmd_type == REQ_TYPE_DRV_PRIV) } else if (!rq->rq_disk && ata_misc_request(rq))
/* /*
* TODO: Once all ULDs have been modified to * TODO: Once all ULDs have been modified to
* check for specific op codes rather than * check for specific op codes rather than
......
...@@ -127,7 +127,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) ...@@ -127,7 +127,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_TASKFILE;
err = blk_execute_rq(drive->queue, NULL, rq, 0); err = blk_execute_rq(drive->queue, NULL, rq, 0);
blk_put_request(rq); blk_put_request(rq);
...@@ -225,6 +226,7 @@ static int generic_drive_reset(ide_drive_t *drive) ...@@ -225,6 +226,7 @@ static int generic_drive_reset(ide_drive_t *drive)
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
scsi_req(rq)->cmd_len = 1; scsi_req(rq)->cmd_len = 1;
scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET; scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET;
if (blk_execute_rq(drive->queue, NULL, rq, 1)) if (blk_execute_rq(drive->queue, NULL, rq, 1))
......
...@@ -36,6 +36,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) ...@@ -36,6 +36,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
scsi_req(rq)->cmd[0] = REQ_PARK_HEADS; scsi_req(rq)->cmd[0] = REQ_PARK_HEADS;
scsi_req(rq)->cmd_len = 1; scsi_req(rq)->cmd_len = 1;
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
rq->special = &timeout; rq->special = &timeout;
rc = blk_execute_rq(q, NULL, rq, 1); rc = blk_execute_rq(q, NULL, rq, 1);
blk_put_request(rq); blk_put_request(rq);
...@@ -54,6 +55,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) ...@@ -54,6 +55,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
scsi_req(rq)->cmd[0] = REQ_UNPARK_HEADS; scsi_req(rq)->cmd[0] = REQ_UNPARK_HEADS;
scsi_req(rq)->cmd_len = 1; scsi_req(rq)->cmd_len = 1;
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
elv_add_request(q, rq, ELEVATOR_INSERT_FRONT); elv_add_request(q, rq, ELEVATOR_INSERT_FRONT);
out: out:
......
...@@ -20,7 +20,8 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -20,7 +20,8 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_ATA_PM_SUSPEND; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_PM_SUSPEND;
rq->special = &rqpm; rq->special = &rqpm;
rqpm.pm_step = IDE_PM_START_SUSPEND; rqpm.pm_step = IDE_PM_START_SUSPEND;
if (mesg.event == PM_EVENT_PRETHAW) if (mesg.event == PM_EVENT_PRETHAW)
...@@ -91,7 +92,8 @@ int generic_ide_resume(struct device *dev) ...@@ -91,7 +92,8 @@ int generic_ide_resume(struct device *dev)
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_ATA_PM_RESUME; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_PM_RESUME;
rq->rq_flags |= RQF_PREEMPT; rq->rq_flags |= RQF_PREEMPT;
rq->special = &rqpm; rq->special = &rqpm;
rqpm.pm_step = IDE_PM_START_RESUME; rqpm.pm_step = IDE_PM_START_RESUME;
...@@ -223,10 +225,10 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) ...@@ -223,10 +225,10 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
#ifdef DEBUG_PM #ifdef DEBUG_PM
printk("%s: completing PM request, %s\n", drive->name, printk("%s: completing PM request, %s\n", drive->name,
(rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND) ? "suspend" : "resume"); (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND) ? "suspend" : "resume");
#endif #endif
spin_lock_irqsave(q->queue_lock, flags); spin_lock_irqsave(q->queue_lock, flags);
if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND) if (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND)
blk_stop_queue(q); blk_stop_queue(q);
else else
drive->dev_flags &= ~IDE_DFLAG_BLOCKED; drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
...@@ -242,11 +244,13 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq) ...@@ -242,11 +244,13 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
{ {
struct ide_pm_state *pm = rq->special; struct ide_pm_state *pm = rq->special;
if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND && if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_PM_SUSPEND &&
pm->pm_step == IDE_PM_START_SUSPEND) pm->pm_step == IDE_PM_START_SUSPEND)
/* Mark drive blocked when starting the suspend sequence. */ /* Mark drive blocked when starting the suspend sequence. */
drive->dev_flags |= IDE_DFLAG_BLOCKED; drive->dev_flags |= IDE_DFLAG_BLOCKED;
else if (rq->cmd_type == REQ_TYPE_ATA_PM_RESUME && else if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_PM_RESUME &&
pm->pm_step == IDE_PM_START_RESUME) { pm->pm_step == IDE_PM_START_RESUME) {
/* /*
* The first thing we do on wakeup is to wait for BSY bit to * The first thing we do on wakeup is to wait for BSY bit to
......
...@@ -577,8 +577,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -577,8 +577,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
req->cmd[0], (unsigned long long)blk_rq_pos(rq), req->cmd[0], (unsigned long long)blk_rq_pos(rq),
blk_rq_sectors(rq)); blk_rq_sectors(rq));
BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || BUG_ON(rq->cmd_type != REQ_TYPE_DRV_PRIV);
rq->cmd_type == REQ_TYPE_ATA_SENSE)); BUG_ON(ide_req(rq)->type != ATA_PRIV_MISC &&
ide_req(rq)->type != ATA_PRIV_SENSE);
/* Retry a failed packet command */ /* Retry a failed packet command */
if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) {
...@@ -856,6 +857,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) ...@@ -856,6 +857,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_DRV_PRIV; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_MISC;
scsi_req(rq)->cmd[13] = cmd; scsi_req(rq)->cmd[13] = cmd;
rq->rq_disk = tape->disk; rq->rq_disk = tape->disk;
rq->__sector = tape->first_frame; rq->__sector = tape->first_frame;
......
...@@ -432,7 +432,8 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, ...@@ -432,7 +432,8 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
rq = blk_get_request(drive->queue, rw, __GFP_RECLAIM); rq = blk_get_request(drive->queue, rw, __GFP_RECLAIM);
scsi_req_init(rq); scsi_req_init(rq);
rq->cmd_type = REQ_TYPE_ATA_TASKFILE; rq->cmd_type = REQ_TYPE_DRV_PRIV;
ide_req(rq)->type = ATA_PRIV_TASKFILE;
/* /*
* (ks) We transfer currently only whole sectors. * (ks) We transfer currently only whole sectors.
......
...@@ -40,24 +40,58 @@ ...@@ -40,24 +40,58 @@
struct device; struct device;
/* IDE-specific values for req->cmd_type */ /* values for ide_request.type */
enum ata_cmd_type_bits { enum ata_priv_type {
REQ_TYPE_ATA_TASKFILE = REQ_TYPE_DRV_PRIV + 1, ATA_PRIV_MISC,
REQ_TYPE_ATA_PC, ATA_PRIV_TASKFILE,
REQ_TYPE_ATA_SENSE, /* sense request */ ATA_PRIV_PC,
REQ_TYPE_ATA_PM_SUSPEND,/* suspend request */ ATA_PRIV_SENSE, /* sense request */
REQ_TYPE_ATA_PM_RESUME, /* resume request */ ATA_PRIV_PM_SUSPEND, /* suspend request */
ATA_PRIV_PM_RESUME, /* resume request */
}; };
#define ata_pm_request(rq) \
((rq)->cmd_type == REQ_TYPE_ATA_PM_SUSPEND || \
(rq)->cmd_type == REQ_TYPE_ATA_PM_RESUME)
struct ide_request { struct ide_request {
struct scsi_request sreq; struct scsi_request sreq;
u8 sense[SCSI_SENSE_BUFFERSIZE]; u8 sense[SCSI_SENSE_BUFFERSIZE];
u8 type;
}; };
static inline struct ide_request *ide_req(struct request *rq)
{
return blk_mq_rq_to_pdu(rq);
}
static inline bool ata_misc_request(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_MISC;
}
static inline bool ata_taskfile_request(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_TASKFILE;
}
static inline bool ata_pc_request(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_PC;
}
static inline bool ata_sense_request(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
ide_req(rq)->type == ATA_PRIV_SENSE;
}
static inline bool ata_pm_request(struct request *rq)
{
return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
(ide_req(rq)->type == ATA_PRIV_PM_SUSPEND ||
ide_req(rq)->type == ATA_PRIV_PM_RESUME);
}
/* Error codes returned in rq->errors to the higher part of the driver. */ /* Error codes returned in rq->errors to the higher part of the driver. */
enum { enum {
IDE_DRV_ERROR_GENERAL = 101, IDE_DRV_ERROR_GENERAL = 101,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册