From patchwork Mon Oct 27 15:55:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 5162441 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 8B04BC11AC for ; Mon, 27 Oct 2014 15:58:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA260202B8 for ; Mon, 27 Oct 2014 15:58:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF1C120254 for ; Mon, 27 Oct 2014 15:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752176AbaJ0P6V (ORCPT ); Mon, 27 Oct 2014 11:58:21 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:50345 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753407AbaJ0P5y (ORCPT ); Mon, 27 Oct 2014 11:57:54 -0400 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=+6coFNvsbXQIIoc3EBPeJ//kR7c4nKEfv0ujDvD5Meo=; b=MgyRUQFRmraqcn/2vvQ6LNlw6pkUW7+Dp8cSqKnlQL39mu7e17xLh7rqZC1Jb8grjsYIefKeWHdUCtW+sCA0sg4D+7F0E1xwSL1Rii3dnvzdwcu+xLLvW3MiMTqIaXKonb5s1iLFQI4/qVDIv0Va884lYgTz05FWZgGKz1mmxVE=; Received: from mailnull by bh-25.webhostbox.net with sa-checked (Exim 4.82) (envelope-from ) id 1Ximg5-000dfT-R8 for linux-pm@vger.kernel.org; Mon, 27 Oct 2014 15:57:54 +0000 Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:54078 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.82) (envelope-from ) id 1Ximg4-000dec-FW; Mon, 27 Oct 2014 15:57:52 +0000 From: Guenter Roeck To: linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, Guenter Roeck , Matt Fleming , linux-efi@vger.kernel.org Subject: [PATCH v3 46/47] efi: Register power-off handler with kernel power-off handler Date: Mon, 27 Oct 2014 08:55:53 -0700 Message-Id: <1414425354-10359-47-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414425354-10359-1-git-send-email-linux@roeck-us.net> References: <1414425354-10359-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.3 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.0A020209.544E6B81.02F3, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-Score: 0.000 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: 264 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 since the efi code states that this is a power-off handler of last resort. Cc: Matt Fleming Acked-by: Matt Fleming Acked-by: Mark Salter Signed-off-by: Guenter Roeck --- 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 drivers/firmware/efi/reboot.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c index 9c59d1c..df0ceb9 100644 --- a/drivers/firmware/efi/reboot.c +++ b/drivers/firmware/efi/reboot.c @@ -3,6 +3,8 @@ * Copyright (c) 2014 Red Hat, Inc., Mark Salter */ #include +#include +#include #include int efi_reboot_quirk_mode = -1; @@ -38,19 +40,32 @@ bool __weak efi_poweroff_required(void) return false; } -static void efi_power_off(void) +static int efi_power_off(struct notifier_block *this, + unsigned long unused1, void *unused2) { efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); + + return NOTIFY_DONE; } +static struct notifier_block efi_power_off_nb = { + .notifier_call = efi_power_off, + .priority = POWER_OFF_PRIORITY_LOW, +}; + static int __init efi_shutdown_init(void) { + int ret = 0; + if (!efi_enabled(EFI_RUNTIME_SERVICES)) return -ENODEV; - if (efi_poweroff_required()) - pm_power_off = efi_power_off; + if (efi_poweroff_required()) { + ret = register_power_off_handler(&efi_power_off_nb); + if (ret) + pr_err("efi: Failed to register power-off handler\n"); + } - return 0; + return ret; } late_initcall(efi_shutdown_init);