Commit 765139ef authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

ide-pm: don't abuse rq->data

Impact: cleanup rq->data usage

ide-pm uses rq->data to carry pointer to struct request_pm_state
through request queue and rq->special is used to carray pointer to
local struct ide_cmd, which isn't necessary.  Use rq->special for
request_pm_state instead and use local ide_cmd in
ide_start_power_step().
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
parent 02e7cf8f
...@@ -368,7 +368,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ...@@ -368,7 +368,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
return execute_drive_cmd(drive, rq); return execute_drive_cmd(drive, rq);
else if (blk_pm_request(rq)) { else if (blk_pm_request(rq)) {
struct request_pm_state *pm = rq->data; struct request_pm_state *pm = rq->special;
#ifdef DEBUG_PM #ifdef DEBUG_PM
printk("%s: start_power_step(step: %d)\n", printk("%s: start_power_step(step: %d)\n",
drive->name, pm->pm_step); drive->name, pm->pm_step);
......
...@@ -7,7 +7,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -7,7 +7,6 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct request *rq; struct request *rq;
struct request_pm_state rqpm; struct request_pm_state rqpm;
struct ide_cmd cmd;
int ret; int ret;
/* call ACPI _GTM only once */ /* call ACPI _GTM only once */
...@@ -15,11 +14,9 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -15,11 +14,9 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
ide_acpi_get_timing(hwif); ide_acpi_get_timing(hwif);
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
memset(&cmd, 0, sizeof(cmd));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_PM_SUSPEND; rq->cmd_type = REQ_TYPE_PM_SUSPEND;
rq->special = &cmd; rq->special = &rqpm;
rq->data = &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)
mesg.event = PM_EVENT_FREEZE; mesg.event = PM_EVENT_FREEZE;
...@@ -41,7 +38,6 @@ int generic_ide_resume(struct device *dev) ...@@ -41,7 +38,6 @@ int generic_ide_resume(struct device *dev)
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
struct request *rq; struct request *rq;
struct request_pm_state rqpm; struct request_pm_state rqpm;
struct ide_cmd cmd;
int err; int err;
/* call ACPI _PS0 / _STM only once */ /* call ACPI _PS0 / _STM only once */
...@@ -53,12 +49,10 @@ int generic_ide_resume(struct device *dev) ...@@ -53,12 +49,10 @@ int generic_ide_resume(struct device *dev)
ide_acpi_exec_tfs(drive); ide_acpi_exec_tfs(drive);
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
memset(&cmd, 0, sizeof(cmd));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
rq->cmd_type = REQ_TYPE_PM_RESUME; rq->cmd_type = REQ_TYPE_PM_RESUME;
rq->cmd_flags |= REQ_PREEMPT; rq->cmd_flags |= REQ_PREEMPT;
rq->special = &cmd; rq->special = &rqpm;
rq->data = &rqpm;
rqpm.pm_step = IDE_PM_START_RESUME; rqpm.pm_step = IDE_PM_START_RESUME;
rqpm.pm_state = PM_EVENT_ON; rqpm.pm_state = PM_EVENT_ON;
...@@ -77,7 +71,7 @@ int generic_ide_resume(struct device *dev) ...@@ -77,7 +71,7 @@ int generic_ide_resume(struct device *dev)
void ide_complete_power_step(ide_drive_t *drive, struct request *rq) void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
{ {
struct request_pm_state *pm = rq->data; struct request_pm_state *pm = rq->special;
#ifdef DEBUG_PM #ifdef DEBUG_PM
printk(KERN_INFO "%s: complete_power_step(step: %d)\n", printk(KERN_INFO "%s: complete_power_step(step: %d)\n",
...@@ -107,10 +101,8 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq) ...@@ -107,10 +101,8 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
{ {
struct request_pm_state *pm = rq->data; struct request_pm_state *pm = rq->special;
struct ide_cmd *cmd = rq->special; struct ide_cmd cmd = { };
memset(cmd, 0, sizeof(*cmd));
switch (pm->pm_step) { switch (pm->pm_step) {
case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
...@@ -123,12 +115,12 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) ...@@ -123,12 +115,12 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
return ide_stopped; return ide_stopped;
} }
if (ata_id_flush_ext_enabled(drive->id)) if (ata_id_flush_ext_enabled(drive->id))
cmd->tf.command = ATA_CMD_FLUSH_EXT; cmd.tf.command = ATA_CMD_FLUSH_EXT;
else else
cmd->tf.command = ATA_CMD_FLUSH; cmd.tf.command = ATA_CMD_FLUSH;
goto out_do_tf; goto out_do_tf;
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
cmd->tf.command = ATA_CMD_STANDBYNOW1; cmd.tf.command = ATA_CMD_STANDBYNOW1;
goto out_do_tf; goto out_do_tf;
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
ide_set_max_pio(drive); ide_set_max_pio(drive);
...@@ -141,7 +133,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) ...@@ -141,7 +133,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
ide_complete_power_step(drive, rq); ide_complete_power_step(drive, rq);
return ide_stopped; return ide_stopped;
case IDE_PM_IDLE: /* Resume step 2 (idle) */ case IDE_PM_IDLE: /* Resume step 2 (idle) */
cmd->tf.command = ATA_CMD_IDLEIMMEDIATE; cmd.tf.command = ATA_CMD_IDLEIMMEDIATE;
goto out_do_tf; goto out_do_tf;
case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
/* /*
...@@ -163,11 +155,11 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) ...@@ -163,11 +155,11 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
return ide_stopped; return ide_stopped;
out_do_tf: out_do_tf:
cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
cmd->valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
cmd->protocol = ATA_PROT_NODATA; cmd.protocol = ATA_PROT_NODATA;
return do_rw_taskfile(drive, cmd); return do_rw_taskfile(drive, &cmd);
} }
/** /**
...@@ -181,7 +173,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) ...@@ -181,7 +173,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
{ {
struct request_queue *q = drive->queue; struct request_queue *q = drive->queue;
struct request_pm_state *pm = rq->data; struct request_pm_state *pm = rq->special;
unsigned long flags; unsigned long flags;
ide_complete_power_step(drive, rq); ide_complete_power_step(drive, rq);
...@@ -207,7 +199,7 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) ...@@ -207,7 +199,7 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
void ide_check_pm_state(ide_drive_t *drive, struct request *rq) void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
{ {
struct request_pm_state *pm = rq->data; struct request_pm_state *pm = rq->special;
if (blk_pm_suspend_request(rq) && if (blk_pm_suspend_request(rq) &&
pm->pm_step == IDE_PM_START_SUSPEND) pm->pm_step == IDE_PM_START_SUSPEND)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment