aboutsummaryrefslogtreecommitdiffstats
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
parentb0cb1a19d05b8ea8611a9ef48a17fe417f1832e6 (diff)
downloadkernel_samsung_smdk4412-296699de6bdc717189a331ab6bbe90e05c94db06.zip
kernel_samsung_smdk4412-296699de6bdc717189a331ab6bbe90e05c94db06.tar.gz
kernel_samsung_smdk4412-296699de6bdc717189a331ab6bbe90e05c94db06.tar.bz2
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>
-rw-r--r--drivers/acpi/Kconfig8
-rw-r--r--drivers/acpi/sleep/Makefile2
-rw-r--r--drivers/acpi/sleep/main.c94
-rw-r--r--drivers/acpi/sleep/proc.c10
-rw-r--r--drivers/acpi/sleep/sleep.h2
-rw-r--r--drivers/base/power/Makefile2
-rw-r--r--drivers/base/power/power.h4
-rw-r--r--include/acpi/acpi_bus.h9
-rw-r--r--include/acpi/acpi_drivers.h4
-rw-r--r--include/linux/freezer.h6
-rw-r--r--include/linux/pm.h15
-rw-r--r--include/linux/suspend.h10
-rw-r--r--kernel/power/Kconfig41
-rw-r--r--kernel/power/Makefile3
-rw-r--r--kernel/power/main.c26
-rw-r--r--kernel/power/power.h10
-rw-r--r--mm/page_alloc.c4
17 files changed, 164 insertions, 86 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 22b401b2..66e78d5 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -63,6 +63,14 @@ config ACPI_PROCFS
Say N to delete /proc/acpi/ files that have moved to /sys/
+config ACPI_PROCFS_SLEEP
+ bool "/proc/acpi/sleep (deprecated)"
+ depends on PM_SLEEP && ACPI_PROCFS
+ default n
+ ---help---
+ Create /proc/acpi/sleep
+ Deprecated by /sys/power/state
+
config ACPI_AC
tristate "AC Adapter"
depends on X86
diff --git a/drivers/acpi/sleep/Makefile b/drivers/acpi/sleep/Makefile
index 01a993a..2bec897 100644
--- a/drivers/acpi/sleep/Makefile
+++ b/drivers/acpi/sleep/Makefile
@@ -1,5 +1,5 @@
obj-y := poweroff.o wakeup.o
-obj-y += main.o
+obj-$(CONFIG_PM_SLEEP) += main.o
obj-$(CONFIG_X86) += proc.o
EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index b4e94c8..e8cff5d 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -21,6 +21,9 @@
u8 sleep_states[ACPI_S_STATE_COUNT];
+static u32 acpi_target_sleep_state = ACPI_STATE_S0;
+
+#ifdef CONFIG_SUSPEND
static struct pm_ops acpi_pm_ops;
extern void do_suspend_lowlevel(void);
@@ -34,11 +37,6 @@ static u32 acpi_suspend_states[] = {
static int init_8259A_after_S1;
-extern int acpi_sleep_prepare(u32 acpi_state);
-extern void acpi_power_off(void);
-
-static u32 acpi_target_sleep_state = ACPI_STATE_S0;
-
/**
* acpi_pm_set_target - Set the target system sleep state to the state
* associated with given @pm_state, if supported.
@@ -163,21 +161,6 @@ static int acpi_pm_finish(suspend_state_t pm_state)
return 0;
}
-int acpi_suspend(u32 acpi_state)
-{
- suspend_state_t states[] = {
- [1] = PM_SUSPEND_STANDBY,
- [3] = PM_SUSPEND_MEM,
- [5] = PM_SUSPEND_MAX
- };
-
- if (acpi_state < 6 && states[acpi_state])
- return pm_suspend(states[acpi_state]);
- if (acpi_state == 4)
- return hibernate();
- return -EINVAL;
-}
-
static int acpi_pm_state_valid(suspend_state_t pm_state)
{
u32 acpi_state;
@@ -202,6 +185,27 @@ static struct pm_ops acpi_pm_ops = {
.finish = acpi_pm_finish,
};
+/*
+ * Toshiba fails to preserve interrupts over S1, reinitialization
+ * of 8259 is needed after S1 resume.
+ */
+static int __init init_ints_after_s1(struct dmi_system_id *d)
+{
+ printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
+ init_8259A_after_S1 = 1;
+ return 0;
+}
+
+static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
+ {
+ .callback = init_ints_after_s1,
+ .ident = "Toshiba Satellite 4030cdt",
+ .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
+ },
+ {},
+};
+#endif /* CONFIG_SUSPEND */
+
#ifdef CONFIG_HIBERNATION
static int acpi_hibernation_prepare(void)
{
@@ -256,6 +260,21 @@ static struct hibernation_ops acpi_hibernation_ops = {
};
#endif /* CONFIG_HIBERNATION */
+int acpi_suspend(u32 acpi_state)
+{
+ suspend_state_t states[] = {
+ [1] = PM_SUSPEND_STANDBY,
+ [3] = PM_SUSPEND_MEM,
+ [5] = PM_SUSPEND_MAX
+ };
+
+ if (acpi_state < 6 && states[acpi_state])
+ return pm_suspend(states[acpi_state]);
+ if (acpi_state == 4)
+ return hibernate();
+ return -EINVAL;
+}
+
/**
* acpi_pm_device_sleep_state - return preferred power state of ACPI device
* in the system sleep state given by %acpi_target_sleep_state
@@ -331,39 +350,22 @@ int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
return d_max;
}
-/*
- * Toshiba fails to preserve interrupts over S1, reinitialization
- * of 8259 is needed after S1 resume.
- */
-static int __init init_ints_after_s1(struct dmi_system_id *d)
-{
- printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
- init_8259A_after_S1 = 1;
- return 0;
-}
-
-static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
- {
- .callback = init_ints_after_s1,
- .ident = "Toshiba Satellite 4030cdt",
- .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
- },
- {},
-};
-
int __init acpi_sleep_init(void)
{
+ acpi_status status;
+ u8 type_a, type_b;
+#ifdef CONFIG_SUSPEND
int i = 0;
dmi_check_system(acpisleep_dmi_table);
+#endif
if (acpi_disabled)
return 0;
+#ifdef CONFIG_SUSPEND
printk(KERN_INFO PREFIX "(supports");
- for (i = 0; i < ACPI_S_STATE_COUNT; i++) {
- acpi_status status;
- u8 type_a, type_b;
+ for (i = ACPI_STATE_S0; i < ACPI_STATE_S4; i++) {
status = acpi_get_sleep_type_data(i, &type_a, &type_b);
if (ACPI_SUCCESS(status)) {
sleep_states[i] = 1;
@@ -373,10 +375,14 @@ int __init acpi_sleep_init(void)
printk(")\n");
pm_set_ops(&acpi_pm_ops);
+#endif
#ifdef CONFIG_HIBERNATION
- if (sleep_states[ACPI_STATE_S4])
+ status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b);
+ if (ACPI_SUCCESS(status)) {
hibernation_set_ops(&acpi_hibernation_ops);
+ sleep_states[ACPI_STATE_S4] = 1;
+ }
#else
sleep_states[ACPI_STATE_S4] = 0;
#endif
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 1b7bbb5..5dfe8b7 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -23,7 +23,7 @@
*/
ACPI_MODULE_NAME("sleep")
-#ifdef CONFIG_ACPI_PROCFS
+#ifdef CONFIG_ACPI_PROCFS_SLEEP
static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
{
int i;
@@ -76,7 +76,7 @@ acpi_system_write_sleep(struct file *file,
Done:
return error ? error : count;
}
-#endif /* CONFIG_ACPI_PROCFS */
+#endif /* CONFIG_ACPI_PROCFS_SLEEP */
#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
/* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */
@@ -471,7 +471,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
.release = single_release,
};
-#ifdef CONFIG_ACPI_PROCFS
+#ifdef CONFIG_ACPI_PROCFS_SLEEP
static const struct file_operations acpi_system_sleep_fops = {
.open = acpi_system_sleep_open_fs,
.read = seq_read,
@@ -479,7 +479,7 @@ static const struct file_operations acpi_system_sleep_fops = {
.llseek = seq_lseek,
.release = single_release,
};
-#endif /* CONFIG_ACPI_PROCFS */
+#endif /* CONFIG_ACPI_PROCFS_SLEEP */
#ifdef HAVE_ACPI_LEGACY_ALARM
static const struct file_operations acpi_system_alarm_fops = {
@@ -506,7 +506,7 @@ static int __init acpi_sleep_proc_init(void)
if (acpi_disabled)
return 0;
-#ifdef CONFIG_ACPI_PROCFS
+#ifdef CONFIG_ACPI_PROCFS_SLEEP
/* 'sleep' [R/W] */
entry =
create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
index f3e7039..ff1f850 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep/sleep.h
@@ -6,3 +6,5 @@ extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
extern void acpi_enable_wakeup_device(u8 sleep_state);
extern void acpi_disable_wakeup_device(u8 sleep_state);
extern void acpi_gpe_sleep_prepare(u32 sleep_state);
+
+extern int acpi_sleep_prepare(u32 acpi_state);
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 966a5e2..9caeaea7 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,5 +1,5 @@
obj-y := shutdown.o
-obj-$(CONFIG_PM) += main.o suspend.o resume.o sysfs.o
+obj-$(CONFIG_PM_SLEEP) += main.o suspend.o resume.o sysfs.o
obj-$(CONFIG_PM_TRACE) += trace.o
ifeq ($(CONFIG_DEBUG_DRIVER),y)
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 591a0dd..8ba0830 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -5,7 +5,7 @@
extern void device_shutdown(void);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
/*
* main.c
@@ -62,7 +62,7 @@ extern int resume_device(struct device *);
*/
extern int suspend_device(struct device *, pm_message_t);
-#else /* CONFIG_PM */
+#else /* CONFIG_PM_SLEEP */
static inline int device_pm_add(struct device * dev)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 533ef40..3d0fea2 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -366,7 +366,16 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer);
acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
+#ifdef CONFIG_PM_SLEEP
int acpi_pm_device_sleep_state(struct device *, int, int *);
+#else /* !CONFIG_PM_SLEEP */
+static inline int acpi_pm_device_sleep_state(struct device *d, int w, int *p)
+{
+ if (p)
+ *p = ACPI_STATE_D0;
+ return ACPI_STATE_D3;
+}
+#endif /* !CONFIG_PM_SLEEP */
#endif /* CONFIG_ACPI */
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index f85f77a..777d37a 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -147,6 +147,10 @@ static inline void unregister_hotplug_dock_device(acpi_handle handle)
/*--------------------------------------------------------------------------
Suspend/Resume
-------------------------------------------------------------------------- */
+#ifdef CONFIG_PM_SLEEP
extern int acpi_sleep_init(void);
+#else
+static inline int acpi_sleep_init(void) { return 0; }
+#endif
#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index c8e02de..efded00 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -5,7 +5,7 @@
#include <linux/sched.h>
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
/*
* Check if a process has been frozen
*/
@@ -126,7 +126,7 @@ static inline void set_freezable(void)
current->flags &= ~PF_NOFREEZE;
}
-#else
+#else /* !CONFIG_PM_SLEEP */
static inline int frozen(struct task_struct *p) { return 0; }
static inline int freezing(struct task_struct *p) { return 0; }
static inline void set_freeze_flag(struct task_struct *p) {}
@@ -143,6 +143,6 @@ static inline void freezer_do_not_count(void) {}
static inline void freezer_count(void) {}
static inline int freezer_should_skip(struct task_struct *p) { return 0; }
static inline void set_freezable(void) {}
-#endif
+#endif /* !CONFIG_PM_SLEEP */
#endif /* FREEZER_H_INCLUDED */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index ad3cc2e..e52f6f8 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -165,6 +165,7 @@ struct pm_ops {
int (*finish)(suspend_state_t state);
};
+#ifdef CONFIG_SUSPEND
extern struct pm_ops *pm_ops;
/**
@@ -193,6 +194,12 @@ extern void arch_suspend_disable_irqs(void);
extern void arch_suspend_enable_irqs(void);
extern int pm_suspend(suspend_state_t state);
+#else /* !CONFIG_SUSPEND */
+#define suspend_valid_only_mem NULL
+
+static inline void pm_set_ops(struct pm_ops *pm_ops) {}
+static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
+#endif /* !CONFIG_SUSPEND */
/*
* Device power management
@@ -266,7 +273,7 @@ typedef struct pm_message {
struct dev_pm_info {
pm_message_t power_state;
unsigned can_wakeup:1;
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
unsigned should_wakeup:1;
struct list_head entry;
#endif
@@ -276,7 +283,7 @@ extern int device_power_down(pm_message_t state);
extern void device_power_up(void);
extern void device_resume(void);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
extern int device_suspend(pm_message_t state);
extern int device_prepare_suspend(pm_message_t state);
@@ -306,7 +313,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
return 0;
}
-#else /* !CONFIG_PM */
+#else /* !CONFIG_PM_SLEEP */
static inline int device_suspend(pm_message_t state)
{
@@ -323,7 +330,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
return 0;
}
-#endif
+#endif /* !CONFIG_PM_SLEEP */
/* changes to device_may_wakeup take effect on the next pm state change.
* by default, devices should wakeup if they can.
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index d16c1b8..388cace 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -24,7 +24,7 @@ struct pbe {
extern void drain_local_pages(void);
extern void mark_free_pages(struct zone *zone);
-#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
+#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
extern int pm_prepare_console(void);
extern void pm_restore_console(void);
#else
@@ -54,7 +54,6 @@ struct hibernation_ops {
void (*restore_cleanup)(void);
};
-#ifdef CONFIG_PM
#ifdef CONFIG_HIBERNATION
/* kernel/power/snapshot.c */
extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
@@ -82,6 +81,7 @@ static inline void hibernation_set_ops(struct hibernation_ops *ops) {}
static inline int hibernate(void) { return -ENOSYS; }
#endif /* CONFIG_HIBERNATION */
+#ifdef CONFIG_PM_SLEEP
void save_processor_state(void);
void restore_processor_state(void);
struct saved_context;
@@ -106,7 +106,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
{ .notifier_call = fn, .priority = pri }; \
register_pm_notifier(&fn##_nb); \
}
-#else /* CONFIG_PM */
+#else /* !CONFIG_PM_SLEEP */
static inline int register_pm_notifier(struct notifier_block *nb)
{
@@ -119,9 +119,9 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
}
#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
-#endif /* CONFIG_PM */
+#endif /* !CONFIG_PM_SLEEP */
-#if !defined CONFIG_HIBERNATION || !defined(CONFIG_PM)
+#ifndef CONFIG_HIBERNATION
static inline void register_nosave_region(unsigned long b, unsigned long e)
{
}
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index c2582a4..412859f 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -46,7 +46,7 @@ config PM_VERBOSE
config DISABLE_CONSOLE_SUSPEND
bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
- depends on PM_DEBUG
+ depends on PM_DEBUG && PM_SLEEP
default n
---help---
This option turns off the console suspend mechanism that prevents
@@ -57,7 +57,7 @@ config DISABLE_CONSOLE_SUSPEND
config PM_TRACE
bool "Suspend/resume event tracing"
- depends on PM_DEBUG && X86 && EXPERIMENTAL
+ depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
default n
---help---
This enables some cheesy code to save the last PM event point in the
@@ -72,9 +72,37 @@ config PM_TRACE
CAUTION: this option will cause your machine's real-time clock to be
set to an invalid time after a resume.
+config SUSPEND_SMP_POSSIBLE
+ bool
+ depends on (X86 && !X86_VOYAGER) || (PPC64 && (PPC_PSERIES || PPC_PMAC))
+ depends on SMP
+ default y
+
+config SUSPEND_SMP
+ bool
+ depends on SUSPEND_SMP_POSSIBLE && PM_SLEEP
+ select HOTPLUG_CPU
+ default y
+
+config PM_SLEEP
+ bool
+ depends on SUSPEND || HIBERNATION
+ default y
+
+config SUSPEND
+ bool "Suspend to RAM and standby"
+ depends on PM
+ depends on !SMP || SUSPEND_SMP_POSSIBLE
+ default y
+ ---help---
+ Allow the system to enter sleep states in which main memory is
+ powered and thus its contents are preserved, such as the
+ suspend-to-RAM state (i.e. the ACPI S3 state).
+
config HIBERNATION
- bool "Hibernation"
- depends on PM && SWAP && (((X86 || PPC64_SWSUSP) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
+ bool "Hibernation (aka 'suspend to disk')"
+ depends on PM && SWAP
+ depends on ((X86 || PPC64_SWSUSP || FRV || PPC32) && !SMP) || SUSPEND_SMP_POSSIBLE
---help---
Enable the suspend to disk (STD) functionality, which is usually
called "hibernation" in user interfaces. STD checkpoints the
@@ -132,11 +160,6 @@ config PM_STD_PARTITION
suspended image to. It will simply pick the first available swap
device.
-config SUSPEND_SMP
- bool
- depends on HOTPLUG_CPU && (X86 || PPC64) && PM
- default y
-
config APM_EMULATION
tristate "Advanced Power Management Emulation"
depends on PM && SYS_SUPPORTS_APM_EMULATION
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index c6b0376..f7dfff2 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -3,8 +3,9 @@ ifeq ($(CONFIG_PM_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
endif
-obj-y := main.o process.o console.o
+obj-y := main.o
obj-$(CONFIG_PM_LEGACY) += pm.o
+obj-$(CONFIG_PM_SLEEP) += process.o console.o
obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
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;
}
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 9080914..95fbf2d 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -176,9 +176,17 @@ struct timeval;
extern void swsusp_show_speed(struct timeval *, struct timeval *,
unsigned int, char *);
+#ifdef CONFIG_SUSPEND
/* kernel/power/main.c */
-extern int suspend_enter(suspend_state_t state);
extern int suspend_devices_and_enter(suspend_state_t state);
+#else /* !CONFIG_SUSPEND */
+static inline int suspend_devices_and_enter(suspend_state_t state)
+{
+ return -ENOSYS;
+}
+#endif /* !CONFIG_SUSPEND */
+
+/* kernel/power/common.c */
extern struct blocking_notifier_head pm_chain_head;
static inline int pm_notifier_call_chain(unsigned long val)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6d3550c..0bd4d82 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -726,7 +726,7 @@ static void __drain_pages(unsigned int cpu)
}
}
-#ifdef CONFIG_PM
+#ifdef CONFIG_HIBERNATION
void mark_free_pages(struct zone *zone)
{
@@ -772,7 +772,7 @@ void drain_local_pages(void)
__drain_pages(smp_processor_id());
local_irq_restore(flags);
}
-#endif /* CONFIG_PM */
+#endif /* CONFIG_HIBERNATION */
/*
* Free a 0-order page