Skip to content

Commit fc38b52

Browse files
committed
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: Tejun Heo <tj@kernel.org> Cc: Jens Axboe <axboe@kernel.dk>
1 parent 5c4be57 commit fc38b52

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

‎drivers/ide/ide-io.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
368368
if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
369369
return execute_drive_cmd(drive, rq);
370370
else if (blk_pm_request(rq)) {
371-
struct request_pm_state *pm = rq->data;
371+
struct request_pm_state *pm = rq->special;
372372
#ifdef DEBUG_PM
373373
printk("%s: start_power_step(step: %d)\n",
374374
drive->name, pm->pm_step);

‎drivers/ide/ide-pm.c‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
77
ide_hwif_t *hwif = drive->hwif;
88
struct request *rq;
99
struct request_pm_state rqpm;
10-
struct ide_cmd cmd;
1110
int ret;
1211

1312
/* call ACPI _GTM only once */
1413
if ((drive->dn & 1) == 0 || pair == NULL)
1514
ide_acpi_get_timing(hwif);
1615

1716
memset(&rqpm, 0, sizeof(rqpm));
18-
memset(&cmd, 0, sizeof(cmd));
1917
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
2018
rq->cmd_type = REQ_TYPE_PM_SUSPEND;
21-
rq->special = &cmd;
22-
rq->data = &rqpm;
19+
rq->special = &rqpm;
2320
rqpm.pm_step = IDE_PM_START_SUSPEND;
2421
if (mesg.event == PM_EVENT_PRETHAW)
2522
mesg.event = PM_EVENT_FREEZE;
@@ -41,7 +38,6 @@ int generic_ide_resume(struct device *dev)
4138
ide_hwif_t *hwif = drive->hwif;
4239
struct request *rq;
4340
struct request_pm_state rqpm;
44-
struct ide_cmd cmd;
4541
int err;
4642

4743
/* call ACPI _PS0 / _STM only once */
@@ -53,12 +49,10 @@ int generic_ide_resume(struct device *dev)
5349
ide_acpi_exec_tfs(drive);
5450

5551
memset(&rqpm, 0, sizeof(rqpm));
56-
memset(&cmd, 0, sizeof(cmd));
5752
rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
5853
rq->cmd_type = REQ_TYPE_PM_RESUME;
5954
rq->cmd_flags |= REQ_PREEMPT;
60-
rq->special = &cmd;
61-
rq->data = &rqpm;
55+
rq->special = &rqpm;
6256
rqpm.pm_step = IDE_PM_START_RESUME;
6357
rqpm.pm_state = PM_EVENT_ON;
6458

@@ -77,7 +71,7 @@ int generic_ide_resume(struct device *dev)
7771

7872
void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
7973
{
80-
struct request_pm_state *pm = rq->data;
74+
struct request_pm_state *pm = rq->special;
8175

8276
#ifdef DEBUG_PM
8377
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)
107101

108102
ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
109103
{
110-
struct request_pm_state *pm = rq->data;
111-
struct ide_cmd *cmd = rq->special;
112-
113-
memset(cmd, 0, sizeof(*cmd));
104+
struct request_pm_state *pm = rq->special;
105+
struct ide_cmd cmd = { };
114106

115107
switch (pm->pm_step) {
116108
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)
123115
return ide_stopped;
124116
}
125117
if (ata_id_flush_ext_enabled(drive->id))
126-
cmd->tf.command = ATA_CMD_FLUSH_EXT;
118+
cmd.tf.command = ATA_CMD_FLUSH_EXT;
127119
else
128-
cmd->tf.command = ATA_CMD_FLUSH;
120+
cmd.tf.command = ATA_CMD_FLUSH;
129121
goto out_do_tf;
130122
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
131-
cmd->tf.command = ATA_CMD_STANDBYNOW1;
123+
cmd.tf.command = ATA_CMD_STANDBYNOW1;
132124
goto out_do_tf;
133125
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
134126
ide_set_max_pio(drive);
@@ -141,7 +133,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
141133
ide_complete_power_step(drive, rq);
142134
return ide_stopped;
143135
case IDE_PM_IDLE: /* Resume step 2 (idle) */
144-
cmd->tf.command = ATA_CMD_IDLEIMMEDIATE;
136+
cmd.tf.command = ATA_CMD_IDLEIMMEDIATE;
145137
goto out_do_tf;
146138
case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
147139
/*
@@ -163,11 +155,11 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
163155
return ide_stopped;
164156

165157
out_do_tf:
166-
cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
167-
cmd->valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
168-
cmd->protocol = ATA_PROT_NODATA;
158+
cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
159+
cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE;
160+
cmd.protocol = ATA_PROT_NODATA;
169161

170-
return do_rw_taskfile(drive, cmd);
162+
return do_rw_taskfile(drive, &cmd);
171163
}
172164

173165
/**
@@ -181,7 +173,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
181173
void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
182174
{
183175
struct request_queue *q = drive->queue;
184-
struct request_pm_state *pm = rq->data;
176+
struct request_pm_state *pm = rq->special;
185177
unsigned long flags;
186178

187179
ide_complete_power_step(drive, rq);
@@ -207,7 +199,7 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
207199

208200
void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
209201
{
210-
struct request_pm_state *pm = rq->data;
202+
struct request_pm_state *pm = rq->special;
211203

212204
if (blk_pm_suspend_request(rq) &&
213205
pm->pm_step == IDE_PM_START_SUSPEND)

0 commit comments

Comments
 (0)