Register with kernel poweroff handler instead of setting pm_power_off directly. Register with high priority value of 192 to reflect that the original code overwrites existing poweroff handlers.
Cc: Thomas Gleixner <t...@linutronix.de> Cc: Ingo Molnar <mi...@redhat.com> Cc: H. Peter Anvin <h...@zytor.com> Cc: Jiri Kosina <jkos...@suse.cz> Signed-off-by: Guenter Roeck <li...@roeck-us.net> --- arch/x86/kernel/apm_32.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index 5848744..84566a6 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c @@ -219,6 +219,7 @@ #include <linux/init.h> #include <linux/time.h> #include <linux/sched.h> +#include <linux/notifier.h> #include <linux/pm.h> #include <linux/capability.h> #include <linux/device.h> @@ -981,7 +982,8 @@ recalc: * on their first cpu. */ -static void apm_power_off(void) +static int apm_power_off(struct notifier_block *this, unsigned long unused1, + void *unused2) { /* Some bioses don't like being called from CPU != 0 */ if (apm_info.realmode_power_off) { @@ -990,8 +992,14 @@ static void apm_power_off(void) } else { (void)set_system_power_state(APM_STATE_OFF); } + return NOTIFY_DONE; } +static struct notifier_block apm_poweroff_nb = { + .notifier_call = apm_power_off, + .priority = 192, +}; + #ifdef CONFIG_APM_DO_ENABLE /** @@ -1847,8 +1855,11 @@ static int apm(void *unused) } /* Install our power off handler.. */ - if (power_off) - pm_power_off = apm_power_off; + if (power_off) { + error = register_poweroff_handler(&apm_poweroff_nb); + if (error) + pr_err("apm: Failed to register poweroff handler\n"); + } if (num_online_cpus() == 1 || smp) { #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) @@ -2408,9 +2419,8 @@ static void __exit apm_exit(void) apm_error("disengage power management", error); } misc_deregister(&apm_device); + unregister_poweroff_handler(&apm_poweroff_nb); remove_proc_entry("apm", NULL); - if (power_off) - pm_power_off = NULL; if (kapmd_task) { kthread_stop(kapmd_task); kapmd_task = NULL; -- 1.9.1 ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel