summaryrefslogtreecommitdiffstats
path: root/kernel/power/main.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-07-29 23:27:18 +0200
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-29 16:45:38 -0700
commit296699de6bdc717189a331ab6bbe90e05c94db06 (patch)
tree53c847ecc8cce11952502921844052e44ca60d5e /kernel/power/main.c
parentb0cb1a19d05b8ea8611a9ef48a17fe417f1832e6 (diff)
downloadop-kernel-dev-296699de6bdc717189a331ab6bbe90e05c94db06.zip
op-kernel-dev-296699de6bdc717189a331ab6bbe90e05c94db06.tar.gz
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.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index cfba698..350b485 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -25,11 +25,13 @@
BLOCKING_NOTIFIER_HEAD(pm_chain_head);
-/*This is just an arbitrary number */
-#define FREE_PAGE_NUMBER (100)
-
DEFINE_MUTEX(pm_mutex);
+#ifdef CONFIG_SUSPEND
+
+/* This is just an arbitrary number */
+#define FREE_PAGE_NUMBER (100)
+
struct pm_ops *pm_ops;
/**
@@ -269,6 +271,8 @@ int pm_suspend(suspend_state_t state)
EXPORT_SYMBOL(pm_suspend);
+#endif /* CONFIG_SUSPEND */
+
decl_subsys(power,NULL,NULL);
@@ -285,13 +289,15 @@ decl_subsys(power,NULL,NULL);
static ssize_t state_show(struct kset *kset, char *buf)
{
+ char *s = buf;
+#ifdef CONFIG_SUSPEND
int i;
- char * s = buf;
for (i = 0; i < PM_SUSPEND_MAX; i++) {
if (pm_states[i] && valid_state(i))
s += sprintf(s,"%s ", pm_states[i]);
}
+#endif
#ifdef CONFIG_HIBERNATION
s += sprintf(s, "%s\n", "disk");
#else
@@ -304,11 +310,13 @@ static ssize_t state_show(struct kset *kset, char *buf)
static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
{
+#ifdef CONFIG_SUSPEND
suspend_state_t state = PM_SUSPEND_STANDBY;
const char * const *s;
+#endif
char *p;
- int error;
int len;
+ int error = -EINVAL;
p = memchr(buf, '\n', n);
len = p ? p - buf : n;
@@ -316,17 +324,19 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
/* First, check if we are requested to hibernate */
if (len == 4 && !strncmp(buf, "disk", len)) {
error = hibernate();
- return error ? error : n;
+ goto Exit;
}
+#ifdef CONFIG_SUSPEND
for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
break;
}
if (state < PM_SUSPEND_MAX && *s)
error = enter_state(state);
- else
- error = -EINVAL;
+#endif
+
+ Exit:
return error ? error : n;
}
OpenPOWER on IntegriCloud