From patchwork Thu Nov 6 16:43:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 5245421 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58558C11AD for ; Thu, 6 Nov 2014 16:47:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7FF5120138 for ; Thu, 6 Nov 2014 16:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F1BA20125 for ; Thu, 6 Nov 2014 16:47:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752599AbaKFQrb (ORCPT ); Thu, 6 Nov 2014 11:47:31 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:56641 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310AbaKFQph (ORCPT ); Thu, 6 Nov 2014 11:45:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=uuFquk0tNz4sOu1Xc/HfiCYnkv4r3oaoPjNsheecNqI=; b=qCQs5jwh2vMgPslZEZZiBJu7jzPPZQgcREr6/xrW/7Uqj7oAzkpxp7mL6LJmgPxG1axbN2pW3btmDBLsTOnbxLPu1d7b+7wwzWix1YFQ+rJh1+2MBH1zP3e+/wGyOdnyAI/UdZoFpadLYACJgSgVOfrrmiligtRnogLanKfWUfk=; Received: from mailnull by bh-25.webhostbox.net with sa-checked (Exim 4.82) (envelope-from ) id 1XmQBk-000WcH-Ih for linux-pm@vger.kernel.org; Thu, 06 Nov 2014 16:45:36 +0000 Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:35346 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.82) (envelope-from ) id 1XmQBi-000WZP-MN; Thu, 06 Nov 2014 16:45:35 +0000 From: Guenter Roeck To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, Guenter Roeck , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [PATCH v5 46/48] x86: pmc_atom: Register power-off handler with kernel power-off handler Date: Thu, 6 Nov 2014 08:43:30 -0800 Message-Id: <1415292213-28652-47-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415292213-28652-1-git-send-email-linux@roeck-us.net> References: <1415292213-28652-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-CTCH-PVer: 0000001 X-CTCH-Spam: Unknown X-CTCH-VOD: Unknown X-CTCH-Flags: 0 X-CTCH-RefID: str=0001.0A020201.545BA5B0.01CD, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-Score: 0.001 X-CTCH-ScoreCust: 0.000 X-CTCH-Rules: C_4847, X-CTCH-SenderID: linux@roeck-us.net X-CTCH-SenderID-Flags: 0 X-CTCH-SenderID-TotalMessages: 266 X-CTCH-SenderID-TotalSpam: 0 X-CTCH-SenderID-TotalSuspected: 0 X-CTCH-SenderID-TotalConfirmed: 0 X-CTCH-SenderID-TotalBulk: 0 X-CTCH-SenderID-TotalVirus: 0 X-CTCH-SenderID-TotalRecipients: 0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: mailgid no entry from get_relayhosts_entry X-Source: X-Source-Args: X-Source-Dir: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Register with kernel power-off handler instead of setting pm_power_off directly. Register with low priority 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 Acked-by: Thomas Gleixner Signed-off-by: Guenter Roeck --- v5: - Rebase to v3.18-rc3 v4: - No change 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 - Use dev_warn instead of dev_err arch/x86/kernel/pmc_atom.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c index 0ee5025e..acb4e78 100644 --- a/arch/x86/kernel/pmc_atom.c +++ b/arch/x86/kernel/pmc_atom.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -92,7 +93,7 @@ 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 void pmc_power_off(struct power_off_handler_block *this) { u16 pm1_cnt_port; u32 pm1_cnt_value; @@ -109,6 +110,11 @@ static void pmc_power_off(void) outl(pm1_cnt_value, pm1_cnt_port); } +static struct power_off_handler_block pmc_power_off_hb = { + .handler = pmc_power_off, + .priority = POWER_OFF_PRIORITY_LOW, +}; + static void pmc_hw_reg_setup(struct pmc_dev *pmc) { /* @@ -252,8 +258,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_power_off_handler(&pmc_power_off_hb); + if (ret) + dev_warn(&pdev->dev, + "Failed to install power-off handler\n"); + } pci_read_config_dword(pdev, PMC_BASE_ADDR_OFFSET, &pmc->base_addr); pmc->base_addr &= PMC_BASE_ADDR_MASK;