diff options
Diffstat (limited to 'kernel/power/suspend.c')
-rw-r--r-- | kernel/power/suspend.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 00aca60904b0..338a6f147974 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
@@ -78,6 +78,26 @@ static bool valid_state(suspend_state_t state) | |||
78 | return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); | 78 | return suspend_ops && suspend_ops->valid && suspend_ops->valid(state); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* | ||
82 | * If this is set, the "mem" label always corresponds to the deepest sleep state | ||
83 | * available, the "standby" label corresponds to the second deepest sleep state | ||
84 | * available (if any), and the "freeze" label corresponds to the remaining | ||
85 | * available sleep state (if there is one). | ||
86 | */ | ||
87 | static bool relative_states; | ||
88 | |||
89 | static int __init sleep_states_setup(char *str) | ||
90 | { | ||
91 | relative_states = !strncmp(str, "1", 1); | ||
92 | if (relative_states) { | ||
93 | pm_states[PM_SUSPEND_MEM].state = PM_SUSPEND_FREEZE; | ||
94 | pm_states[PM_SUSPEND_FREEZE].state = 0; | ||
95 | } | ||
96 | return 1; | ||
97 | } | ||
98 | |||
99 | __setup("relative_sleep_states=", sleep_states_setup); | ||
100 | |||
81 | /** | 101 | /** |
82 | * suspend_set_ops - Set the global suspend method table. | 102 | * suspend_set_ops - Set the global suspend method table. |
83 | * @ops: Suspend operations to use. | 103 | * @ops: Suspend operations to use. |
@@ -85,12 +105,20 @@ static bool valid_state(suspend_state_t state) | |||
85 | void suspend_set_ops(const struct platform_suspend_ops *ops) | 105 | void suspend_set_ops(const struct platform_suspend_ops *ops) |
86 | { | 106 | { |
87 | suspend_state_t i; | 107 | suspend_state_t i; |
108 | int j = PM_SUSPEND_MAX - 1; | ||
88 | 109 | ||
89 | lock_system_sleep(); | 110 | lock_system_sleep(); |
90 | 111 | ||
91 | suspend_ops = ops; | 112 | suspend_ops = ops; |
92 | for (i = PM_SUSPEND_STANDBY; i <= PM_SUSPEND_MEM; i++) | 113 | for (i = PM_SUSPEND_MEM; i >= PM_SUSPEND_STANDBY; i--) |
93 | pm_states[i].state = valid_state(i) ? i : 0; | 114 | if (valid_state(i)) |
115 | pm_states[j--].state = i; | ||
116 | else if (!relative_states) | ||
117 | pm_states[j--].state = 0; | ||
118 | |||
119 | pm_states[j--].state = PM_SUSPEND_FREEZE; | ||
120 | while (j >= PM_SUSPEND_MIN) | ||
121 | pm_states[j--].state = 0; | ||
94 | 122 | ||
95 | unlock_system_sleep(); | 123 | unlock_system_sleep(); |
96 | } | 124 | } |