From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bh-25.webhostbox.net (bh-25.webhostbox.net [208.91.199.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id A71951A17B1 for ; Tue, 7 Oct 2014 16:30:57 +1100 (EST) Received: from mailnull by bh-25.webhostbox.net with sa-checked (Exim 4.82) (envelope-from ) id 1XbNMN-002j39-GX for linuxppc-dev@lists.ozlabs.org; Tue, 07 Oct 2014 05:30:55 +0000 From: Guenter Roeck To: linux-kernel@vger.kernel.org Subject: [PATCH 41/44] x86: pmc_atom: Register poweroff handler with kernel poweroff handler Date: Mon, 6 Oct 2014 22:28:43 -0700 Message-Id: <1412659726-29957-42-git-send-email-linux@roeck-us.net> In-Reply-To: <1412659726-29957-1-git-send-email-linux@roeck-us.net> References: <1412659726-29957-1-git-send-email-linux@roeck-us.net> Cc: linux-m32r-ja@ml.linux-m32r.org, linux-mips@linux-mips.org, linux-efi@vger.kernel.org, linux-ia64@vger.kernel.org, linux-xtensa@linux-xtensa.org, "H. Peter Anvin" , Thomas Gleixner , devel@driverdev.osuosl.org, linux-s390@vger.kernel.org, lguest@lists.ozlabs.org, linux-c6x-dev@linux-c6x.org, linux-hexagon@vger.kernel.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, Ingo Molnar , xen-devel@lists.xenproject.org, Guenter Roeck , devicetree@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, linux-pm@vger.kernel.org, adi-buildroot-devel@lists.sourceforge.net, linux-m68k@lists.linux-m68k.org, linux-am33-list@redhat.com, linux-tegra@vger.kernel.org, openipmi-developer@lists.sourceforge.net, linux-metag@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-parisc@vger.kernel.org, linux-cris-kernel@axis.com, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Register with kernel poweroff handler instead of setting pm_power_off directly. Register with a low priority value of 64 to reflect that the original code only sets pm_power_off if it was not already set. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: H. Peter Anvin Signed-off-by: Guenter Roeck --- arch/x86/kernel/pmc_atom.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c index 0c424a6..79331a2 100644 --- a/arch/x86/kernel/pmc_atom.c +++ b/arch/x86/kernel/pmc_atom.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -92,7 +94,8 @@ static inline void pmc_reg_write(struct pmc_dev *pmc, int reg_offset, u32 val) writel(val, pmc->regmap + reg_offset); } -static void pmc_power_off(void) +static int pmc_power_off(struct notifier_block *this, unsigned long unused1, + void *unused2) { u16 pm1_cnt_port; u32 pm1_cnt_value; @@ -107,8 +110,15 @@ static void pmc_power_off(void) pm1_cnt_value |= SLEEP_ENABLE; outl(pm1_cnt_value, pm1_cnt_port); + + return NOTIFY_DONE; } +static struct notifier_block pmc_poweroff_nb = { + .notifier_call = pmc_power_off, + .priority = 64, +}; + static void pmc_hw_reg_setup(struct pmc_dev *pmc) { /* @@ -247,8 +257,12 @@ static int pmc_setup_dev(struct pci_dev *pdev) acpi_base_addr &= ACPI_BASE_ADDR_MASK; /* Install power off function */ - if (acpi_base_addr != 0 && pm_power_off == NULL) - pm_power_off = pmc_power_off; + if (acpi_base_addr != 0) { + ret = register_poweroff_handler(&pmc_poweroff_nb); + if (ret) + dev_err(&pdev->dev, + "Failed to install poweroff handler\n"); + } pci_read_config_dword(pdev, PMC_BASE_ADDR_OFFSET, &pmc->base_addr); pmc->base_addr &= PMC_BASE_ADDR_MASK; -- 1.9.1