aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-07-29 17:27:18 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-29 19:45:38 -0400
commit296699de6bdc717189a331ab6bbe90e05c94db06 (patch)
tree53c847ecc8cce11952502921844052e44ca60d5e /include
parentb0cb1a19d05b8ea8611a9ef48a17fe417f1832e6 (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 'include')
-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
5 files changed, 32 insertions, 12 deletions
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 533ef40f7cc..3d0fea235bf 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);
366acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 366acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
367#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle)) 367#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
368 368
369#ifdef CONFIG_PM_SLEEP
369int acpi_pm_device_sleep_state(struct device *, int, int *); 370int acpi_pm_device_sleep_state(struct device *, int, int *);
371#else /* !CONFIG_PM_SLEEP */
372static inline int acpi_pm_device_sleep_state(struct device *d, int w, int *p)
373{
374 if (p)
375 *p = ACPI_STATE_D0;
376 return ACPI_STATE_D3;
377}
378#endif /* !CONFIG_PM_SLEEP */
370 379
371#endif /* CONFIG_ACPI */ 380#endif /* CONFIG_ACPI */
372 381
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index f85f77a538a..777d37ae81a 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)
147/*-------------------------------------------------------------------------- 147/*--------------------------------------------------------------------------
148 Suspend/Resume 148 Suspend/Resume
149 -------------------------------------------------------------------------- */ 149 -------------------------------------------------------------------------- */
150#ifdef CONFIG_PM_SLEEP
150extern int acpi_sleep_init(void); 151extern int acpi_sleep_init(void);
152#else
153static inline int acpi_sleep_init(void) { return 0; }
154#endif
151 155
152#endif /*__ACPI_DRIVERS_H__*/ 156#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index c8e02de737f..efded00ad08 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -5,7 +5,7 @@
5 5
6#include <linux/sched.h> 6#include <linux/sched.h>
7 7
8#ifdef CONFIG_PM 8#ifdef CONFIG_PM_SLEEP
9/* 9/*
10 * Check if a process has been frozen 10 * Check if a process has been frozen
11 */ 11 */
@@ -126,7 +126,7 @@ static inline void set_freezable(void)
126 current->flags &= ~PF_NOFREEZE; 126 current->flags &= ~PF_NOFREEZE;
127} 127}
128 128
129#else 129#else /* !CONFIG_PM_SLEEP */
130static inline int frozen(struct task_struct *p) { return 0; } 130static inline int frozen(struct task_struct *p) { return 0; }
131static inline int freezing(struct task_struct *p) { return 0; } 131static inline int freezing(struct task_struct *p) { return 0; }
132static inline void set_freeze_flag(struct task_struct *p) {} 132static inline void set_freeze_flag(struct task_struct *p) {}
@@ -143,6 +143,6 @@ static inline void freezer_do_not_count(void) {}
143static inline void freezer_count(void) {} 143static inline void freezer_count(void) {}
144static inline int freezer_should_skip(struct task_struct *p) { return 0; } 144static inline int freezer_should_skip(struct task_struct *p) { return 0; }
145static inline void set_freezable(void) {} 145static inline void set_freezable(void) {}
146#endif 146#endif /* !CONFIG_PM_SLEEP */
147 147
148#endif /* FREEZER_H_INCLUDED */ 148#endif /* FREEZER_H_INCLUDED */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index ad3cc2eb0d3..e52f6f83c06 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -165,6 +165,7 @@ struct pm_ops {
165 int (*finish)(suspend_state_t state); 165 int (*finish)(suspend_state_t state);
166}; 166};
167 167
168#ifdef CONFIG_SUSPEND
168extern struct pm_ops *pm_ops; 169extern struct pm_ops *pm_ops;
169 170
170/** 171/**
@@ -193,6 +194,12 @@ extern void arch_suspend_disable_irqs(void);
193extern void arch_suspend_enable_irqs(void); 194extern void arch_suspend_enable_irqs(void);
194 195
195extern int pm_suspend(suspend_state_t state); 196extern int pm_suspend(suspend_state_t state);
197#else /* !CONFIG_SUSPEND */
198#define suspend_valid_only_mem NULL
199
200static inline void pm_set_ops(struct pm_ops *pm_ops) {}
201static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
202#endif /* !CONFIG_SUSPEND */
196 203
197/* 204/*
198 * Device power management 205 * Device power management
@@ -266,7 +273,7 @@ typedef struct pm_message {
266struct dev_pm_info { 273struct dev_pm_info {
267 pm_message_t power_state; 274 pm_message_t power_state;
268 unsigned can_wakeup:1; 275 unsigned can_wakeup:1;
269#ifdef CONFIG_PM 276#ifdef CONFIG_PM_SLEEP
270 unsigned should_wakeup:1; 277 unsigned should_wakeup:1;
271 struct list_head entry; 278 struct list_head entry;
272#endif 279#endif
@@ -276,7 +283,7 @@ extern int device_power_down(pm_message_t state);
276extern void device_power_up(void); 283extern void device_power_up(void);
277extern void device_resume(void); 284extern void device_resume(void);
278 285
279#ifdef CONFIG_PM 286#ifdef CONFIG_PM_SLEEP
280extern int device_suspend(pm_message_t state); 287extern int device_suspend(pm_message_t state);
281extern int device_prepare_suspend(pm_message_t state); 288extern int device_prepare_suspend(pm_message_t state);
282 289
@@ -306,7 +313,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
306 return 0; 313 return 0;
307} 314}
308 315
309#else /* !CONFIG_PM */ 316#else /* !CONFIG_PM_SLEEP */
310 317
311static inline int device_suspend(pm_message_t state) 318static inline int device_suspend(pm_message_t state)
312{ 319{
@@ -323,7 +330,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
323 return 0; 330 return 0;
324} 331}
325 332
326#endif 333#endif /* !CONFIG_PM_SLEEP */
327 334
328/* changes to device_may_wakeup take effect on the next pm state change. 335/* changes to device_may_wakeup take effect on the next pm state change.
329 * by default, devices should wakeup if they can. 336 * by default, devices should wakeup if they can.
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index d16c1b85d51..388cace9751 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -24,7 +24,7 @@ struct pbe {
24extern void drain_local_pages(void); 24extern void drain_local_pages(void);
25extern void mark_free_pages(struct zone *zone); 25extern void mark_free_pages(struct zone *zone);
26 26
27#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) 27#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
28extern int pm_prepare_console(void); 28extern int pm_prepare_console(void);
29extern void pm_restore_console(void); 29extern void pm_restore_console(void);
30#else 30#else
@@ -54,7 +54,6 @@ struct hibernation_ops {
54 void (*restore_cleanup)(void); 54 void (*restore_cleanup)(void);
55}; 55};
56 56
57#ifdef CONFIG_PM
58#ifdef CONFIG_HIBERNATION 57#ifdef CONFIG_HIBERNATION
59/* kernel/power/snapshot.c */ 58/* kernel/power/snapshot.c */
60extern void __register_nosave_region(unsigned long b, unsigned long e, int km); 59extern 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) {}
82static inline int hibernate(void) { return -ENOSYS; } 81static inline int hibernate(void) { return -ENOSYS; }
83#endif /* CONFIG_HIBERNATION */ 82#endif /* CONFIG_HIBERNATION */
84 83
84#ifdef CONFIG_PM_SLEEP
85void save_processor_state(void); 85void save_processor_state(void);
86void restore_processor_state(void); 86void restore_processor_state(void);
87struct saved_context; 87struct saved_context;
@@ -106,7 +106,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
106 { .notifier_call = fn, .priority = pri }; \ 106 { .notifier_call = fn, .priority = pri }; \
107 register_pm_notifier(&fn##_nb); \ 107 register_pm_notifier(&fn##_nb); \
108} 108}
109#else /* CONFIG_PM */ 109#else /* !CONFIG_PM_SLEEP */
110 110
111static inline int register_pm_notifier(struct notifier_block *nb) 111static inline int register_pm_notifier(struct notifier_block *nb)
112{ 112{
@@ -119,9 +119,9 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
119} 119}
120 120
121#define pm_notifier(fn, pri) do { (void)(fn); } while (0) 121#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
122#endif /* CONFIG_PM */ 122#endif /* !CONFIG_PM_SLEEP */
123 123
124#if !defined CONFIG_HIBERNATION || !defined(CONFIG_PM) 124#ifndef CONFIG_HIBERNATION
125static inline void register_nosave_region(unsigned long b, unsigned long e) 125static inline void register_nosave_region(unsigned long b, unsigned long e)
126{ 126{
127} 127}