Skip to content

Commit 0d346ba

Browse files
committed
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>
1 parent d1d7671 commit 0d346ba

3 files changed

Lines changed: 40 additions & 60 deletions

File tree

‎drivers/ide/ide-io.c‎

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
132132
}
133133
EXPORT_SYMBOL(ide_end_request);
134134

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-
141-
enum {
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-
150135
static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error)
151136
{
152137
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
155140
return;
156141

157142
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) */
159144
if (pm->pm_state == PM_EVENT_FREEZE)
160-
pm->pm_step = ide_pm_state_completed;
145+
pm->pm_step = IDE_PM_COMPLETED;
161146
else
162-
pm->pm_step = idedisk_pm_standby;
147+
pm->pm_step = IDE_PM_STANDBY;
163148
break;
164-
case idedisk_pm_standby: /* Suspend step 2 (standby) complete */
165-
pm->pm_step = ide_pm_state_completed;
149+
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
150+
pm->pm_step = IDE_PM_COMPLETED;
166151
break;
167-
case idedisk_pm_restore_pio: /* Resume step 1 complete */
168-
pm->pm_step = idedisk_pm_idle;
152+
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
153+
pm->pm_step = IDE_PM_IDLE;
169154
break;
170-
case idedisk_pm_idle: /* Resume step 2 (idle) complete */
171-
pm->pm_step = ide_pm_restore_dma;
155+
case IDE_PM_IDLE: /* Resume step 2 (idle)*/
156+
pm->pm_step = IDE_PM_RESTORE_DMA;
172157
break;
173158
}
174159
}
@@ -181,7 +166,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
181166
memset(args, 0, sizeof(*args));
182167

183168
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) */
185170
if (drive->media != ide_disk)
186171
break;
187172
/* 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 *
195180
else
196181
args->tf.command = ATA_CMD_FLUSH;
197182
goto out_do_tf;
198-
199-
case idedisk_pm_standby: /* Suspend step 2 (standby) */
183+
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
200184
args->tf.command = ATA_CMD_STANDBYNOW1;
201185
goto out_do_tf;
202-
203-
case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */
186+
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
204187
ide_set_max_pio(drive);
205188
/*
206-
* skip idedisk_pm_idle for ATAPI devices
189+
* skip IDE_PM_IDLE for ATAPI devices
207190
*/
208191
if (drive->media != ide_disk)
209-
pm->pm_step = ide_pm_restore_dma;
192+
pm->pm_step = IDE_PM_RESTORE_DMA;
210193
else
211194
ide_complete_power_step(drive, rq, 0, 0);
212195
return ide_stopped;
213-
214-
case idedisk_pm_idle: /* Resume step 2 (idle) */
196+
case IDE_PM_IDLE: /* Resume step 2 (idle) */
215197
args->tf.command = ATA_CMD_IDLEIMMEDIATE;
216198
goto out_do_tf;
217-
218-
case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */
199+
case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
219200
/*
220201
* Right now, all we do is call ide_set_dma(drive),
221202
* 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 *
229210
ide_set_dma(drive);
230211
break;
231212
}
232-
pm->pm_step = ide_pm_state_completed;
213+
214+
pm->pm_step = IDE_PM_COMPLETED;
233215
return ide_stopped;
234216

235217
out_do_tf:
@@ -345,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
345327
drive->name, rq->pm->pm_step, stat, err);
346328
#endif
347329
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)
349331
ide_complete_pm_request(drive, rq);
350332
return;
351333
}
@@ -778,11 +760,11 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
778760
struct request_pm_state *pm = rq->data;
779761

780762
if (blk_pm_suspend_request(rq) &&
781-
pm->pm_step == ide_pm_state_start_suspend)
763+
pm->pm_step == IDE_PM_START_SUSPEND)
782764
/* Mark drive blocked when starting the suspend sequence. */
783765
drive->dev_flags |= IDE_DFLAG_BLOCKED;
784766
else if (blk_pm_resume_request(rq) &&
785-
pm->pm_step == ide_pm_state_start_resume) {
767+
pm->pm_step == IDE_PM_START_RESUME) {
786768
/*
787769
* The first thing we do on wakeup is to wait for BSY bit to
788770
* 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)
862844
#endif
863845
startstop = ide_start_power_step(drive, rq);
864846
if (startstop == ide_stopped &&
865-
pm->pm_step == ide_pm_state_completed)
847+
pm->pm_step == IDE_PM_COMPLETED)
866848
ide_complete_pm_request(drive, rq);
867849
return startstop;
868850
} else if (!rq->rq_disk && blk_special_request(rq))

‎drivers/ide/ide.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
388388
rq->cmd_type = REQ_TYPE_PM_SUSPEND;
389389
rq->special = &args;
390390
rq->data = &rqpm;
391-
rqpm.pm_step = ide_pm_state_start_suspend;
391+
rqpm.pm_step = IDE_PM_START_SUSPEND;
392392
if (mesg.event == PM_EVENT_PRETHAW)
393393
mesg.event = PM_EVENT_FREEZE;
394394
rqpm.pm_state = mesg.event;
@@ -427,7 +427,7 @@ static int generic_ide_resume(struct device *dev)
427427
rq->cmd_flags |= REQ_PREEMPT;
428428
rq->special = &args;
429429
rq->data = &rqpm;
430-
rqpm.pm_step = ide_pm_state_start_resume;
430+
rqpm.pm_step = IDE_PM_START_RESUME;
431431
rqpm.pm_state = PM_EVENT_ON;
432432

433433
err = blk_execute_rq(drive->queue, NULL, rq, 1);

‎include/linux/ide.h‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -988,36 +988,34 @@ enum {
988988
}
989989

990990
/*
991-
* Power Management step value (rq->pm->pm_step).
991+
* Power Management state machine (rq->pm->pm_step).
992992
*
993-
* The step value starts at 0 (ide_pm_state_start_suspend) for a
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.
993+
* For each step, the core calls ide_start_power_step() first.
998994
* This can return:
999995
* - ide_stopped : In this case, the core calls us back again unless
1000996
* step have been set to ide_power_state_completed.
1001997
* - ide_started : In this case, the channel is left busy until an
1002998
* 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
10041000
* do_rw_taskfile().
10051001
*
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()
10071003
* with the error code if any. This routine should update the step value
10081004
* 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
1010-
* ide_power_state_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.
1005+
* ide_start_power_step() for the new step value, unless step have been
1006+
* set to IDE_PM_COMPLETED.
10151007
*/
1016-
10171008
enum {
1018-
ide_pm_state_completed = -1,
1019-
ide_pm_state_start_suspend = 0,
1020-
ide_pm_state_start_resume = 1000,
1009+
IDE_PM_START_SUSPEND,
1010+
IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND,
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,
10211019
};
10221020

10231021
/*

0 commit comments

Comments
 (0)