PM / sleep: Use valid_state() for platform-dependent sleep states only

Use the observation that, for platform-dependent sleep states
(PM_SUSPEND_STANDBY, PM_SUSPEND_MEM), a given state is either
always supported or always unsupported and store that information
in pm_states[] instead of calling valid_state() every time we
need to check it.

Also do not use valid_state() for PM_SUSPEND_FREEZE, which is always
valid, and move the pm_test_level validity check for PM_SUSPEND_FREEZE
directly into enter_state().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Rafael J. Wysocki 2014-05-26 13:40:53 +02:00
parent 27ddcc6596
commit 43e8317b0b
4 changed files with 36 additions and 37 deletions

View file

@ -162,7 +162,7 @@ static int __init test_suspend(void)
/* PM is initialized by now; is that state testable? */
if (test_state == PM_SUSPEND_ON)
goto done;
if (!valid_state(test_state)) {
if (!pm_states[test_state].state) {
printk(warn_bad_state, pm_states[test_state].label);
goto done;
}