From patchwork Mon Jan 30 17:15:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9545743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2160D604A8 for ; Mon, 30 Jan 2017 17:15:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3AED27F7F for ; Mon, 30 Jan 2017 17:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E86772811E; Mon, 30 Jan 2017 17:15:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D17827F7F for ; Mon, 30 Jan 2017 17:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753824AbdA3RPQ (ORCPT ); Mon, 30 Jan 2017 12:15:16 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34521 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172AbdA3RPN (ORCPT ); Mon, 30 Jan 2017 12:15:13 -0500 Received: by mail-wm0-f66.google.com with SMTP id c85so78376582wmi.1; Mon, 30 Jan 2017 09:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NilG/tngOVTWg48uqVl5+syiMG/uy8ktJt/ScbDUf/Y=; b=TwDKQf/emZFYfOnsSIKSkRL3gp5qEMm779KJFDBkA5tGyibcfRjOK7t1vMQKTOiz7e 3dQH+6pTzXxh4vSSxiPI+TbEsaLVn4tUBPyZ7SH3uSWT+4CU74/VIQNQY+1royl9jw3R Tr7E8H1q3dLtcaTeLxRuVCcPvxIanSp6mlhDgsyZKpS/zycf0svygqaxiYDI3Bbj7EEJ oEiR3PQNshRyrGHAcFGYWb1nilgA/sp0CPFkwMmyEz0Hi1V3qA+nwBE7O/+3CHsZp+Kk 0TJiFHR+jU4lVA/LE4CgUdMARnSZYsAFwIT2hgEAYB35hUxLZpiHloetzQgSAqWoLWvN PQbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NilG/tngOVTWg48uqVl5+syiMG/uy8ktJt/ScbDUf/Y=; b=swMfihAr8wpymoMDj4aMyZqW5m+scq0zDpvOTsw5k8IG36Ob6djI/uF9yleUPPD4BE w+ra+q+s75eUcs8l8+cx/LlJA3VY4oAUR4/EKoFaXGY7FoJXKa48+bDoue+c48hX1ZgC 0UuNdG5wN0wREP6cW1du6n7Wxe2J5EgA7UbftsAdfzOvuP57r7HsuJjxWsxFsYo8mThj cgk8d1NS2qfvRoYQMw9oAm6XSQt3bBdnYvkzEq7kKj49majrLJZjbMV+13fsUesxvTFf jz80xu3ihn5Li6JgVBiyJxZ7Bn4z7oC/hxtrS5fLcS7/4zB5QWY1NBdX0Yg2sZ5BIpfx aosA== X-Gm-Message-State: AIkVDXLAJRG1iIk7ouYxQdpCQuR455AkkhWU9H8OPA99FJX8kiezePVKogfdYlxje6I+LA== X-Received: by 10.28.45.213 with SMTP id t204mr12601696wmt.113.1485796512409; Mon, 30 Jan 2017 09:15:12 -0800 (PST) Received: from localhost (port-6519.pppoe.wtnet.de. [84.46.25.144]) by smtp.gmail.com with ESMTPSA id c9sm19774163wmi.16.2017.01.30.09.15.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jan 2017 09:15:11 -0800 (PST) From: Thierry Reding To: Linus Torvalds , Greg Kroah-Hartman , "Rafael J . Wysocki" , Pavel Machek Cc: Sebastian Reichel , Guenter Roeck , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 2/3] kernel: Wire up system power framework Date: Mon, 30 Jan 2017 18:15:05 +0100 Message-Id: <20170130171506.3527-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170130171506.3527-1-thierry.reding@gmail.com> References: <20170130171506.3527-1-thierry.reding@gmail.com> 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 From: Thierry Reding Instead of relying on the globally defined pm_power_off_prepare() and pm_power_off() function pointers, use the equivalent global functions from the system-power framework. The system-power framework implements a fallback that relies on these global functions in case no system power chips have been registered. Signed-off-by: Thierry Reding --- kernel/reboot.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index bd30a973fe94..ea075e285832 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -15,6 +15,7 @@ #include #include #include +#include #include /* @@ -257,8 +258,7 @@ EXPORT_SYMBOL_GPL(kernel_halt); void kernel_power_off(void) { kernel_shutdown_prepare(SYSTEM_POWER_OFF); - if (pm_power_off_prepare) - pm_power_off_prepare(); + system_power_off_prepare(); migrate_to_reboot_cpu(); syscore_shutdown(); pr_emerg("Power down\n"); @@ -305,10 +305,11 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, if (ret) return ret; - /* Instead of trying to make the power_off code look like - * halt when pm_power_off is not set do it the easy way. + /* + * Instead of trying to make the power_off code look like halt when + * power off is not supported do it the easy way. */ - if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) + if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !system_can_power_off()) cmd = LINUX_REBOOT_CMD_HALT; mutex_lock(&reboot_mutex);