On 05/21/11 05:12, Rafael J. Wysocki wrote:> From: Rafael J. Wysocki <rjw@sisk.pl>> > 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.

Hi Rafael,

Several of the functions are missing function parameter notations, asnoted below.

> + *> + * Use the platform driver to prepare the system for resume from a hibernation> + * image.> + *> + * If the restore fails after this function has been called,> + * platform_restore_cleanup() must be called.> */> -> static int platform_pre_restore(int platform_mode)> {> return (platform_mode && hibernation_ops) ?> @@ -182,12 +188,15 @@ static int platform_pre_restore(int plat> }> > /**> - * platform_restore_cleanup - switch the platform to the normal mode of> - * operation after a failing restore. If platform_pre_restore() has been> - * called before the failing restore, this function must be called too,> - * regardless of the result of platform_pre_restore().> + * platform_restore_cleanup - Switch to the working state after failing restore.

* @platform_mode: <description>

> + *> + * Use the platform driver to switch the system to the normal mode of operation> + * after a failing restore.> + *> + * If platform_pre_restore() has been called before the failing restore, this> + * function must be called too, regardless of the result of> + * platform_pre_restore().> */> -> static void platform_restore_cleanup(int platform_mode)> {> if (platform_mode && hibernation_ops)> @@ -195,10 +204,8 @@ static void platform_restore_cleanup(int> }> > /**> - * platform_recover - recover the platform from a failure to suspend> - * devices.> + * platform_recover - Recover the platform from a failure to suspend devices.

> + *> + * Execute device drivers' .freeze_noirq() callbacks, restore the contents of> + * highmem that have not been restored yet from the image and run the low-level> + * code that will restore the remaining contents of memory and switch to the> + * just restored target kernel.> */> -> static int resume_target_kernel(bool platform_mode)> {> int error;> @@ -445,14 +450,12 @@ static int resume_target_kernel(bool pla> }> > /**> - * hibernation_restore - quiesce devices and restore the hibernation> - * snapshot image. If successful, control returns in hibernation_snaphot()> - * @platform_mode - if set, use the platform driver, if available, to> - * prepare the platform firmware for the transition.> + * hibernation_restore - Quiesce devices and restore from a hibernation image.> + * @platform_mode: If set, use platform driver to prepare for the transition.> *> - * Must be called with pm_mutex held> + * This routine must be called with pm_mutex held. If it is successful, control> + * reappears in the restored target kernel in hibernation_snaphot().> */> -> int hibernation_restore(int platform_mode)> {> int error;> @@ -472,10 +475,8 @@ int hibernation_restore(int platform_mod> }> > /**> - * hibernation_platform_enter - enter the hibernation state using the> - * platform driver (if available)> + * hibernation_platform_enter - Power off the system using the platform driver.> */> -> int hibernation_platform_enter(void)> {> int error;> @@ -546,12 +547,12 @@ int hibernation_platform_enter(void)> }> > /**> - * power_down - Shut the machine down for hibernation.> + * power_down - Shut the machine down for hibernation.> *> - * Use the platform driver, if configured so; otherwise try> - * to power off or reboot.> + * Use the platform driver, if configured, to put the system into the sleep> + * state corresponding to hibernation, or try to power it off or reboot,> + * depending on the value of hibernation_mode.> */> -> static void power_down(void)> {> switch (hibernation_mode) {> @@ -588,9 +589,8 @@ static int prepare_processes(void)> }> > /**> - * hibernate - The granpappy of the built-in hibernation management> + * hibernate - Carry out system hibernation, including saving the image.> */> -> int hibernate(void)> {> int error;> @@ -668,17 +668,20 @@ int hibernate(void)> > > /**> - * software_resume - Resume from a saved image.> + * software_resume - Resume from a saved hibernation image.> + *> + * This routine is called as a late initcall, when all devices have been> + * discovered and initialized already.> *> - * Called as a late_initcall (so all devices are discovered and> - * initialized), we call swsusp to see if we have a saved image or not.> - * If so, we quiesce devices, the restore the saved image. We will> - * return above (in hibernate() ) if everything goes well.> - * Otherwise, we fail gracefully and return to the normally> - * scheduled program.> + * The image reading code is called to see if there is a hibernation image> + * available for reading. If that is the case, devices are quiesced and the> + * contents of memory is restored from the saved image.> *> + * If this is successful, control reappears in the restored target kernel in> + * hibernation_snaphot() which returns to hibernate(). Otherwise, the routine> + * attempts to recover gracefully and make the kernel return to the normal mode> + * of operation.> */> -> static int software_resume(void)> {> int error;> @@ -808,21 +811,17 @@ static const char * const hibernation_mo> [HIBERNATION_TESTPROC] = "testproc",> };> > -/**> - * disk - Control hibernation mode> +/*> + * /sys/power/disk - Control hibernation mode.> *> - * Suspend-to-disk can be handled in several ways. We have a few options> - * for putting the system to sleep - using the platform driver (e.g. ACPI> - * or other hibernation_ops), powering off the system or rebooting the> - * system (for testing) as well as the two test modes.> - *> - * The system can support 'platform', and that is known a priori (and> - * encoded by the presence of hibernation_ops). However, the user may> - * choose 'shutdown' or 'reboot' as alternatives, as well as one fo the> - * test modes, 'test' or 'testproc'.> + * Hibernation can be handled in several ways. There are a few different ways> + * to put the system into the sleep state: using the platform driver (e.g. ACPI> + * or other hibernation_ops), powering it off or rebooting it (for testing> + * mostly), or using one of the two available test modes.> *> - * show() will display what the mode is currently set to.> - * store() will accept one of> + * The sysfs file /sys/power/disk provides an interface for selecting the> + * hibernation mode to use. Reading from this file causes the available modes> + * to be printed. There are 5 modes that can be supported:> *> * 'platform'> * 'shutdown'> @@ -830,8 +829,14 @@ static const char * const hibernation_mo> * 'test'> * 'testproc'> *> - * It will only change to 'platform' if the system> - * supports it (as determined by having hibernation_ops).> + * If a platform hibernation driver is in use, 'platform' will be supported> + * and will be used by default. Otherwise, 'shutdown' will be used by default.> + * The selected option (i.e. the one corresponding to the current value of> + * hibernation_mode) is enclosed by a square bracket.> + *> + * To select a given hibernation mode it is necessary to write the mode's> + * string representation (as returned by reading from /sys/power/disk) back> + * into /sys/power/disk.> */> > static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,> @@ -864,7 +869,6 @@ static ssize_t disk_show(struct kobject> return buf-start;> }> > -> static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,> const char *buf, size_t n)> {>