aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/suspend.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/suspend.h')
-rw-r--r--include/linux/suspend.h60
1 files changed, 29 insertions, 31 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 4360e0816956..1d7d4c5797ee 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -38,18 +38,16 @@ typedef int __bitwise suspend_state_t;
38 * There is the %suspend_valid_only_mem function available that can be 38 * There is the %suspend_valid_only_mem function available that can be
39 * assigned to this if the platform only supports mem sleep. 39 * assigned to this if the platform only supports mem sleep.
40 * 40 *
41 * @set_target: Tell the platform which system sleep state is going to be 41 * @begin: Initialise a transition to given system sleep state.
42 * entered. 42 * @begin() is executed right prior to suspending devices. The information
43 * @set_target() is executed right prior to suspending devices. The 43 * conveyed to the platform code by @begin() should be disregarded by it as
44 * information conveyed to the platform code by @set_target() should be 44 * soon as @end() is executed. If @begin() fails (ie. returns nonzero),
45 * disregarded by the platform as soon as @finish() is executed and if
46 * @prepare() fails. If @set_target() fails (ie. returns nonzero),
47 * @prepare(), @enter() and @finish() will not be called by the PM core. 45 * @prepare(), @enter() and @finish() will not be called by the PM core.
48 * This callback is optional. However, if it is implemented, the argument 46 * This callback is optional. However, if it is implemented, the argument
49 * passed to @enter() is meaningless and should be ignored. 47 * passed to @enter() is redundant and should be ignored.
50 * 48 *
51 * @prepare: Prepare the platform for entering the system sleep state indicated 49 * @prepare: Prepare the platform for entering the system sleep state indicated
52 * by @set_target(). 50 * by @begin().
53 * @prepare() is called right after devices have been suspended (ie. the 51 * @prepare() is called right after devices have been suspended (ie. the
54 * appropriate .suspend() method has been executed for each device) and 52 * appropriate .suspend() method has been executed for each device) and
55 * before the nonboot CPUs are disabled (it is executed with IRQs enabled). 53 * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
@@ -57,8 +55,8 @@ typedef int __bitwise suspend_state_t;
57 * error code otherwise, in which case the system cannot enter the desired 55 * error code otherwise, in which case the system cannot enter the desired
58 * sleep state (@enter() and @finish() will not be called in that case). 56 * sleep state (@enter() and @finish() will not be called in that case).
59 * 57 *
60 * @enter: Enter the system sleep state indicated by @set_target() or 58 * @enter: Enter the system sleep state indicated by @begin() or represented by
61 * represented by the argument if @set_target() is not implemented. 59 * the argument if @begin() is not implemented.
62 * This callback is mandatory. It returns 0 on success or a negative 60 * This callback is mandatory. It returns 0 on success or a negative
63 * error code otherwise, in which case the system cannot enter the desired 61 * error code otherwise, in which case the system cannot enter the desired
64 * sleep state. 62 * sleep state.
@@ -69,13 +67,22 @@ typedef int __bitwise suspend_state_t;
69 * This callback is optional, but should be implemented by the platforms 67 * This callback is optional, but should be implemented by the platforms
70 * that implement @prepare(). If implemented, it is always called after 68 * that implement @prepare(). If implemented, it is always called after
71 * @enter() (even if @enter() fails). 69 * @enter() (even if @enter() fails).
70 *
71 * @end: Called by the PM core right after resuming devices, to indicate to
72 * the platform that the system has returned to the working state or
73 * the transition to the sleep state has been aborted.
74 * This callback is optional, but should be implemented by the platforms
75 * that implement @begin(), but platforms implementing @begin() should
76 * also provide a @end() which cleans up transitions aborted before
77 * @enter().
72 */ 78 */
73struct platform_suspend_ops { 79struct platform_suspend_ops {
74 int (*valid)(suspend_state_t state); 80 int (*valid)(suspend_state_t state);
75 int (*set_target)(suspend_state_t state); 81 int (*begin)(suspend_state_t state);
76 int (*prepare)(void); 82 int (*prepare)(void);
77 int (*enter)(suspend_state_t state); 83 int (*enter)(suspend_state_t state);
78 void (*finish)(void); 84 void (*finish)(void);
85 void (*end)(void);
79}; 86};
80 87
81#ifdef CONFIG_SUSPEND 88#ifdef CONFIG_SUSPEND
@@ -123,20 +130,22 @@ struct pbe {
123}; 130};
124 131
125/* mm/page_alloc.c */ 132/* mm/page_alloc.c */
126extern void drain_local_pages(void);
127extern void mark_free_pages(struct zone *zone); 133extern void mark_free_pages(struct zone *zone);
128 134
129/** 135/**
130 * struct platform_hibernation_ops - hibernation platform support 136 * struct platform_hibernation_ops - hibernation platform support
131 * 137 *
132 * The methods in this structure allow a platform to override the default 138 * The methods in this structure allow a platform to carry out special
133 * mechanism of shutting down the machine during a hibernation transition. 139 * operations required by it during a hibernation transition.
134 * 140 *
135 * All three methods must be assigned. 141 * All the methods below must be implemented.
136 * 142 *
137 * @start: Tell the platform driver that we're starting hibernation. 143 * @begin: Tell the platform driver that we're starting hibernation.
138 * Called right after shrinking memory and before freezing devices. 144 * Called right after shrinking memory and before freezing devices.
139 * 145 *
146 * @end: Called by the PM core right after resuming devices, to indicate to
147 * the platform that the system has returned to the working state.
148 *
140 * @pre_snapshot: Prepare the platform for creating the hibernation image. 149 * @pre_snapshot: Prepare the platform for creating the hibernation image.
141 * Called right after devices have been frozen and before the nonboot 150 * Called right after devices have been frozen and before the nonboot
142 * CPUs are disabled (runs with IRQs on). 151 * CPUs are disabled (runs with IRQs on).
@@ -171,7 +180,8 @@ extern void mark_free_pages(struct zone *zone);
171 * thawing devices (runs with IRQs on). 180 * thawing devices (runs with IRQs on).
172 */ 181 */
173struct platform_hibernation_ops { 182struct platform_hibernation_ops {
174 int (*start)(void); 183 int (*begin)(void);
184 void (*end)(void);
175 int (*pre_snapshot)(void); 185 int (*pre_snapshot)(void);
176 void (*finish)(void); 186 void (*finish)(void);
177 int (*prepare)(void); 187 int (*prepare)(void);
@@ -211,22 +221,10 @@ static inline int hibernate(void) { return -ENOSYS; }
211#ifdef CONFIG_PM_SLEEP 221#ifdef CONFIG_PM_SLEEP
212void save_processor_state(void); 222void save_processor_state(void);
213void restore_processor_state(void); 223void restore_processor_state(void);
214struct saved_context;
215void __save_processor_state(struct saved_context *ctxt);
216void __restore_processor_state(struct saved_context *ctxt);
217 224
218/* kernel/power/main.c */ 225/* kernel/power/main.c */
219extern struct blocking_notifier_head pm_chain_head; 226extern int register_pm_notifier(struct notifier_block *nb);
220 227extern int unregister_pm_notifier(struct notifier_block *nb);
221static inline int register_pm_notifier(struct notifier_block *nb)
222{
223 return blocking_notifier_chain_register(&pm_chain_head, nb);
224}
225
226static inline int unregister_pm_notifier(struct notifier_block *nb)
227{
228 return blocking_notifier_chain_unregister(&pm_chain_head, nb);
229}
230 228
231#define pm_notifier(fn, pri) { \ 229#define pm_notifier(fn, pri) { \
232 static struct notifier_block fn##_nb = \ 230 static struct notifier_block fn##_nb = \