From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guenter Roeck Subject: [PATCH v5 31/48] x86: apm: Register with kernel power-off handler Date: Thu, 6 Nov 2014 08:43:15 -0800 Message-ID: <1415292213-28652-32-git-send-email-linux@roeck-us.net> References: <1415292213-28652-1-git-send-email-linux@roeck-us.net> Return-path: Received: from bh-25.webhostbox.net ([208.91.199.152]:56399 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbaKFQoz (ORCPT ); Thu, 6 Nov 2014 11:44:55 -0500 Received: from mailnull by bh-25.webhostbox.net with sa-checked (Exim 4.82) (envelope-from ) id 1XmQB5-000UW4-8x for linux-pm@vger.kernel.org; Thu, 06 Nov 2014 16:44:55 +0000 In-Reply-To: <1415292213-28652-1-git-send-email-linux@roeck-us.net> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, Guenter Roeck , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Jiri Kosina , x86@kernel.org Register with kernel power-off handler instead of setting pm_power_off directly. Register with high priority to reflect that the original code overwrites existing power-off handlers. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: H. Peter Anvin Cc: Jiri Kosina Acked-by: Thomas Gleixner Reviewed-by: Jiri Kosina Signed-off-by: Guenter Roeck --- v5: - Rebase to v3.18-rc3 v4: - Do not use notifiers but internal functions and data structures to manage the list of power-off handlers. Drop unused parameters from callbacks, and make the power-off function type void v3: - Replace poweroff in all newly introduced variables and in text with power_off or power-off as appropriate - Replace POWEROFF_PRIORITY_xxx with POWER_OFF_PRIORITY_xxx v2: - Use define to specify poweroff handler priority arch/x86/kernel/apm_32.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index 5848744..04910de 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c @@ -981,7 +981,7 @@ recalc: * on their first cpu. */ -static void apm_power_off(void) +static void apm_power_off(struct power_off_handler_block *this) { /* Some bioses don't like being called from CPU != 0 */ if (apm_info.realmode_power_off) { @@ -992,6 +992,11 @@ static void apm_power_off(void) } } +static struct power_off_handler_block apm_power_off_hb = { + .handler = apm_power_off, + .priority = POWER_OFF_PRIORITY_HIGH, +}; + #ifdef CONFIG_APM_DO_ENABLE /** @@ -1847,8 +1852,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_power_off_handler(&apm_power_off_hb); + if (error) + pr_warn("apm: Failed to register power-off handler\n"); + } if (num_online_cpus() == 1 || smp) { #if defined(CONFIG_APM_DISPLAY_BLANK) && defined(CONFIG_VT) @@ -2408,9 +2416,8 @@ static void __exit apm_exit(void) apm_error("disengage power management", error); } misc_deregister(&apm_device); + unregister_power_off_handler(&apm_power_off_hb); 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