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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent d1d76714
...@@ -132,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) ...@@ -132,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
} }
EXPORT_SYMBOL(ide_end_request); EXPORT_SYMBOL(ide_end_request);
/*
* Power Management state machine. This one is rather trivial for now,
* we should probably add more, like switching back to PIO on suspend
* to help some BIOSes, re-do the door locking on resume, etc...
*/
enum {
ide_pm_flush_cache = ide_pm_state_start_suspend,
idedisk_pm_standby,
idedisk_pm_restore_pio = ide_pm_state_start_resume,
idedisk_pm_idle,
ide_pm_restore_dma,
};
static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error) static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error)
{ {
struct request_pm_state *pm = rq->data; 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,20 +140,20 @@ static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 s
return; return;
switch (pm->pm_step) { switch (pm->pm_step) {
case ide_pm_flush_cache: /* Suspend step 1 (flush cache) complete */ case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
if (pm->pm_state == PM_EVENT_FREEZE) if (pm->pm_state == PM_EVENT_FREEZE)
pm->pm_step = ide_pm_state_completed; pm->pm_step = IDE_PM_COMPLETED;
else else
pm->pm_step = idedisk_pm_standby; pm->pm_step = IDE_PM_STANDBY;
break; break;
case idedisk_pm_standby: /* Suspend step 2 (standby) complete */ case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
pm->pm_step = ide_pm_state_completed; pm->pm_step = IDE_PM_COMPLETED;
break; break;
case idedisk_pm_restore_pio: /* Resume step 1 complete */ case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
pm->pm_step = idedisk_pm_idle; pm->pm_step = IDE_PM_IDLE;
break; break;
case idedisk_pm_idle: /* Resume step 2 (idle) complete */ case IDE_PM_IDLE: /* Resume step 2 (idle)*/
pm->pm_step = ide_pm_restore_dma; pm->pm_step = IDE_PM_RESTORE_DMA;
break; break;
} }
} }
...@@ -181,7 +166,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * ...@@ -181,7 +166,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof(*args));
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) */
if (drive->media != ide_disk) if (drive->media != ide_disk)
break; break;
/* Not supported? Switch to next step now. */ /* 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,27 +180,23 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
else else
args->tf.command = ATA_CMD_FLUSH; args->tf.command = ATA_CMD_FLUSH;
goto out_do_tf; goto out_do_tf;
case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
case idedisk_pm_standby: /* Suspend step 2 (standby) */
args->tf.command = ATA_CMD_STANDBYNOW1; args->tf.command = ATA_CMD_STANDBYNOW1;
goto out_do_tf; goto out_do_tf;
case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */
ide_set_max_pio(drive); ide_set_max_pio(drive);
/* /*
* skip idedisk_pm_idle for ATAPI devices * skip IDE_PM_IDLE for ATAPI devices
*/ */
if (drive->media != ide_disk) if (drive->media != ide_disk)
pm->pm_step = ide_pm_restore_dma; pm->pm_step = IDE_PM_RESTORE_DMA;
else else
ide_complete_power_step(drive, rq, 0, 0); ide_complete_power_step(drive, rq, 0, 0);
return ide_stopped; return ide_stopped;
case IDE_PM_IDLE: /* Resume step 2 (idle) */
case idedisk_pm_idle: /* Resume step 2 (idle) */
args->tf.command = ATA_CMD_IDLEIMMEDIATE; args->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) */
/* /*
* Right now, all we do is call ide_set_dma(drive), * Right now, all we do is call ide_set_dma(drive),
* we could be smarter and check for current xfer_speed * 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,7 +210,8 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
ide_set_dma(drive); ide_set_dma(drive);
break; break;
} }
pm->pm_step = ide_pm_state_completed;
pm->pm_step = IDE_PM_COMPLETED;
return ide_stopped; return ide_stopped;
out_do_tf: out_do_tf:
...@@ -345,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) ...@@ -345,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
drive->name, rq->pm->pm_step, stat, err); drive->name, rq->pm->pm_step, stat, err);
#endif #endif
ide_complete_power_step(drive, rq, stat, err); ide_complete_power_step(drive, rq, stat, err);
if (pm->pm_step == ide_pm_state_completed) if (pm->pm_step == IDE_PM_COMPLETED)
ide_complete_pm_request(drive, rq); ide_complete_pm_request(drive, rq);
return; return;
} }
...@@ -778,11 +760,11 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) ...@@ -778,11 +760,11 @@ static 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->data;
if (blk_pm_suspend_request(rq) && if (blk_pm_suspend_request(rq) &&
pm->pm_step == ide_pm_state_start_suspend) pm->pm_step == IDE_PM_START_SUSPEND)
/* Mark drive blocked when starting the suspend sequence. */ /* Mark drive blocked when starting the suspend sequence. */
drive->dev_flags |= IDE_DFLAG_BLOCKED; drive->dev_flags |= IDE_DFLAG_BLOCKED;
else if (blk_pm_resume_request(rq) && else if (blk_pm_resume_request(rq) &&
pm->pm_step == ide_pm_state_start_resume) { pm->pm_step == IDE_PM_START_RESUME) {
/* /*
* The first thing we do on wakeup is to wait for BSY bit to * The first thing we do on wakeup is to wait for BSY bit to
* go away (with a looong timeout) as a drive on this hwif may * 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,7 +844,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
#endif #endif
startstop = ide_start_power_step(drive, rq); startstop = ide_start_power_step(drive, rq);
if (startstop == ide_stopped && if (startstop == ide_stopped &&
pm->pm_step == ide_pm_state_completed) pm->pm_step == IDE_PM_COMPLETED)
ide_complete_pm_request(drive, rq); ide_complete_pm_request(drive, rq);
return startstop; return startstop;
} else if (!rq->rq_disk && blk_special_request(rq)) } else if (!rq->rq_disk && blk_special_request(rq))
......
...@@ -388,7 +388,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -388,7 +388,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
rq->cmd_type = REQ_TYPE_PM_SUSPEND; rq->cmd_type = REQ_TYPE_PM_SUSPEND;
rq->special = &args; rq->special = &args;
rq->data = &rqpm; rq->data = &rqpm;
rqpm.pm_step = ide_pm_state_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;
rqpm.pm_state = mesg.event; rqpm.pm_state = mesg.event;
...@@ -427,7 +427,7 @@ static int generic_ide_resume(struct device *dev) ...@@ -427,7 +427,7 @@ static int generic_ide_resume(struct device *dev)
rq->cmd_flags |= REQ_PREEMPT; rq->cmd_flags |= REQ_PREEMPT;
rq->special = &args; rq->special = &args;
rq->data = &rqpm; rq->data = &rqpm;
rqpm.pm_step = ide_pm_state_start_resume; rqpm.pm_step = IDE_PM_START_RESUME;
rqpm.pm_state = PM_EVENT_ON; rqpm.pm_state = PM_EVENT_ON;
err = blk_execute_rq(drive->queue, NULL, rq, 1); err = blk_execute_rq(drive->queue, NULL, rq, 1);
......
...@@ -988,36 +988,34 @@ enum { ...@@ -988,36 +988,34 @@ enum {
} }
/* /*
* Power Management step value (rq->pm->pm_step). * Power Management state machine (rq->pm->pm_step).
* *
* The step value starts at 0 (ide_pm_state_start_suspend) for a * For each step, the core calls ide_start_power_step() first.
* suspend operation or 1000 (ide_pm_state_start_resume) for a
* resume operation.
*
* For each step, the core calls the subdriver start_power_step() first.
* This can return: * This can return:
* - ide_stopped : In this case, the core calls us back again unless * - ide_stopped : In this case, the core calls us back again unless
* step have been set to ide_power_state_completed. * step have been set to ide_power_state_completed.
* - ide_started : In this case, the channel is left busy until an * - ide_started : In this case, the channel is left busy until an
* async event (interrupt) occurs. * async event (interrupt) occurs.
* Typically, start_power_step() will issue a taskfile request with * Typically, ide_start_power_step() will issue a taskfile request with
* do_rw_taskfile(). * do_rw_taskfile().
* *
* Upon reception of the interrupt, the core will call complete_power_step() * Upon reception of the interrupt, the core will call ide_complete_power_step()
* with the error code if any. This routine should update the step value * with the error code if any. This routine should update the step value
* and return. It should not start a new request. The core will call * and return. It should not start a new request. The core will call
* start_power_step for the new step value, unless step have been set to * ide_start_power_step() for the new step value, unless step have been
* ide_power_state_completed. * set to IDE_PM_COMPLETED.
*
* Subdrivers are expected to define their own additional power
* steps from 1..999 for suspend and from 1001..1999 for resume,
* other values are reserved for future use.
*/ */
enum { enum {
ide_pm_state_completed = -1, IDE_PM_START_SUSPEND,
ide_pm_state_start_suspend = 0, IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND,
ide_pm_state_start_resume = 1000, IDE_PM_STANDBY,
IDE_PM_START_RESUME,
IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME,
IDE_PM_IDLE,
IDE_PM_RESTORE_DMA,
IDE_PM_COMPLETED,
}; };
/* /*
......
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