diff options
| author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-05-09 05:33:18 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-09 15:30:48 -0400 |
| commit | a3d25c275d383975504dc53c25b691df59bd3c48 (patch) | |
| tree | 161a2ae12a20a630c2f639e144872db2b92eb098 /include/linux | |
| parent | d60846c4d16f9518b098b905af2b87cb6bf6dc42 (diff) | |
PM: Separate hibernation code from suspend code
[ With Johannes Berg <johannes@sipsolutions.net> ]
Separate the hibernation (aka suspend to disk code) from the other suspend
code. In particular:
* Remove the definitions related to hibernation from include/linux/pm.h
* Introduce struct hibernation_ops and a new hibernate() function to hibernate
the system, defined in include/linux/suspend.h
* Separate suspend code in kernel/power/main.c from hibernation-related code
in kernel/power/disk.c and kernel/power/user.c (with the help of
hibernation_ops)
* Switch ACPI (the only user of pm_ops.pm_disk_mode) to hibernation_ops
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Nigel Cunningham <nigel@nigel.suspend2.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/pm.h | 31 | ||||
| -rw-r--r-- | include/linux/suspend.h | 24 |
2 files changed, 25 insertions, 30 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index 6e8fa3049e5d..87545e0f0b58 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
| @@ -107,26 +107,11 @@ typedef int __bitwise suspend_state_t; | |||
| 107 | #define PM_SUSPEND_ON ((__force suspend_state_t) 0) | 107 | #define PM_SUSPEND_ON ((__force suspend_state_t) 0) |
| 108 | #define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) | 108 | #define PM_SUSPEND_STANDBY ((__force suspend_state_t) 1) |
| 109 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) | 109 | #define PM_SUSPEND_MEM ((__force suspend_state_t) 3) |
| 110 | #define PM_SUSPEND_DISK ((__force suspend_state_t) 4) | 110 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 4) |
| 111 | #define PM_SUSPEND_MAX ((__force suspend_state_t) 5) | ||
| 112 | |||
| 113 | typedef int __bitwise suspend_disk_method_t; | ||
| 114 | |||
| 115 | /* invalid must be 0 so struct pm_ops initialisers can leave it out */ | ||
| 116 | #define PM_DISK_INVALID ((__force suspend_disk_method_t) 0) | ||
| 117 | #define PM_DISK_PLATFORM ((__force suspend_disk_method_t) 1) | ||
| 118 | #define PM_DISK_SHUTDOWN ((__force suspend_disk_method_t) 2) | ||
| 119 | #define PM_DISK_REBOOT ((__force suspend_disk_method_t) 3) | ||
| 120 | #define PM_DISK_TEST ((__force suspend_disk_method_t) 4) | ||
| 121 | #define PM_DISK_TESTPROC ((__force suspend_disk_method_t) 5) | ||
| 122 | #define PM_DISK_MAX ((__force suspend_disk_method_t) 6) | ||
| 123 | 111 | ||
| 124 | /** | 112 | /** |
| 125 | * struct pm_ops - Callbacks for managing platform dependent suspend states. | 113 | * struct pm_ops - Callbacks for managing platform dependent suspend states. |
| 126 | * @valid: Callback to determine whether the given state can be entered. | 114 | * @valid: Callback to determine whether the given state can be entered. |
| 127 | * If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is | ||
| 128 | * always valid and never passed to this call. If not assigned, | ||
| 129 | * no suspend states are valid. | ||
| 130 | * Valid states are advertised in /sys/power/state but can still | 115 | * Valid states are advertised in /sys/power/state but can still |
| 131 | * be rejected by prepare or enter if the conditions aren't right. | 116 | * be rejected by prepare or enter if the conditions aren't right. |
| 132 | * There is a %pm_valid_only_mem function available that can be assigned | 117 | * There is a %pm_valid_only_mem function available that can be assigned |
| @@ -140,24 +125,12 @@ typedef int __bitwise suspend_disk_method_t; | |||
| 140 | * | 125 | * |
| 141 | * @finish: Called when the system has left the given state and all devices | 126 | * @finish: Called when the system has left the given state and all devices |
| 142 | * are resumed. The return value is ignored. | 127 | * are resumed. The return value is ignored. |
| 143 | * | ||
| 144 | * @pm_disk_mode: The generic code always allows one of the shutdown methods | ||
| 145 | * %PM_DISK_SHUTDOWN, %PM_DISK_REBOOT, %PM_DISK_TEST and | ||
| 146 | * %PM_DISK_TESTPROC. If this variable is set, the mode it is set | ||
| 147 | * to is allowed in addition to those modes and is also made default. | ||
| 148 | * When this mode is sent selected, the @prepare call will be called | ||
| 149 | * before suspending to disk (if present), the @enter call should be | ||
| 150 | * present and will be called after all state has been saved and the | ||
| 151 | * machine is ready to be powered off; the @finish callback is called | ||
| 152 | * after state has been restored. All these calls are called with | ||
| 153 | * %PM_SUSPEND_DISK as the state. | ||
| 154 | */ | 128 | */ |
| 155 | struct pm_ops { | 129 | struct pm_ops { |
| 156 | int (*valid)(suspend_state_t state); | 130 | int (*valid)(suspend_state_t state); |
| 157 | int (*prepare)(suspend_state_t state); | 131 | int (*prepare)(suspend_state_t state); |
| 158 | int (*enter)(suspend_state_t state); | 132 | int (*enter)(suspend_state_t state); |
| 159 | int (*finish)(suspend_state_t state); | 133 | int (*finish)(suspend_state_t state); |
| 160 | suspend_disk_method_t pm_disk_mode; | ||
| 161 | }; | 134 | }; |
| 162 | 135 | ||
| 163 | /** | 136 | /** |
| @@ -276,8 +249,6 @@ extern void device_power_up(void); | |||
| 276 | extern void device_resume(void); | 249 | extern void device_resume(void); |
| 277 | 250 | ||
| 278 | #ifdef CONFIG_PM | 251 | #ifdef CONFIG_PM |
| 279 | extern suspend_disk_method_t pm_disk_mode; | ||
| 280 | |||
| 281 | extern int device_suspend(pm_message_t state); | 252 | extern int device_suspend(pm_message_t state); |
| 282 | extern int device_prepare_suspend(pm_message_t state); | 253 | extern int device_prepare_suspend(pm_message_t state); |
| 283 | 254 | ||
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 9d2aa1a12aa0..d74da9122b60 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -32,6 +32,24 @@ static inline int pm_prepare_console(void) { return 0; } | |||
| 32 | static inline void pm_restore_console(void) {} | 32 | static inline void pm_restore_console(void) {} |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | /** | ||
| 36 | * struct hibernation_ops - hibernation platform support | ||
| 37 | * | ||
| 38 | * The methods in this structure allow a platform to override the default | ||
| 39 | * mechanism of shutting down the machine during a hibernation transition. | ||
| 40 | * | ||
| 41 | * All three methods must be assigned. | ||
| 42 | * | ||
| 43 | * @prepare: prepare system for hibernation | ||
| 44 | * @enter: shut down system after state has been saved to disk | ||
| 45 | * @finish: finish/clean up after state has been reloaded | ||
| 46 | */ | ||
| 47 | struct hibernation_ops { | ||
| 48 | int (*prepare)(void); | ||
| 49 | int (*enter)(void); | ||
| 50 | void (*finish)(void); | ||
| 51 | }; | ||
| 52 | |||
| 35 | #if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) | 53 | #if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) |
| 36 | /* kernel/power/snapshot.c */ | 54 | /* kernel/power/snapshot.c */ |
| 37 | extern void __init register_nosave_region(unsigned long, unsigned long); | 55 | extern void __init register_nosave_region(unsigned long, unsigned long); |
| @@ -39,11 +57,17 @@ extern int swsusp_page_is_forbidden(struct page *); | |||
| 39 | extern void swsusp_set_page_free(struct page *); | 57 | extern void swsusp_set_page_free(struct page *); |
| 40 | extern void swsusp_unset_page_free(struct page *); | 58 | extern void swsusp_unset_page_free(struct page *); |
| 41 | extern unsigned long get_safe_page(gfp_t gfp_mask); | 59 | extern unsigned long get_safe_page(gfp_t gfp_mask); |
| 60 | |||
| 61 | extern void hibernation_set_ops(struct hibernation_ops *ops); | ||
| 62 | extern int hibernate(void); | ||
| 42 | #else | 63 | #else |
| 43 | static inline void register_nosave_region(unsigned long b, unsigned long e) {} | 64 | static inline void register_nosave_region(unsigned long b, unsigned long e) {} |
| 44 | static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } | 65 | static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } |
| 45 | static inline void swsusp_set_page_free(struct page *p) {} | 66 | static inline void swsusp_set_page_free(struct page *p) {} |
| 46 | static inline void swsusp_unset_page_free(struct page *p) {} | 67 | static inline void swsusp_unset_page_free(struct page *p) {} |
| 68 | |||
| 69 | static inline void hibernation_set_ops(struct hibernation_ops *ops) {} | ||
| 70 | static inline int hibernate(void) { return -ENOSYS; } | ||
| 47 | #endif /* defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) */ | 71 | #endif /* defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) */ |
| 48 | 72 | ||
| 49 | void save_processor_state(void); | 73 | void save_processor_state(void); |
