aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-pm.c')
-rw-r--r--drivers/ide/ide-pm.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 60538d9c84ee..ebf2d21ebdcb 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -1,6 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h>
4 3
5int generic_ide_suspend(struct device *dev, pm_message_t mesg) 4int generic_ide_suspend(struct device *dev, pm_message_t mesg)
6{ 5{
@@ -8,7 +7,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
8 ide_hwif_t *hwif = drive->hwif; 7 ide_hwif_t *hwif = drive->hwif;
9 struct request *rq; 8 struct request *rq;
10 struct request_pm_state rqpm; 9 struct request_pm_state rqpm;
11 ide_task_t args; 10 struct ide_cmd cmd;
12 int ret; 11 int ret;
13 12
14 /* call ACPI _GTM only once */ 13 /* call ACPI _GTM only once */
@@ -16,10 +15,10 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
16 ide_acpi_get_timing(hwif); 15 ide_acpi_get_timing(hwif);
17 16
18 memset(&rqpm, 0, sizeof(rqpm)); 17 memset(&rqpm, 0, sizeof(rqpm));
19 memset(&args, 0, sizeof(args)); 18 memset(&cmd, 0, sizeof(cmd));
20 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 19 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
21 rq->cmd_type = REQ_TYPE_PM_SUSPEND; 20 rq->cmd_type = REQ_TYPE_PM_SUSPEND;
22 rq->special = &args; 21 rq->special = &cmd;
23 rq->data = &rqpm; 22 rq->data = &rqpm;
24 rqpm.pm_step = IDE_PM_START_SUSPEND; 23 rqpm.pm_step = IDE_PM_START_SUSPEND;
25 if (mesg.event == PM_EVENT_PRETHAW) 24 if (mesg.event == PM_EVENT_PRETHAW)
@@ -42,7 +41,7 @@ int generic_ide_resume(struct device *dev)
42 ide_hwif_t *hwif = drive->hwif; 41 ide_hwif_t *hwif = drive->hwif;
43 struct request *rq; 42 struct request *rq;
44 struct request_pm_state rqpm; 43 struct request_pm_state rqpm;
45 ide_task_t args; 44 struct ide_cmd cmd;
46 int err; 45 int err;
47 46
48 /* call ACPI _PS0 / _STM only once */ 47 /* call ACPI _PS0 / _STM only once */
@@ -54,11 +53,11 @@ int generic_ide_resume(struct device *dev)
54 ide_acpi_exec_tfs(drive); 53 ide_acpi_exec_tfs(drive);
55 54
56 memset(&rqpm, 0, sizeof(rqpm)); 55 memset(&rqpm, 0, sizeof(rqpm));
57 memset(&args, 0, sizeof(args)); 56 memset(&cmd, 0, sizeof(cmd));
58 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 57 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
59 rq->cmd_type = REQ_TYPE_PM_RESUME; 58 rq->cmd_type = REQ_TYPE_PM_RESUME;
60 rq->cmd_flags |= REQ_PREEMPT; 59 rq->cmd_flags |= REQ_PREEMPT;
61 rq->special = &args; 60 rq->special = &cmd;
62 rq->data = &rqpm; 61 rq->data = &rqpm;
63 rqpm.pm_step = IDE_PM_START_RESUME; 62 rqpm.pm_step = IDE_PM_START_RESUME;
64 rqpm.pm_state = PM_EVENT_ON; 63 rqpm.pm_state = PM_EVENT_ON;
@@ -109,9 +108,9 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
109ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) 108ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
110{ 109{
111 struct request_pm_state *pm = rq->data; 110 struct request_pm_state *pm = rq->data;
112 ide_task_t *args = rq->special; 111 struct ide_cmd *cmd = rq->special;
113 112
114 memset(args, 0, sizeof(*args)); 113 memset(cmd, 0, sizeof(*cmd));
115 114
116 switch (pm->pm_step) { 115 switch (pm->pm_step) {
117 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ 116 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
@@ -124,12 +123,12 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
124 return ide_stopped; 123 return ide_stopped;
125 } 124 }
126 if (ata_id_flush_ext_enabled(drive->id)) 125 if (ata_id_flush_ext_enabled(drive->id))
127 args->tf.command = ATA_CMD_FLUSH_EXT; 126 cmd->tf.command = ATA_CMD_FLUSH_EXT;
128 else 127 else
129 args->tf.command = ATA_CMD_FLUSH; 128 cmd->tf.command = ATA_CMD_FLUSH;
130 goto out_do_tf; 129 goto out_do_tf;
131 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ 130 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
132 args->tf.command = ATA_CMD_STANDBYNOW1; 131 cmd->tf.command = ATA_CMD_STANDBYNOW1;
133 goto out_do_tf; 132 goto out_do_tf;
134 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ 133 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
135 ide_set_max_pio(drive); 134 ide_set_max_pio(drive);
@@ -142,7 +141,7 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
142 ide_complete_power_step(drive, rq); 141 ide_complete_power_step(drive, rq);
143 return ide_stopped; 142 return ide_stopped;
144 case IDE_PM_IDLE: /* Resume step 2 (idle) */ 143 case IDE_PM_IDLE: /* Resume step 2 (idle) */
145 args->tf.command = ATA_CMD_IDLEIMMEDIATE; 144 cmd->tf.command = ATA_CMD_IDLEIMMEDIATE;
146 goto out_do_tf; 145 goto out_do_tf;
147 case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ 146 case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
148 /* 147 /*
@@ -160,27 +159,34 @@ ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
160 } 159 }
161 160
162 pm->pm_step = IDE_PM_COMPLETED; 161 pm->pm_step = IDE_PM_COMPLETED;
162
163 return ide_stopped; 163 return ide_stopped;
164 164
165out_do_tf: 165out_do_tf:
166 args->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 166 cmd->tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
167 args->data_phase = TASKFILE_NO_DATA; 167 cmd->protocol = ATA_PROT_NODATA;
168 return do_rw_taskfile(drive, args); 168
169 return do_rw_taskfile(drive, cmd);
169} 170}
170 171
171/** 172/**
172 * ide_complete_pm_request - end the current Power Management request 173 * ide_complete_pm_rq - end the current Power Management request
173 * @drive: target drive 174 * @drive: target drive
174 * @rq: request 175 * @rq: request
175 * 176 *
176 * This function cleans up the current PM request and stops the queue 177 * This function cleans up the current PM request and stops the queue
177 * if necessary. 178 * if necessary.
178 */ 179 */
179void ide_complete_pm_request(ide_drive_t *drive, struct request *rq) 180void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
180{ 181{
181 struct request_queue *q = drive->queue; 182 struct request_queue *q = drive->queue;
183 struct request_pm_state *pm = rq->data;
182 unsigned long flags; 184 unsigned long flags;
183 185
186 ide_complete_power_step(drive, rq);
187 if (pm->pm_step != IDE_PM_COMPLETED)
188 return;
189
184#ifdef DEBUG_PM 190#ifdef DEBUG_PM
185 printk("%s: completing PM request, %s\n", drive->name, 191 printk("%s: completing PM request, %s\n", drive->name,
186 blk_pm_suspend_request(rq) ? "suspend" : "resume"); 192 blk_pm_suspend_request(rq) ? "suspend" : "resume");