aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:38 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:38 -0400
commit0d346ba0730d84f04022f9f984d3f606f69cef37 (patch)
tree0e68c29e5cbea6766cded4feb9274d87698f8b72
parentd1d76714e2f0c520b6c2a84ab5b050d0b3244949 (diff)
ide: sanitize ide*_pm_* enums
* Move ide*_pm_* enums from ide-io.c to <linux/ide.h>. * idedisk_pm_* -> ide_pm_* * ide_pm_state_* -> ide_pm_* * No need to set ide_pm_* enums to the fixed values. * Uppercase ide_pm_* enums. * Fix/update comments. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-io.c62
-rw-r--r--drivers/ide/ide.c4
-rw-r--r--include/linux/ide.h34
3 files changed, 40 insertions, 60 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 623f6c246cf5..f8d8642903da 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -132,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
132} 132}
133EXPORT_SYMBOL(ide_end_request); 133EXPORT_SYMBOL(ide_end_request);
134 134
135/*
136 * Power Management state machine. This one is rather trivial for now,
137 * we should probably add more, like switching back to PIO on suspend
138 * to help some BIOSes, re-do the door locking on resume, etc...
139 */
140
141enum {
142 ide_pm_flush_cache = ide_pm_state_start_suspend,
143 idedisk_pm_standby,
144
145 idedisk_pm_restore_pio = ide_pm_state_start_resume,
146 idedisk_pm_idle,
147 ide_pm_restore_dma,
148};
149
150static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error) 135static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error)
151{ 136{
152 struct request_pm_state *pm = rq->data; 137 struct request_pm_state *pm = rq->data;
@@ -155,20 +140,20 @@ static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 s
155 return; 140 return;
156 141
157 switch (pm->pm_step) { 142 switch (pm->pm_step) {
158 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) complete */ 143 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
159 if (pm->pm_state == PM_EVENT_FREEZE) 144 if (pm->pm_state == PM_EVENT_FREEZE)
160 pm->pm_step = ide_pm_state_completed; 145 pm->pm_step = IDE_PM_COMPLETED;
161 else 146 else
162 pm->pm_step = idedisk_pm_standby; 147 pm->pm_step = IDE_PM_STANDBY;
163 break; 148 break;
164 case idedisk_pm_standby: /* Suspend step 2 (standby) complete */ 149 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
165 pm->pm_step = ide_pm_state_completed; 150 pm->pm_step = IDE_PM_COMPLETED;
166 break; 151 break;
167 case idedisk_pm_restore_pio: /* Resume step 1 complete */ 152 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
168 pm->pm_step = idedisk_pm_idle; 153 pm->pm_step = IDE_PM_IDLE;
169 break; 154 break;
170 case idedisk_pm_idle: /* Resume step 2 (idle) complete */ 155 case IDE_PM_IDLE: /* Resume step 2 (idle)*/
171 pm->pm_step = ide_pm_restore_dma; 156 pm->pm_step = IDE_PM_RESTORE_DMA;
172 break; 157 break;
173 } 158 }
174} 159}
@@ -181,7 +166,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
181 memset(args, 0, sizeof(*args)); 166 memset(args, 0, sizeof(*args));
182 167
183 switch (pm->pm_step) { 168 switch (pm->pm_step) {
184 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) */ 169 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
185 if (drive->media != ide_disk) 170 if (drive->media != ide_disk)
186 break; 171 break;
187 /* Not supported? Switch to next step now. */ 172 /* Not supported? Switch to next step now. */
@@ -195,27 +180,23 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
195 else 180 else
196 args->tf.command = ATA_CMD_FLUSH; 181 args->tf.command = ATA_CMD_FLUSH;
197 goto out_do_tf; 182 goto out_do_tf;
198 183 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
199 case idedisk_pm_standby: /* Suspend step 2 (standby) */
200 args->tf.command = ATA_CMD_STANDBYNOW1; 184 args->tf.command = ATA_CMD_STANDBYNOW1;
201 goto out_do_tf; 185 goto out_do_tf;
202 186 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
203 case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */
204 ide_set_max_pio(drive); 187 ide_set_max_pio(drive);
205 /* 188 /*
206 * skip idedisk_pm_idle for ATAPI devices 189 * skip IDE_PM_IDLE for ATAPI devices
207 */ 190 */
208 if (drive->media != ide_disk) 191 if (drive->media != ide_disk)
209 pm->pm_step = ide_pm_restore_dma; 192 pm->pm_step = IDE_PM_RESTORE_DMA;
210 else 193 else
211 ide_complete_power_step(drive, rq, 0, 0); 194 ide_complete_power_step(drive, rq, 0, 0);
212 return ide_stopped; 195 return ide_stopped;
213 196 case IDE_PM_IDLE: /* Resume step 2 (idle) */
214 case idedisk_pm_idle: /* Resume step 2 (idle) */
215 args->tf.command = ATA_CMD_IDLEIMMEDIATE; 197 args->tf.command = ATA_CMD_IDLEIMMEDIATE;
216 goto out_do_tf; 198 goto out_do_tf;
217 199 case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
218 case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */
219 /* 200 /*
220 * Right now, all we do is call ide_set_dma(drive), 201 * Right now, all we do is call ide_set_dma(drive),
221 * we could be smarter and check for current xfer_speed 202 * we could be smarter and check for current xfer_speed
@@ -229,7 +210,8 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
229 ide_set_dma(drive); 210 ide_set_dma(drive);
230 break; 211 break;
231 } 212 }
232 pm->pm_step = ide_pm_state_completed; 213
214 pm->pm_step = IDE_PM_COMPLETED;
233 return ide_stopped; 215 return ide_stopped;
234 216
235out_do_tf: 217out_do_tf:
@@ -345,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
345 drive->name, rq->pm->pm_step, stat, err); 327 drive->name, rq->pm->pm_step, stat, err);
346#endif 328#endif
347 ide_complete_power_step(drive, rq, stat, err); 329 ide_complete_power_step(drive, rq, stat, err);
348 if (pm->pm_step == ide_pm_state_completed) 330 if (pm->pm_step == IDE_PM_COMPLETED)
349 ide_complete_pm_request(drive, rq); 331 ide_complete_pm_request(drive, rq);
350 return; 332 return;
351 } 333 }
@@ -778,11 +760,11 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
778 struct request_pm_state *pm = rq->data; 760 struct request_pm_state *pm = rq->data;
779 761
780 if (blk_pm_suspend_request(rq) && 762 if (blk_pm_suspend_request(rq) &&
781 pm->pm_step == ide_pm_state_start_suspend) 763 pm->pm_step == IDE_PM_START_SUSPEND)
782 /* Mark drive blocked when starting the suspend sequence. */ 764 /* Mark drive blocked when starting the suspend sequence. */
783 drive->dev_flags |= IDE_DFLAG_BLOCKED; 765 drive->dev_flags |= IDE_DFLAG_BLOCKED;
784 else if (blk_pm_resume_request(rq) && 766 else if (blk_pm_resume_request(rq) &&
785 pm->pm_step == ide_pm_state_start_resume) { 767 pm->pm_step == IDE_PM_START_RESUME) {
786 /* 768 /*
787 * The first thing we do on wakeup is to wait for BSY bit to 769 * The first thing we do on wakeup is to wait for BSY bit to
788 * go away (with a looong timeout) as a drive on this hwif may 770 * go away (with a looong timeout) as a drive on this hwif may
@@ -862,7 +844,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
862#endif 844#endif
863 startstop = ide_start_power_step(drive, rq); 845 startstop = ide_start_power_step(drive, rq);
864 if (startstop == ide_stopped && 846 if (startstop == ide_stopped &&
865 pm->pm_step == ide_pm_state_completed) 847 pm->pm_step == IDE_PM_COMPLETED)
866 ide_complete_pm_request(drive, rq); 848 ide_complete_pm_request(drive, rq);
867 return startstop; 849 return startstop;
868 } else if (!rq->rq_disk && blk_special_request(rq)) 850 } else if (!rq->rq_disk && blk_special_request(rq))
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 78776bbb537e..40b5a4614340 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -388,7 +388,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
388 rq->cmd_type = REQ_TYPE_PM_SUSPEND; 388 rq->cmd_type = REQ_TYPE_PM_SUSPEND;
389 rq->special = &args; 389 rq->special = &args;
390 rq->data = &rqpm; 390 rq->data = &rqpm;
391 rqpm.pm_step = ide_pm_state_start_suspend; 391 rqpm.pm_step = IDE_PM_START_SUSPEND;
392 if (mesg.event == PM_EVENT_PRETHAW) 392 if (mesg.event == PM_EVENT_PRETHAW)
393 mesg.event = PM_EVENT_FREEZE; 393 mesg.event = PM_EVENT_FREEZE;
394 rqpm.pm_state = mesg.event; 394 rqpm.pm_state = mesg.event;
@@ -427,7 +427,7 @@ static int generic_ide_resume(struct device *dev)
427 rq->cmd_flags |= REQ_PREEMPT; 427 rq->cmd_flags |= REQ_PREEMPT;
428 rq->special = &args; 428 rq->special = &args;
429 rq->data = &rqpm; 429 rq->data = &rqpm;
430 rqpm.pm_step = ide_pm_state_start_resume; 430 rqpm.pm_step = IDE_PM_START_RESUME;
431 rqpm.pm_state = PM_EVENT_ON; 431 rqpm.pm_state = PM_EVENT_ON;
432 432
433 err = blk_execute_rq(drive->queue, NULL, rq, 1); 433 err = blk_execute_rq(drive->queue, NULL, rq, 1);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index cf7ec3a9d173..02984f1f041a 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -988,36 +988,34 @@ enum {
988} 988}
989 989
990/* 990/*
991 * Power Management step value (rq->pm->pm_step). 991 * Power Management state machine (rq->pm->pm_step).
992 * 992 *
993 * The step value starts at 0 (ide_pm_state_start_suspend) for a 993 * For each step, the core calls ide_start_power_step() first.
994 * suspend operation or 1000 (ide_pm_state_start_resume) for a
995 * resume operation.
996 *
997 * For each step, the core calls the subdriver start_power_step() first.
998 * This can return: 994 * This can return:
999 * - ide_stopped : In this case, the core calls us back again unless 995 * - ide_stopped : In this case, the core calls us back again unless
1000 * step have been set to ide_power_state_completed. 996 * step have been set to ide_power_state_completed.
1001 * - ide_started : In this case, the channel is left busy until an 997 * - ide_started : In this case, the channel is left busy until an
1002 * async event (interrupt) occurs. 998 * async event (interrupt) occurs.
1003 * Typically, start_power_step() will issue a taskfile request with 999 * Typically, ide_start_power_step() will issue a taskfile request with
1004 * do_rw_taskfile(). 1000 * do_rw_taskfile().
1005 * 1001 *
1006 * Upon reception of the interrupt, the core will call complete_power_step() 1002 * Upon reception of the interrupt, the core will call ide_complete_power_step()
1007 * with the error code if any. This routine should update the step value 1003 * with the error code if any. This routine should update the step value
1008 * and return. It should not start a new request. The core will call 1004 * and return. It should not start a new request. The core will call
1009 * start_power_step for the new step value, unless step have been set to 1005 * ide_start_power_step() for the new step value, unless step have been
1010 * ide_power_state_completed. 1006 * set to IDE_PM_COMPLETED.
1011 *
1012 * Subdrivers are expected to define their own additional power
1013 * steps from 1..999 for suspend and from 1001..1999 for resume,
1014 * other values are reserved for future use.
1015 */ 1007 */
1016
1017enum { 1008enum {
1018 ide_pm_state_completed = -1, 1009 IDE_PM_START_SUSPEND,
1019 ide_pm_state_start_suspend = 0, 1010 IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND,
1020 ide_pm_state_start_resume = 1000, 1011 IDE_PM_STANDBY,
1012
1013 IDE_PM_START_RESUME,
1014 IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME,
1015 IDE_PM_IDLE,
1016 IDE_PM_RESTORE_DMA,
1017
1018 IDE_PM_COMPLETED,
1021}; 1019};
1022 1020
1023/* 1021/*