aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-05-24 17:36:06 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-05-24 17:36:06 -0400
commitf42a9813fbf930fea3bdd0524dcb43c7feb0c977 (patch)
tree9396a7cf0b18ff2ce04cbe4698466ad6196afc75 /kernel
parent354258011e8e86961f7a72ad154ca8caf0c4c6f7 (diff)
PM / Hibernate: Update kerneldoc comments in hibernate.c
Some of the kerneldoc comments in kernel/power/hibernate.c are outdated and some of them don't adhere to the kernel's standards. Update them and make them look in a consistent way. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/hibernate.c194
1 files changed, 104 insertions, 90 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 16aa3bcd6b54..8f7b1db1ece1 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -54,10 +54,9 @@ static int hibernation_mode = HIBERNATION_SHUTDOWN;
54static const struct platform_hibernation_ops *hibernation_ops; 54static const struct platform_hibernation_ops *hibernation_ops;
55 55
56/** 56/**
57 * hibernation_set_ops - set the global hibernate operations 57 * hibernation_set_ops - Set the global hibernate operations.
58 * @ops: the hibernation operations to use in subsequent hibernation transitions 58 * @ops: Hibernation operations to use in subsequent hibernation transitions.
59 */ 59 */
60
61void hibernation_set_ops(const struct platform_hibernation_ops *ops) 60void hibernation_set_ops(const struct platform_hibernation_ops *ops)
62{ 61{
63 if (ops && !(ops->begin && ops->end && ops->pre_snapshot 62 if (ops && !(ops->begin && ops->end && ops->pre_snapshot
@@ -114,10 +113,9 @@ static int hibernation_test(int level) { return 0; }
114#endif /* !CONFIG_PM_DEBUG */ 113#endif /* !CONFIG_PM_DEBUG */
115 114
116/** 115/**
117 * platform_begin - tell the platform driver that we're starting 116 * platform_begin - Call platform to start hibernation.
118 * hibernation 117 * @platform_mode: Whether or not to use the platform driver.
119 */ 118 */
120
121static int platform_begin(int platform_mode) 119static int platform_begin(int platform_mode)
122{ 120{
123 return (platform_mode && hibernation_ops) ? 121 return (platform_mode && hibernation_ops) ?
@@ -125,10 +123,9 @@ static int platform_begin(int platform_mode)
125} 123}
126 124
127/** 125/**
128 * platform_end - tell the platform driver that we've entered the 126 * platform_end - Call platform to finish transition to the working state.
129 * working state 127 * @platform_mode: Whether or not to use the platform driver.
130 */ 128 */
131
132static void platform_end(int platform_mode) 129static void platform_end(int platform_mode)
133{ 130{
134 if (platform_mode && hibernation_ops) 131 if (platform_mode && hibernation_ops)
@@ -136,8 +133,11 @@ static void platform_end(int platform_mode)
136} 133}
137 134
138/** 135/**
139 * platform_pre_snapshot - prepare the machine for hibernation using the 136 * platform_pre_snapshot - Call platform to prepare the machine for hibernation.
140 * platform driver if so configured and return an error code if it fails 137 * @platform_mode: Whether or not to use the platform driver.
138 *
139 * Use the platform driver to prepare the system for creating a hibernate image,
140 * if so configured, and return an error code if that fails.
141 */ 141 */
142 142
143static int platform_pre_snapshot(int platform_mode) 143static int platform_pre_snapshot(int platform_mode)
@@ -147,10 +147,14 @@ static int platform_pre_snapshot(int platform_mode)
147} 147}
148 148
149/** 149/**
150 * platform_leave - prepare the machine for switching to the normal mode 150 * platform_leave - Call platform to prepare a transition to the working state.
151 * of operation using the platform driver (called with interrupts disabled) 151 * @platform_mode: Whether or not to use the platform driver.
152 *
153 * Use the platform driver prepare to prepare the machine for switching to the
154 * normal mode of operation.
155 *
156 * This routine is called on one CPU with interrupts disabled.
152 */ 157 */
153
154static void platform_leave(int platform_mode) 158static void platform_leave(int platform_mode)
155{ 159{
156 if (platform_mode && hibernation_ops) 160 if (platform_mode && hibernation_ops)
@@ -158,10 +162,14 @@ static void platform_leave(int platform_mode)
158} 162}
159 163
160/** 164/**
161 * platform_finish - switch the machine to the normal mode of operation 165 * platform_finish - Call platform to switch the system to the working state.
162 * using the platform driver (must be called after platform_prepare()) 166 * @platform_mode: Whether or not to use the platform driver.
167 *
168 * Use the platform driver to switch the machine to the normal mode of
169 * operation.
170 *
171 * This routine must be called after platform_prepare().
163 */ 172 */
164
165static void platform_finish(int platform_mode) 173static void platform_finish(int platform_mode)
166{ 174{
167 if (platform_mode && hibernation_ops) 175 if (platform_mode && hibernation_ops)
@@ -169,11 +177,15 @@ static void platform_finish(int platform_mode)
169} 177}
170 178
171/** 179/**
172 * platform_pre_restore - prepare the platform for the restoration from a 180 * platform_pre_restore - Prepare for hibernate image restoration.
173 * hibernation image. If the restore fails after this function has been 181 * @platform_mode: Whether or not to use the platform driver.
174 * called, platform_restore_cleanup() must be called. 182 *
183 * Use the platform driver to prepare the system for resume from a hibernation
184 * image.
185 *
186 * If the restore fails after this function has been called,
187 * platform_restore_cleanup() must be called.
175 */ 188 */
176
177static int platform_pre_restore(int platform_mode) 189static int platform_pre_restore(int platform_mode)
178{ 190{
179 return (platform_mode && hibernation_ops) ? 191 return (platform_mode && hibernation_ops) ?
@@ -181,12 +193,16 @@ static int platform_pre_restore(int platform_mode)
181} 193}
182 194
183/** 195/**
184 * platform_restore_cleanup - switch the platform to the normal mode of 196 * platform_restore_cleanup - Switch to the working state after failing restore.
185 * operation after a failing restore. If platform_pre_restore() has been 197 * @platform_mode: Whether or not to use the platform driver.
186 * called before the failing restore, this function must be called too, 198 *
187 * regardless of the result of platform_pre_restore(). 199 * Use the platform driver to switch the system to the normal mode of operation
200 * after a failing restore.
201 *
202 * If platform_pre_restore() has been called before the failing restore, this
203 * function must be called too, regardless of the result of
204 * platform_pre_restore().
188 */ 205 */
189
190static void platform_restore_cleanup(int platform_mode) 206static void platform_restore_cleanup(int platform_mode)
191{ 207{
192 if (platform_mode && hibernation_ops) 208 if (platform_mode && hibernation_ops)
@@ -194,10 +210,9 @@ static void platform_restore_cleanup(int platform_mode)
194} 210}
195 211
196/** 212/**
197 * platform_recover - recover the platform from a failure to suspend 213 * platform_recover - Recover from a failure to suspend devices.
198 * devices. 214 * @platform_mode: Whether or not to use the platform driver.
199 */ 215 */
200
201static void platform_recover(int platform_mode) 216static void platform_recover(int platform_mode)
202{ 217{
203 if (platform_mode && hibernation_ops && hibernation_ops->recover) 218 if (platform_mode && hibernation_ops && hibernation_ops->recover)
@@ -205,13 +220,12 @@ static void platform_recover(int platform_mode)
205} 220}
206 221
207/** 222/**
208 * swsusp_show_speed - print the time elapsed between two events. 223 * swsusp_show_speed - Print time elapsed between two events during hibernation.
209 * @start: Starting event. 224 * @start: Starting event.
210 * @stop: Final event. 225 * @stop: Final event.
211 * @nr_pages - number of pages processed between @start and @stop 226 * @nr_pages: Number of memory pages processed between @start and @stop.
212 * @msg - introductory message to print 227 * @msg: Additional diagnostic message to print.
213 */ 228 */
214
215void swsusp_show_speed(struct timeval *start, struct timeval *stop, 229void swsusp_show_speed(struct timeval *start, struct timeval *stop,
216 unsigned nr_pages, char *msg) 230 unsigned nr_pages, char *msg)
217{ 231{
@@ -234,11 +248,14 @@ void swsusp_show_speed(struct timeval *start, struct timeval *stop,
234} 248}
235 249
236/** 250/**
237 * create_image - freeze devices that need to be frozen with interrupts 251 * create_image - Create a hibernation image.
238 * off, create the hibernation image and thaw those devices. Control 252 * @platform_mode: Whether or not to use the platform driver.
239 * reappears in this routine after a restore. 253 *
254 * Execute device drivers' .freeze_noirq() callbacks, create a hibernation image
255 * and execute the drivers' .thaw_noirq() callbacks.
256 *
257 * Control reappears in this routine after the subsequent restore.
240 */ 258 */
241
242static int create_image(int platform_mode) 259static int create_image(int platform_mode)
243{ 260{
244 int error; 261 int error;
@@ -303,14 +320,11 @@ static int create_image(int platform_mode)
303} 320}
304 321
305/** 322/**
306 * hibernation_snapshot - quiesce devices and create the hibernation 323 * hibernation_snapshot - Quiesce devices and create a hibernation image.
307 * snapshot image. 324 * @platform_mode: If set, use platform driver to prepare for the transition.
308 * @platform_mode - if set, use the platform driver, if available, to
309 * prepare the platform firmware for the power transition.
310 * 325 *
311 * Must be called with pm_mutex held 326 * This routine must be called with pm_mutex held.
312 */ 327 */
313
314int hibernation_snapshot(int platform_mode) 328int hibernation_snapshot(int platform_mode)
315{ 329{
316 pm_message_t msg = PMSG_RECOVER; 330 pm_message_t msg = PMSG_RECOVER;
@@ -370,13 +384,14 @@ int hibernation_snapshot(int platform_mode)
370} 384}
371 385
372/** 386/**
373 * resume_target_kernel - prepare devices that need to be suspended with 387 * resume_target_kernel - Restore system state from a hibernation image.
374 * interrupts off, restore the contents of highmem that have not been 388 * @platform_mode: Whether or not to use the platform driver.
375 * restored yet from the image and run the low level code that will restore 389 *
376 * the remaining contents of memory and switch to the just restored target 390 * Execute device drivers' .freeze_noirq() callbacks, restore the contents of
377 * kernel. 391 * highmem that have not been restored yet from the image and run the low-level
392 * code that will restore the remaining contents of memory and switch to the
393 * just restored target kernel.
378 */ 394 */
379
380static int resume_target_kernel(bool platform_mode) 395static int resume_target_kernel(bool platform_mode)
381{ 396{
382 int error; 397 int error;
@@ -444,14 +459,12 @@ static int resume_target_kernel(bool platform_mode)
444} 459}
445 460
446/** 461/**
447 * hibernation_restore - quiesce devices and restore the hibernation 462 * hibernation_restore - Quiesce devices and restore from a hibernation image.
448 * snapshot image. If successful, control returns in hibernation_snaphot() 463 * @platform_mode: If set, use platform driver to prepare for the transition.
449 * @platform_mode - if set, use the platform driver, if available, to
450 * prepare the platform firmware for the transition.
451 * 464 *
452 * Must be called with pm_mutex held 465 * This routine must be called with pm_mutex held. If it is successful, control
466 * reappears in the restored target kernel in hibernation_snaphot().
453 */ 467 */
454
455int hibernation_restore(int platform_mode) 468int hibernation_restore(int platform_mode)
456{ 469{
457 int error; 470 int error;
@@ -471,10 +484,8 @@ int hibernation_restore(int platform_mode)
471} 484}
472 485
473/** 486/**
474 * hibernation_platform_enter - enter the hibernation state using the 487 * hibernation_platform_enter - Power off the system using the platform driver.
475 * platform driver (if available)
476 */ 488 */
477
478int hibernation_platform_enter(void) 489int hibernation_platform_enter(void)
479{ 490{
480 int error; 491 int error;
@@ -545,12 +556,12 @@ int hibernation_platform_enter(void)
545} 556}
546 557
547/** 558/**
548 * power_down - Shut the machine down for hibernation. 559 * power_down - Shut the machine down for hibernation.
549 * 560 *
550 * Use the platform driver, if configured so; otherwise try 561 * Use the platform driver, if configured, to put the system into the sleep
551 * to power off or reboot. 562 * state corresponding to hibernation, or try to power it off or reboot,
563 * depending on the value of hibernation_mode.
552 */ 564 */
553
554static void power_down(void) 565static void power_down(void)
555{ 566{
556 switch (hibernation_mode) { 567 switch (hibernation_mode) {
@@ -587,9 +598,8 @@ static int prepare_processes(void)
587} 598}
588 599
589/** 600/**
590 * hibernate - The granpappy of the built-in hibernation management 601 * hibernate - Carry out system hibernation, including saving the image.
591 */ 602 */
592
593int hibernate(void) 603int hibernate(void)
594{ 604{
595 int error; 605 int error;
@@ -667,17 +677,20 @@ int hibernate(void)
667 677
668 678
669/** 679/**
670 * software_resume - Resume from a saved image. 680 * software_resume - Resume from a saved hibernation image.
681 *
682 * This routine is called as a late initcall, when all devices have been
683 * discovered and initialized already.
671 * 684 *
672 * Called as a late_initcall (so all devices are discovered and 685 * The image reading code is called to see if there is a hibernation image
673 * initialized), we call swsusp to see if we have a saved image or not. 686 * available for reading. If that is the case, devices are quiesced and the
674 * If so, we quiesce devices, the restore the saved image. We will 687 * contents of memory is restored from the saved image.
675 * return above (in hibernate() ) if everything goes well.
676 * Otherwise, we fail gracefully and return to the normally
677 * scheduled program.
678 * 688 *
689 * If this is successful, control reappears in the restored target kernel in
690 * hibernation_snaphot() which returns to hibernate(). Otherwise, the routine
691 * attempts to recover gracefully and make the kernel return to the normal mode
692 * of operation.
679 */ 693 */
680
681static int software_resume(void) 694static int software_resume(void)
682{ 695{
683 int error; 696 int error;
@@ -807,21 +820,17 @@ static const char * const hibernation_modes[] = {
807 [HIBERNATION_TESTPROC] = "testproc", 820 [HIBERNATION_TESTPROC] = "testproc",
808}; 821};
809 822
810/** 823/*
811 * disk - Control hibernation mode 824 * /sys/power/disk - Control hibernation mode.
812 *
813 * Suspend-to-disk can be handled in several ways. We have a few options
814 * for putting the system to sleep - using the platform driver (e.g. ACPI
815 * or other hibernation_ops), powering off the system or rebooting the
816 * system (for testing) as well as the two test modes.
817 * 825 *
818 * The system can support 'platform', and that is known a priori (and 826 * Hibernation can be handled in several ways. There are a few different ways
819 * encoded by the presence of hibernation_ops). However, the user may 827 * to put the system into the sleep state: using the platform driver (e.g. ACPI
820 * choose 'shutdown' or 'reboot' as alternatives, as well as one fo the 828 * or other hibernation_ops), powering it off or rebooting it (for testing
821 * test modes, 'test' or 'testproc'. 829 * mostly), or using one of the two available test modes.
822 * 830 *
823 * show() will display what the mode is currently set to. 831 * The sysfs file /sys/power/disk provides an interface for selecting the
824 * store() will accept one of 832 * hibernation mode to use. Reading from this file causes the available modes
833 * to be printed. There are 5 modes that can be supported:
825 * 834 *
826 * 'platform' 835 * 'platform'
827 * 'shutdown' 836 * 'shutdown'
@@ -829,8 +838,14 @@ static const char * const hibernation_modes[] = {
829 * 'test' 838 * 'test'
830 * 'testproc' 839 * 'testproc'
831 * 840 *
832 * It will only change to 'platform' if the system 841 * If a platform hibernation driver is in use, 'platform' will be supported
833 * supports it (as determined by having hibernation_ops). 842 * and will be used by default. Otherwise, 'shutdown' will be used by default.
843 * The selected option (i.e. the one corresponding to the current value of
844 * hibernation_mode) is enclosed by a square bracket.
845 *
846 * To select a given hibernation mode it is necessary to write the mode's
847 * string representation (as returned by reading from /sys/power/disk) back
848 * into /sys/power/disk.
834 */ 849 */
835 850
836static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr, 851static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
@@ -863,7 +878,6 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
863 return buf-start; 878 return buf-start;
864} 879}
865 880
866
867static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr, 881static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
868 const char *buf, size_t n) 882 const char *buf, size_t n)
869{ 883{