diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-07-29 17:27:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-29 19:45:38 -0400 |
commit | 296699de6bdc717189a331ab6bbe90e05c94db06 (patch) | |
tree | 53c847ecc8cce11952502921844052e44ca60d5e /kernel/power/main.c | |
parent | b0cb1a19d05b8ea8611a9ef48a17fe417f1832e6 (diff) |
Introduce CONFIG_SUSPEND for suspend-to-Ram and standby
Introduce CONFIG_SUSPEND representing the ability to enter system sleep
states, such as the ACPI S3 state, and allow the user to choose SUSPEND
and HIBERNATION independently of each other.
Make HOTPLUG_CPU be selected automatically if SUSPEND or HIBERNATION has
been chosen and the kernel is intended for SMP systems.
Also, introduce CONFIG_PM_SLEEP which is automatically selected if
CONFIG_SUSPEND or CONFIG_HIBERNATION is set and use it to select the
code needed for both suspend and hibernation.
The top-level power management headers and the ACPI code related to
suspend and hibernation are modified to use the new definitions (the
changes in drivers/acpi/sleep/main.c are, mostly, moving code to reduce
the number of ifdefs).
There are many other files in which CONFIG_PM can be replaced with
CONFIG_PM_SLEEP or even with CONFIG_SUSPEND, but they can be updated in
the future.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/main.c')
-rw-r--r-- | kernel/power/main.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c index cfba6987ae7d..350b485b3b60 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c | |||
@@ -25,11 +25,13 @@ | |||
25 | 25 | ||
26 | BLOCKING_NOTIFIER_HEAD(pm_chain_head); | 26 | BLOCKING_NOTIFIER_HEAD(pm_chain_head); |
27 | 27 | ||
28 | /*This is just an arbitrary number */ | ||
29 | #define FREE_PAGE_NUMBER (100) | ||
30 | |||
31 | DEFINE_MUTEX(pm_mutex); | 28 | DEFINE_MUTEX(pm_mutex); |
32 | 29 | ||
30 | #ifdef CONFIG_SUSPEND | ||
31 | |||
32 | /* This is just an arbitrary number */ | ||
33 | #define FREE_PAGE_NUMBER (100) | ||
34 | |||
33 | struct pm_ops *pm_ops; | 35 | struct pm_ops *pm_ops; |
34 | 36 | ||
35 | /** | 37 | /** |
@@ -269,6 +271,8 @@ int pm_suspend(suspend_state_t state) | |||
269 | 271 | ||
270 | EXPORT_SYMBOL(pm_suspend); | 272 | EXPORT_SYMBOL(pm_suspend); |
271 | 273 | ||
274 | #endif /* CONFIG_SUSPEND */ | ||
275 | |||
272 | decl_subsys(power,NULL,NULL); | 276 | decl_subsys(power,NULL,NULL); |
273 | 277 | ||
274 | 278 | ||
@@ -285,13 +289,15 @@ decl_subsys(power,NULL,NULL); | |||
285 | 289 | ||
286 | static ssize_t state_show(struct kset *kset, char *buf) | 290 | static ssize_t state_show(struct kset *kset, char *buf) |
287 | { | 291 | { |
292 | char *s = buf; | ||
293 | #ifdef CONFIG_SUSPEND | ||
288 | int i; | 294 | int i; |
289 | char * s = buf; | ||
290 | 295 | ||
291 | for (i = 0; i < PM_SUSPEND_MAX; i++) { | 296 | for (i = 0; i < PM_SUSPEND_MAX; i++) { |
292 | if (pm_states[i] && valid_state(i)) | 297 | if (pm_states[i] && valid_state(i)) |
293 | s += sprintf(s,"%s ", pm_states[i]); | 298 | s += sprintf(s,"%s ", pm_states[i]); |
294 | } | 299 | } |
300 | #endif | ||
295 | #ifdef CONFIG_HIBERNATION | 301 | #ifdef CONFIG_HIBERNATION |
296 | s += sprintf(s, "%s\n", "disk"); | 302 | s += sprintf(s, "%s\n", "disk"); |
297 | #else | 303 | #else |
@@ -304,11 +310,13 @@ static ssize_t state_show(struct kset *kset, char *buf) | |||
304 | 310 | ||
305 | static ssize_t state_store(struct kset *kset, const char *buf, size_t n) | 311 | static ssize_t state_store(struct kset *kset, const char *buf, size_t n) |
306 | { | 312 | { |
313 | #ifdef CONFIG_SUSPEND | ||
307 | suspend_state_t state = PM_SUSPEND_STANDBY; | 314 | suspend_state_t state = PM_SUSPEND_STANDBY; |
308 | const char * const *s; | 315 | const char * const *s; |
316 | #endif | ||
309 | char *p; | 317 | char *p; |
310 | int error; | ||
311 | int len; | 318 | int len; |
319 | int error = -EINVAL; | ||
312 | 320 | ||
313 | p = memchr(buf, '\n', n); | 321 | p = memchr(buf, '\n', n); |
314 | len = p ? p - buf : n; | 322 | len = p ? p - buf : n; |
@@ -316,17 +324,19 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n) | |||
316 | /* First, check if we are requested to hibernate */ | 324 | /* First, check if we are requested to hibernate */ |
317 | if (len == 4 && !strncmp(buf, "disk", len)) { | 325 | if (len == 4 && !strncmp(buf, "disk", len)) { |
318 | error = hibernate(); | 326 | error = hibernate(); |
319 | return error ? error : n; | 327 | goto Exit; |
320 | } | 328 | } |
321 | 329 | ||
330 | #ifdef CONFIG_SUSPEND | ||
322 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { | 331 | for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { |
323 | if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) | 332 | if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) |
324 | break; | 333 | break; |
325 | } | 334 | } |
326 | if (state < PM_SUSPEND_MAX && *s) | 335 | if (state < PM_SUSPEND_MAX && *s) |
327 | error = enter_state(state); | 336 | error = enter_state(state); |
328 | else | 337 | #endif |
329 | error = -EINVAL; | 338 | |
339 | Exit: | ||
330 | return error ? error : n; | 340 | return error ? error : n; |
331 | } | 341 | } |
332 | 342 | ||