From patchwork Wed Oct 27 21:16:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A691C19772 for ; Wed, 27 Oct 2021 21:18:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A67AD610FF for ; Wed, 27 Oct 2021 21:18:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A67AD610FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217214.377126 (Exim 4.92) (envelope-from ) id 1mfqJ7-00018a-9b; Wed, 27 Oct 2021 21:18:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217214.377126; Wed, 27 Oct 2021 21:18:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJ7-00018T-4T; Wed, 27 Oct 2021 21:18:01 +0000 Received: by outflank-mailman (input) for mailman id 217214; Wed, 27 Oct 2021 21:18:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJ6-0000sJ-8E for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:00 +0000 Received: from mail-lf1-x135.google.com (unknown [2a00:1450:4864:20::135]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bce1809a-144c-4b61-baea-055b3065fd00; Wed, 27 Oct 2021 21:17:55 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id l13so8987907lfg.6 for ; Wed, 27 Oct 2021 14:17:55 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:17:54 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bce1809a-144c-4b61-baea-055b3065fd00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wTvK5kO0FUcGnxCyVmK+GKrZNfPhZFNt57h0QWat/qo=; b=ZqOcoukrajwjG0ttfhDDamRtFbZgEiaFrpLAXOR7yQBANjFcnFFXOdYomTLQXBItFZ 6fsN0Gio8AJkokF0BnxXjlaJgq1CP0FdapZULDkVLC880wSvbduG3ij7wOgm65yyZHfb /MEYtYvu3WnHHl8p/60KRwD6dDnaqpWEGWZELHlL42ECg0BG3xSUbLaFXBGJ8l5anvCb nmVZ+GAgVHAauuOzz3lnhLFItX2Cbpx7VOJRMQdOkh5vDNRTVY6CLlgAa8SfZ45DmHqN vHhGZ7nhCEzJCcCT39f5nwGqOjoorbJierMaHF5OrWAM3eykGjghB0x8WQgbnqhmKJ6c aKlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wTvK5kO0FUcGnxCyVmK+GKrZNfPhZFNt57h0QWat/qo=; b=MIyTjnIccPfpARTs5S90w7eSfTcVG97Wl1FCYn1foRqK1bM3rJxz8MNBBFJt5qIOFz JvNNj8UN3W57LU5sLm6RaT7n2+khgZ7SoylSHQWk/5TkEqKxPR+hZbFn+7OIuUkcaRmE uB0BL9uBmZzMY+aAbUljOB46JF0TaDhdfb7eT/VqlYCnVuq5IG3l20zr7maxOVSqQU/+ ymr5GstanfdYpB3AD3SJnD57nZipAL/lQLeHdkVNH9sQIcG3Izeg8CcO63srO4t2OiGb /ECsspTdje2lLOidOQCRglJ313Zk4UYMhpGkWOSPWEh3ELzEpBqD7cugUh7b2q9Fettd nf6w== X-Gm-Message-State: AOAM530/VMHBivxVEjajZTXAgviYAAmdkRbZon9ycXjEytv44oN+bTaR OHoJeYkbl9dDgLPyqEyHN48= X-Google-Smtp-Source: ABdhPJwuKOrqeex0uVzCe5G2iTS4vzkdpHKtiR+d5t3erf2uXeC/mCcisVEMxQQhKVgKCWNS6EmCsw== X-Received: by 2002:a05:6512:38d0:: with SMTP id p16mr80629lft.483.1635369474451; Wed, 27 Oct 2021 14:17:54 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 01/45] notifier: Remove extern annotation from function prototypes Date: Thu, 28 Oct 2021 00:16:31 +0300 Message-Id: <20211027211715.12671-2-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 There is no need to annotate function prototypes with 'extern', it makes code less readable. Remove unnecessary annotations from . Signed-off-by: Dmitry Osipenko --- include/linux/notifier.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 87069b8459af..4b80a815b666 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -90,7 +90,7 @@ struct srcu_notifier_head { } while (0) /* srcu_notifier_heads must be cleaned up dynamically */ -extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); +void srcu_init_notifier_head(struct srcu_notifier_head *nh); #define srcu_cleanup_notifier_head(name) \ cleanup_srcu_struct(&(name)->srcu); @@ -141,36 +141,36 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); #ifdef __KERNEL__ -extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh, +int atomic_notifier_chain_register(struct atomic_notifier_head *nh, struct notifier_block *nb); -extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh, +int blocking_notifier_chain_register(struct blocking_notifier_head *nh, struct notifier_block *nb); -extern int raw_notifier_chain_register(struct raw_notifier_head *nh, +int raw_notifier_chain_register(struct raw_notifier_head *nh, struct notifier_block *nb); -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh, +int srcu_notifier_chain_register(struct srcu_notifier_head *nh, struct notifier_block *nb); -extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, +int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, struct notifier_block *nb); -extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, +int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, struct notifier_block *nb); -extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh, +int raw_notifier_chain_unregister(struct raw_notifier_head *nh, struct notifier_block *nb); -extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh, +int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh, struct notifier_block *nb); -extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh, +int atomic_notifier_call_chain(struct atomic_notifier_head *nh, unsigned long val, void *v); -extern int blocking_notifier_call_chain(struct blocking_notifier_head *nh, +int blocking_notifier_call_chain(struct blocking_notifier_head *nh, unsigned long val, void *v); -extern int raw_notifier_call_chain(struct raw_notifier_head *nh, +int raw_notifier_call_chain(struct raw_notifier_head *nh, unsigned long val, void *v); -extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh, +int srcu_notifier_call_chain(struct srcu_notifier_head *nh, unsigned long val, void *v); -extern int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, +int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, unsigned long val_up, unsigned long val_down, void *v); -extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, +int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, unsigned long val_up, unsigned long val_down, void *v); #define NOTIFY_DONE 0x0000 /* Don't care */ From patchwork Wed Oct 27 21:16:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2895BC433EF for ; Wed, 27 Oct 2021 21:18:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEBFF6112F for ; Wed, 27 Oct 2021 21:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CEBFF6112F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217215.377137 (Exim 4.92) (envelope-from ) id 1mfqJC-0001Ti-L1; Wed, 27 Oct 2021 21:18:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217215.377137; Wed, 27 Oct 2021 21:18:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJC-0001TX-Gg; Wed, 27 Oct 2021 21:18:06 +0000 Received: by outflank-mailman (input) for mailman id 217215; Wed, 27 Oct 2021 21:18:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJB-0000sJ-8S for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:05 +0000 Received: from mail-lf1-x132.google.com (unknown [2a00:1450:4864:20::132]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 69deffbd-45dd-4bf9-95f2-79beb43a3f9b; Wed, 27 Oct 2021 21:17:57 +0000 (UTC) Received: by mail-lf1-x132.google.com with SMTP id u11so9038212lfs.1 for ; Wed, 27 Oct 2021 14:17:57 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:17:56 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 69deffbd-45dd-4bf9-95f2-79beb43a3f9b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4OzDm5Q6AH2k+PTLkkEFou1ZT7VKkxRv+kE3WUpAOf8=; b=UQ/1aCiL3zbAzp7+64ENWMFEP+bdpmbq+KH3NTi7hX2kN+fFVrO8S32QtOPwQfMxxS B4dmeXUf/BzuJhhzqG8VnHaUgY25bdcGnTrwxpDILzBPa9fYkIseD/FA90YqGQJP6GXZ PaIGof4Fo+LwMmngjVzKDktvBb6N6F/Oq7yFljDHwAcSrBHnke6Ooi6gGMrQtQGLY6gt DkEqtfwDzQkavBqxwLa+DWQ8L/Pn42h6a2KO1Y5kAXNNdt6/bA2gpVm767XfMu2cU+ZD 8088MqymRILm5tETDMubwXrrDQl/PbR2eeFdMLFjmwWobAMprcx5uRuWc88/LBbNkX13 zK7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4OzDm5Q6AH2k+PTLkkEFou1ZT7VKkxRv+kE3WUpAOf8=; b=7j3IyY68TzNv5tdjXXE7+W/Y4efqcM8OnXKuAUH0Z8HvLDEFMXzNPu6dQHlZM2Bq4k 2XMmCYgN/gKzXFUHPrldfDTGKZfnHbhr9hkuOvMqN6WIf3IGmqiT+weFsFjAhHr/EKvs aOuAfgf/EAYRMfyK87S/XfsSkK+h5vEafjKRWEkI16n5T+j5UiJKjopd0y12IxjN1bFc LNFFymRqB48awzR9T/MqGxj019M0ARI67Y+vGa970a8Y8np89rjBXcDs/o8h6tX1eCAE vb28fJJPMuPUFj7NwgvIUhcP9w+C/CrzveBO8k0Gm2p1IaOmQNekmjhxRvAbuLRMrG8T ptBg== X-Gm-Message-State: AOAM532EQOPWywgYQYpDqQupjgGQhMZrohxfLb9FnyAqGCRXduFX+OPy jaESA1jIXeeXUVrpjp2ZHH0= X-Google-Smtp-Source: ABdhPJyeN/kGQE6WfHsDgri2jvM3EdB0FfWjlbwbrCss0fAIUEYOe9Prwt7QavBIliqBuOmpkw05Og== X-Received: by 2002:a05:6512:3f04:: with SMTP id y4mr128266lfa.180.1635369476308; Wed, 27 Oct 2021 14:17:56 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 02/45] notifier: Add blocking_notifier_call_chain_empty() Date: Thu, 28 Oct 2021 00:16:32 +0300 Message-Id: <20211027211715.12671-3-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Add blocking_notifier_call_chain_empty() that returns true if call chain is empty. Signed-off-by: Dmitry Osipenko --- include/linux/notifier.h | 2 ++ kernel/notifier.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 4b80a815b666..054271e9cb20 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh, int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, unsigned long val_up, unsigned long val_down, void *v); +bool blocking_notifier_call_chain_empty(struct blocking_notifier_head *nh); + #define NOTIFY_DONE 0x0000 /* Don't care */ #define NOTIFY_OK 0x0001 /* Suits me */ #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ diff --git a/kernel/notifier.c b/kernel/notifier.c index b8251dc0bc0f..1f7ba8988b90 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, } EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); +/** + * blocking_notifier_call_chain_empty - Check whether notifier chain is empty + * @nh: Pointer to head of the blocking notifier chain + * + * Checks whether notifier chain is empty. + * + * Returns true is notifier chain is empty, false otherwise. + */ +bool blocking_notifier_call_chain_empty(struct blocking_notifier_head *nh) +{ + return !rcu_access_pointer(nh->head); +} +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_empty); + /* * Raw notifier chain routines. There is no protection; * the caller must provide it. Use at your own risk! From patchwork Wed Oct 27 21:16:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAA81C4321E for ; Wed, 27 Oct 2021 21:18:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73D5B610CF for ; Wed, 27 Oct 2021 21:18:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 73D5B610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217216.377148 (Exim 4.92) (envelope-from ) id 1mfqJH-0001q1-0i; Wed, 27 Oct 2021 21:18:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217216.377148; Wed, 27 Oct 2021 21:18:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJG-0001po-Sz; Wed, 27 Oct 2021 21:18:10 +0000 Received: by outflank-mailman (input) for mailman id 217216; Wed, 27 Oct 2021 21:18:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJG-0000sJ-8f for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:10 +0000 Received: from mail-lf1-x12d.google.com (unknown [2a00:1450:4864:20::12d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 92f7f69c-ba4d-45e9-915e-e2b0259386cd; Wed, 27 Oct 2021 21:17:59 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id bq11so8953119lfb.10 for ; Wed, 27 Oct 2021 14:17:59 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:17:57 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 92f7f69c-ba4d-45e9-915e-e2b0259386cd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gfPQe0zgS4I4UWFZNFBbY1KeZFawP+pEpuBLVF6wdKM=; b=IF53pE4MG8dtqJfDztqJu8/A7a/y14/j36v2nKdiMw6iu4DWmrRW8MOeE8LURQLXaK Ga0+xYwPRFyxojC/znNrOvpLGs+k6KHlhVWadULFKWtX+mXFusF6mHh4CLs+vcnkJVbI sCT8nKeVlZGK2TnNZ10Uo/TFQPsaFWopDEGJma2V9OokstL1aGUJunbAvrHKFFxOtEwg lD8/h9mw7UJrhz8Lza29Xoci0CHBwnwZJdD56IRSRRGiIs4vKcta6w27872hpSmyCu02 ZBL1gjD87s9mbzpJUGm1Sbte3r8qhTN12pgeySe/LAcZyKJ0wXtrJhOtFLQB3UvQJ2Q1 ctBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gfPQe0zgS4I4UWFZNFBbY1KeZFawP+pEpuBLVF6wdKM=; b=64LdfLFdyNs9FIPPEP7qdkbVqEL93mZAkB9Tc8XfpIuWXw+Lydsq4mT3ttKfHdDIAY 66A3gSoTk3+P98ft+5eBhowddOwiahM8qwr0wjdftq6FuH6fLEBy+o2f+jFI4RyY7g5H Jucn37Aj6V5gTLwWHr6XASacoboBrnxJ5iNQlUf1pLqEdhGHLvaJ7Z1bydOGpCx53D/m E96VXOb2jM7emsXlvF+T/fsjexp6Hn1/7TcfpmqihZE6Vg5JmF13rbIpCkzkycKi05kw kYoMYxO8s+bimz5v0gs+WsuWiJO2bQI6lJ9CbMMN7saWgR/pHM72MiogG5k2d7pLVGJ3 zMTQ== X-Gm-Message-State: AOAM531v933gp1gYyJVSW4wA4r336AucWFC+dISX9Z3ldhyRuHtaH12k akfYXo7Z0oWrtaMVrTVna5o= X-Google-Smtp-Source: ABdhPJxkIyEtMiQViKWR5fwy6fiT3tpzf12+F4/RJZJ4BQVHBt5yXcPBTwu2lq74yYNLjaS3GsmWQQ== X-Received: by 2002:a05:6512:1095:: with SMTP id j21mr130850lfg.274.1635369478293; Wed, 27 Oct 2021 14:17:58 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 03/45] notifier: Add atomic/blocking_notifier_has_unique_priority() Date: Thu, 28 Oct 2021 00:16:33 +0300 Message-Id: <20211027211715.12671-4-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Add atomic/blocking_notifier_has_unique_priority() helpers which return true if given handler has unique priority. Signed-off-by: Dmitry Osipenko --- include/linux/notifier.h | 5 +++ kernel/notifier.c | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 054271e9cb20..b782ce100022 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -175,6 +175,11 @@ int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, bool blocking_notifier_call_chain_empty(struct blocking_notifier_head *nh); +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh, + struct notifier_block *nb); +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh, + struct notifier_block *nb); + #define NOTIFY_DONE 0x0000 /* Don't care */ #define NOTIFY_OK 0x0001 /* Suits me */ #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ diff --git a/kernel/notifier.c b/kernel/notifier.c index 1f7ba8988b90..cf0e1c4bd364 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -203,6 +203,40 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh, EXPORT_SYMBOL_GPL(atomic_notifier_call_chain); NOKPROBE_SYMBOL(atomic_notifier_call_chain); +/** + * atomic_notifier_has_unique_priority - Checks whether notifier's priority is unique + * @nh: Pointer to head of the atomic notifier chain + * @n: Entry in notifier chain to check + * + * Checks whether there is another notifier in the chain with the same priority. + * Must be called in process context. + * + * Returns true if priority is unique, false otherwise. + */ +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh, + struct notifier_block *n) +{ + struct notifier_block **nl = &nh->head; + unsigned long flags; + bool ret = true; + + spin_lock_irqsave(&nh->lock, flags); + + while ((*nl) != NULL && (*nl)->priority >= n->priority) { + if ((*nl)->priority == n->priority && (*nl) != n) { + ret = false; + break; + } + + nl = &((*nl)->next); + } + + spin_unlock_irqrestore(&nh->lock, flags); + + return ret; +} +EXPORT_SYMBOL_GPL(atomic_notifier_has_unique_priority); + /* * Blocking notifier chain routines. All access to the chain is * synchronized by an rwsem. @@ -336,6 +370,46 @@ bool blocking_notifier_call_chain_empty(struct blocking_notifier_head *nh) } EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_empty); +/** + * blocking_notifier_has_unique_priority - Checks whether notifier's priority is unique + * @nh: Pointer to head of the blocking notifier chain + * @n: Entry in notifier chain to check + * + * Checks whether there is another notifier in the chain with the same priority. + * Must be called in process context. + * + * Returns true if priority is unique, false otherwise. + */ +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh, + struct notifier_block *n) +{ + struct notifier_block **nl = &nh->head; + bool ret = true; + + /* + * This code gets used during boot-up, when task switching is + * not yet working and interrupts must remain disabled. At + * such times we must not call down_write(). + */ + if (system_state != SYSTEM_BOOTING) + down_write(&nh->rwsem); + + while ((*nl) != NULL && (*nl)->priority >= n->priority) { + if ((*nl)->priority == n->priority && (*nl) != n) { + ret = false; + break; + } + + nl = &((*nl)->next); + } + + if (system_state != SYSTEM_BOOTING) + up_write(&nh->rwsem); + + return ret; +} +EXPORT_SYMBOL_GPL(blocking_notifier_has_unique_priority); + /* * Raw notifier chain routines. There is no protection; * the caller must provide it. Use at your own risk! From patchwork Wed Oct 27 21:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69516C4167B for ; Wed, 27 Oct 2021 21:18:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3961A6112E for ; Wed, 27 Oct 2021 21:18:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3961A6112E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217217.377159 (Exim 4.92) (envelope-from ) id 1mfqJM-0002Jq-Av; Wed, 27 Oct 2021 21:18:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217217.377159; Wed, 27 Oct 2021 21:18:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJM-0002Iz-6D; Wed, 27 Oct 2021 21:18:16 +0000 Received: by outflank-mailman (input) for mailman id 217217; Wed, 27 Oct 2021 21:18:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJL-0000sJ-8f for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:15 +0000 Received: from mail-lj1-x22e.google.com (unknown [2a00:1450:4864:20::22e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7ba8bc2f-320b-42ee-a31a-b7b5adb59c29; Wed, 27 Oct 2021 21:18:01 +0000 (UTC) Received: by mail-lj1-x22e.google.com with SMTP id 17so3837676ljq.0 for ; Wed, 27 Oct 2021 14:18:01 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:17:59 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7ba8bc2f-320b-42ee-a31a-b7b5adb59c29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TugVlbRXpFiQ9yttEJ2CYhwYKdBA8PSz6pBjqNjtqe8=; b=LxdZEWQx3suPqkadhSlrIg8Y/wBbCgZ19oaPbtBfHJRBGXgu8OvRhmKtGBeiAtGOi+ liDoShgJoGfChatXJvVHlGfhJqZTZfaSa614IMYrTFjYDb/peXO5oxQ8SJntz+ROu8lH ob1M7/DUPmtXRrZcD8cMolSz0IhB48FDFGrv8rmurlnFUtz5GHTwT3bfswp5rSRPgw7Q Bzriun3on2U4+nPpGH/7v8uRLlN52ALrwjKmwn0fNW7IfodPJ5+z4OBz44Q0tz7qr3AI hQkqoobZyhuG5/zdS6+8c5M7BaM8ouPopuZJKxbxjokH3QVc4vnRaK15kTyz9igV7eYm 7uUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TugVlbRXpFiQ9yttEJ2CYhwYKdBA8PSz6pBjqNjtqe8=; b=IXqTipDTIzwpDTqhy+sJ2IQ63aPFevIucceFggjYkAVfMl3MI6aNEqDCQfnsfxrg2s 6VnoCLe5tfoxmzSy7XljZfqR/ilFIOpVD0D1LfIa2zHN6T9LSq79Mx8g/yvcsD2ua433 Fvk1iG3ZgfmxkpWG4Jc0M23rechwMW+3zslGdsEhvJd9Y6GtTQQ4nlEsNgIrReITu6+f AiiMFoud53eEVERoPpF0MunLXXFE/ckYHwklRyCrvUpcFM2qe0brRfhX8psi/4YxpI5M v0bjbuGv0rszvopx/HTYHD9r0jRXGNb/yora4p2RkcD3s9gijk469dyy/TaZuYp26WYI B9Zg== X-Gm-Message-State: AOAM530g3PbQi30kHQQWbJVfy4MbDUuh6VD4iKoe3XmfJJoPCb6vBRmo 3uhPgOnOkAvij/g1YEC/UD8= X-Google-Smtp-Source: ABdhPJzuqmviV3vutEjHAVvh6ry+9Hwrmd//Nm2QPeCY1TzVEUwjdrrEOpdr1ds5exnt/bZhRUUrMg== X-Received: by 2002:a2e:a5c8:: with SMTP id n8mr301030ljp.307.1635369480150; Wed, 27 Oct 2021 14:18:00 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 04/45] reboot: Correct typo in a comment Date: Thu, 28 Oct 2021 00:16:34 +0300 Message-Id: <20211027211715.12671-5-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Correct s/implemenations/implementations/ in . Signed-off-by: Dmitry Osipenko --- include/linux/reboot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index af907a3d68d1..7c288013a3ca 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -63,7 +63,7 @@ struct pt_regs; extern void machine_crash_shutdown(struct pt_regs *); /* - * Architecture independent implemenations of sys_reboot commands. + * Architecture independent implementations of sys_reboot commands. */ extern void kernel_restart_prepare(char *cmd); From patchwork Wed Oct 27 21:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64076C433FE for ; Wed, 27 Oct 2021 21:18:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BD4660E73 for ; Wed, 27 Oct 2021 21:18:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1BD4660E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217218.377170 (Exim 4.92) (envelope-from ) id 1mfqJR-0002th-Kx; Wed, 27 Oct 2021 21:18:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217218.377170; Wed, 27 Oct 2021 21:18:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJR-0002tQ-Gh; Wed, 27 Oct 2021 21:18:21 +0000 Received: by outflank-mailman (input) for mailman id 217218; Wed, 27 Oct 2021 21:18:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJQ-0000sJ-8j for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:20 +0000 Received: from mail-lf1-x133.google.com (unknown [2a00:1450:4864:20::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2e7b98de-8165-4f45-971f-8de142cf3589; Wed, 27 Oct 2021 21:18:03 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id bp15so9011871lfb.4 for ; Wed, 27 Oct 2021 14:18:03 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:01 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2e7b98de-8165-4f45-971f-8de142cf3589 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O+IvQoJf2OjzCPAk90L+IlIvsTQGqRsS8A3mVG9thss=; b=BbS8+/zxVJ00rr3ixtYTd3bTdxqjkUjnBr55DaOxzJArvyNX4521PAqPigYX/BjB1N aGylVDFiYrs5wRaWuZx6L52it/PPywema7yDnahBHenwiuFnc4S3m//ivsOGtXuUlPNB ubXOhenNVEu1KXB2mXMptIWVwaeJRf3hxW3c8R68HPPg3pjoH3MM7xhUxuphpty83aFx DGHamMHIXY7/zgP3wsKkRhZ7yEHgmahY/byikn8BiZjEw2DWUQkjcB5nYo+Xgh+eH8p4 oVpJycq4ZWi1GYj36y1/HBYlXfcjUxN5WpbpwFTT0cF/PRko7dGul5P66XpFeKCAINSY 8XVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O+IvQoJf2OjzCPAk90L+IlIvsTQGqRsS8A3mVG9thss=; b=UrfxMbjD6aQoXDBgVtOUbnWc7vAvnH2w3/rUs7LcfMphW1ZXGXJyq9lh1MVz6uVbqk SGlM5lcxzse7UHKOMm1smaDj1Mmy0ii9G+lGn3AcanYrIEwnI+Dx4DL3ec3JfKiuGThH dFdt+0Syw8B2psNEoijmQwaXBomClChOXwE/vbU8k2Zz/ZMOLo4uQ71HM0DwbTwTlkls nd1hH9CoAST9DZT0M+0DLvJmmPNlPndJWSwj9L+rWm/zBJ+mddO9vjXWbmV4rXx8DLXH 7c1EmoE/gRR9iaZ8M7Nu6sCUIE99+CVu7luE27o6kuFUtRCUsUdu950raQWn/TMZWWGK 2hLQ== X-Gm-Message-State: AOAM531ZoPascVNJv1Xnz4IO88Octe6frNZVLO+3PmAk/2JUHFPWsjyw 3nGTLCCQPJFVES/oEGPZAOo= X-Google-Smtp-Source: ABdhPJxyJaCNELbykyJ8mI+u0lU4wtjMFWua0Lm4EEmjlSiKb32hiTjDEQ+OHhGC/feOlGuy6qCfSA== X-Received: by 2002:ac2:4285:: with SMTP id m5mr140041lfh.86.1635369481970; Wed, 27 Oct 2021 14:18:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 05/45] reboot: Warn if restart handler has duplicated priority Date: Thu, 28 Oct 2021 00:16:35 +0300 Message-Id: <20211027211715.12671-6-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Add sanity check which ensures that there are no two restart handlers registered with the same priority. Normally it's a direct sign of a problem if two handlers use the same priority. Signed-off-by: Dmitry Osipenko --- kernel/reboot.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index efb40d095d1e..d39e599c3c99 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -182,7 +182,20 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list); */ int register_restart_handler(struct notifier_block *nb) { - return atomic_notifier_chain_register(&restart_handler_list, nb); + int ret; + + ret = atomic_notifier_chain_register(&restart_handler_list, nb); + if (ret) + return ret; + + /* + * Handler must have unique priority. Otherwise invocation order is + * determined by the registration order, which is presumed to be + * unreliable. + */ + WARN_ON(!atomic_notifier_has_unique_priority(&restart_handler_list, nb)); + + return 0; } EXPORT_SYMBOL(register_restart_handler); From patchwork Wed Oct 27 21:16:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CE26C4167D for ; Wed, 27 Oct 2021 21:18:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6B60610C7 for ; Wed, 27 Oct 2021 21:18:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6B60610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217223.377180 (Exim 4.92) (envelope-from ) id 1mfqJX-0003Sk-5a; Wed, 27 Oct 2021 21:18:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217223.377180; Wed, 27 Oct 2021 21:18:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJX-0003Sa-0W; Wed, 27 Oct 2021 21:18:27 +0000 Received: by outflank-mailman (input) for mailman id 217223; Wed, 27 Oct 2021 21:18:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJV-0000sJ-8v for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:25 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed0e3168-9c8e-4547-b3ab-80654ef25559; Wed, 27 Oct 2021 21:18:04 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id f3so803673lfu.12 for ; Wed, 27 Oct 2021 14:18:04 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:03 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ed0e3168-9c8e-4547-b3ab-80654ef25559 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iOJthmuPEC7IB5L8OM1uajmE3s/Ei+DiZXNIsEtdoSk=; b=M6DsUnX+Dqnnl5/0WkKsChXFOe/dRyATOHCL/N/d/DYRaMuFNhNXN2y8l/5KKDdvO8 HePUBv3ijZ6wA1hQMS8r/8Dy8p8fDstfsgPNvYzogEnoiN08aVSWSCzuevGifeB4Cbsl JU+F7xYiyB1f3JwKGti4sTNyf7tgTKcPyJdN2KeBPBno+Y11B21cmAzeN1UTCPeELLZl qo9vl+NLInil/J95xFZK38OdgQBYthlLceqQb/6Zg0gcqPneeFesfA544/Mc5a4V8TTa vBfOArxwV6NLDS9FtxVb4oHCbiHa9QgKi34nHbfFFiWQfKG+GQY4kpTfJykuXmLPssEZ NnyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iOJthmuPEC7IB5L8OM1uajmE3s/Ei+DiZXNIsEtdoSk=; b=v2Wu1pBzcuimhXiQpobWtfPQk1jmkCVHOFitT/T+vNyNgxEblaa05wvJxqwIEACx/c kWCPNkiUfpofFZ8AzXxfF1h9GgiZwIlHx7woH8y3b5mwakOLaOGgNgeifd1j4xjcqjyU hFi3faP/fl4NGm7Rb/HtWWZDIwHQ9ZGX60IUclnmsKfivqGZuRP42PdUaNZp3Um51oK4 tqYBUM+C7Rwy+y2w4KBtvNyxLLfHCYi3r4SnU5FFrmtPSdnl1SQ0OvA8fYqrvCl0hd7g 5Oy24C6s7ppuP/UNcg6a6zQdAhuPicPDZMfegF3KA14DpFoietjAM59eHz4+AQgTysZh WuGg== X-Gm-Message-State: AOAM532sWDDIKQt36CQ3TnAQ6ct21G3ht4iBnLlolyOyxUdF36n54XjA TwnCkHeHtO//ZgXQlW5pYas= X-Google-Smtp-Source: ABdhPJySbOm+27yOjORJjCzB1RrKvb62o79gukvdjDZzwYphfPzvlvqWgT3cY5UK3KGllNbg7CmL+w== X-Received: by 2002:a05:6512:344a:: with SMTP id j10mr74981lfr.653.1635369483872; Wed, 27 Oct 2021 14:18:03 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 06/45] reboot: Warn if unregister_restart_handler() fails Date: Thu, 28 Oct 2021 00:16:36 +0300 Message-Id: <20211027211715.12671-7-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Emit warning if unregister_restart_handler() fails since it never should fail. This will ease further API development by catching mistakes early. Signed-off-by: Dmitry Osipenko --- kernel/reboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index d39e599c3c99..291d44082f42 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler); */ int unregister_restart_handler(struct notifier_block *nb) { - return atomic_notifier_chain_unregister(&restart_handler_list, nb); + return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb)); } EXPORT_SYMBOL(unregister_restart_handler); From patchwork Wed Oct 27 21:16:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7792C4332F for ; Wed, 27 Oct 2021 21:18:39 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65384610FC for ; Wed, 27 Oct 2021 21:18:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 65384610FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217228.377192 (Exim 4.92) (envelope-from ) id 1mfqJb-00041M-DB; Wed, 27 Oct 2021 21:18:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217228.377192; Wed, 27 Oct 2021 21:18:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJb-00041E-9P; Wed, 27 Oct 2021 21:18:31 +0000 Received: by outflank-mailman (input) for mailman id 217228; Wed, 27 Oct 2021 21:18:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJa-0000sJ-92 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:30 +0000 Received: from mail-lj1-x22f.google.com (unknown [2a00:1450:4864:20::22f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9f7f8704-d885-405c-9c50-3b01bfd973f5; Wed, 27 Oct 2021 21:18:06 +0000 (UTC) Received: by mail-lj1-x22f.google.com with SMTP id n7so6988482ljp.5 for ; Wed, 27 Oct 2021 14:18:06 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:05 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9f7f8704-d885-405c-9c50-3b01bfd973f5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YMqE3plwxFsGF2jAAFpub/HIgtQoag7R/7s0kLQElmo=; b=FUIf1ArHmNaCMJZ4bSQxWbL5JCSm2CJKzXGlBqJrWaAR8tSPTufWS8xOyLSwSu1PM5 2liVJ/5r60CrtJJr5DfBlw1KykabxABPWMHDsuYjgXtr14EcQg2JUBTjbQBqUDOiqreb QGWgVclCqks9knb00wTu5MnkQu4fzkoUJI9+ACesDxpbb8YGJKMHlYbydkINuBcjzEjx IFIHDVdQgtIeC1A4mREDvIovPg1tG0nOTZB7ncUf8fLjV8foPKyZUn+53/McMAaFU2Ip XymrGCj037mcVReap7wcm8US/GqkUtNAHHKTZ6VwLbtZ8u26dh3C526wfrT0Bgbs2S/w m+/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YMqE3plwxFsGF2jAAFpub/HIgtQoag7R/7s0kLQElmo=; b=agydHyY3LtTwXzA4hAoSA7OCZXDaF4mqDR8dRXHztPFIo8PCdiPJhpL9vXlzY4HQMK hRdKi+cdnWzAnpr6obM3m5OSv0/Bfdu6bK+1F77eFZGKsFnrx/zKV+PoViPGNMMNa9Yw 6TgbES9p4XDwrYMF53H1R9e6f69wtBMyIYNmLqaJfwHP5UW0Nz0MP9FpPwjQX1Pe7Lrg 4UEcDjKPCzF+gom6GE2jaSliMvQkk4EuZBPfUobzRxvRsDhVCfNgZrPdKqxnUrKXZVn3 7uuhKJdEAantDviyVOdnM/nlquzDIKFoQbGw+xP80YYTAOh6ZbtzOt7eGpihjDtosA2f 0qzA== X-Gm-Message-State: AOAM531mZGPuHLVrhRYoZ3Cr2K/ovUhQx0vnGMFbZMmeNliaFe9QGePW AiqQArBoqyrgoGdg/iaevvM= X-Google-Smtp-Source: ABdhPJwf9klS71294z2BVTXZCugJ9JFGgS+3s6bIBq/C8DIXy9Ezc+U1oWDuHg++RtezU/Ib7TxqLQ== X-Received: by 2002:a2e:2f19:: with SMTP id v25mr310304ljv.281.1635369485711; Wed, 27 Oct 2021 14:18:05 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 07/45] reboot: Remove extern annotation from function prototypes Date: Thu, 28 Oct 2021 00:16:37 +0300 Message-Id: <20211027211715.12671-8-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 There is no need to annotate function prototypes with 'extern', it makes code less readable. Remove unnecessary annotations from . Signed-off-by: Dmitry Osipenko --- include/linux/reboot.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index 7c288013a3ca..b7fa25726323 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -40,36 +40,36 @@ extern int reboot_cpu; extern int reboot_force; -extern int register_reboot_notifier(struct notifier_block *); -extern int unregister_reboot_notifier(struct notifier_block *); +int register_reboot_notifier(struct notifier_block *); +int unregister_reboot_notifier(struct notifier_block *); -extern int devm_register_reboot_notifier(struct device *, struct notifier_block *); +int devm_register_reboot_notifier(struct device *, struct notifier_block *); -extern int register_restart_handler(struct notifier_block *); -extern int unregister_restart_handler(struct notifier_block *); -extern void do_kernel_restart(char *cmd); +int register_restart_handler(struct notifier_block *); +int unregister_restart_handler(struct notifier_block *); +void do_kernel_restart(char *cmd); /* * Architecture-specific implementations of sys_reboot commands. */ -extern void migrate_to_reboot_cpu(void); -extern void machine_restart(char *cmd); -extern void machine_halt(void); -extern void machine_power_off(void); +void migrate_to_reboot_cpu(void); +void machine_restart(char *cmd); +void machine_halt(void); +void machine_power_off(void); -extern void machine_shutdown(void); +void machine_shutdown(void); struct pt_regs; -extern void machine_crash_shutdown(struct pt_regs *); +void machine_crash_shutdown(struct pt_regs *); /* * Architecture independent implementations of sys_reboot commands. */ -extern void kernel_restart_prepare(char *cmd); -extern void kernel_restart(char *cmd); -extern void kernel_halt(void); -extern void kernel_power_off(void); +void kernel_restart_prepare(char *cmd); +void kernel_restart(char *cmd); +void kernel_halt(void); +void kernel_power_off(void); extern int C_A_D; /* for sysctl */ void ctrl_alt_del(void); @@ -77,15 +77,15 @@ void ctrl_alt_del(void); #define POWEROFF_CMD_PATH_LEN 256 extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN]; -extern void orderly_poweroff(bool force); -extern void orderly_reboot(void); +void orderly_poweroff(bool force); +void orderly_reboot(void); void hw_protection_shutdown(const char *reason, int ms_until_forced); /* * Emergency restart, callable from an interrupt handler. */ -extern void emergency_restart(void); +void emergency_restart(void); #include #endif /* _LINUX_REBOOT_H */ From patchwork Wed Oct 27 21:16:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39172C433FE for ; Wed, 27 Oct 2021 21:18:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E052D610C7 for ; Wed, 27 Oct 2021 21:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E052D610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217233.377214 (Exim 4.92) (envelope-from ) id 1mfqJm-00059H-11; Wed, 27 Oct 2021 21:18:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217233.377214; Wed, 27 Oct 2021 21:18:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJl-000598-Tq; Wed, 27 Oct 2021 21:18:41 +0000 Received: by outflank-mailman (input) for mailman id 217233; Wed, 27 Oct 2021 21:18:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJk-0000sJ-9F for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:40 +0000 Received: from mail-lj1-x229.google.com (unknown [2a00:1450:4864:20::229]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3344fc9b-88c1-4226-bfe0-1e061a865c5c; Wed, 27 Oct 2021 21:18:08 +0000 (UTC) Received: by mail-lj1-x229.google.com with SMTP id e2so6926591ljg.13 for ; Wed, 27 Oct 2021 14:18:08 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:07 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3344fc9b-88c1-4226-bfe0-1e061a865c5c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fMubR/4yBWUsww90rEyWY4dQ/XIE0qHuvtbXYbD4Pcs=; b=PqCG395LcNV60Qtp9Eu+DTDleDk9S+RpTfMF0TfPgeQNI7so50v1YaWYDZEm91iiCp stqqT31Aw/f237mfaJZBez2KJOlBBu7yQ98GuPbn0Fd6OHOrOUOIxbGKQzyeoEhI5d7U MaBsKPUXg/EUUv+aX6yG0KDR/rz5MnoalTZ2EQX7cxTfGCEi5fn/e2tAfWVQjz7cx+Cl FA6SmHKqY94Xx88iXkSj3vwZ5v8NluykZ6pHT7wJbq5dzQ3vU6x4mnoyEhNfbPxeYtlB xjgt4J5kOapwcnmeYf3Jiro9Ajf5AzXtfbVfgy9Vs0NcvOiCK5vS43vmXx4Ff0yYTgVu NUXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fMubR/4yBWUsww90rEyWY4dQ/XIE0qHuvtbXYbD4Pcs=; b=izQ5CZGekrlIHPN/N2Ihz05dL9/rP3NQhcwdOEgOEEWCAmtmxc1sr4lNuf/Q/8qswa wcsbXaJZ0JSTcV1+g53ixywPuWGeuGpeA06Y8i5Bm7wXnvYAnCbmfRPGzkhxGB0X7Xzc YJ53lQlZJxuHiTFwQM0IDAOCSQCbv5/YNHnoklisw4Im10YkXmzgwWCk4yuVCiH8G7tT L/HcUe81dPW5DMb3AixJIx5+SElsCNQzHRP1V3EeQEo0CypvW8M0zo5ScmDe4dAj8NIm X/tDw2vwHcQTp/bKvGtCapyNHTMr/D6BXVuBayE3VOHG1bea1nMp9YgBjtgWf2Zrf6b5 Ysdw== X-Gm-Message-State: AOAM532+uKeB77BK9qDnwu67UFKmo8RYNXBxBsWk2pyprisoX0y0niNq VWKIKx8wr801qYTdZu2TIgaQ5XTPYLU= X-Google-Smtp-Source: ABdhPJx+Js0me0cUAXGk9csOUj0IQmbpvMK95ONWvTRhfCm5GVYebrAN8Mns/32HOctyWJz6JrEWGw== X-Received: by 2002:a2e:b701:: with SMTP id j1mr325708ljo.133.1635369487617; Wed, 27 Oct 2021 14:18:07 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 08/45] kernel: Add combined power-off+restart handler call chain API Date: Thu, 28 Oct 2021 00:16:38 +0300 Message-Id: <20211027211715.12671-9-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 SoC platforms often have multiple options of how to perform system's power-off and restart operations. Meanwhile today's kernel is limited to a single option. Add combined power-off+restart handler call chain API, which is inspired by the restart API. The new API provides both power-off and restart functionality. The old pm_power_off method will be kept around till all users are converted to the new API. Current restart API will be replaced by the new unified API since new API is its superset. The restart functionality of the power-handler API is built upon the existing restart-notifier APIs. In order to ease conversion to the new API, convenient helpers are added for the common use-cases. They will reduce amount of boilerplate code and remove global variables. These helpers preserve old behaviour for cases where only one power-off handler is executed, this is what existing drivers want, and thus, they could be easily converted to the new API. Users of the new API should explicitly enable power-off chaining by setting corresponding flag of the power_handler structure. Signed-off-by: Dmitry Osipenko --- include/linux/reboot.h | 176 +++++++++++- kernel/power/hibernate.c | 2 +- kernel/reboot.c | 601 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 768 insertions(+), 11 deletions(-) diff --git a/include/linux/reboot.h b/include/linux/reboot.h index b7fa25726323..0ec835338c27 100644 --- a/include/linux/reboot.h +++ b/include/linux/reboot.h @@ -8,10 +8,16 @@ struct device; -#define SYS_DOWN 0x0001 /* Notify of system down */ -#define SYS_RESTART SYS_DOWN -#define SYS_HALT 0x0002 /* Notify of system halt */ -#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ +enum reboot_prepare_mode { + SYS_DOWN = 1, /* Notify of system down */ + SYS_RESTART = SYS_DOWN, + SYS_HALT, /* Notify of system halt */ + SYS_POWER_OFF, /* Notify of system power off */ +}; + +#define RESTART_PRIO_RESERVED 0 +#define RESTART_PRIO_DEFAULT 128 +#define RESTART_PRIO_HIGH 192 enum reboot_mode { REBOOT_UNDEFINED = -1, @@ -49,6 +55,167 @@ int register_restart_handler(struct notifier_block *); int unregister_restart_handler(struct notifier_block *); void do_kernel_restart(char *cmd); +/* + * Unified poweroff + restart API. + */ + +#define POWEROFF_PRIO_RESERVED 0 +#define POWEROFF_PRIO_PLATFORM 1 +#define POWEROFF_PRIO_DEFAULT 128 +#define POWEROFF_PRIO_HIGH 192 +#define POWEROFF_PRIO_FIRMWARE 224 + +enum poweroff_mode { + POWEROFF_NORMAL = 0, + POWEROFF_PREPARE, +}; + +struct power_off_data { + void *cb_data; +}; + +struct power_off_prep_data { + void *cb_data; +}; + +struct restart_data { + void *cb_data; + const char *cmd; + enum reboot_mode mode; +}; + +struct reboot_prep_data { + void *cb_data; + const char *cmd; + enum reboot_prepare_mode mode; +}; + +struct power_handler_private_data { + struct notifier_block reboot_prep_nb; + struct notifier_block power_off_nb; + struct notifier_block restart_nb; + void (*trivial_power_off_cb)(void); + void (*simple_power_off_cb)(void *data); + void *simple_power_off_cb_data; + bool registered; +}; + +/** + * struct power_handler - Machine power-off + restart handler + * + * Describes power-off and restart handlers which are invoked by kernel + * to power off or restart this machine. Supports prioritized chaining for + * both restart and power-off handlers. Callback's priority must be unique. + * Intended to be used by device drivers that are responsible for restarting + * and powering off hardware which kernel is running on. + * + * Struct power_handler can be static. Members of this structure must not be + * altered while handler is registered. + * + * Fill the structure members and pass it to register_power_handler(). + */ +struct power_handler { + /** + * @cb_data: + * + * User data included in callback's argument. + */ + void *cb_data; + + /** + * @power_off_cb: + * + * Callback that should turn off machine. Inactive if NULL. + */ + void (*power_off_cb)(struct power_off_data *data); + + /** + * @power_off_prepare_cb: + * + * Power-off preparation callback. All power-off preparation callbacks + * are invoked before @restart_cb. Inactive if NULL. + */ + void (*power_off_prepare_cb)(struct power_off_prep_data *data); + + /** + * @power_off_priority: + * + * Power-off callback priority, must be unique. Zero value is + * reassigned to default priority. Inactive if @power_off_cb is NULL. + */ + int power_off_priority; + + /** + * @power_off_chaining_allowed: + * + * False if callbacks execution should stop when @power_off_cb fails + * to power off machine. True if further lower priority power-off + * callback should be executed. + */ + bool power_off_chaining_allowed; + + /** + * @restart_cb: + * + * Callback that should reboot machine. Inactive if NULL. + */ + void (*restart_cb)(struct restart_data *data); + + /** + * @restart_priority: + * + * Restart callback priority, must be unique. Zero value is reassigned + * to default priority. Inactive if @restart_cb is NULL. + */ + int restart_priority; + + /** + * @reboot_prepare_cb: + * + * Reboot preparation callback. All reboot preparation callbacks are + * invoked before @restart_cb. Inactive if NULL. + */ + void (*reboot_prepare_cb)(struct reboot_prep_data *data); + + /** + * @priv: + * + * Internal data. Shouldn't be touched. + */ + const struct power_handler_private_data priv; +}; + +int register_power_handler(struct power_handler *handler); +void unregister_power_handler(struct power_handler *handler); + +struct power_handler * +register_simple_power_off_handler(void (*callback)(void *data), void *data); + +void unregister_simple_power_off_handler(struct power_handler *handler); + +int devm_register_power_handler(struct device *dev, + struct power_handler *handler); + +int devm_register_simple_power_off_handler(struct device *dev, + void (*callback)(void *data), + void *data); + +int devm_register_trivial_power_off_handler(struct device *dev, + void (*callback)(void)); + +int devm_register_simple_restart_handler(struct device *dev, + void (*callback)(struct restart_data *data), + void *data); + +int devm_register_prioritized_restart_handler(struct device *dev, + int priority, + void (*callback)(struct restart_data *data), + void *data); + +int register_platform_power_off(void (*power_off)(void)); + +void do_kernel_power_off(void); + /* * Architecture-specific implementations of sys_reboot commands. */ @@ -70,6 +237,7 @@ void kernel_restart_prepare(char *cmd); void kernel_restart(char *cmd); void kernel_halt(void); void kernel_power_off(void); +bool kernel_can_power_off(void); extern int C_A_D; /* for sysctl */ void ctrl_alt_del(void); diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 559acef3fddb..13ad98352fde 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -664,7 +664,7 @@ static void power_down(void) hibernation_platform_enter(); fallthrough; case HIBERNATION_SHUTDOWN: - if (pm_power_off) + if (kernel_can_power_off()) kernel_power_off(); break; } diff --git a/kernel/reboot.c b/kernel/reboot.c index 291d44082f42..779429726616 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -189,9 +189,8 @@ int register_restart_handler(struct notifier_block *nb) return ret; /* - * Handler must have unique priority. Otherwise invocation order is - * determined by the registration order, which is presumed to be - * unreliable. + * Handler must have unique priority. Otherwise call order is + * determined by registration order, which is unreliable. */ WARN_ON(!atomic_notifier_has_unique_priority(&restart_handler_list, nb)); @@ -294,6 +293,587 @@ void kernel_halt(void) } EXPORT_SYMBOL_GPL(kernel_halt); +/* + * Notifier list for kernel code which wants to be called + * to power off the system. + */ +static BLOCKING_NOTIFIER_HEAD(power_off_handler_list); + +static void dummy_pm_power_off(void) +{ + /* temporary stub until pm_power_off() is gone, see more below */ +} + +static struct notifier_block *pm_power_off_nb; + +/** + * register_power_off_handler - Register function to be called to power off + * the system + * @nb: Info about handler function to be called + * @nb->priority: Handler priority. Handlers should follow the + * following guidelines for setting priorities. + * 0: Power-off handler of last resort, + * with limited power-off capabilities + * 128: Default power-off handler; use if no other + * power-off handler is expected to be available, + * and/or if power-off functionality is + * sufficient to power-off the entire system + * 255: Highest priority power-off handler, will + * preempt all other power-off handlers + * + * Registers a function with code to be called to power off the + * system. + * + * Registered functions will be called as last step of the power-off + * sequence. + * + * Registered functions are expected to power off the system immediately. + * If more than one function is registered, the power-off handler priority + * selects which function will be called first. + * + * Power-off handlers are expected to be registered from non-architecture + * code, typically from drivers. A typical use case would be a system + * where power-off functionality is provided through a PMIC. Multiple + * power-off handlers may exist; for example, one power-off handler might + * turn off the entire system, while another only turns off part of + * system. In such cases, the power-off handler which only disables part + * of the hardware is expected to register with low priority to ensure + * that it only runs if no other means to power off the system is + * available. + * + * Currently always returns zero, as blocking_notifier_chain_register() + * always returns zero. + */ +static int register_power_off_handler(struct notifier_block *nb) +{ + int ret; + + ret = blocking_notifier_chain_register(&power_off_handler_list, nb); + if (ret) + return ret; + + /* + * Handler must have unique priority. Otherwise invocation order is + * determined by the registration order, which is presumed to be + * unreliable. + */ + WARN_ON(!blocking_notifier_has_unique_priority(&power_off_handler_list, nb)); + + /* + * Some drivers check whether pm_power_off was already installed. + * Install dummy callback using new API to preserve old behaviour + * for those drivers during period of transition to the new API. + */ + if (!pm_power_off) { + pm_power_off = dummy_pm_power_off; + pm_power_off_nb = nb; + } + + return 0; +} + +static void unregister_power_off_handler(struct notifier_block *nb) +{ + if (nb == pm_power_off_nb) { + /* + * Check whether somebody replaced pm_power_off behind + * out back. + */ + if (!WARN_ON(pm_power_off != dummy_pm_power_off)) + pm_power_off = NULL; + + pm_power_off_nb = NULL; + } + + WARN_ON(blocking_notifier_chain_unregister(&power_off_handler_list, nb)); +} + +static void devm_unregister_power_off_handler(void *data) +{ + struct notifier_block *nb = data; + + unregister_power_off_handler(nb); +} + +static int devm_register_power_off_handler(struct device *dev, + struct notifier_block *nb) +{ + int err; + + err = register_power_off_handler(nb); + if (err) + return err; + + return devm_add_action_or_reset(dev, devm_unregister_power_off_handler, + nb); +} + +static int power_handler_power_off(struct notifier_block *nb, + unsigned long mode, void *unused) +{ + struct power_off_prep_data prep_data = {}; + struct power_handler_private_data *priv; + struct power_off_data data = {}; + struct power_handler *h; + int ret = NOTIFY_DONE; + + priv = container_of(nb, struct power_handler_private_data, power_off_nb); + h = container_of(priv, struct power_handler, priv); + prep_data.cb_data = h->cb_data; + data.cb_data = h->cb_data; + + switch (mode) { + case POWEROFF_NORMAL: + if (h->power_off_cb) + h->power_off_cb(&data); + + if (priv->simple_power_off_cb) + priv->simple_power_off_cb(priv->simple_power_off_cb_data); + + if (priv->trivial_power_off_cb) + priv->trivial_power_off_cb(); + + if (!h->power_off_chaining_allowed) + ret = NOTIFY_STOP; + + break; + + case POWEROFF_PREPARE: + if (h->power_off_prepare_cb) + h->power_off_prepare_cb(&prep_data); + + break; + + default: + unreachable(); + } + + return ret; +} + +static int power_handler_restart(struct notifier_block *nb, + unsigned long mode, void *cmd) +{ + struct power_handler_private_data *priv; + struct restart_data data = {}; + struct power_handler *h; + + priv = container_of(nb, struct power_handler_private_data, restart_nb); + h = container_of(priv, struct power_handler, priv); + + data.cb_data = h->cb_data; + data.mode = mode; + data.cmd = cmd; + + h->restart_cb(&data); + + return NOTIFY_DONE; +} + +static int power_handler_restart_prep(struct notifier_block *nb, + unsigned long mode, void *cmd) +{ + struct power_handler_private_data *priv; + struct reboot_prep_data data = {}; + struct power_handler *h; + + priv = container_of(nb, struct power_handler_private_data, reboot_prep_nb); + h = container_of(priv, struct power_handler, priv); + + data.cb_data = h->cb_data; + data.mode = mode; + data.cmd = cmd; + + h->reboot_prepare_cb(&data); + + return NOTIFY_DONE; +} + +static struct power_handler_private_data * +power_handler_private_data(struct power_handler *handler) +{ + return (struct power_handler_private_data *)&handler->priv; +} + +/** + * devm_register_power_handler - Register power handler + * @dev: Device that registers handler + * @handler: Power handler descriptor + * + * Registers power handler that will be called as last step of the + * power-off and restart sequences. + * + * Returns zero on success, or error code on failure. + */ +int register_power_handler(struct power_handler *handler) +{ + struct power_handler_private_data *priv = power_handler_private_data(handler); + int err, priority; + + /* sanity-check whether handler is registered twice */ + if (WARN_ON(priv->registered)) + return -EBUSY; + + if (handler->power_off_cb || handler->power_off_prepare_cb) { + if (handler->power_off_priority == POWEROFF_PRIO_RESERVED) + priority = POWEROFF_PRIO_DEFAULT; + else + priority = handler->power_off_priority; + + priv->power_off_nb.notifier_call = power_handler_power_off; + priv->power_off_nb.priority = priority; + + err = register_power_off_handler(&priv->power_off_nb); + if (err) + goto reset_power_handler; + } + + if (handler->restart_cb) { + if (handler->restart_priority == RESTART_PRIO_RESERVED) + priority = RESTART_PRIO_DEFAULT; + else + priority = handler->restart_priority; + + priv->restart_nb.notifier_call = power_handler_restart; + priv->restart_nb.priority = priority; + + err = register_restart_handler(&priv->restart_nb); + if (err) + goto unreg_power_off_handler; + } + + if (handler->reboot_prepare_cb) { + priv->reboot_prep_nb.notifier_call = power_handler_restart_prep; + priv->reboot_prep_nb.priority = 0; + + err = register_reboot_notifier(&priv->reboot_prep_nb); + if (err) + goto unreg_restart_handler; + } + + priv->registered = true; + + return 0; + +unreg_restart_handler: + if (handler->restart_cb) + unregister_restart_handler(&priv->restart_nb); + +unreg_power_off_handler: + if (handler->power_off_cb) + unregister_power_off_handler(&priv->power_off_nb); + +reset_power_handler: + memset(priv, 0, sizeof(*priv)); + + return err; +} +EXPORT_SYMBOL(register_power_handler); + +/** + * unregister_power_handler - Unregister power handler + * @handler: Power handler descriptor + * + * Unregisters a previously registered power handler. Does nothing if + * handler is NULL. + */ +void unregister_power_handler(struct power_handler *handler) +{ + struct power_handler_private_data *priv; + + if (!handler) + return; + + priv = power_handler_private_data(handler); + + /* sanity-check whether handler is unregistered twice */ + if (WARN_ON(!priv->registered)) + return; + + if (handler->reboot_prepare_cb) + unregister_reboot_notifier(&priv->reboot_prep_nb); + + if (handler->restart_cb) + unregister_restart_handler(&priv->restart_nb); + + if (handler->power_off_cb) + unregister_power_off_handler(&priv->power_off_nb); + + memset(priv, 0, sizeof(*priv)); +} +EXPORT_SYMBOL(unregister_power_handler); + +static void devm_unregister_power_handler(void *data) +{ + struct power_handler *handler = data; + + unregister_power_handler(handler); +} + +/** + * devm_register_power_handler - Register power handler + * @dev: Device that registers handler + * @handler: Power handler descriptor + * + * Resource-managed variant of register_power_handler(); + * + * Returns zero on success, or error code on failure. + */ +int devm_register_power_handler(struct device *dev, + struct power_handler *handler) +{ + int err; + + err = register_power_handler(handler); + if (err) + return err; + + return devm_add_action_or_reset(dev, devm_unregister_power_handler, + handler); +} +EXPORT_SYMBOL(devm_register_power_handler); + +/** + * register_simple_power_off_handler - Register simple power-off callback + * @dev: Device that registers callback + * @callback: Callback function + * @data: Callback's argument + * + * Registers power-off callback with default priority, it will be called + * as last step of the power-off sequence. + * + * Returns power_handler pointer on success, or ERR_PTR on failure. + */ +struct power_handler * +register_simple_power_off_handler(void (*callback)(void *data), void *data) +{ + struct power_handler_private_data *priv; + struct power_handler *handler; + int err; + + handler = kzalloc(sizeof(*handler), GFP_KERNEL); + if (!handler) + return ERR_PTR(-ENOMEM); + + priv = power_handler_private_data(handler); + + priv->power_off_nb.notifier_call = power_handler_power_off; + priv->power_off_nb.priority = POWEROFF_PRIO_DEFAULT; + priv->simple_power_off_cb_data = data; + priv->simple_power_off_cb = callback; + + err = register_power_off_handler(&priv->power_off_nb); + if (err) { + kfree(handler); + return ERR_PTR(err); + } + + return handler; +} +EXPORT_SYMBOL(register_simple_power_off_handler); + +/** + * unregister_power_handler - Unregister simple power-off handler + * @handler: Power handler descriptor + * + * Unregisters power handler that was registered by + * register_simple_power_off_handler(). Does nothing if handler is + * error or NULL. + */ +void unregister_simple_power_off_handler(struct power_handler *handler) +{ + struct power_handler_private_data *priv; + + if (!IS_ERR_OR_NULL(handler)) { + priv = power_handler_private_data(handler); + unregister_power_off_handler(&priv->power_off_nb); + kfree(handler); + } +} +EXPORT_SYMBOL(unregister_simple_power_off_handler); + +/** + * devm_register_simple_power_off_handler - Register simple power-off callback + * @dev: Device that registers callback + * @callback: Callback function + * @data: Callback's argument + * + * Registers resource-managed power-off callback with default priority, + * it will be called as last step of the power-off sequence. Further + * lower priority callbacks won't be executed if this @callback fails. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_simple_power_off_handler(struct device *dev, + void (*callback)(void *data), + void *data) +{ + struct power_handler_private_data *priv; + struct power_handler *handler; + + handler = devm_kzalloc(dev, sizeof(*handler), GFP_KERNEL); + if (!handler) + return -ENOMEM; + + priv = power_handler_private_data(handler); + + priv->power_off_nb.notifier_call = power_handler_power_off; + priv->power_off_nb.priority = POWEROFF_PRIO_DEFAULT; + priv->simple_power_off_cb_data = data; + priv->simple_power_off_cb = callback; + + return devm_register_power_off_handler(dev, &priv->power_off_nb); +} +EXPORT_SYMBOL(devm_register_simple_power_off_handler); + +/** + * devm_register_trivial_power_off_handler - Register trivial power-off callback + * @dev: Device that registers callback + * @desc: Callback descriptor + * + * Same as devm_register_simple_power_off_handler(), but callback + * doesn't take argument. Further lower priority callbacks won't be + * executed if this @callback fails. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_trivial_power_off_handler(struct device *dev, + void (*callback)(void)) +{ + struct power_handler_private_data *priv; + struct power_handler *handler; + + handler = devm_kzalloc(dev, sizeof(*handler), GFP_KERNEL); + if (!handler) + return -ENOMEM; + + priv = power_handler_private_data(handler); + + priv->power_off_nb.notifier_call = power_handler_power_off; + priv->power_off_nb.priority = POWEROFF_PRIO_DEFAULT; + priv->trivial_power_off_cb = callback; + + return devm_register_power_off_handler(dev, &priv->power_off_nb); +} +EXPORT_SYMBOL(devm_register_trivial_power_off_handler); + +/** + * devm_register_simple_restart_handler - Register simple restart callback + * @dev: Device that registers callback + * @callback: Callback function + * @data: Callback's argument + * + * Registers resource-managed restart callback with default priority, + * it will be called as last step of the restart sequence. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_simple_restart_handler(struct device *dev, + void (*callback)(struct restart_data *data), + void *data) +{ + return devm_register_prioritized_restart_handler(dev, + RESTART_PRIO_DEFAULT, + callback, data); +} +EXPORT_SYMBOL(devm_register_simple_restart_handler); + +/** + * devm_register_prioritized_restart_handler - Register prioritized restart callback + * @dev: Device that registers callback + * @priority: Callback's priority + * @callback: Callback function + * @data: Callback's argument + * + * Registers resource-managed restart callback with a given priority, + * it will be called as last step of the restart sequence. + * + * Returns zero on success, or error code on failure. + */ +int devm_register_prioritized_restart_handler(struct device *dev, + int priority, + void (*callback)(struct restart_data *data), + void *data) +{ + struct power_handler *handler; + + handler = devm_kzalloc(dev, sizeof(*handler), GFP_KERNEL); + if (!handler) + return -ENOMEM; + + handler->restart_priority = priority; + handler->restart_cb = callback; + handler->cb_data = data; + + return devm_register_power_handler(dev, handler); +} +EXPORT_SYMBOL(devm_register_prioritized_restart_handler); + +static struct power_handler platform_power_off_handler = { + .priv = { + .power_off_nb = { + .notifier_call = power_handler_power_off, + .priority = POWEROFF_PRIO_PLATFORM, + }, + }, +}; + +/** + * register_platform_power_off - Register platform-level power-off callback + * @power_off: Power-off callback + * + * Registers power-off callback that will be called as last step + * of the power-off sequence. This callback is expected to be invoked + * for the last resort. Further lower priority callbacks won't be + * executed if @power_off fails. Only one platform power-off callback + * is allowed to be registered. + * + * Returns zero on success, or error code on failure. + */ +int register_platform_power_off(void (*power_off)(void)) +{ + struct power_handler_private_data *priv; + + /* this function is allowed to be called only once */ + if (WARN_ON(platform_power_off_handler.priv.trivial_power_off_cb)) + return -EBUSY; + + priv = power_handler_private_data(&platform_power_off_handler); + priv->trivial_power_off_cb = power_off; + + return register_power_off_handler(&priv->power_off_nb); +} + +/** + * do_kernel_power_off - Execute kernel power-off handler call chain + * + * Calls functions registered with register_power_off_handler. + * + * Expected to be called as last step of the power-off sequence. + * + * Powers off the system immediately if a power-off handler function has + * been registered. Otherwise does nothing. + */ +void do_kernel_power_off(void) +{ + /* legacy pm_power_off() is unchained and it has highest priority */ + if (pm_power_off && pm_power_off != dummy_pm_power_off) + return pm_power_off(); + + blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_NORMAL, + NULL); +} + +static void do_kernel_power_off_prepare(void) +{ + /* legacy pm_power_off_prepare() is unchained and it has highest priority */ + if (pm_power_off_prepare) + return pm_power_off_prepare(); + + blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_PREPARE, + NULL); +} + /** * kernel_power_off - power_off the system * @@ -302,8 +882,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(); + do_kernel_power_off_prepare(); migrate_to_reboot_cpu(); syscore_shutdown(); pr_emerg("Power down\n"); @@ -312,6 +891,16 @@ void kernel_power_off(void) } EXPORT_SYMBOL_GPL(kernel_power_off); +bool kernel_can_power_off(void) +{ + if (!pm_power_off && + blocking_notifier_call_chain_empty(&power_off_handler_list)) + return false; + + return true; +} +EXPORT_SYMBOL_GPL(kernel_can_power_off); + DEFINE_MUTEX(system_transition_mutex); /* @@ -353,7 +942,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, /* Instead of trying to make the power_off code look like * halt when pm_power_off is not set do it the easy way. */ - if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) + if (cmd == LINUX_REBOOT_CMD_POWER_OFF && !kernel_can_power_off()) cmd = LINUX_REBOOT_CMD_HALT; mutex_lock(&system_transition_mutex); From patchwork Wed Oct 27 21:16:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A29FC4332F for ; Wed, 27 Oct 2021 21:18:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 063EA610EA for ; Wed, 27 Oct 2021 21:18:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 063EA610EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217231.377203 (Exim 4.92) (envelope-from ) id 1mfqJg-0004a8-NA; Wed, 27 Oct 2021 21:18:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217231.377203; Wed, 27 Oct 2021 21:18:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJg-0004Zz-JE; Wed, 27 Oct 2021 21:18:36 +0000 Received: by outflank-mailman (input) for mailman id 217231; Wed, 27 Oct 2021 21:18:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJf-0000sJ-9B for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:35 +0000 Received: from mail-lf1-x12d.google.com (unknown [2a00:1450:4864:20::12d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1b76926b-f49a-49cc-98f7-b7d95f05d555; Wed, 27 Oct 2021 21:18:10 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id p16so9034533lfa.2 for ; Wed, 27 Oct 2021 14:18:10 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:09 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1b76926b-f49a-49cc-98f7-b7d95f05d555 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BPtMBppPEnkW8FAu+XIJVa0vPCxV8oSZETkwJ9fGFM4=; b=evvP7MsJwkqVHf9WWHeVtMPJGHU+mvo2PJqLCvURQO+gDiXejWyY7GbQhAh5S2Yuq3 zE+MXp6bpyTV9PKDTbTfo9WWXpFtGfj5n4Qz8ioZr0QyDkpV7sVDFNZi5aSeGd0r1ssm FaiC2SGtT+UwMk3wtZhRptmS5Jh1EvMlK22P6yAvTfzVBpKlWKTd0CWvNC0iHDJeCUVq 3jvnGl27YfW1MAZwLzhuSz3oPcJmkrZj59ainuK5d21Jqe/MApWPiIhI2vk+XeD9jyY+ vEN96KR+en3glKlYAHFchamcvD6xrJYfM61Zs7aonaQIhrzZ8Vd1+JewhOn6GxzMgcou E++w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BPtMBppPEnkW8FAu+XIJVa0vPCxV8oSZETkwJ9fGFM4=; b=5fFOu7DkrF+vSSDHjfbO0LPf9+sl2ZbJF843RTdbIZjDQErnn0URrS3PVpBr6JmuIl IRQakIOIy71lcYlF5MliBe23A/QR6Sv1u7okFU/a8xUqv4wDYNTY0SCw4KwbH95NE2uE erSvBFqpl+nJhnakJq1CH7/qPwmUj+7QzwBQp9KSYClbOvinCdxU9GBqWWbDj5NFGe/T PqjIpvkXLBK3Q7rIyJ3dnktobJSLY5rFND+aZ9L+03EO5lDKHvHowXR+QBNhgiUwUj1G EhZ4cI4r5wSjIff7cFKPElY0QnYBQskX2FDa6kdh/5IqL3jfQiN++dquDKgswZVKw0I7 gBDw== X-Gm-Message-State: AOAM530ablZrBRX8cUOxilCjAkXMrEqugPHAm1G0CgUSJAJ0xUuZbJxf KDfzNYe6iMlD7yIRjP6sda8= X-Google-Smtp-Source: ABdhPJwclkCD48sSOOyIVpWJhTUvxO0ayPfEAseJaJV46PV2ffR0qGAwcKjO8WTuzPJQEhkUDZtmqQ== X-Received: by 2002:a05:6512:aca:: with SMTP id n10mr147591lfu.66.1635369489587; Wed, 27 Oct 2021 14:18:09 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 09/45] xen/x86: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:39 +0300 Message-Id: <20211027211715.12671-10-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko Acked-by: Juergen Gross --- arch/x86/xen/enlighten_pv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 4f63117f09bb..4a0b9b7baf02 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -1087,8 +1088,7 @@ static void xen_machine_halt(void) static void xen_machine_power_off(void) { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); xen_reboot(SHUTDOWN_poweroff); } From patchwork Wed Oct 27 21:16:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4961CC433FE for ; Wed, 27 Oct 2021 21:28:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 121F460E73 for ; Wed, 27 Oct 2021 21:28:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 121F460E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217293.377357 (Exim 4.92) (envelope-from ) id 1mfqSr-0003m0-Dn; Wed, 27 Oct 2021 21:28:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217293.377357; Wed, 27 Oct 2021 21:28:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSq-0003kR-Sv; Wed, 27 Oct 2021 21:28:04 +0000 Received: by outflank-mailman (input) for mailman id 217293; Wed, 27 Oct 2021 21:28:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJp-0000sJ-9M for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:45 +0000 Received: from mail-lj1-x22c.google.com (unknown [2a00:1450:4864:20::22c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fa87cbdc-a519-4dc2-8f4a-cb53f367af93; Wed, 27 Oct 2021 21:18:12 +0000 (UTC) Received: by mail-lj1-x22c.google.com with SMTP id d23so5636747ljj.10 for ; Wed, 27 Oct 2021 14:18:12 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:11 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fa87cbdc-a519-4dc2-8f4a-cb53f367af93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SC0z1BXiHBYdSnCagR43oAXvnFYzAsSZgTyQ9BiR6xA=; b=OqqZ454WmFhFtJRhrw1iVetFaZ5cTmy1bK8cAKF7x4FJ4EjwPLEB4smQoL+kFj8hga BjmXNHow4qrZGAK5gLKqSouT5oIb6yppthDueiLerRGv55Pbl/JgRUYLNcFzmXzu9NWO EfhhNkXWXYZNWJhLg94zD8UyrvrtUOP73QnC8NTzMu/ENt6HanrdBXR7OCg2dyRE+fYN 1aO4sBj2Cdgy8VygaDgIGG5bFgsrX38xxJAfHh6M83eOLzNNbly5jBUwBwT1c3/ScSfl 6ZeIfaA93j63rbj1hC4fiWUjcO1LV9zENBfV1gxkADNuk/sNHvjjMOa2SIgObFEQihCd GDlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SC0z1BXiHBYdSnCagR43oAXvnFYzAsSZgTyQ9BiR6xA=; b=z8Q9DWuAXsgqcQ+MIzqcXJHobJKYZWvEqvg0H235r9zMqA89hhRgneH+IPwWrFSesw YE5in9E7gjCHF7cGxDJREE0CQbTHL2h8GLZ+fKuaSct/PAUnfYp8mczqZGeokYaOUG/9 PxeRY6Sv8pAXo/PuEEVut4DY+kQ2zodZwndePD9DRHHEQvDV70VtLUmV4PNpMzmRTWk0 jH2tcF83UN+o8oY/kWUhyko+goqAoXhWXGZMADZ9XAzXEe5a8yvV2xj7w8/m0q4ZDHeC +SzFW01yhwVakB4vykrdlxIhjitx5oU1BG4d8mnBE4kuM230TAUeAEezxSVuDRbiAiGi enEA== X-Gm-Message-State: AOAM532Fuwwy6f9Zx6XVafLo+C420Yq6VBnzuNeHuDBEy8Ex9/3LzPj9 nexmhH7BY/jxwLmtC4HomVM= X-Google-Smtp-Source: ABdhPJyn+zaTZhCmg6enYSN9xCI0Iv7Hmc/0KiXYEr7/tCUpX3ufLRXDN1zs5d0zePAVBcBxKNrxsQ== X-Received: by 2002:a05:651c:291:: with SMTP id b17mr380232ljo.90.1635369491425; Wed, 27 Oct 2021 14:18:11 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 10/45] ARM: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:40 +0300 Message-Id: <20211027211715.12671-11-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko Reviewed-by: Russell King (Oracle) --- arch/arm/kernel/reboot.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c index 3044fcb8d073..2cb943422554 100644 --- a/arch/arm/kernel/reboot.c +++ b/arch/arm/kernel/reboot.c @@ -116,9 +116,7 @@ void machine_power_off(void) { local_irq_disable(); smp_send_stop(); - - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); } /* From patchwork Wed Oct 27 21:16:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 602E4C433EF for ; Wed, 27 Oct 2021 21:28:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2ADD46109E for ; Wed, 27 Oct 2021 21:28:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2ADD46109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217347.377449 (Exim 4.92) (envelope-from ) id 1mfqTK-00010h-D1; Wed, 27 Oct 2021 21:28:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217347.377449; Wed, 27 Oct 2021 21:28:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTK-0000zd-04; Wed, 27 Oct 2021 21:28:34 +0000 Received: by outflank-mailman (input) for mailman id 217347; Wed, 27 Oct 2021 21:28:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJu-0000sJ-9U for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:50 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1cbb708e-fa5f-44cb-a7bf-37c8ad45fecb; Wed, 27 Oct 2021 21:18:14 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id j9so8977387lfu.7 for ; Wed, 27 Oct 2021 14:18:14 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:13 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1cbb708e-fa5f-44cb-a7bf-37c8ad45fecb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mkT4WvxT7RtftPa0rTvgt/WDicZUVRxbWN0FWKN7Smg=; b=Yo8WLAj00ehYxZyZdDVWixoWYFZCxGC5pnXCEDD+Lpmu7VCTkoyMEfgBUZ5rd74829 10cwYzMjgPMmfgRZlSo7KTAiAM4JViXknvJSGF9v6lX6GD7KJFaPvImanRJ6VVtdquR5 UWHkY3wgAzq9P8o4pg5QZxxWrvHm8PSEPWuEh07SLsPZUVJPf1GZYbO3PdmhFgXJ+BA3 yKffg+/c59X1/gl1a+krdkF8Zrm1ykankDPCOetkz+NKynMz9QOH9WwpSKXop30n94Hj u5jmdqBNWkVvyuWeZCuboMhJEA6otxFAt6GyTyoGvAX05kLjRNIXysRA8hScLTqoqleX /lfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mkT4WvxT7RtftPa0rTvgt/WDicZUVRxbWN0FWKN7Smg=; b=0Jw+nd7IidZADIwIV+ErH9Rnd1i4QILDUDuz7LNKXf6z8kxBU4HYKJrlD4h1HONk/m idUBXpaXrJaoJtPNFjgxaAF7KK87j5JukYbhnbACIao/su+b6Jiuc+OLpyViv03PxfoW q9x+cvbM7Z5Td20QRhsGzs9cVcFLuv+zkgKmiYeESRX4OFfNm+O1cxM8IBeyzauI0P8D EFieZj0GdQNhaj7rGyUfAnX1ReZt9v8OXBXkX2JdlHVu1k5kYUjjpg5rn+YkKKP+IcYJ MOMXxLh9qEvuAolseM6XPcjeqrXCPim3CXf/RoyeWQ3fZnQvmSy0wXyPYac734ISYh5v Pmuw== X-Gm-Message-State: AOAM532VivzYfoMuhYXkirHsMRl3kZICJFv6YX25uQUj5fvrKc7HFJyF v6CswwxALD7qDlJRHZvpnrs= X-Google-Smtp-Source: ABdhPJwGPYNJdHipR88AgCsSNedxVrXKRLPSbCNZ0Vw/PQMqS4/ZZmjcey45JQAWlpQD9BTSBOkxoA== X-Received: by 2002:ac2:5fea:: with SMTP id s10mr112420lfg.652.1635369493279; Wed, 27 Oct 2021 14:18:13 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 11/45] arm64: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:41 +0300 Message-Id: <20211027211715.12671-12-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko Acked-by: Catalin Marinas --- arch/arm64/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index aacf2f5559a8..f8db031afa7d 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -110,8 +110,7 @@ void machine_power_off(void) { local_irq_disable(); smp_send_stop(); - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); } /* From patchwork Wed Oct 27 21:16:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45CC6C4332F for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 008A8610CA for ; Wed, 27 Oct 2021 21:28:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 008A8610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217282.377288 (Exim 4.92) (envelope-from ) id 1mfqSf-00015B-Bc; Wed, 27 Oct 2021 21:27:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217282.377288; Wed, 27 Oct 2021 21:27:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSf-00012Q-0E; Wed, 27 Oct 2021 21:27:53 +0000 Received: by outflank-mailman (input) for mailman id 217282; Wed, 27 Oct 2021 21:27:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqJz-0000sJ-9b for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:18:55 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0222bae1-7769-490d-af5a-95eedee2bd43; Wed, 27 Oct 2021 21:18:16 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id u21so8955846lff.8 for ; Wed, 27 Oct 2021 14:18:16 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:14 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0222bae1-7769-490d-af5a-95eedee2bd43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vv5v7NJqa2pgRBcibgPiURAuuSzsOgTRkcWT+pa422M=; b=VGbgvR+u/npCM8vNPn38NuZ+MIrzGhV81ZfjU+MvKS7AiNy8hSxCjA7ujiUYCw1avb GAS28yQKe3RY82NkG0EyIE3kAScJ6kyKTE9XbDbIDpQ4/fNIy31zksAcsMcf8bk9+oZI 1wHpYlYvsjYNqCu/GmNzEr8yZmApiaFT6QsgmW5CvvcXj9w3x5S6f7cRGSestmqNVLhh o9VGqc+8lw97d2ugsZVtaD4DU57/XiuAmduAg/0PPfMVALR+BIUtVf/vGT/0dSW22xNm 0l5U0Yw6vCM5eFCBC2LE4tjs/ctA+ukPU11+6ITwiBuENW3D9cS5YJDtN5S1cIiSXp7j wB1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vv5v7NJqa2pgRBcibgPiURAuuSzsOgTRkcWT+pa422M=; b=0F+OIJvsYsGhRiZNJ72olscU3yMuCPfgyQTS+uu7olyHpLJDpnKujzpOoH5QIYWjRl f0QxYEMFk18jonOGw5y/nS5NHMTMIZ1vjCjk/UU9KKz5MP6tDpnJmBpbDMIX2ZtkvVeB UqlgpoTLivzGTAW8rtvmQAI6utRG6Ksb9GdRS8dIo0/X1MCt/PrvSMDVQNT0JvXTrh5K OGYv4zjRSNu09OwfZ0je/Fbz7ZKxFWRmxzrbSM4gObu3KIePnVEYsGj6wCiBs8U99LKM 21hnGX3tUihmsZn14Az8TgzHu9DQ8F/3gHptJXf+1dobEnXoLKkHYPSuk1Ot+RTnpnQn CPDQ== X-Gm-Message-State: AOAM530DKGns7N7S9ogSVOYjDGJew81eHlmrAqBbu+oSuayO43iAldjW 1C+aab59xWUTNTLC581sM0g= X-Google-Smtp-Source: ABdhPJycpSIBttPaIIeVkgKRen/cPXePW42pRZoMffRx62Sit7qS0BR3pB37ZmB7g4nrP0IYjPFMsA== X-Received: by 2002:ac2:5c43:: with SMTP id s3mr133719lfp.248.1635369495190; Wed, 27 Oct 2021 14:18:15 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 12/45] csky: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:42 +0300 Message-Id: <20211027211715.12671-13-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/csky/kernel/power.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/csky/kernel/power.c b/arch/csky/kernel/power.c index 923ee4e381b8..86ee202906f8 100644 --- a/arch/csky/kernel/power.c +++ b/arch/csky/kernel/power.c @@ -9,16 +9,14 @@ EXPORT_SYMBOL(pm_power_off); void machine_power_off(void) { local_irq_disable(); - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); asm volatile ("bkpt"); } void machine_halt(void) { local_irq_disable(); - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); asm volatile ("bkpt"); } From patchwork Wed Oct 27 21:16:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BDFCC43219 for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55F0060E74 for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55F0060E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217276.377262 (Exim 4.92) (envelope-from ) id 1mfqSd-0000YS-9R; Wed, 27 Oct 2021 21:27:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217276.377262; Wed, 27 Oct 2021 21:27:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSd-0000Xy-2E; Wed, 27 Oct 2021 21:27:51 +0000 Received: by outflank-mailman (input) for mailman id 217276; Wed, 27 Oct 2021 21:27:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqK4-0000sJ-9s for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:00 +0000 Received: from mail-lf1-x135.google.com (unknown [2a00:1450:4864:20::135]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 53a3346b-be90-451c-9701-5a2efea95047; Wed, 27 Oct 2021 21:18:18 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id j9so8977658lfu.7 for ; Wed, 27 Oct 2021 14:18:17 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:16 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 53a3346b-be90-451c-9701-5a2efea95047 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jIixMSKlDuHM/ROsyXYWDI0GhGtBfDPAGuo/NFEP3H8=; b=VuUlnz7weOhSfAIMvRGdAiCqe8Shtv78aoHm3EO65feC0nT0nvvBnSk8QPIhVywkUj RNOysBHRGg3KyTpFUTlL4md1P0VicBRamsV0pMYoslyc5mszXHbTC0wuGj5LLTuLIDD2 VnVcbr+sDBlhSPvrsCXrkM2C7rhvtU8y8OQkbc+espeBKofEXAYEbW1oSchhu8gpHnH6 5hh0T8v4+pCxxupjUbq3tFFMpwd3gXAylv/eoy7+WuK9q+47ahw0aKqYniKpkL9kizMT KLoyc7ML3E1XRsxFnCpxt+IjBVgNhbN/TY6BaYE18l22YJ+9HYMvndESw4+sKVIU4K+r XT2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jIixMSKlDuHM/ROsyXYWDI0GhGtBfDPAGuo/NFEP3H8=; b=m32cSMLIJsIH0DOHYa91t7YgFBaA5HiMMsmYTv8uP8K3GbLEVtT5zgPgkE8GwiPHaH p68lWC6qRAZAhh+q9teoz4UIXQY+LI5rAX/bxs6yfOgqs7+dU57DueaRXEvt8FgWrVom /bqsyvRvid8/qOm6iTwVJS3tPDqOd1YALp27GzDVR+Lb4ZzJe5nyfTE4zKsw9GtQZg94 uwWGzuvJQ4BuASPOrqPAhjUSxVg/a6dmoM1z+KQbFxzlJq3D5FkVKFvVuARlYFnScw26 4IuH79nPJ4l0MfJhgIxzTYyvJfQe0THnTJs/kJz4xIpwlf8Oxgh5oDA7h0As/PxYTNOO yOiQ== X-Gm-Message-State: AOAM530PSjzCtKlj9PQUfIa2DToNa2yzpBPTIY41adC8Msoha7dCmqai jha6ZzQCbMj1ccLoJofeHgs= X-Google-Smtp-Source: ABdhPJzTnlhiIBlvhjatRngwhlUNPcdRxQkZ5VPhYXoHnLeJsw7ZI6sTw6Ma1GzH+vutcEMuVDSyeQ== X-Received: by 2002:a05:6512:228e:: with SMTP id f14mr113005lfu.610.1635369497072; Wed, 27 Oct 2021 14:18:17 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 13/45] ia64: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:43 +0300 Message-Id: <20211027211715.12671-14-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/ia64/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c index 834df24a88f1..cee4d7db2143 100644 --- a/arch/ia64/kernel/process.c +++ b/arch/ia64/kernel/process.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -599,8 +600,7 @@ machine_halt (void) void machine_power_off (void) { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); machine_halt(); } From patchwork Wed Oct 27 21:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE2BFC433EF for ; Wed, 27 Oct 2021 21:28:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A5F060E73 for ; Wed, 27 Oct 2021 21:28:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A5F060E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217288.377332 (Exim 4.92) (envelope-from ) id 1mfqSk-0002UJ-FD; Wed, 27 Oct 2021 21:27:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217288.377332; Wed, 27 Oct 2021 21:27:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSk-0002SB-3b; Wed, 27 Oct 2021 21:27:58 +0000 Received: by outflank-mailman (input) for mailman id 217288; Wed, 27 Oct 2021 21:27:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqK9-0000sJ-9k for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:05 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c91dc08f-1be2-4c3f-99b3-2504c75db291; Wed, 27 Oct 2021 21:18:19 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id p16so9035184lfa.2 for ; Wed, 27 Oct 2021 14:18:19 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:18 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c91dc08f-1be2-4c3f-99b3-2504c75db291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cc0IUGWHitJ0Cooyguk/vAdy9iAEtCRPuqNtfJHYmrA=; b=hGiOk7puznFSxpZSFm/Eya2Cl9N4a04S/N7AMKzyQzEzjBU4DjBRSyeAPC6r2d+wM7 xUQ7Ac9D1vF+xVotAvlC6ZCck4cXMzjLk9AuV7aPkEcOFRxo/Y6dcKGr+AskSfh12zZH j4t9S3xSdGJpshUHlnXLi2wz4oVxcxE35PVQckWFsoWLYAS6gGsox7O/ylTaKD83bUPI lt0JfBMnsOVk10t4KXi669c5Oy5pFEzyyvF+GC9JzvCvwEtP2Bq8P5zo32YZHs5FWOMt Vb6ZGXWglhHchKGKPrIHgEEJ9wGUMKsnUwpN3Lz0Uy/fasmq0C+gajXgFsv262T+m1RI GwKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cc0IUGWHitJ0Cooyguk/vAdy9iAEtCRPuqNtfJHYmrA=; b=6/zYNa7H2H+Tpaf4MJDAU+tL/EjCzLf1K4unL8znIpbxRO6a3/6jqVGLnVA2tzry9S q1nA5wnh81VkUU5AcjIcxsQwf3qdqNL3WOXlmJBVwDAOVzDHxaUTLVuTmR/AoQSVQrcS KI2gfdrIRkTEtT5aZsSWdDRM13oRsF5lijbzMdqZ3IhEExqNCP9JE72pLpprqhVKitxN 4kFSVlz9ekb40Zqz+f2ITnZOIc8iZTfe1NX1DuMKejBUZ+rvJMxVvwpO2MdX0Nt4RQUs VZLQri3Nl7rYxce20oZk9JkNUP7w6wot5tx64MCLv9CeNC2NbEI4Oc8hLImLEII374MP IR1w== X-Gm-Message-State: AOAM533//XLFn/TKjefQlJLcyLzf33Wi8sDJVPQvSSUEIrgbLyJGZsh5 c6UGcjpzJH4kN/Tu2GRV+Ks= X-Google-Smtp-Source: ABdhPJygpdJSNoXRh8ba3OotHfDcr8CSl9bSWUL0hunV++q/wiTfcZPk6onGhghey5UXGxJAqpQkjw== X-Received: by 2002:a05:6512:228a:: with SMTP id f10mr83288lfu.489.1635369498913; Wed, 27 Oct 2021 14:18:18 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 14/45] mips: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:44 +0300 Message-Id: <20211027211715.12671-15-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/mips/kernel/reset.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c index 6288780b779e..e7ce07b3e79b 100644 --- a/arch/mips/kernel/reset.c +++ b/arch/mips/kernel/reset.c @@ -114,8 +114,7 @@ void machine_halt(void) void machine_power_off(void) { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); #ifdef CONFIG_SMP preempt_disable(); From patchwork Wed Oct 27 21:16:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B41C433EF for ; Wed, 27 Oct 2021 21:29:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0862B610C7 for ; Wed, 27 Oct 2021 21:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0862B610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217372.377537 (Exim 4.92) (envelope-from ) id 1mfqTd-0005DX-4f; Wed, 27 Oct 2021 21:28:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217372.377537; Wed, 27 Oct 2021 21:28:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTc-00059t-He; Wed, 27 Oct 2021 21:28:52 +0000 Received: by outflank-mailman (input) for mailman id 217372; Wed, 27 Oct 2021 21:28:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKE-0000sJ-9s for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:10 +0000 Received: from mail-lf1-x12a.google.com (unknown [2a00:1450:4864:20::12a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0b8a1e4b-85eb-4c9e-ba9c-2f8a196adde9; Wed, 27 Oct 2021 21:18:21 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id u11so9039924lfs.1 for ; Wed, 27 Oct 2021 14:18:21 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:20 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0b8a1e4b-85eb-4c9e-ba9c-2f8a196adde9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IgdEY3brdUGAcbkVUTuopyRaDKQjmT9IOiG4donLZPs=; b=A3JO6VvJimX2FDA0dLxQreYnwNBhx07tWQqQ/SXHhnBPoY3sXPbkG7/+E3nQpmOX0A xlWT2EkBKpC8k8ZWfgyhIneFn7gx6l3JU5mZMCJ9Gg2YcXAy3/1zaAAc5fiz8vpe6tlD ZvghxSem0XLQoHwdT6xVe9kcSCqZDVrl06JyyBvtaA4P5y8CnmEwrM6jHVXlGrSBhDO0 o8SePrtzTGOU2c+h0yCzi7vHVuNfd1Z0T1OIQTsX0utpaovYy+QkExsu3rsU1LEkDfsA b8P9cl2mQ3B7fspke5UfEwNdCDRC5NS7RaIYXDvPpdxxluddWoVhn2i0iC+LZc0Zjzjl nizw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IgdEY3brdUGAcbkVUTuopyRaDKQjmT9IOiG4donLZPs=; b=08iVB7RQGYBcC9LIiw7uhNy98+HvujL5P93s1q88YJbqKGpQ7Awv+XRJGbaPbjJzP5 SGb5ZnDVnyWtHXpuoDlM/w6WCRBBcC5Cmb8A1c25J7b7xYjxz1kWd+b2736qgGqwV9iR Eclw1PBap1h7x91P7IDsXIyugynMEoziMGwJlmj1rKaUYRmBb1z1bgFvQEv1XreHC0kj aAnEbhl/X5txrjcdyqgo8wPPE6rpZc9x5H8k7TVT8XjmkpVGYPn9BXzHw8gbnnm/D4Lu pJBu9NhtBB8w2PNtWG14FRerdel7ChzjY8oqtQjIBYAIYlSTlljjSTi7ctzjdSLcZ5Wu ZEeg== X-Gm-Message-State: AOAM530PUgffhrAveixWGtV+j+wG2cIWtUsWLnD7H/a0qXczQVPNzy5u im4u2GVvHBrXULXefBPNM0o= X-Google-Smtp-Source: ABdhPJwtMjA7PlvcFRu5kz6vTDm0WOPOzzhi40W0Cp5+CpUA24meJt6Drh8JDJU/Rr1wsTlEzin4/g== X-Received: by 2002:a05:6512:401f:: with SMTP id br31mr96058lfb.169.1635369500752; Wed, 27 Oct 2021 14:18:20 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 15/45] nds32: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:45 +0300 Message-Id: <20211027211715.12671-16-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/nds32/kernel/process.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/nds32/kernel/process.c b/arch/nds32/kernel/process.c index 49fab9e39cbf..0936dcd7db1b 100644 --- a/arch/nds32/kernel/process.c +++ b/arch/nds32/kernel/process.c @@ -54,8 +54,7 @@ EXPORT_SYMBOL(machine_halt); void machine_power_off(void) { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); } EXPORT_SYMBOL(machine_power_off); From patchwork Wed Oct 27 21:16:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C0EC433F5 for ; Wed, 27 Oct 2021 21:28:57 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EA5960E74 for ; Wed, 27 Oct 2021 21:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9EA5960E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217357.377481 (Exim 4.92) (envelope-from ) id 1mfqTP-0002AJ-9U; Wed, 27 Oct 2021 21:28:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217357.377481; Wed, 27 Oct 2021 21:28:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTO-00025c-SL; Wed, 27 Oct 2021 21:28:38 +0000 Received: by outflank-mailman (input) for mailman id 217357; Wed, 27 Oct 2021 21:28:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKJ-0000sJ-AC for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:15 +0000 Received: from mail-lj1-x22e.google.com (unknown [2a00:1450:4864:20::22e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8325c7f7-cc0c-4dff-b219-56797cb660da; Wed, 27 Oct 2021 21:18:23 +0000 (UTC) Received: by mail-lj1-x22e.google.com with SMTP id n7so6989547ljp.5 for ; Wed, 27 Oct 2021 14:18:23 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:22 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8325c7f7-cc0c-4dff-b219-56797cb660da DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZQw7CI0X8q8oTyepUGNJOSZqk2PM67xqdSRvFtKKmiw=; b=h1ou+u32rU4cYIn0OrunTZVHH8PVsk/s4rO9s8rIgCD+KKjcifq4iXhOSD/tIm7Qin P6ARY8cS2LdXxM+CoAbgm367SWuzYvU7Z79bJYgTCDi7YlT7Y5yuy0qGD8YIp/7ys02d pQwjIRkz9TYZYOpAy67AqOhS7slV4KAtJVEBcoUUJ83/AZzv5dclkL7bTj62SJ6cw7H4 UW+yIUAnRXLn6nWbS4xhDtCDZfNdRtv+xAYYROwA+IIcIffcm5Q9yfNkOiBLfH2Y/wmk oOdsC/qn1zU/au/+LxlGh/gFJDeofp5A7xGvQ93uStcIj752OCcUSwSsN/9T0qMY5YTe dvtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZQw7CI0X8q8oTyepUGNJOSZqk2PM67xqdSRvFtKKmiw=; b=qSeavAipE4/55i1CIBdyrfgRSMnWrGYua7QqembtjS9VS5zGf9DGFghBZ9FA5grlYo +Gu1XVyy4utsUewS6AIO40Bwj7Vxm/U+MeFAyUFEpvT9vxiZgA02ZHSQ4OE4F9FYfzB+ 6HaLDqfjJdAPUqTgLTmI4uY2207RYoz/l+XbySPKdeGKoEkMZ3KmuvG/CVc+tw0B6isB quuONDLs2T9vMWNfGUQKNoNIEVFwALxGIUwF3g5MwUmwMsUdtx+Woopw5YO86ygoKi8a ru7xXV+i79EB8iZxDXZoIvIVvY3Kss6WtHpYLI3w8cs4uhn1xq71ZG2HyjmdfI9L5GMX VvRg== X-Gm-Message-State: AOAM533/WVh8D2oVwDK1WobA/8Ufx1ZALSEESOsk1VgBEnJIug8P1E8g VbBG9oA9j3i9echvY5FkzaQ= X-Google-Smtp-Source: ABdhPJztZrtJsxWmkjJ9e0hDv7W0ZJONlmNUbIC8cbkqFySfq5YC9V4Azd52J8+C4kw5eLOToEAzlw== X-Received: by 2002:a2e:bf1c:: with SMTP id c28mr359960ljr.150.1635369502589; Wed, 27 Oct 2021 14:18:22 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 16/45] parisc: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:46 +0300 Message-Id: <20211027211715.12671-17-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko Acked-by: Helge Deller # parisc --- arch/parisc/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index ea3d83b6fb62..928201b1f58f 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -114,8 +115,7 @@ void machine_power_off(void) pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN); /* ipmi_poweroff may have been installed. */ - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); /* It seems we have no way to power the system off via * software. The user has to press the button himself. */ From patchwork Wed Oct 27 21:16:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C99BC433EF for ; Wed, 27 Oct 2021 21:29:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 55710610EA for ; Wed, 27 Oct 2021 21:29:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55710610EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217360.377496 (Exim 4.92) (envelope-from ) id 1mfqTT-0002qE-5h; Wed, 27 Oct 2021 21:28:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217360.377496; Wed, 27 Oct 2021 21:28:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTS-0002mD-2y; Wed, 27 Oct 2021 21:28:42 +0000 Received: by outflank-mailman (input) for mailman id 217360; Wed, 27 Oct 2021 21:28:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKO-0000sJ-AH for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:20 +0000 Received: from mail-lj1-x229.google.com (unknown [2a00:1450:4864:20::229]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 01087dc5-ad54-4608-8e65-24125bedb2ea; Wed, 27 Oct 2021 21:18:25 +0000 (UTC) Received: by mail-lj1-x229.google.com with SMTP id q16so7018224ljg.3 for ; Wed, 27 Oct 2021 14:18:25 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:24 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 01087dc5-ad54-4608-8e65-24125bedb2ea DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rn6kChPkfoFMf9bWYHf70bnGYIj3LFIVKDTZ1qePG0M=; b=UpWsh/FpGieodrD9s3cNqzK6jy31h5ljZFEwQ+D2q0RTlqvYeysLYZeRQo1KpYyV2E FrJFQ3pk1ZjLGkSmkQuMqpQGm3pLQYdGN7MewaJIFH4jHkVWFJbftv36SpE7wHzAfM6f KfYBgHNJAt7rLgdyfNzETIqs5AkGlF85N8K8c3T6GaZ5ArdlodepiLYddRqHEhO/3Klg D8JJS7iUiqx+skaUr3SoIxZKpGEOkheRNugtxOQ9N5fX3CP32io6EjkCrnAIhbDZrUUD zN+4zZTl26WGoleIrx97PYAjrTar40Pf+ijrpXYWtFKLlTkmoUa0DEaDGbd2O74e82mz NNrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rn6kChPkfoFMf9bWYHf70bnGYIj3LFIVKDTZ1qePG0M=; b=qRh9j7hbT/NKISwO62UTVlxZgn42/1NU4tzS4UVF8vNNARgoD3KmoViiZzCjclwGRy uG2hs9rri+ztNo1Hk7yMsf+dLTxS7Iw+sAexSES89/2DEc3HlLxo84S8vNYFtfMgHbG4 hZMIF73DmyldBEycSVCOf74eBCwwDU4cOMI+2KH97bXebZB0V51CBVs2xr4Pk2Vq+49P id0J17DybQkunC5GyZkTA+VKV+ExCvDqwnowIhmhQR5NzZ4zR8HEE6c9TNNBwyOF9jIs kEnZu94qMd3IyaYyvB+xblR7in5kuPvErlbc9k89e9ukHdKHBuZdRY7q6FPO9Zu93OfL 3O6Q== X-Gm-Message-State: AOAM532u//tee7kJ4nR5X0INZjR6SO+yYlL4qV8ubpARwWLx8ASaUl/w tbYlISZpWFFK1d3930DlzgA= X-Google-Smtp-Source: ABdhPJzozXX9CLT+V56pSkYTIT6ENXsjFNJw478xo/aJxRV2fH58rMxN8jZgU4s16hZZ4d9qEx0Lfg== X-Received: by 2002:a05:651c:114b:: with SMTP id h11mr321181ljo.35.1635369504516; Wed, 27 Oct 2021 14:18:24 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 17/45] powerpc: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:47 +0300 Message-Id: <20211027211715.12671-18-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/powerpc/kernel/setup-common.c | 4 +--- arch/powerpc/xmon/xmon.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 4f1322b65760..71c4ccd9bbb1 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -161,9 +161,7 @@ void machine_restart(char *cmd) void machine_power_off(void) { machine_shutdown(); - if (pm_power_off) - pm_power_off(); - + do_kernel_power_off(); smp_send_stop(); machine_hang(); } diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index dd8241c009e5..9d835807d645 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -1243,8 +1243,7 @@ static void bootcmds(void) } else if (cmd == 'h') { ppc_md.halt(); } else if (cmd == 'p') { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); } } From patchwork Wed Oct 27 21:16:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C420C433EF for ; Wed, 27 Oct 2021 21:28:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BAE666109E for ; Wed, 27 Oct 2021 21:28:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BAE666109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217295.377369 (Exim 4.92) (envelope-from ) id 1mfqSt-0004GG-U7; Wed, 27 Oct 2021 21:28:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217295.377369; Wed, 27 Oct 2021 21:28:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSt-0004B9-4f; Wed, 27 Oct 2021 21:28:07 +0000 Received: by outflank-mailman (input) for mailman id 217295; Wed, 27 Oct 2021 21:28:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKT-0000sJ-AJ for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:25 +0000 Received: from mail-lj1-x22f.google.com (unknown [2a00:1450:4864:20::22f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b85a0f4c-68ce-41fd-81db-436811659b39; Wed, 27 Oct 2021 21:18:27 +0000 (UTC) Received: by mail-lj1-x22f.google.com with SMTP id s19so6943375ljj.11 for ; Wed, 27 Oct 2021 14:18:27 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:26 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b85a0f4c-68ce-41fd-81db-436811659b39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+aSuiMovnmRlKPN5Rl3JuNmFHUt6skQo3O4wD7dX5JQ=; b=ehfhpJuO10tH0JJc+NToykiYU0vR9QNQWRGBFoJEmaOxGSK6IxZtCBEULR0W0LLrnh rWgUh4Kku73ZADq2I2DXfxnNngsudNBU15HzSYHJ5ZGaDy4yKkQqtcH85+TmIu3x8kh9 Xstkp84P8gb9NHhImh/kkEu/eLRzihVMriWTiS1lyvVYlI0S9doH7srHH4uUDtgtagHH NnlFwVxtytB+YFKInQI4zlx/qw9ggp+d792cFqZ86NXSDRvmn2HsZCjK5JnAlXZtcFzO y6wwCc1x7j8EpGXUAyH+X2YWcF6tl/6iZWVr+mUSLKEmJFL/9H+FbFwe9fJf0ZNH5qP/ q9Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+aSuiMovnmRlKPN5Rl3JuNmFHUt6skQo3O4wD7dX5JQ=; b=yDZar7Z4ETp0eiJMYqbWz+Pv9sP/D9+OjaQQiTCH2cy9PFh/9b4EbdLdECZdz3eByQ nlubfo90lbmCH0UpQMGoQQ7lvbdKVWrLWKbg3Yb2r/zq2+DjPUr3BJSMcjuJtydQy41+ ElyYpdnDUe7+iBGJmtDTa3O31K4BamF5WZMkxPcbDm5RdF4GL7A2fwP8hKxMlB0ZmrAq VheMi+jJHltaVvY/+jKi1Hxx77i+GaikoB+YZYG8yQvzN57Yp88AaQa4iZM0EHFa18cS 2Q/sTFEOqJcsKTbBoImdSVdDw26F1btxxVaIpRYNqja84Zqvse//2thnzWE8bi5NI40C BoQQ== X-Gm-Message-State: AOAM5339T7wC4DSHhL6SxFZqYKsBVBIOHvPIAkfRqWs3Q2YeIRIlsmiZ J2L56yJBv6FO3Sk3YwVOMto= X-Google-Smtp-Source: ABdhPJySCnLdJnyefyOJzA6HMZEBF+hyXH0EM8QKUFyfoUHamOZK7R7lRqwGKBcRpuomVJFL6q66/Q== X-Received: by 2002:a2e:891a:: with SMTP id d26mr331100lji.368.1635369506344; Wed, 27 Oct 2021 14:18:26 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 18/45] riscv: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:48 +0300 Message-Id: <20211027211715.12671-19-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko Acked-by: Palmer Dabbelt --- arch/riscv/kernel/reset.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c index 9c842c41684a..912288572226 100644 --- a/arch/riscv/kernel/reset.c +++ b/arch/riscv/kernel/reset.c @@ -23,16 +23,12 @@ void machine_restart(char *cmd) void machine_halt(void) { - if (pm_power_off != NULL) - pm_power_off(); - else - default_power_off(); + do_kernel_power_off(); + default_power_off(); } void machine_power_off(void) { - if (pm_power_off != NULL) - pm_power_off(); - else - default_power_off(); + do_kernel_power_off(); + default_power_off(); } From patchwork Wed Oct 27 21:16:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18974C4332F for ; Wed, 27 Oct 2021 21:28:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D76986109E for ; Wed, 27 Oct 2021 21:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D76986109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217342.377429 (Exim 4.92) (envelope-from ) id 1mfqTH-0000Fg-FL; Wed, 27 Oct 2021 21:28:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217342.377429; Wed, 27 Oct 2021 21:28:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTH-0000Em-8C; Wed, 27 Oct 2021 21:28:31 +0000 Received: by outflank-mailman (input) for mailman id 217342; Wed, 27 Oct 2021 21:28:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKY-0000sJ-AS for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:30 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9f389b0c-6a35-4f94-9ef8-4b8e581c515e; Wed, 27 Oct 2021 21:18:29 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id u21so8956897lff.8 for ; Wed, 27 Oct 2021 14:18:29 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:28 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9f389b0c-6a35-4f94-9ef8-4b8e581c515e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=032w538UVpeATjNmIAIpxMVbSRQ+KkFSikcjH52Go7E=; b=i8kSi+aWSekhMHl+RIohvB2J9+GhXDqC8y87gHZKIo3HgrCgrxAFgJBJNd643IAUw8 g9MSIRkc2bpIwozO+KBB9OaCJ9xgY87SwdOaEqBvwzFZ8T3iGC1OLWPTCXnsFCHj5/5U sps32PSa8KExjTmWa9ZRL9t+O9qr0b8kzTl0fgjkERRFIi+xDfIxjTflHCHCDk5rZ0mt zfhXGA8+rDpphj6+WcqiIpDWahpS8la7wRdBB0/XTYtTbOXFjjBe+uIATNvGTQr/gKbD b/xTsJZdL1e/rQ412ul4+9vATu7deYBtZoT3x3kO5sbA1sdcdzRIoZ4KvX2dngppNAWQ v1fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=032w538UVpeATjNmIAIpxMVbSRQ+KkFSikcjH52Go7E=; b=bw3fD/MMX27aKYnvSDOUOSLRmXplsrMnpZlahUi3WGGS0jwoa55B0M1BapMn+pcDyM f4FJ23U90tsl7C+uEIzLp5B8bmeVU30sXo/FKon/Ycd6C2WHO57HNbmD4p3axFuKRUsI bjyR0Eh4aoyrULyIreR7Uz0nFwnvltN5R8k0A7aqODcm1Qou/v3MuIkgLHjR1ZJvs0hh j4WIjJ2dp1QGko0fH3Kng/gbbnrxY6eY+7bAae/Us4QW8dVn+6uFLi6IGY0TgZT69g1e AOYyDK+m0KFwhCnxxnCFxPjn5hopliaSSXwnsUfMdmFZrJA1GAPHdP6yJVxdYFAi2dCH Mb5A== X-Gm-Message-State: AOAM533CiNkFN3jGqSiTv1+o2H95SBi17uQwPDb8KmVwvjXVFdPDs083 yce+SSwUSTA6mH/BPbiH7lE= X-Google-Smtp-Source: ABdhPJxRtK/tJ0GqKzVRuD4r9yGdXpMq7YD+HTcHjRYwt7Ifx6KwMehlmhPixjH5hNZN4Zb5ESKkAg== X-Received: by 2002:a05:6512:1316:: with SMTP id x22mr96787lfu.291.1635369508415; Wed, 27 Oct 2021 14:18:28 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 19/45] sh: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:49 +0300 Message-Id: <20211027211715.12671-20-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/sh/kernel/reboot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c index 5c33f036418b..e8eeedc9b182 100644 --- a/arch/sh/kernel/reboot.c +++ b/arch/sh/kernel/reboot.c @@ -46,8 +46,7 @@ static void native_machine_shutdown(void) static void native_machine_power_off(void) { - if (pm_power_off) - pm_power_off(); + do_kernel_power_off(); } static void native_machine_halt(void) From patchwork Wed Oct 27 21:16:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9514C433FE for ; Wed, 27 Oct 2021 21:28:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58B0B60E73 for ; Wed, 27 Oct 2021 21:28:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 58B0B60E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217270.377239 (Exim 4.92) (envelope-from ) id 1mfqSb-0008TD-EW; Wed, 27 Oct 2021 21:27:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217270.377239; Wed, 27 Oct 2021 21:27:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSb-0008T6-9H; Wed, 27 Oct 2021 21:27:49 +0000 Received: by outflank-mailman (input) for mailman id 217270; Wed, 27 Oct 2021 21:27:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKi-0000sJ-Ar for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:40 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6b544073-9049-4d9c-951a-73ca878768f3; Wed, 27 Oct 2021 21:18:31 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id j9so8978698lfu.7 for ; Wed, 27 Oct 2021 14:18:31 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:29 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6b544073-9049-4d9c-951a-73ca878768f3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0HObz0L7jYC33/Dxy7x3kt14KoppaRcQ+sU+HcRStgU=; b=juuYY7khswyJq9WLrD2Xv0L7DT3egfGiA3J+op4ykA5lhTUc4DxfT1yB0Oh88agPiv UhoKqT4ns2hfuw9gr/v0jAGL8GkGSlrTsMjRAQAm62Utk3Ft2TKiyIKDHiM1MbMECMuo YhNAqYcsFGhVw4jQXQFg7Xiu9P0ShsfWNYxHZwYj/2saBc/VAXVzxB4ozqBsrO+obQNg sFt44IAUuRDv+vAvbmBDNGqc/rVW0RxicCJ9k+jGGnO7zutAFJ4cO/39uMNR4REocLb+ fT+JvIjl7o4XFJOJc5uobpc1ra4sZ3Uq0sG0p07pr/mfIHANj05r1FY541LLyuiyYuuI 01TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0HObz0L7jYC33/Dxy7x3kt14KoppaRcQ+sU+HcRStgU=; b=acfnmuqIlNnfB4OFtbYvx1D968GPMkRdfh2lNKsjbWRFq19PSfqf4hRhTNo1Q3h/FD DHUCu4fJNkCTuFvyuYIneEN5b7xqBjtJU+y3GPLonIqPQU68tpZ9l1Q2Th0blRR5s1rb A0HEciiNi+XbXqOmx5motbnuhX2joRtgHymw+5aaglI8sTd8uZ6jYjValMkq29nVJYPf jVHcHFpsC9IJZPPUrAB7FHfxsTj+DBiVPJkgONvPg/GJr8Y2qDaMibQYAnjX0E7+1JHd 8aOkXgpK3cWm7FhizFrvbg3nEjpYXvTLl8sRxKdiW4rCoxtPCBC8RKYokBmAZVRkjsXG hx/w== X-Gm-Message-State: AOAM5333kPG0SLpK+KdwFOWehCItqYKd+5eB1DdyMFZScbUuPCo1jkBO Qld38IZYdTI49x+m7o7WCdI= X-Google-Smtp-Source: ABdhPJwvis6SZ3kogk4xA1IHskuhNiRlAlBXPnsBTS3IAzxRcr2G+o3cy4E7zzZ6V+F8EKCBP2j+FA== X-Received: by 2002:ac2:4ec4:: with SMTP id p4mr108449lfr.127.1635369510228; Wed, 27 Oct 2021 14:18:30 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 20/45] x86: Use do_kernel_power_off() Date: Thu, 28 Oct 2021 00:16:50 +0300 Message-Id: <20211027211715.12671-21-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use do_kernel_power_off() that invokes chained power-off handlers. It also invokes legacy pm_power_off() for now, which will be removed once all drivers will be converted to the new power-off API. Signed-off-by: Dmitry Osipenko --- arch/x86/kernel/reboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 0a40df66a40d..cd7d9416d81a 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -747,10 +747,10 @@ static void native_machine_halt(void) static void native_machine_power_off(void) { - if (pm_power_off) { + if (kernel_can_power_off()) { if (!reboot_force) machine_shutdown(); - pm_power_off(); + do_kernel_power_off(); } /* A fallback in case there is no PM info available */ tboot_shutdown(TB_SHUTDOWN_HALT); From patchwork Wed Oct 27 21:16:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A194CC433F5 for ; Wed, 27 Oct 2021 21:29:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AFF4610CA for ; Wed, 27 Oct 2021 21:29:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5AFF4610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217363.377502 (Exim 4.92) (envelope-from ) id 1mfqTU-0003AY-FY; Wed, 27 Oct 2021 21:28:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217363.377502; Wed, 27 Oct 2021 21:28:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTT-00033w-NJ; Wed, 27 Oct 2021 21:28:43 +0000 Received: by outflank-mailman (input) for mailman id 217363; Wed, 27 Oct 2021 21:28:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKn-0000sJ-B1 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:45 +0000 Received: from mail-lf1-x134.google.com (unknown [2a00:1450:4864:20::134]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fed3223e-1a96-44bf-b846-2ec276fe5515; Wed, 27 Oct 2021 21:18:33 +0000 (UTC) Received: by mail-lf1-x134.google.com with SMTP id b32so5809968lfv.0 for ; Wed, 27 Oct 2021 14:18:33 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:31 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fed3223e-1a96-44bf-b846-2ec276fe5515 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=guWA5fFZeGPtiBZOYoQcCwu2VFdVsVhLW9/JhrymZ0g=; b=Y3ajD9hSFiO6I4QqBgfg35JQ5CG9aR8SawQdCZ/PvBPpTrKpea4VQPEYGG2e2LlPNw INBF/7ltt3G3417Dh9CdQfPTHSkRg6FMpjv8P1ntJFwpZqSV1uSTE4GmrYnNoXeajbha R/xICM0awt4oVDfnXFmFRQIZuNOfUQCww36nBDR3iRSiJcFpUgR7ytoBp8ilJAXX1BoV q3WrRdzyqUShxUhnVnyU+VPDZDBm93MNtu5SNFBPibM7EM2q+6x7IVUVp7KS5HkYIUo5 6/azutWfWLEZTqcTTzvxBwc0sMsrgJicmN8uMy0n0bR+IWtSXzppNigQSpvDusN76BYk OmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=guWA5fFZeGPtiBZOYoQcCwu2VFdVsVhLW9/JhrymZ0g=; b=6mZxwjxX8n/6jWjp9NQ3L1SsmMkt0ikUFuq8nEr97Dt4c1g8L0wGs//PXlADKfrMuT ok6M9jXJXs12wMbndXbWFbCyZB9mwwA81HbbkdpoY2wJKe66CXqCtdnqLcVnlj24UTxI loLEZyBgJKtPI5Df4EuuJq/UKzS5gesLo49P41Me7y0xUlI2+ezVGy6NILKb1aNYLD24 VCJ1iMODYtgu1yg16yey3GRWDzUzDqitTX5cuTBBh7vR3SI19zI9kWJeVLqLxvdhXQ6l mdV7i8x3AB+NQ8cGFadhyHYnhaU/bQjAplGHvsL1C8DJ83fn/YE5fXmvjQ+MzQcrg7bw aHsg== X-Gm-Message-State: AOAM530ij2vVunU9aLOySLUnJLN1IvTUVKCdi4sK2GX45DZCP2Ncodt5 td4MYNCpqUo9wgCpLbLuvPw= X-Google-Smtp-Source: ABdhPJw9hBA3rUBC1cmHCV5isZVZ9pveXdrJpcvckt2xCHU4v9xkBuaEqDJVomXcVNELr8shz4+44g== X-Received: by 2002:a05:6512:324d:: with SMTP id c13mr91026lfr.349.1635369512043; Wed, 27 Oct 2021 14:18:32 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 21/45] m68k: Switch to new power-handler API Date: Thu, 28 Oct 2021 00:16:51 +0300 Message-Id: <20211027211715.12671-22-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Kernel now supports chained power-off handlers. Use register_power_off_handler() that registers power-off handlers and do_kernel_power_off() that invokes chained power-off handlers. Legacy pm_power_off() will be removed once all drivers will be converted to the new power-off API. Normally arch code should adopt only the do_kernel_power_off() at first, but m68k is a special case because it uses pm_power_off() "inside out", i.e. pm_power_off() invokes machine_power_off() [in fact it does nothing], while it's machine_power_off() that should invoke the pm_power_off(), and thus, we can't convert platforms to the new API separately. There are only two platforms changed here, so it's not a big deal. Signed-off-by: Dmitry Osipenko --- arch/m68k/emu/natfeat.c | 3 ++- arch/m68k/include/asm/machdep.h | 1 - arch/m68k/kernel/process.c | 5 ++--- arch/m68k/kernel/setup_mm.c | 1 - arch/m68k/kernel/setup_no.c | 1 - arch/m68k/mac/config.c | 4 +++- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c index 71b78ecee75c..b19dc00026d9 100644 --- a/arch/m68k/emu/natfeat.c +++ b/arch/m68k/emu/natfeat.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -90,5 +91,5 @@ void __init nf_init(void) pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16, version & 0xffff); - mach_power_off = nf_poweroff; + register_platform_power_off(nf_poweroff); } diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h index 8fd80ef1b77e..8d8c3ee2069f 100644 --- a/arch/m68k/include/asm/machdep.h +++ b/arch/m68k/include/asm/machdep.h @@ -24,7 +24,6 @@ extern int (*mach_get_rtc_pll)(struct rtc_pll_info *); extern int (*mach_set_rtc_pll)(struct rtc_pll_info *); extern void (*mach_reset)( void ); extern void (*mach_halt)( void ); -extern void (*mach_power_off)( void ); extern unsigned long (*mach_hd_init) (unsigned long, unsigned long); extern void (*mach_hd_setup)(char *, int *); extern void (*mach_heartbeat) (int); diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index a6030dbaa089..e160a7c57bd3 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c @@ -67,12 +67,11 @@ void machine_halt(void) void machine_power_off(void) { - if (mach_power_off) - mach_power_off(); + do_kernel_power_off(); for (;;); } -void (*pm_power_off)(void) = machine_power_off; +void (*pm_power_off)(void); EXPORT_SYMBOL(pm_power_off); void show_regs(struct pt_regs * regs) diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c index 4b51bfd38e5f..50f4f120a4ff 100644 --- a/arch/m68k/kernel/setup_mm.c +++ b/arch/m68k/kernel/setup_mm.c @@ -98,7 +98,6 @@ EXPORT_SYMBOL(mach_get_rtc_pll); EXPORT_SYMBOL(mach_set_rtc_pll); void (*mach_reset)( void ); void (*mach_halt)( void ); -void (*mach_power_off)( void ); #ifdef CONFIG_HEARTBEAT void (*mach_heartbeat) (int); EXPORT_SYMBOL(mach_heartbeat); diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c index 5e4104f07a44..00bf82258233 100644 --- a/arch/m68k/kernel/setup_no.c +++ b/arch/m68k/kernel/setup_no.c @@ -55,7 +55,6 @@ int (*mach_hwclk) (int, struct rtc_time*); /* machine dependent reboot functions */ void (*mach_reset)(void); void (*mach_halt)(void); -void (*mach_power_off)(void); #ifdef CONFIG_M68000 #if defined(CONFIG_M68328) diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 5d16f9b47aa9..727320dedf08 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -139,7 +140,6 @@ void __init config_mac(void) mach_hwclk = mac_hwclk; mach_reset = mac_reset; mach_halt = mac_poweroff; - mach_power_off = mac_poweroff; #if IS_ENABLED(CONFIG_INPUT_M68K_BEEP) mach_beep = mac_mksound; #endif @@ -159,6 +159,8 @@ void __init config_mac(void) if (macintosh_config->ident == MAC_MODEL_IICI) mach_l2_flush = via_l2_flush; + + register_platform_power_off(mac_poweroff); } From patchwork Wed Oct 27 21:16:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5BDBC433F5 for ; Wed, 27 Oct 2021 21:28:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AEDF360E73 for ; Wed, 27 Oct 2021 21:28:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AEDF360E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217349.377453 (Exim 4.92) (envelope-from ) id 1mfqTK-00017W-V4; Wed, 27 Oct 2021 21:28:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217349.377453; Wed, 27 Oct 2021 21:28:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTK-00015O-KK; Wed, 27 Oct 2021 21:28:34 +0000 Received: by outflank-mailman (input) for mailman id 217349; Wed, 27 Oct 2021 21:28:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqKs-0000sJ-B1 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:19:50 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dd7093c0-ce60-4352-a841-5e64a19135f8; Wed, 27 Oct 2021 21:18:34 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id bq11so8955702lfb.10 for ; Wed, 27 Oct 2021 14:18:34 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:33 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dd7093c0-ce60-4352-a841-5e64a19135f8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4OWbCpLiTrW70NMTPpPUNVkhVF3RKPzG5GTofMVph+0=; b=nyjF7CMTiXZTknDCkjxSlwBlmez3wFeA+zehsvTRn8HWRCKWBbu+VeqUVL44ms69wV nnBlf5yP21RTavxXaqxcjkZ3KCf591eZC6XUlLgNrDZoqwAeG0e8waWDmBuDqGJPa/ia TWGnRhqwCJRO6ZHGrxxDEuuBCRuC8gitnwXoBy6yPn2yaI52p7BdBoMEudji1fyrvZ7s jQQkx67Vh3JRx01BzNxvLauTbUeZkFSOIEd8jQMxIMky+FUXABFowKrpCYCop+RjKrYK 44VAj9OlGjdC9id5DEzvny9pb4y7eTDKQL+s4i3zBATQTR5zvjDC+NzhG9GB4CVWfx2z vHjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4OWbCpLiTrW70NMTPpPUNVkhVF3RKPzG5GTofMVph+0=; b=yAUNVwKW7EnBX8Z9BTD4hyfSHPCeqfPmkkQmdhKYGYzDVYOSqkVvXiKL4AIwEyk/rV PvNzbVrVETplO1Hboup8cptVlK4GPnVn+F47GwzObpPyTM/304RrK0b7XbB3J33za9N+ hsJ0lpsNw9exaFzRC75n5qlQVjtwhX+2e9NhNeJw1JahiKaS29mVWB+TS2aI0sufSd2b r5N2BlQxuKTXAMMDts/jsH9+l/mevP9ICm8y/r8X3wcQD+SIE5yw7Uebml7/IYE49EDa jkIg0Dcf7PpZdW5jn+KWgpt38tRTJtLR0AscuWy4YG0bzepbJxEdGC9de1sYQ1qatKZ8 NuLA== X-Gm-Message-State: AOAM531AsjhwQq/wiXqKwW+G5Bc/I8EqN0EE3xVSnddS2tHDTQXooLFd hhEXFD3LNx8DQ4NfXpzBuJ4= X-Google-Smtp-Source: ABdhPJy61JBdPHWehe+0JZDFDtaEYRkwyYUuH0JZUFf3l53X5Ds5OQvvxR8PRHj15LQUp0FSRiIF9w== X-Received: by 2002:ac2:53a5:: with SMTP id j5mr141454lfh.130.1635369513848; Wed, 27 Oct 2021 14:18:33 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 22/45] memory: emif: Use kernel_can_power_off() Date: Thu, 28 Oct 2021 00:16:52 +0300 Message-Id: <20211027211715.12671-23-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Replace legacy pm_power_off with kernel_can_power_off() helper that is aware about chained power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/memory/emif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c index 762d0c0f0716..cab10d5274a0 100644 --- a/drivers/memory/emif.c +++ b/drivers/memory/emif.c @@ -630,7 +630,7 @@ static irqreturn_t emif_threaded_isr(int irq, void *dev_id) dev_emerg(emif->dev, "SDRAM temperature exceeds operating limit.. Needs shut down!!!\n"); /* If we have Power OFF ability, use it, else try restarting */ - if (pm_power_off) { + if (kernel_can_power_off()) { kernel_power_off(); } else { WARN(1, "FIXME: NO pm_power_off!!! trying restart\n"); From patchwork Wed Oct 27 21:16:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12B2FC4321E for ; Wed, 27 Oct 2021 21:28:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB11160E74 for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BB11160E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217277.377265 (Exim 4.92) (envelope-from ) id 1mfqSd-0000dU-Jc; Wed, 27 Oct 2021 21:27:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217277.377265; Wed, 27 Oct 2021 21:27:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSd-0000cJ-EU; Wed, 27 Oct 2021 21:27:51 +0000 Received: by outflank-mailman (input) for mailman id 217277; Wed, 27 Oct 2021 21:27:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqL7-0000sJ-Bg for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:05 +0000 Received: from mail-lf1-x130.google.com (unknown [2a00:1450:4864:20::130]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8e7ff3db-fb04-477a-9d59-8253b9171804; Wed, 27 Oct 2021 21:18:36 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id x27so9004728lfu.5 for ; Wed, 27 Oct 2021 14:18:36 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:35 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8e7ff3db-fb04-477a-9d59-8253b9171804 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rTg0c6UJkUtA3xox9iyqZdpwaCfteR79knUJVekTw18=; b=IOOovw4HthrHOXjOs46Y3yITm9+R54zah3HqdDtgfe0CoTVx3Ny/qQfSWJECq3va5v POFxHfUV4nFfAVF/2xQmQF0GAuAxqBjz1BtRvOKx4MR0EfN6IoGEZZUqz+WUpBWyPywt GrOnqTwA95eu+J8qffyJd/WsYZnQLcqOy0MiUotidUtoWBtzitEMBsbvSCmIUhOFOmfU TN0N1IIFJs2PwhqjyrirBl5OZM0AJ4ETZ7OvQijCQBnaCq4fjrrAiLoAARG8gCOMWpFL isJ90k/kflRmNXJGxu4rOU7Ttcg3V2boCXpvP5Lo62Urd2fuc4VonqYdYqPHg73Ap8Wn SfNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rTg0c6UJkUtA3xox9iyqZdpwaCfteR79knUJVekTw18=; b=2Ryq/cOZEhk7RoiARC42+tDS60H2d+EuMIyg06Q1PpOG0Yq/s7z6Ap68lw8o9xwuJC qqbj+4IRq/+LcU6dpevIT+wTLbm731cyOdcK0FJAkJDWFkpRZI9OpB9spds1NB0AA7Me kqT5K0zvrC/ter1x+4gx3iA6IKc6DhisEBNIROm4dBfHLROH42Umyzdr9S+uadT5k9O0 U3tKYYhAzFqQcT44405loytao+6b7LpxiZuC2WuJz1qmRytNdt400E5pipIuj2fG7HzS FRXP/5T5ELECNh5TfthLVOwh0KbOWpct7SnEcdnekY3cRr39LUAnPIzt88/yPDAPvTGG LtEA== X-Gm-Message-State: AOAM531sfyCzsovH055k4VMx/4FneZeIxwzXNmsEXBMqBXUpHGZN1ILT Q6FVsobAu+oYhePupn//BR4= X-Google-Smtp-Source: ABdhPJxFzFVD2w1ioavz6oJ1REfrGLdo1ULxWozIc4isKil/5p3npr9c6ZJggbEvwegyiOXfsqbr2g== X-Received: by 2002:a05:6512:3699:: with SMTP id d25mr132127lfs.380.1635369515664; Wed, 27 Oct 2021 14:18:35 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 23/45] ACPI: power: Switch to power-handler API Date: Thu, 28 Oct 2021 00:16:53 +0300 Message-Id: <20211027211715.12671-24-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Switch to power-handler API that replaces legacy pm_power_off callbacks. Signed-off-by: Dmitry Osipenko --- drivers/acpi/sleep.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 3023224515ab..41b3ea867f8f 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -47,19 +47,11 @@ static void acpi_sleep_tts_switch(u32 acpi_state) } } -static int tts_notify_reboot(struct notifier_block *this, - unsigned long code, void *x) +static void tts_reboot_prepare(struct reboot_prep_data *data) { acpi_sleep_tts_switch(ACPI_STATE_S5); - return NOTIFY_DONE; } -static struct notifier_block tts_notifier = { - .notifier_call = tts_notify_reboot, - .next = NULL, - .priority = 0, -}; - static int acpi_sleep_prepare(u32 acpi_state) { #ifdef CONFIG_ACPI_SLEEP @@ -1016,7 +1008,7 @@ static void acpi_sleep_hibernate_setup(void) static inline void acpi_sleep_hibernate_setup(void) {} #endif /* !CONFIG_HIBERNATION */ -static void acpi_power_off_prepare(void) +static void acpi_power_off_prepare(struct power_off_prep_data *data) { /* Prepare to power off the system */ acpi_sleep_prepare(ACPI_STATE_S5); @@ -1024,7 +1016,7 @@ static void acpi_power_off_prepare(void) acpi_os_wait_events_complete(); } -static void acpi_power_off(void) +static void acpi_power_off(struct power_off_data *data) { /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ pr_debug("%s called\n", __func__); @@ -1032,6 +1024,11 @@ static void acpi_power_off(void) acpi_enter_sleep_state(ACPI_STATE_S5); } +static struct power_handler acpi_power_handler = { + .power_off_priority = POWEROFF_PRIO_FIRMWARE, + .reboot_prepare_cb = tts_reboot_prepare, +}; + int __init acpi_sleep_init(void) { char supported[ACPI_S_STATE_COUNT * 3 + 1]; @@ -1048,8 +1045,8 @@ int __init acpi_sleep_init(void) if (acpi_sleep_state_supported(ACPI_STATE_S5)) { sleep_states[ACPI_STATE_S5] = 1; - pm_power_off_prepare = acpi_power_off_prepare; - pm_power_off = acpi_power_off; + acpi_power_handler.power_off_cb = acpi_power_off; + acpi_power_handler.power_off_prepare_cb = acpi_power_off_prepare; } else { acpi_no_s5 = true; } @@ -1065,6 +1062,6 @@ int __init acpi_sleep_init(void) * Register the tts_notifier to reboot notifier list so that the _TTS * object can also be evaluated when the system enters S5. */ - register_reboot_notifier(&tts_notifier); + register_power_handler(&acpi_power_handler); return 0; } From patchwork Wed Oct 27 21:16:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2601C433FE for ; Wed, 27 Oct 2021 21:28:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A15BC60E74 for ; Wed, 27 Oct 2021 21:28:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A15BC60E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217283.377297 (Exim 4.92) (envelope-from ) id 1mfqSg-0001L2-4V; Wed, 27 Oct 2021 21:27:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217283.377297; Wed, 27 Oct 2021 21:27:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSf-0001G3-Os; Wed, 27 Oct 2021 21:27:53 +0000 Received: by outflank-mailman (input) for mailman id 217283; Wed, 27 Oct 2021 21:27:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLC-0000sJ-Bf for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:10 +0000 Received: from mail-lj1-x229.google.com (unknown [2a00:1450:4864:20::229]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e3b334e6-cd33-456a-ab3a-269c6b97cb7a; Wed, 27 Oct 2021 21:18:38 +0000 (UTC) Received: by mail-lj1-x229.google.com with SMTP id d23so5638600ljj.10 for ; Wed, 27 Oct 2021 14:18:38 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:37 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e3b334e6-cd33-456a-ab3a-269c6b97cb7a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RsN03A/v4Sm7hW8tBAQNfAIwim2Ix+phU87uldQTcUU=; b=aSBcb4MObsGcKwVtxhkQi6r6MrllJ5Wvhx4AXr7+3ZZIOmNeNayjB4H7wS3yJIQaI0 vfLkw8dEY0bAB5FpyHupYLxHHW8temP9OImGFFR4LDmE7/mvPRk5uTYf1q52vThLv1Ot CBrv1hpmeU5p/gGow8523dqz9J8N1faFeN/IXFxxWyp7mhT8fq2Z7acBEZ06y9nx6CF2 oI6Bf+jKcKCu1O6+i0B6l4EesA9cDqHIJQrezIg8dnd+TlutJ/VurnoBCjdUW8FVuBfF rgIrNrWNCUTYVjuoeGUx+HMg9DODFrvmZsdKkZzK15Dx1U5yq0D3h61n1EAZrJfufwr8 qWRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RsN03A/v4Sm7hW8tBAQNfAIwim2Ix+phU87uldQTcUU=; b=OHfHyq85RsRt/yzp0dtbFhmdlQQbtE9RDQFutPsx65jgZ3GCcOnJLc9G/gfVhNzWGD OoKDcdqKybndotrveSIVAMk6C+dJqNKtIPiTX5s3YOvHsyaYuLFIkic6c4re2CeNWPE1 kekf3suRqBASTL+apcpeV32KNtPDi87fHSr2Dmb7ohS0gAe/+SznOjfuXDU/eBIZmCPC sJZvIzTLPFU42/BPqAhHOQ9Lz0IeHz0kZVVgdCHTETalKIaFs5+ZZoRu0PBFZCU2Gtj+ Q3Fori8AmaIAcY2PtRWt9p0cFzsc1KDKDWiP+piIz5imLoK9Tbywr3SHIZ2+4w3DLuXS u7Bw== X-Gm-Message-State: AOAM533haRxmYCqMCQCg0OtJokdBKv2hU4J3jVErmuPcxivSt/74OUQl gPwtdGX50V65VjQocRonLs4= X-Google-Smtp-Source: ABdhPJwvRw65HVRl6UYG4kSDngjOw+VDWoznyGC0SQFAdeVNXxGihIuJGUkpMtbqNUFYMuUZsUPclw== X-Received: by 2002:a2e:3e08:: with SMTP id l8mr351596lja.194.1635369517590; Wed, 27 Oct 2021 14:18:37 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 24/45] regulator: pfuze100: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:16:54 +0300 Message-Id: <20211027211715.12671-25-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_power_handler() that replaces global pm_power_off_prepare variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko Acked-by: Mark Brown --- drivers/regulator/pfuze100-regulator.c | 39 ++++++++++---------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index d60d7d1b7fa2..73d5baf9d3ea 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ struct pfuze_chip { struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR]; struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR]; struct pfuze_regulator *pfuze_regulators; + struct power_handler power_handler; }; static const int pfuze100_swbst[] = { @@ -569,10 +571,10 @@ static inline struct device_node *match_of_node(int index) return pfuze_matches[index].of_node; } -static struct pfuze_chip *syspm_pfuze_chip; - -static void pfuze_power_off_prepare(void) +static void pfuze_power_off_prepare(struct power_off_prep_data *data) { + struct pfuze_chip *syspm_pfuze_chip = data->cb_data; + dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off"); /* Switch from default mode: APS/APS to APS/Off */ @@ -611,24 +613,24 @@ static void pfuze_power_off_prepare(void) static int pfuze_power_off_prepare_init(struct pfuze_chip *pfuze_chip) { + int err; + if (pfuze_chip->chip_id != PFUZE100) { dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler for not supported chip\n"); return -ENODEV; } - if (pm_power_off_prepare) { - dev_warn(pfuze_chip->dev, "pm_power_off_prepare is already registered.\n"); - return -EBUSY; - } + pfuze_chip->power_handler.power_off_prepare_cb = pfuze_power_off_prepare; + pfuze_chip->power_handler.cb_data = pfuze_chip; - if (syspm_pfuze_chip) { - dev_warn(pfuze_chip->dev, "syspm_pfuze_chip is already set.\n"); - return -EBUSY; + err = devm_register_power_handler(pfuze_chip->dev, + &pfuze_chip->power_handler); + if (err) { + dev_err(pfuze_chip->dev, + "failed to register power handler: %d\n", err); + return err; } - syspm_pfuze_chip = pfuze_chip; - pm_power_off_prepare = pfuze_power_off_prepare; - return 0; } @@ -837,23 +839,12 @@ static int pfuze100_regulator_probe(struct i2c_client *client, return 0; } -static int pfuze100_regulator_remove(struct i2c_client *client) -{ - if (syspm_pfuze_chip) { - syspm_pfuze_chip = NULL; - pm_power_off_prepare = NULL; - } - - return 0; -} - static struct i2c_driver pfuze_driver = { .driver = { .name = "pfuze100-regulator", .of_match_table = pfuze_dt_ids, }, .probe = pfuze100_regulator_probe, - .remove = pfuze100_regulator_remove, }; module_i2c_driver(pfuze_driver); From patchwork Wed Oct 27 21:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8AFAC433F5 for ; Wed, 27 Oct 2021 21:28:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3AA56109E for ; Wed, 27 Oct 2021 21:28:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A3AA56109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217287.377327 (Exim 4.92) (envelope-from ) id 1mfqSj-0002ND-Mc; Wed, 27 Oct 2021 21:27:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217287.377327; Wed, 27 Oct 2021 21:27:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSj-0002L7-D2; Wed, 27 Oct 2021 21:27:57 +0000 Received: by outflank-mailman (input) for mailman id 217287; Wed, 27 Oct 2021 21:27:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLM-0000sJ-C4 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:20 +0000 Received: from mail-lf1-x131.google.com (unknown [2a00:1450:4864:20::131]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 785f57b0-ec27-457a-9ea3-6dcf331783c7; Wed, 27 Oct 2021 21:18:42 +0000 (UTC) Received: by mail-lf1-x131.google.com with SMTP id l13so8991223lfg.6 for ; Wed, 27 Oct 2021 14:18:42 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:41 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 785f57b0-ec27-457a-9ea3-6dcf331783c7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mcl172dtfGlkf1TcslUPgwMlkZWwlYhkCJ06Bxg/bBU=; b=cr3OoRz90WYilQxW+1X5mebi5NSQ3xkQzRtxCrXFmhmNlKVd4Mk6BghlahMCy7Iyto a4UuDalJ4f78KLT3HAaBh5614BnSWOH/t9zbr0YPxrmg6/JuWnf5dAnKZsc2b4GAIVeJ 9uKqX2hlny1afoYheoedvOJbugyMQlznsmVrZlOSaKsdu2draZ6B8WFqE5e4JBYGYqhC KXF/Z/WyDDccTQoDfFgyc6FoM2LFPomJZ3hRr6/JbV3znQY16GvUC7Q6Zprq2NGBD3P+ O43c0LmvrM3DBmK/z7V4e9Zq9h2WiaNFgKFrXs2jyu8jI7tMHdmmNyPNNNQGazHFhhOk f27Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mcl172dtfGlkf1TcslUPgwMlkZWwlYhkCJ06Bxg/bBU=; b=hA2Ppv3OGcoDsMCW9909dv08NGy3GCE+pkv9bk9nM6DhYTLZiahgnMC9D2ENxX8olW 8cb7hVb8hLk7m7gLTOlT9fGui+ZAgXpkWw4LRh6sLsHr7V812uTmG4VGOKAtEBxGZQnB iq1PMuhBEnTCBmagp7boRy1f+7Ohd9hp7R2eQdbDHysyfxpFZ8XF2KUuePnWQEJPvtTe cQwUbZRReOe6/CyjbCHKYgeFu5QHFd/SPAYVVG0P/rIc2ZE9sNJOcQJFFkffmBSBmdoN E/EqzcByhqcVY8vS80GnP1XZcPw0O7y+Wkb8pzVGAcU6BkHJ1PgxK/tDpRdnpAd2K0FW x8tQ== X-Gm-Message-State: AOAM533W/UKW+SUnHNTJX44GjJSVvH4lAhhlyMU5/IGBuW3TNF/HpI81 +2XDVbqk0MfB6EleZkSr7bk= X-Google-Smtp-Source: ABdhPJwc0gXcQNbXi4wauxJdUJOzB/R/HFQ4KaA94+CkBW5unEGwAKJM6qsNc2djNTohX6NYEK5drA== X-Received: by 2002:a05:6512:3ca3:: with SMTP id h35mr145327lfv.128.1635369521305; Wed, 27 Oct 2021 14:18:41 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 26/45] soc/tegra: pmc: Utilize power-handler API to power off Nexus 7 properly Date: Thu, 28 Oct 2021 00:16:56 +0300 Message-Id: <20211027211715.12671-27-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Nexus 7 Android tablet can be turned off using a special bootloader command which is conveyed to bootloader by putting magic value into specific scratch register and then rebooting normally. This power-off method should be invoked if USB cable is connected. Bootloader then will display battery status and power off the device. This behaviour is borrowed from downstream kernel and matches user expectations, otherwise it looks like device got hung during power-off and it may wake up on USB disconnect. Switch PMC driver to power-handler API, which provides drivers with combined power-off+restart call chains functionality, replacing the restart-only call chain API. Signed-off-by: Dmitry Osipenko --- drivers/soc/tegra/pmc.c | 54 +++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index 575d6d5b4294..a01330099e1a 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +108,7 @@ #define PMC_USB_DEBOUNCE_DEL 0xec #define PMC_USB_AO 0xf0 +#define PMC_SCRATCH37 0x130 #define PMC_SCRATCH41 0x140 #define PMC_WAKE2_MASK 0x160 @@ -1064,10 +1066,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid) return tegra_powergate_remove_clamping(id); } -static int tegra_pmc_restart_notify(struct notifier_block *this, - unsigned long action, void *data) +static void tegra_pmc_restart(const char *cmd) { - const char *cmd = data; u32 value; value = tegra_pmc_scratch_readl(pmc, pmc->soc->regs->scratch0); @@ -1090,13 +1090,33 @@ static int tegra_pmc_restart_notify(struct notifier_block *this, value = tegra_pmc_readl(pmc, PMC_CNTRL); value |= PMC_CNTRL_MAIN_RST; tegra_pmc_writel(pmc, value, PMC_CNTRL); +} - return NOTIFY_DONE; +static void tegra_pmc_restart_handler(struct restart_data *data) +{ + tegra_pmc_restart(data->cmd); } -static struct notifier_block tegra_pmc_restart_handler = { - .notifier_call = tegra_pmc_restart_notify, - .priority = 128, +static void tegra_pmc_power_off_handler(struct power_off_data *data) +{ + /* + * Reboot Nexus 7 into special bootloader mode if USB cable is + * connected in order to display battery status and power off. + */ + if (of_machine_is_compatible("asus,grouper") && + power_supply_is_system_supplied()) { + const u32 go_to_charger_mode = 0xa5a55a5a; + + tegra_pmc_writel(pmc, go_to_charger_mode, PMC_SCRATCH37); + tegra_pmc_restart(NULL); + } +} + +static struct power_handler tegra_pmc_power_handler = { + .restart_cb = tegra_pmc_restart_handler, + .power_off_cb = tegra_pmc_power_off_handler, + .power_off_priority = POWEROFF_PRIO_FIRMWARE, + .power_off_chaining_allowed = true, }; static int powergate_show(struct seq_file *s, void *data) @@ -2859,6 +2879,13 @@ static int tegra_pmc_probe(struct platform_device *pdev) pmc->clk = NULL; } + err = devm_register_power_handler(&pdev->dev, &tegra_pmc_power_handler); + if (err) { + dev_err(&pdev->dev, "unable to register power handler, %d\n", + err); + return err; + } + /* * PCLK clock rate can't be retrieved using CLK API because it * causes lockup if CPU enters LP2 idle state from some other @@ -2890,20 +2917,13 @@ static int tegra_pmc_probe(struct platform_device *pdev) goto cleanup_sysfs; } - err = register_restart_handler(&tegra_pmc_restart_handler); - if (err) { - dev_err(&pdev->dev, "unable to register restart handler, %d\n", - err); - goto cleanup_debugfs; - } - err = tegra_pmc_pinctrl_init(pmc); if (err) - goto cleanup_restart_handler; + goto cleanup_debugfs; err = tegra_pmc_regmap_init(pmc); if (err < 0) - goto cleanup_restart_handler; + goto cleanup_debugfs; err = tegra_powergate_init(pmc, pdev->dev.of_node); if (err < 0) @@ -2926,8 +2946,6 @@ static int tegra_pmc_probe(struct platform_device *pdev) cleanup_powergates: tegra_powergate_remove_all(pdev->dev.of_node); -cleanup_restart_handler: - unregister_restart_handler(&tegra_pmc_restart_handler); cleanup_debugfs: debugfs_remove(pmc->debugfs); cleanup_sysfs: From patchwork Wed Oct 27 21:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5453C433EF for ; Wed, 27 Oct 2021 21:28:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 838DF610C7 for ; Wed, 27 Oct 2021 21:28:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 838DF610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217294.377364 (Exim 4.92) (envelope-from ) id 1mfqSs-00040e-Ta; Wed, 27 Oct 2021 21:28:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217294.377364; Wed, 27 Oct 2021 21:28:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSs-0003sc-0v; Wed, 27 Oct 2021 21:28:06 +0000 Received: by outflank-mailman (input) for mailman id 217294; Wed, 27 Oct 2021 21:28:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLW-0000sJ-CQ for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:30 +0000 Received: from mail-lf1-x129.google.com (unknown [2a00:1450:4864:20::129]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 86a69c89-a557-4740-824b-69dfcad5c2ab; Wed, 27 Oct 2021 21:18:44 +0000 (UTC) Received: by mail-lf1-x129.google.com with SMTP id l13so8991340lfg.6 for ; Wed, 27 Oct 2021 14:18:44 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:42 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 86a69c89-a557-4740-824b-69dfcad5c2ab DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C0CUDQ/mpKr8nQVI8ALn1ZNGlMYg+VmEWd/lyCBC2+I=; b=Z3brf9Hxnc2b6ua3/QaRBg13ceKk9pypP3vq3e3axfEBPvBW41vI/qfBl8+BwawzwO NlHu2lL93XTrvXoS8prTqJO+oc3t3LVioKZpz1/2twqHxmO2Rep4n956JPepAb55tnvu Yq8u1nymmyHqcHNTOwToESfBr2ALI5JLRcu8Vew43TUipSvAyYGlhtxcdEE10JjxQ8L7 CgvM26J/cz900816o54jCXMSmEWOFUvtpqIxxDad09smC+hGdBM0SBN82Upy8AJEypnh RA0SpOKKidR5e2HsVPYqqyxDECtb4bl9tRIXX4QIA46Li7tlvPD9rk0WAJDNE7RcwF/Y YL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C0CUDQ/mpKr8nQVI8ALn1ZNGlMYg+VmEWd/lyCBC2+I=; b=QYZHkayd1rU4KUiFbHPPi7aR8O2qeW/LVfrCQJUYnt5HStEqeB4cg1UyF+ntyiDSbR jaIhcVRzEnHzAmiXgs7z8+SdkQZtI+tggiZaPAByC+woMHrPOMvpxICkR07c0xdj39jO a2YuBoUt7OStOf4xYlYP4478ZMpXsBWhjhQTlgQ52lWhTmQqLqmFOmQiGWa9aVgXVC3w ZuSpHDgU/bh+Vm/rX3duBTih7fO2AFJ8IUAbmo0ybvN0cyZph/NyQe00ob6A85X+nqDr arbtgiLmI7wMMjQsrNAFV254AWJnBSwmuBY7VkPl064RVEkRy3ipEfuRpiTLvCi0w5Je vN+Q== X-Gm-Message-State: AOAM5315Xdz3q2hAqaORyn7zn0EdN/AegwxiVJYasd95BRO0OuLhlDun HoBA0WoC3QUdfPNktT2YM1g= X-Google-Smtp-Source: ABdhPJw9ag+XL4jMbHM8NK1hhlQp61Q60DmRHFpovh5w79ZSq7lT/XD7C7FFPkBUSvk0m7mbQoA/BQ== X-Received: by 2002:a05:6512:31a:: with SMTP id t26mr125024lfp.280.1635369523122; Wed, 27 Oct 2021 14:18:43 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 27/45] mfd: ntxec: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:16:57 +0300 Message-Id: <20211027211715.12671-28-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_power_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. It also provides restart-handler support, i.e. all in one API. Signed-off-by: Dmitry Osipenko Reviewed-by: Jonathan Neuschäfer Tested-by: Jonathan Neuschäfer --- drivers/mfd/ntxec.c | 50 ++++++++++----------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/drivers/mfd/ntxec.c b/drivers/mfd/ntxec.c index b711e73eedcb..fd6410cbe153 100644 --- a/drivers/mfd/ntxec.c +++ b/drivers/mfd/ntxec.c @@ -32,12 +32,11 @@ #define NTXEC_POWERKEEP_VALUE 0x0800 #define NTXEC_RESET_VALUE 0xff00 -static struct i2c_client *poweroff_restart_client; - -static void ntxec_poweroff(void) +static void ntxec_poweroff(struct power_off_data *data) { int res; u8 buf[3] = { NTXEC_REG_POWEROFF }; + struct i2c_client *poweroff_restart_client = data->cb_data; struct i2c_msg msgs[] = { { .addr = poweroff_restart_client->addr, @@ -62,8 +61,7 @@ static void ntxec_poweroff(void) msleep(5000); } -static int ntxec_restart(struct notifier_block *nb, - unsigned long action, void *data) +static void ntxec_restart(struct restart_data *data) { int res; u8 buf[3] = { NTXEC_REG_RESET }; @@ -72,6 +70,7 @@ static int ntxec_restart(struct notifier_block *nb, * it causes an I2C error. (The reset handler in the downstream driver * does send the full two-byte value, but doesn't check the result). */ + struct i2c_client *poweroff_restart_client = data->cb_data; struct i2c_msg msgs[] = { { .addr = poweroff_restart_client->addr, @@ -87,13 +86,11 @@ static int ntxec_restart(struct notifier_block *nb, if (res < 0) dev_warn(&poweroff_restart_client->dev, "Failed to restart (err = %d)\n", res); - - return NOTIFY_DONE; } -static struct notifier_block ntxec_restart_handler = { - .notifier_call = ntxec_restart, - .priority = 128, +static struct power_handler ntxec_power_handler = { + .restart_cb = ntxec_restart, + .power_off_cb = ntxec_poweroff, }; static int regmap_ignore_write(void *context, @@ -208,25 +205,12 @@ static int ntxec_probe(struct i2c_client *client) if (res < 0) return res; - if (poweroff_restart_client) - /* - * Another instance of the driver already took - * poweroff/restart duties. - */ - dev_err(ec->dev, "poweroff_restart_client already assigned\n"); - else - poweroff_restart_client = client; - - if (pm_power_off) - /* Another driver already registered a poweroff handler. */ - dev_err(ec->dev, "pm_power_off already assigned\n"); - else - pm_power_off = ntxec_poweroff; - - res = register_restart_handler(&ntxec_restart_handler); + ntxec_power_handler.cb_data = client; + + res = devm_register_power_handler(ec->dev, &ntxec_power_handler); if (res) dev_err(ec->dev, - "Failed to register restart handler: %d\n", res); + "Failed to register power handler: %d\n", res); } i2c_set_clientdata(client, ec); @@ -239,17 +223,6 @@ static int ntxec_probe(struct i2c_client *client) return res; } -static int ntxec_remove(struct i2c_client *client) -{ - if (client == poweroff_restart_client) { - poweroff_restart_client = NULL; - pm_power_off = NULL; - unregister_restart_handler(&ntxec_restart_handler); - } - - return 0; -} - static const struct of_device_id of_ntxec_match_table[] = { { .compatible = "netronix,ntxec", }, {} @@ -262,7 +235,6 @@ static struct i2c_driver ntxec_driver = { .of_match_table = of_ntxec_match_table, }, .probe_new = ntxec_probe, - .remove = ntxec_remove, }; module_i2c_driver(ntxec_driver); From patchwork Wed Oct 27 21:16:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2557C433F5 for ; Wed, 27 Oct 2021 21:28:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68F62610CA for ; Wed, 27 Oct 2021 21:28:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 68F62610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217291.377349 (Exim 4.92) (envelope-from ) id 1mfqSp-0003Pb-6T; Wed, 27 Oct 2021 21:28:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217291.377349; Wed, 27 Oct 2021 21:28:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSp-0003PH-2K; Wed, 27 Oct 2021 21:28:03 +0000 Received: by outflank-mailman (input) for mailman id 217291; Wed, 27 Oct 2021 21:28:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLg-0000sJ-Cm for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:40 +0000 Received: from mail-lj1-x22c.google.com (unknown [2a00:1450:4864:20::22c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2a30c3a8-3914-4552-9591-340833ae07dc; Wed, 27 Oct 2021 21:18:45 +0000 (UTC) Received: by mail-lj1-x22c.google.com with SMTP id k13so6922068ljj.12 for ; Wed, 27 Oct 2021 14:18:45 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:44 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2a30c3a8-3914-4552-9591-340833ae07dc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XVkgO3q8+3iXvnI8C7YHW1hpsebxqvqNvVwPho8vSws=; b=JvBjth71MhsyIm0JdpPylPRsS4KUFW6BneSIAqxDXDzbFjW9Bt93MWfm5UnDUVT+LY PN2DoVOg4LkGHqR46okUaH0xtknlZuN7sz1m2rXWFP+8ycrv0mDE2+lXOLhNQyopT3Vb C9HJqmEvn5NNTeFE+Yqt8PhYhqF5nNL7X6uD9nn3NzyyFpNh4ofur6IOki9Q5zCOptdK PNXfyjJD/8x2BE3QO9lZ5RaDpWCetJjHnzeJvzuWrsMKLwqp5dFqdwNw5X1p5tIb9H77 X9gwILOKempj602Hj9wd8g1ui3+PA2eteBB91Roi8uzQIKwV7mQ4s5O8fFD8fUrtUyG6 Kjfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XVkgO3q8+3iXvnI8C7YHW1hpsebxqvqNvVwPho8vSws=; b=Cv6uTIRUoRiNxUDYded0HSpKvlZPwGeb2gPoFy0B36ap8b767QFpNMBV3eQwfBlSQu YbuJgQ5blV6EV/LFQB4WxtL4goTzHhJN5L3zeKyCh/gZOnbWW3/03T24r4b2O3YuAl3d lu4C+bCFb0/+merDn1ZnM0tMC0lZO20loeqvgHd22ZLe86HlyaEkBVLx01yZvjIScBwG smxWdTRQjkalmg7AGdlb6w1SYvEwlVUlZJCIHpwf0urSSQ5K+IjgJSSnEjJhPKY3xh1A 1fXA7GDMzn2lCQ6SOpgzt5P5L7h0un+MUx0J6TZTgNzBt9PLu86Ubxi/NKQUeyk5htiC OLzw== X-Gm-Message-State: AOAM533V+wAfoJO5TwDZNOi1ZykbfglfosZqd2HY5ujTzdI+krnVL4+8 0OuMOVx4vbuZT7+WtpfjWVo= X-Google-Smtp-Source: ABdhPJyyXdjb3N9Ed9Jr705ZzPzIsFRHZUJ+KOYE2dHtjD39JQsr/OWSSeXdN0P7Zob21uOYhbWDdA== X-Received: by 2002:a2e:9b55:: with SMTP id o21mr306486ljj.141.1635369524980; Wed, 27 Oct 2021 14:18:44 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 28/45] mfd: rn5t618: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:16:58 +0300 Message-Id: <20211027211715.12671-29-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_power_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. It also provides restart-handler support, i.e. all in one API. Signed-off-by: Dmitry Osipenko --- drivers/mfd/rn5t618.c | 56 ++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 384acb459427..12d7b2339bbe 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -84,9 +84,6 @@ static const struct regmap_irq_chip rc5t619_irq_chip = { .mask_invert = true, }; -static struct i2c_client *rn5t618_pm_power_off; -static struct notifier_block rn5t618_restart_handler; - static int rn5t618_irq_init(struct rn5t618 *rn5t618) { const struct regmap_irq_chip *irq_chip = NULL; @@ -115,7 +112,9 @@ static int rn5t618_irq_init(struct rn5t618 *rn5t618) return ret; } -static void rn5t618_trigger_poweroff_sequence(bool repower) +static void +rn5t618_trigger_poweroff_sequence(struct i2c_client *rn5t618_pm_power_off, + bool repower) { int ret; @@ -151,25 +150,31 @@ static void rn5t618_trigger_poweroff_sequence(bool repower) dev_alert(&rn5t618_pm_power_off->dev, "Failed to shutdown (err = %d)\n", ret); } -static void rn5t618_power_off(void) +static void rn5t618_power_off(struct power_off_data *data) { - rn5t618_trigger_poweroff_sequence(false); + struct i2c_client *client = data->cb_data; + + rn5t618_trigger_poweroff_sequence(client, false); } -static int rn5t618_restart(struct notifier_block *this, - unsigned long mode, void *cmd) +static void rn5t618_restart(struct restart_data *data) { - rn5t618_trigger_poweroff_sequence(true); + struct i2c_client *client = data->cb_data; + + rn5t618_trigger_poweroff_sequence(client, true); /* * Re-power factor detection on PMIC side is not instant. 1ms * proved to be enough time until reset takes effect. */ mdelay(1); - - return NOTIFY_DONE; } +static struct power_handler rn5t618_power_handler = { + .restart_cb = rn5t618_restart, + .restart_priority = RESTART_PRIO_HIGH, +}; + static const struct of_device_id rn5t618_of_match[] = { { .compatible = "ricoh,rn5t567", .data = (void *)RN5T567 }, { .compatible = "ricoh,rn5t618", .data = (void *)RN5T618 }, @@ -221,38 +226,20 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c) return ret; } - rn5t618_pm_power_off = i2c; - if (of_device_is_system_power_controller(i2c->dev.of_node)) { - if (!pm_power_off) - pm_power_off = rn5t618_power_off; - else - dev_warn(&i2c->dev, "Poweroff callback already assigned\n"); - } + if (of_device_is_system_power_controller(i2c->dev.of_node)) + rn5t618_power_handler.power_off_cb = rn5t618_power_off; - rn5t618_restart_handler.notifier_call = rn5t618_restart; - rn5t618_restart_handler.priority = 192; + rn5t618_power_handler.cb_data = i2c; - ret = register_restart_handler(&rn5t618_restart_handler); + ret = devm_register_power_handler(&i2c->dev, &rn5t618_power_handler); if (ret) { - dev_err(&i2c->dev, "cannot register restart handler, %d\n", ret); + dev_err(&i2c->dev, "failed to register power handler: %d\n", ret); return ret; } return rn5t618_irq_init(priv); } -static int rn5t618_i2c_remove(struct i2c_client *i2c) -{ - if (i2c == rn5t618_pm_power_off) { - rn5t618_pm_power_off = NULL; - pm_power_off = NULL; - } - - unregister_restart_handler(&rn5t618_restart_handler); - - return 0; -} - static int __maybe_unused rn5t618_i2c_suspend(struct device *dev) { struct rn5t618 *priv = dev_get_drvdata(dev); @@ -284,7 +271,6 @@ static struct i2c_driver rn5t618_i2c_driver = { .pm = &rn5t618_i2c_dev_pm_ops, }, .probe_new = rn5t618_i2c_probe, - .remove = rn5t618_i2c_remove, }; module_i2c_driver(rn5t618_i2c_driver); From patchwork Wed Oct 27 21:16:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F07F1C433F5 for ; Wed, 27 Oct 2021 21:28:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C01660E74 for ; Wed, 27 Oct 2021 21:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9C01660E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217340.377425 (Exim 4.92) (envelope-from ) id 1mfqTG-0000BF-WA; Wed, 27 Oct 2021 21:28:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217340.377425; Wed, 27 Oct 2021 21:28:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTG-00008j-RD; Wed, 27 Oct 2021 21:28:30 +0000 Received: by outflank-mailman (input) for mailman id 217340; Wed, 27 Oct 2021 21:28:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLl-0000sJ-Ct for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:45 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 649940cd-d36d-4ca6-8e33-520c1685eb77; Wed, 27 Oct 2021 21:18:47 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id j9so8979909lfu.7 for ; Wed, 27 Oct 2021 14:18:47 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:46 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 649940cd-d36d-4ca6-8e33-520c1685eb77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VpMTaQaJ0cjNLgvNqh3di7liIGTew7KcJqDZRitT+Gs=; b=IWwdEP2zbLaLlU4mCU5s8PpqrkaIWlck+oA3xnCuAzsOirLY91m5COquObIzRO/SOa ZZIFcDLGTP22p0/7Hcw3xr55ftJZWhQ4nU6sBNGCfWjV2gTeJrHUPc9jLo/fr5xO0l0l 0SNS1n6R63fMlbNJFT3gbKkQCc0Ia7/EAvKfYLtASP95KzfXrWNNTSb1yRqxn8x5d6xD hciHreIyBYgx6dcdUlzTSBb07ys9RFpq3Y5/l5Vd2vvkqxnAXOO/WD9ek4xsO4aDTsfM H41ne9Olkj2NqvJkNPysdfnoteByPeCFY3T52VBJFYJ9FKDG6+cEspYVw2UY7y4ppIDD pOHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VpMTaQaJ0cjNLgvNqh3di7liIGTew7KcJqDZRitT+Gs=; b=RqdCZsuPuXVDshcCV9ZuWRS9ycon7W4A1fnVSfv83Ql2mcWskO7RRnPBBEJ/1ty5l7 bbFZKSxerXH6O0qcjyAcsFHQbHMdQ2XlhnyrEz0LYrpmYjg1q487EQsdId+xzbwC6adM jmhZz2SU9sNREpawQUSvRq8qt02oO3WjFnXMkRWoyOj1MAUOk8hmJ6EkoeFswypVotXk EUuVX9fcrYy8W/I24BXkCRIxztlHizUnrr1kgD6Jq5B3aa1RjYr6lhhjl4b81ox5erUF JZHI9fp6OxrGjOI/fztNxoWq9mSHQJUIXblQGMaYtvdS1QhKGECXNlXCwPPhvGmJgBpj 4X/Q== X-Gm-Message-State: AOAM532JcXTqEu0wFc0NjYli1BbzC1Tj47kksX2nTQg5T/uvklp8ra86 oP3te+1I09knbtGaJPEFOPY= X-Google-Smtp-Source: ABdhPJys0u/+wFsWDr/9j4b/C5x8WEos0EuABuOI0MYqETh3mbRQO/mjL91g1gnGx/4TO6/Fje2n8g== X-Received: by 2002:ac2:4c9a:: with SMTP id d26mr128014lfl.344.1635369526848; Wed, 27 Oct 2021 14:18:46 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 29/45] mfd: acer-a500: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:16:59 +0300 Message-Id: <20211027211715.12671-30-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_power_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. It also provides restart-handler support, i.e. all in one API. Signed-off-by: Dmitry Osipenko --- drivers/mfd/acer-ec-a500.c | 52 ++++++++++++++------------------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/drivers/mfd/acer-ec-a500.c b/drivers/mfd/acer-ec-a500.c index 80c2fdd14fc4..fc864abc0049 100644 --- a/drivers/mfd/acer-ec-a500.c +++ b/drivers/mfd/acer-ec-a500.c @@ -31,8 +31,6 @@ enum { REG_COLD_REBOOT = 0x55, }; -static struct i2c_client *a500_ec_client_pm_off; - static int a500_ec_read(void *context, const void *reg_buf, size_t reg_size, void *val_buf, size_t val_sizel) { @@ -104,32 +102,35 @@ static const struct regmap_bus a500_ec_regmap_bus = { .max_raw_read = 2, }; -static void a500_ec_poweroff(void) +static void a500_ec_power_off_handler(struct power_off_data *data) { - i2c_smbus_write_word_data(a500_ec_client_pm_off, - REG_SHUTDOWN, CMD_SHUTDOWN); + struct i2c_client *client = data->cb_data; + + i2c_smbus_write_word_data(client, REG_SHUTDOWN, CMD_SHUTDOWN); mdelay(A500_EC_POWER_CMD_TIMEOUT); } -static int a500_ec_restart_notify(struct notifier_block *this, - unsigned long reboot_mode, void *data) +static void a500_ec_restart_handler(struct restart_data *data) { - if (reboot_mode == REBOOT_WARM) - i2c_smbus_write_word_data(a500_ec_client_pm_off, + struct i2c_client *client = data->cb_data; + + if (data->mode == REBOOT_WARM) + i2c_smbus_write_word_data(client, REG_WARM_REBOOT, CMD_WARM_REBOOT); else - i2c_smbus_write_word_data(a500_ec_client_pm_off, + i2c_smbus_write_word_data(client, REG_COLD_REBOOT, CMD_COLD_REBOOT); mdelay(A500_EC_POWER_CMD_TIMEOUT); - - return NOTIFY_DONE; } -static struct notifier_block a500_ec_restart_handler = { - .notifier_call = a500_ec_restart_notify, - .priority = 200, +static struct power_handler a500_ec_power_handler = { + .restart_cb = a500_ec_restart_handler, + .restart_priority = RESTART_PRIO_HIGH, + + .power_off_cb = a500_ec_power_off_handler, + .power_off_priority = POWEROFF_PRIO_HIGH, }; static const struct mfd_cell a500_ec_cells[] = { @@ -156,26 +157,12 @@ static int a500_ec_probe(struct i2c_client *client) } if (of_device_is_system_power_controller(client->dev.of_node)) { - a500_ec_client_pm_off = client; + a500_ec_power_handler.cb_data = client; - err = register_restart_handler(&a500_ec_restart_handler); + err = devm_register_power_handler(&client->dev, + &a500_ec_power_handler); if (err) return err; - - if (!pm_power_off) - pm_power_off = a500_ec_poweroff; - } - - return 0; -} - -static int a500_ec_remove(struct i2c_client *client) -{ - if (of_device_is_system_power_controller(client->dev.of_node)) { - if (pm_power_off == a500_ec_poweroff) - pm_power_off = NULL; - - unregister_restart_handler(&a500_ec_restart_handler); } return 0; @@ -193,7 +180,6 @@ static struct i2c_driver a500_ec_driver = { .of_match_table = a500_ec_match, }, .probe_new = a500_ec_probe, - .remove = a500_ec_remove, }; module_i2c_driver(a500_ec_driver); From patchwork Wed Oct 27 21:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43A74C433EF for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFD2B60E73 for ; Wed, 27 Oct 2021 21:28:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EFD2B60E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217271.377244 (Exim 4.92) (envelope-from ) id 1mfqSb-0008W1-Nc; Wed, 27 Oct 2021 21:27:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217271.377244; Wed, 27 Oct 2021 21:27:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSb-0008Uy-Hl; Wed, 27 Oct 2021 21:27:49 +0000 Received: by outflank-mailman (input) for mailman id 217271; Wed, 27 Oct 2021 21:27:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLq-0000sJ-D1 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:50 +0000 Received: from mail-lf1-x12b.google.com (unknown [2a00:1450:4864:20::12b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6b24b17d-f326-4da9-87af-f64c80f064d3; Wed, 27 Oct 2021 21:18:49 +0000 (UTC) Received: by mail-lf1-x12b.google.com with SMTP id f3so806989lfu.12 for ; Wed, 27 Oct 2021 14:18:49 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:48 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6b24b17d-f326-4da9-87af-f64c80f064d3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=umNH2+YT7M6ZKcjQGvjjohnKVEe/3rK29YQH+BDj6i4=; b=nj5zb43OqtwdizDOJ4YZ+fYZadM1gdDKmRqYZUCoy6YYJ9FK+h8NFV8Fm4J2Ku+dUO VD1iu0fINLYL61cuY7tNDYLtDDcpQWTMBS3LiXmrEVigOlROqEfbjJpsrnK8lw9w6k0A Q5RVvk+HURAmLxg4yngnt6lHHBxEc4oSlIcG3ZpIBx+R3YAOuuSSdjMf/vRVMuvqCw1Z E8uGSsJkZ6VWq/NOLfLD+OAnXKEDLZsNGIWjcaZrIrkicK6f30puV4871fbRXrX4aoDM yS04DJACEKWBr3KF/AjOj2De3JGJ2p+GHt74NSrUBKQDPvr858UletsNh5sICSkmVEWD 3KsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=umNH2+YT7M6ZKcjQGvjjohnKVEe/3rK29YQH+BDj6i4=; b=wRRl6TaF/lWmwyCCvr9GZAD93OnfkRb//X5tW9b5zEnU0uM2wAWxS4zjUIpclUVpBD VM40jfJIKs9MgJ+0HlH7YUr54szABsr+RAjAGiLcTQu5qxOYA/Hgpq5WkAXgdBv5JjhD OVjB8H/yAA3W6SVDmOHXEIigvB4m3W0pL6Gkcd6qssCrxoTGHD54VDWiy6rTTflhxlij 1zu/k6X1FJFyzpT7JSsB2BXJIW7lQxQrTIQA4evCaMeFTxxLPbU/RZk5w/r1heTDQaT5 MVNIrDb8Yfpq6i9L6yMIMnYwsubjUZNXuq+LDx4ex6rQNglXGBpNu7Il9e+uUMTqTLaN B+eQ== X-Gm-Message-State: AOAM531Xz80I7RwlXZ6T1lICkZCULmqZ2QUBAViKksvq4b1zn7TJjX7M ZeCBqlwuN83zg5DfVy1BRqg= X-Google-Smtp-Source: ABdhPJyzuSZuOYHEQbprBgwtJMyx5L9tc7ERtjIIXrEKG72XHaUi8WMWlLHXLzXgCVfDIwEbrdMbVw== X-Received: by 2002:a05:6512:38d0:: with SMTP id p16mr83922lft.483.1635369528748; Wed, 27 Oct 2021 14:18:48 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 30/45] mfd: ene-kb3930: Use devm_register_power_handler() Date: Thu, 28 Oct 2021 00:17:00 +0300 Message-Id: <20211027211715.12671-31-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_power_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. It also provides restart-handler support, i.e. all in one API. Signed-off-by: Dmitry Osipenko --- drivers/mfd/ene-kb3930.c | 45 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/mfd/ene-kb3930.c b/drivers/mfd/ene-kb3930.c index 1b73318d1f1f..6a3c5f48e5e1 100644 --- a/drivers/mfd/ene-kb3930.c +++ b/drivers/mfd/ene-kb3930.c @@ -31,10 +31,9 @@ struct kb3930 { struct i2c_client *client; struct regmap *ram_regmap; struct gpio_descs *off_gpios; + struct power_handler power_handler; }; -static struct kb3930 *kb3930_power_off; - #define EC_GPIO_WAVE 0 #define EC_GPIO_OFF_MODE 1 @@ -60,21 +59,19 @@ static void kb3930_off(struct kb3930 *ddata, int off_mode) } } -static int kb3930_restart(struct notifier_block *this, - unsigned long mode, void *cmd) +static void kb3930_restart(struct restart_data *data) { - kb3930_off(kb3930_power_off, EC_OFF_MODE_REBOOT); - return NOTIFY_DONE; + struct kb3930 *ddata = data->cb_data; + + kb3930_off(ddata, EC_OFF_MODE_REBOOT); } -static void kb3930_pm_power_off(void) +static void kb3930_power_off(struct power_off_data *data) { - kb3930_off(kb3930_power_off, EC_OFF_MODE_POWER); -} + struct kb3930 *ddata = data->cb_data; -static struct notifier_block kb3930_restart_nb = { - .notifier_call = kb3930_restart, -}; + kb3930_off(ddata, EC_OFF_MODE_POWER); +} static const struct mfd_cell ariel_ec_cells[] = { { .name = "dell-wyse-ariel-led", }, @@ -131,7 +128,6 @@ static int kb3930_probe(struct i2c_client *client) if (!ddata) return -ENOMEM; - kb3930_power_off = ddata; ddata->client = client; i2c_set_clientdata(client, ddata); @@ -169,24 +165,14 @@ static int kb3930_probe(struct i2c_client *client) } if (ddata->off_gpios) { - register_restart_handler(&kb3930_restart_nb); - if (!pm_power_off) - pm_power_off = kb3930_pm_power_off; - } + ddata->power_handler.cb_data = ddata; + ddata->power_handler.restart_cb = kb3930_restart; + ddata->power_handler.power_off_cb = kb3930_power_off; - return 0; -} - -static int kb3930_remove(struct i2c_client *client) -{ - struct kb3930 *ddata = i2c_get_clientdata(client); - - if (ddata->off_gpios) { - if (pm_power_off == kb3930_pm_power_off) - pm_power_off = NULL; - unregister_restart_handler(&kb3930_restart_nb); + ret = devm_register_power_handler(dev, &ddata->power_handler); + if (ret) + return ret; } - kb3930_power_off = NULL; return 0; } @@ -199,7 +185,6 @@ MODULE_DEVICE_TABLE(of, kb3930_dt_ids); static struct i2c_driver kb3930_driver = { .probe_new = kb3930_probe, - .remove = kb3930_remove, .driver = { .name = "ene-kb3930", .of_match_table = kb3930_dt_ids, From patchwork Wed Oct 27 21:17:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41A27C433FE for ; Wed, 27 Oct 2021 21:28:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E404C60E74 for ; Wed, 27 Oct 2021 21:28:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E404C60E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217350.377460 (Exim 4.92) (envelope-from ) id 1mfqTM-0001PZ-92; Wed, 27 Oct 2021 21:28:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217350.377460; Wed, 27 Oct 2021 21:28:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTL-0001M3-Gf; Wed, 27 Oct 2021 21:28:35 +0000 Received: by outflank-mailman (input) for mailman id 217350; Wed, 27 Oct 2021 21:28:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqLv-0000sJ-D2 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:20:55 +0000 Received: from mail-lf1-x132.google.com (unknown [2a00:1450:4864:20::132]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 765197f5-6d84-42ba-939a-91f43f9d5d2b; Wed, 27 Oct 2021 21:18:51 +0000 (UTC) Received: by mail-lf1-x132.google.com with SMTP id bi35so8959697lfb.9 for ; Wed, 27 Oct 2021 14:18:51 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:50 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 765197f5-6d84-42ba-939a-91f43f9d5d2b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MQWhTF0wBI+IugzPE3ghLHT129hypIGKpejDwrM3hyE=; b=RZvyurGZNweTiQS39Ean2OjgLccYrK032pC/dpD5TIetEdWActoZDZ0pbxUwZ65EB3 f6HHqHOjaIJRkLRbNXFH+a9dD2g5xu+MxS8srOD+UoT89FXGbOpnIpBzsogwI4SrHnvI Xp4OXB4rFx2UJNCOe+1ontZRmKhqDl18fc0h55fLU7qhbVovqyZfQtN1oE2ZBblN4A6p LG+FlNBhlZ+ejJ/tR/o9Ca2I3+iU/ni7hPa9YCzdcCgi2bkMHewfSz0zfMDsoGnOZiG5 WYH0N8y7+ABYK8jopd3eQsXttqeRRQN+xpWJ5QIjK2cUfd8tbZPE8negDAsL0a+gaJ2V fJ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MQWhTF0wBI+IugzPE3ghLHT129hypIGKpejDwrM3hyE=; b=TrWHUXfnUy4TAP/21iJjmHLf5D1rssfNba3HCQtdgoa5UnY5Gi69Peuh2LaeSC+HEg GplshlLQwjhwi+JFPFZxZbD10p0ScPYIeMDnqQRZAK25R+CLzpOZl5y/xSZ+frcY/I9s PbMxWxRFTQiNpT/87xIN5ChognVwVms5Q2P8G/xhi7xQ/n072b//jy7Dfvmk4Wj1IsL8 0hyhAhYaiiXjbDJo4p2V0b5t36wk3xBay4WEPAAR4Em4Vjo+wL3PeOr2Ypjop/r6DCB6 hjGzu96SPJs7tUvc9OZ4qPQze0lNQ/58+FbKNRuGJai3ux1t8cbIIW8d2gFs652OrqTk uR5Q== X-Gm-Message-State: AOAM533Zd8U4h9uqqxFDJ/+xq9vNGZY9tzp3qtR+BJ8GRFZAm6rKXpzL Rj+mKIBS1lrrF0u1roulv7M= X-Google-Smtp-Source: ABdhPJyooWx5IN/z+hq1uWs5thGA811Cpi77JA6dUlt/XGnE5KIxJDhql9o1FzopBJlB1UrwswiMLg== X-Received: by 2002:a05:6512:3f04:: with SMTP id y4mr131405lfa.180.1635369530580; Wed, 27 Oct 2021 14:18:50 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 31/45] mfd: axp20x: Use register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:01 +0300 Message-Id: <20211027211715.12671-32-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/axp20x.c | 22 +++++++++++----------- include/linux/mfd/axp20x.h | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 8161a5dc68e8..db31fdb169e4 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -823,9 +824,10 @@ static const struct mfd_cell axp813_cells[] = { }, }; -static struct axp20x_dev *axp20x_pm_power_off; -static void axp20x_power_off(void) +static void axp20x_power_off(void *data) { + struct axp20x_dev *axp20x_pm_power_off = data; + if (axp20x_pm_power_off->variant == AXP288_ID) return; @@ -1000,10 +1002,12 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) return ret; } - if (!pm_power_off) { - axp20x_pm_power_off = axp20x; - pm_power_off = axp20x_power_off; - } + axp20x->power_handler = + register_simple_power_off_handler(axp20x_power_off, axp20x); + + if (IS_ERR(axp20x->power_handler)) + dev_err(axp20x->dev, "failed to register power-off handler: %pe", + axp20x->power_handler); dev_info(axp20x->dev, "AXP20X driver loaded\n"); @@ -1013,11 +1017,7 @@ EXPORT_SYMBOL(axp20x_device_probe); void axp20x_device_remove(struct axp20x_dev *axp20x) { - if (axp20x == axp20x_pm_power_off) { - axp20x_pm_power_off = NULL; - pm_power_off = NULL; - } - + unregister_simple_power_off_handler(axp20x->power_handler); mfd_remove_devices(axp20x->dev); regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc); } diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 9ab0e2fca7ea..49319a0ac369 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -643,6 +643,7 @@ struct axp20x_dev { const struct mfd_cell *cells; const struct regmap_config *regmap_cfg; const struct regmap_irq_chip *regmap_irq_chip; + struct power_handler *power_handler; }; /* generic helper function for reading 9-16 bit wide regs */ From patchwork Wed Oct 27 21:17:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 215ACC433FE for ; Wed, 27 Oct 2021 21:28:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CED9060E74 for ; Wed, 27 Oct 2021 21:28:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CED9060E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217311.377395 (Exim 4.92) (envelope-from ) id 1mfqT2-00066Y-5v; Wed, 27 Oct 2021 21:28:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217311.377395; Wed, 27 Oct 2021 21:28:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqT1-00062N-Cu; Wed, 27 Oct 2021 21:28:15 +0000 Received: by outflank-mailman (input) for mailman id 217311; Wed, 27 Oct 2021 21:28:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqM0-0000sJ-D6 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:21:00 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9672a8f3-3b40-45f5-bd54-2ef11c63971a; Wed, 27 Oct 2021 21:18:53 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id bq11so8957029lfb.10 for ; Wed, 27 Oct 2021 14:18:53 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:52 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9672a8f3-3b40-45f5-bd54-2ef11c63971a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3tizDJEeWC2iLbZdJm6My4oRtC+CKaYmiKRSIM6veO0=; b=P2SMTBdUazDV2Wnt33aO9FM2Ioz84SezmWonZoC9di4gBNxmpSDTZT6tEbAs+vJh3H Fl3mZiziafsNnSwbT1iMyr0r9bKbxSiHP3xJiOBIo4ewxSS3FiLigSFoEgJOcOsMECFU Ealy6ndYpUfciCkbDSvwvbDJBaKQyOcr0jiZpeL2e0iKkV4AQLDVCHRPOCPCDpkazzgq BERHUZw176GWVNNNOqpmpYaLAn7f4joDeIeKRo11vDGHWht2ujkzv0CrGvSNdzJe9tR3 GFiFAzCfeg61A5JBu27BdMdrz99RW2oVhEudj/a2XZux9KH22qJjawF87cCiFM6fKipn F+kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3tizDJEeWC2iLbZdJm6My4oRtC+CKaYmiKRSIM6veO0=; b=WKuF3f5jMtIPIfAp9WX/XWuZm0OkzVRuQ8n1SSOmvmAYeqHB8/JVNlgutqTd7ao/I/ 4sLUvoS8w+lUoXpHkxG4Km/HbvH2AYth1+56pNotULysNpLyFJMblvJjt9o148NCRFY3 jh2rh7iLolIwrxXjQEgDgTUgZKu/0XzQ3h0f5bD2Nm1hOJMu8GDzbx+T5qx2s0cJ71I+ jDRTZQ2bEqrbchtaSwBuGxqFymxnuuEFz3egntDoXUyAco0BAk4VIvt6z4PzIugTJSde LmmV62eUjqGp27fMVlGPjJ0o/+Kow+WlYMx/f3zSmjAXfBuO7q+22MM2FAT84BaorbK2 JFoA== X-Gm-Message-State: AOAM532rBXGmjDWEC0Jx6V9lAx3yhBc7WLLK2Nl1UFLIVJ0YrQD9X+ak zAQFJA6Ii4n6j21/IFoiNIo= X-Google-Smtp-Source: ABdhPJw7dGE4iKe+cyeyTSJFUn+l5q/Abxrr3B6KYrOVBl1p66aP04j6vH2fcBbUhHRs8nFJgDlWqw== X-Received: by 2002:a05:6512:1095:: with SMTP id j21mr134174lfg.274.1635369532441; Wed, 27 Oct 2021 14:18:52 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 32/45] mfd: retu: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:02 +0300 Message-Id: <20211027211715.12671-33-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/retu-mfd.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c index c748fd29a220..d18f05c1f095 100644 --- a/drivers/mfd/retu-mfd.c +++ b/drivers/mfd/retu-mfd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -81,9 +82,6 @@ static struct regmap_irq_chip retu_irq_chip = { .ack_base = RETU_REG_IDR, }; -/* Retu device registered for the power off. */ -static struct retu_dev *retu_pm_power_off; - static const struct resource tahvo_usb_res[] = { { .name = "tahvo-usb", @@ -165,12 +163,12 @@ int retu_write(struct retu_dev *rdev, u8 reg, u16 data) } EXPORT_SYMBOL_GPL(retu_write); -static void retu_power_off(void) +static void retu_power_off(void *data) { - struct retu_dev *rdev = retu_pm_power_off; + struct retu_dev *rdev = data; int reg; - mutex_lock(&retu_pm_power_off->mutex); + mutex_lock(&rdev->mutex); /* Ignore power button state */ regmap_read(rdev->regmap, RETU_REG_CC1, ®); @@ -183,7 +181,7 @@ static void retu_power_off(void) for (;;) cpu_relax(); - mutex_unlock(&retu_pm_power_off->mutex); + mutex_unlock(&rdev->mutex); } static int retu_regmap_read(void *context, const void *reg, size_t reg_size, @@ -261,6 +259,17 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) (ret & RETU_REG_ASICR_VILMA) ? rdat->companion_name : "", (ret >> 4) & 0x7, ret & 0xf); + if (i2c->addr == 1) { + ret = devm_register_simple_power_off_handler(&i2c->dev, + retu_power_off, + rdev); + if (ret) { + dev_err(rdev->dev, + "could not register power-off handler: %d\n", ret); + return ret; + } + } + /* Mask all interrupts. */ ret = retu_write(rdev, rdat->irq_chip->mask_base, 0xffff); if (ret < 0) @@ -279,10 +288,6 @@ static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) return ret; } - if (i2c->addr == 1 && !pm_power_off) { - retu_pm_power_off = rdev; - pm_power_off = retu_power_off; - } return 0; } @@ -291,10 +296,6 @@ static int retu_remove(struct i2c_client *i2c) { struct retu_dev *rdev = i2c_get_clientdata(i2c); - if (retu_pm_power_off == rdev) { - pm_power_off = NULL; - retu_pm_power_off = NULL; - } mfd_remove_devices(rdev->dev); regmap_del_irq_chip(i2c->irq, rdev->irq_data); From patchwork Wed Oct 27 21:17:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 908ADC433F5 for ; Wed, 27 Oct 2021 21:29:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4AE0860E74 for ; Wed, 27 Oct 2021 21:29:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4AE0860E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217365.377511 (Exim 4.92) (envelope-from ) id 1mfqTW-0003Xo-OX; Wed, 27 Oct 2021 21:28:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217365.377511; Wed, 27 Oct 2021 21:28:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTV-0003S7-Hy; Wed, 27 Oct 2021 21:28:45 +0000 Received: by outflank-mailman (input) for mailman id 217365; Wed, 27 Oct 2021 21:28:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqMA-0000sJ-DL for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:21:10 +0000 Received: from mail-lj1-x233.google.com (unknown [2a00:1450:4864:20::233]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5b88031b-e522-4827-becf-81d9a5b22854; Wed, 27 Oct 2021 21:18:55 +0000 (UTC) Received: by mail-lj1-x233.google.com with SMTP id s19so6945173ljj.11 for ; Wed, 27 Oct 2021 14:18:55 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:53 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5b88031b-e522-4827-becf-81d9a5b22854 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Vtt3o4MswiJ8Uwk5SbVoJldxGf1+YbPRO7EtWlQaYpw=; b=h9Sc10ekNHuFL9pzFR5ivr4ubnoV3ErBKpxwq8qtLnmmEwmpDGD4jSeaWauc76yLUe mSt4r4zCNyFKj4h5OR8HLlxF7zfIwR2mYZXQxAs/YUFPraXy5oJXAYRRb5XFp5DFvHId dp4uwopusQmPxwo8pBprt9hjoN+nwfiSLFgat9Xg5VUZGhfoEbJhN2yWrZJiei/Mb3oo mtgvsX4Y0EPIUr2yLJuO6jAqsOYLbfr0p9vS8kzfJK4fcF7aAzjiqNMDP4LlFTOflII0 /Ozi7fljMZ5bdh0k27GOMuAQZgJbYkevh7WpkJcoo8VpN/Xp7c/9529BJm6xL6ZNrYi/ VmuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vtt3o4MswiJ8Uwk5SbVoJldxGf1+YbPRO7EtWlQaYpw=; b=zW87Cb28Ra2mF2jh4VUx07tpYuwVyYlSNfj0U7XmyzkZpQuNfeUdQ4/n10xQoMjNC8 FUK1KqBAkBhCPeXGGhAZFPqEVm3kAWH/RndMpAihmVB5wkb4LdCdagmUHiD676OmCok2 wQDbtaWAo7/KIJpquQEKL4m805JcAdIf0Kbu/j7McZDEoJVo318DFpqyJKkb4Swqbjry 3/a4tTNn8jIzEgOg9lzxyr+jzNNBsz3VQLNE7ywcNk+h+En4uDJlEEUOmsOOEV1UvTgR yEKTjc/T0mBFfj64LwjKcuReEBFROImb1tDEcL4fz3Ilb/MQ5eEudvL4NQWscE1bT8j+ E2+A== X-Gm-Message-State: AOAM532MK1UbnfPtD7V6pnkmI72J6+YTu0sPPclaJG8qmKGsZQsFyCFY B2rATSksO3C722yk0MYwezw= X-Google-Smtp-Source: ABdhPJyyBz+GAYvcNwhzUHtMKnc91wku7za2iucydPD6HlUd9fBk/92YnwCUeQIBB5tQ4kJ4zljd+g== X-Received: by 2002:a2e:b804:: with SMTP id u4mr293626ljo.425.1635369534279; Wed, 27 Oct 2021 14:18:54 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 33/45] mfd: rk808: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:03 +0300 Message-Id: <20211027211715.12671-34-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/rk808.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index b181fe401330..3bf369469053 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -18,6 +18,7 @@ #include #include #include +#include #include struct rk808_reg_data { @@ -526,12 +527,11 @@ static const struct regmap_irq_chip rk818_irq_chip = { .init_ack_masked = true, }; -static struct i2c_client *rk808_i2c_client; - -static void rk808_pm_power_off(void) +static void rk808_pm_power_off(void *data) { int ret; unsigned int reg, bit; + struct i2c_client *rk808_i2c_client = data; struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); switch (rk808->variant) { @@ -725,8 +725,14 @@ static int rk808_probe(struct i2c_client *client, } if (of_property_read_bool(np, "rockchip,system-power-controller")) { - rk808_i2c_client = client; - pm_power_off = rk808_pm_power_off; + ret = devm_register_simple_power_off_handler(&client->dev, + rk808_pm_power_off, + client); + if (ret) { + dev_err(&client->dev, + "failed to register power-off handler %d\n", ret); + goto err_irq; + } } return 0; @@ -742,13 +748,6 @@ static int rk808_remove(struct i2c_client *client) regmap_del_irq_chip(client->irq, rk808->irq_data); - /** - * pm_power_off may points to a function from another module. - * Check if the pointer is set by us and only then overwrite it. - */ - if (pm_power_off == rk808_pm_power_off) - pm_power_off = NULL; - return 0; } From patchwork Wed Oct 27 21:17:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A72C5C433EF for ; Wed, 27 Oct 2021 21:29:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 556A0610CA for ; Wed, 27 Oct 2021 21:29:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 556A0610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217381.377555 (Exim 4.92) (envelope-from ) id 1mfqTh-0006Jn-W2; Wed, 27 Oct 2021 21:28:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217381.377555; Wed, 27 Oct 2021 21:28:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTh-0006H9-E9; Wed, 27 Oct 2021 21:28:57 +0000 Received: by outflank-mailman (input) for mailman id 217381; Wed, 27 Oct 2021 21:28:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqMK-0000sJ-DQ for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:21:20 +0000 Received: from mail-lj1-x232.google.com (unknown [2a00:1450:4864:20::232]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7da57f3f-7eb8-46f0-ab3f-75a2e3b9b760; Wed, 27 Oct 2021 21:18:57 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id u5so6967447ljo.8 for ; Wed, 27 Oct 2021 14:18:57 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:55 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7da57f3f-7eb8-46f0-ab3f-75a2e3b9b760 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J0jiL1GV/+pRa/Pi8omBJ059E/kI2yC/kBEGzY3TRbg=; b=FJbtoAu7rbq7E5RaKvepyk9plUf7jLnT+ML08UZjLgFiOZ5VaykzHp5Ff2lObAbFB8 5GZGzZ57ZApIGsXSOF6gLQA97YsI0ZAQ/ZGu34m5aZxcCPPjtIEcQp67CojYOup39/Xv xsYx/9Bl6pD+/d5Egre5OsJvj19u3KKVwrkexlOW8n23RNvDolWdvTv8CSXdsnambAlA jmNsfq7r35M1wkX74Jgv3A3xCPTBUP4sDGuQeSw9FU1X/TxBftWhWMRe81zJ6SuXHAM8 TvqOPVU0PykNu+1EXPWfVa52MP/IYJ4S57Q0SiUIct4v8BdbY1Ush4O+dDWBQRJUzf+C FQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J0jiL1GV/+pRa/Pi8omBJ059E/kI2yC/kBEGzY3TRbg=; b=dHcADv7uU+wNiNSiWnlJL7NX6jn65nJijzmlWEvvgGnBUh+NUbR4Vdy26OE6JOw+64 J7Z3xIydOzcWbjHCn6ZJa4NOqOIyiobMyPlvAfT4997NFcrma2Peo+dG9uKnhGVvNdEP Akmx4Qay1ptUH4FakaQM3X0n0xxscirrXeMs+kTOrzc6diA5Bz+bA43bTP8+Gxr8619f Eulg9j6dn4YOg3qgtAabiMvTN6sJbya2Cas02nf/3nnQfYdWM2Ks0HPC8xsrZkUJrH2L WjqBZm5ZY0m6HlMBw6yvS4StIgVe9HybzSeAlb1tvCFMfDnuFgqNSauYsCAUia/GqVi5 9Rhg== X-Gm-Message-State: AOAM533gbJOWrxW48lXYAoodtvfh9O8C/IZ+t1V8hzh8f8UAEJyORn14 q8la2lWLKEnCZjW4fd4lltI= X-Google-Smtp-Source: ABdhPJwO9DbKrxmMzwfiSQzUITuZHuDXfhRgNgPDDhUghYThRMLe5cQOKy/B7VPBX8OP8l5Jmu7iAw== X-Received: by 2002:a2e:8097:: with SMTP id i23mr314285ljg.287.1635369536096; Wed, 27 Oct 2021 14:18:56 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 34/45] mfd: palmas: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:04 +0300 Message-Id: <20211027211715.12671-35-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/palmas.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index f5b3fa973b13..c7d4d48d2fda 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -420,12 +421,12 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, "ti,system-power-controller"); } -static struct palmas *palmas_dev; -static void palmas_power_off(void) +static void palmas_power_off(void *data) { unsigned int addr; int ret, slave; u8 powerhold_mask; + struct palmas *palmas_dev = data; struct device_node *np = palmas_dev->dev->of_node; if (of_property_read_bool(np, "ti,palmas-override-powerhold")) { @@ -680,12 +681,16 @@ static int palmas_i2c_probe(struct i2c_client *i2c, */ if (node) { ret = devm_of_platform_populate(&i2c->dev); - if (ret < 0) { + if (ret < 0) + goto err_irq; + } + + if (pdata->pm_off) { + ret = devm_register_simple_power_off_handler(&i2c->dev, + palmas_power_off, + palmas); + if (ret) goto err_irq; - } else if (pdata->pm_off && !pm_power_off) { - palmas_dev = palmas; - pm_power_off = palmas_power_off; - } } return ret; @@ -712,11 +717,6 @@ static int palmas_i2c_remove(struct i2c_client *i2c) i2c_unregister_device(palmas->i2c_clients[i]); } - if (palmas == palmas_dev) { - pm_power_off = NULL; - palmas_dev = NULL; - } - return 0; } From patchwork Wed Oct 27 21:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5A1C433EF for ; Wed, 27 Oct 2021 21:28:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BEE7160E73 for ; Wed, 27 Oct 2021 21:28:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BEE7160E73 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217301.377383 (Exim 4.92) (envelope-from ) id 1mfqSz-0005Ma-Br; Wed, 27 Oct 2021 21:28:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217301.377383; Wed, 27 Oct 2021 21:28:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSy-0005If-9k; Wed, 27 Oct 2021 21:28:12 +0000 Received: by outflank-mailman (input) for mailman id 217301; Wed, 27 Oct 2021 21:28:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqMP-0000sJ-Dd for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:21:25 +0000 Received: from mail-lf1-x135.google.com (unknown [2a00:1450:4864:20::135]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed9f40e7-2116-4b6d-ad37-3eab09f39abc; Wed, 27 Oct 2021 21:18:58 +0000 (UTC) Received: by mail-lf1-x135.google.com with SMTP id bp15so9015747lfb.4 for ; Wed, 27 Oct 2021 14:18:58 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:57 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ed9f40e7-2116-4b6d-ad37-3eab09f39abc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/Hqy/1scbv2xgSJ+Pfjnwd9vR5EU0n/d3WfB2tugTgE=; b=fdXEajT5ReWU0k76RL+UMQexWX6+dI9dqZX5MdJXsVZcuokskYVO71+oKjzDY4A2wc hJ1YtaH4eNeZaWabxSPD6IdHvppV9tDUjSfbiCZ9pzJbnyd1ILGvgPlaBo02Y2jjZnzD JbO/7oiPSFxLAQwFLHGGO2Gfwy8dZZlQdidry7vBInQu2wS67Np/bBN1rUC/SIaULQAp mZSgP8kJbrDoclvDh2sRCaJ+wiPArCAPZMKwm6/7+fwfn1T4SmuQIaJDkhw4NUU2izwl 4ikxIWp8MhgEKidppyJcozjOV5jYdL31Pn9EYMxWJrcs7VGZ0QCvDnuFIw51Kr2focF2 kW1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/Hqy/1scbv2xgSJ+Pfjnwd9vR5EU0n/d3WfB2tugTgE=; b=I5kACTmRG3JXiYMQEH1UugQcBwvTXlF1XclwGQBRTjvuJaE0IxJJwOWY/DxLZCTp9L +JFN6Y64/SnZohMczrBKTUbhipu/mO8zH13VmfBpVU9M9yEvMYEnKHKE5BMSeLC+Bc9P d5aQPCM93zwqCgRAR9rfKSRn/YWKAolcBCOtz4XZ6P0HQinSGybdt3mW1qIoaTjabBv8 oHREsBzclOFRJGvczhT1yK6Fd/8YpHK+BEuH1dNIRAvKVOLkK/uQXEGoU5eyyZCiQRGe J72MoujsJVmYKq45CRzfJo2LukPQYj3Ki8AN72lDhFRTVlSIJ6SquICz9I/K+tZzqERA gnFw== X-Gm-Message-State: AOAM5330ZC1+DL/qhfcxPA91rYSj0jeo7o3+ZhzlY0Cjlf2JudUXDye2 laUjQDMBgyLf4MFUgGJrcMQ= X-Google-Smtp-Source: ABdhPJxErOfbgWaHoJDyROU+wtxCyzAJwEEk/21TSkl3Wl7+6OTCwc5MbFi2KTtZM0ExVMRMX2XJDw== X-Received: by 2002:a05:6512:344a:: with SMTP id j10mr78084lfr.653.1635369538003; Wed, 27 Oct 2021 14:18:58 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 35/45] mfd: max8907: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:05 +0300 Message-Id: <20211027211715.12671-36-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/max8907.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c index 41f566e6a096..58699510311b 100644 --- a/drivers/mfd/max8907.c +++ b/drivers/mfd/max8907.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -174,9 +175,10 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = { .num_irqs = ARRAY_SIZE(max8907_rtc_irqs), }; -static struct max8907 *max8907_pm_off; -static void max8907_power_off(void) +static void max8907_power_off(void *data) { + struct max8907 *max8907_pm_off = data; + regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG, MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF); } @@ -214,6 +216,17 @@ static int max8907_i2c_probe(struct i2c_client *i2c, goto err_regmap_gen; } + if (pm_off) { + ret = devm_register_simple_power_off_handler(&i2c->dev, + max8907_power_off, + max8907); + if (ret) { + dev_err(&i2c->dev, + "failed to register power-off handler: %d\n", ret); + return ret; + } + } + max8907->i2c_rtc = i2c_new_dummy_device(i2c->adapter, MAX8907_RTC_I2C_ADDR); if (IS_ERR(max8907->i2c_rtc)) { ret = PTR_ERR(max8907->i2c_rtc); @@ -260,11 +273,6 @@ static int max8907_i2c_probe(struct i2c_client *i2c, goto err_add_devices; } - if (pm_off && !pm_power_off) { - max8907_pm_off = max8907; - pm_power_off = max8907_power_off; - } - return 0; err_add_devices: From patchwork Wed Oct 27 21:17:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB53CC433F5 for ; Wed, 27 Oct 2021 21:29:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3FD2610C7 for ; Wed, 27 Oct 2021 21:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A3FD2610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217366.377518 (Exim 4.92) (envelope-from ) id 1mfqTZ-0004DJ-7Y; Wed, 27 Oct 2021 21:28:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217366.377518; Wed, 27 Oct 2021 21:28:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTY-00044A-F1; Wed, 27 Oct 2021 21:28:48 +0000 Received: by outflank-mailman (input) for mailman id 217366; Wed, 27 Oct 2021 21:28:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqMU-0000sJ-Dm for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:21:30 +0000 Received: from mail-lf1-x12f.google.com (unknown [2a00:1450:4864:20::12f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f281c280-7e2c-4b52-8649-7ff7b12073ce; Wed, 27 Oct 2021 21:19:00 +0000 (UTC) Received: by mail-lf1-x12f.google.com with SMTP id bi35so8960334lfb.9 for ; Wed, 27 Oct 2021 14:19:00 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:59 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f281c280-7e2c-4b52-8649-7ff7b12073ce DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/EvvYGeTVCQImKsIJ5eG/5fF3PWyG/w2giRYqfawyD8=; b=WISWhItqSg2B7RF+VMq4lOAEaPJboj2meAQ+IB5/V1NHbNJFBmj5XS0xlb4zCXSKCT 6NsXWHZYq9LRGS+jBn6SfWgsJR2EyLsQBWeeDJtEZfPXB1ZJ5N3cxcINwqw5WxZcKDSN DIvIUkbk9mQPYxMXhFN2I7TObVzLJ8eVxU8hzEXgYSzj8Cm7i8BXlPfHwlq3yNPgneQb CHkJFZxdfY5RLlI3BGfXo88fraOgWdNEzamQkJbIJD18e+/pItOdQTQl7YVu3LpCjfDV vOVdkFjMAfH4ytXgGRWsun/uVtAnjn/uKIwgKMmU3X2UQuuCd1+gugzIIN8JE0FZ4XsA 8FgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/EvvYGeTVCQImKsIJ5eG/5fF3PWyG/w2giRYqfawyD8=; b=U+exVGjIuZrTZvaorfdlm/oyMq/hAou4g7Vw/VviOIsVhOIHQaH7ZsgzcBUs7BDYjA xraSSIeYu8vLir9B69E23edFmqksnkzkDjlj0XX9iP/YQjAQsOqBvPE2H0o4GgtlRZWU hNb8Vt0pzE/X4FnG6j1bTSaVkkiaPKZy4XStEshgOR5EVDgbiCYau9+cgT96W8kxvvjh Jes/wNAAN6xcwNzNW7NF/R1UoYY+g3+1Tetx6QyDld+fZiZBt8XbGVa6aKBwJ2veesUB ejKBdjDxK1tTRYWB6HttVhUmGEiggrsbBMFOpESh0/WytCeQjzfCZBdMqOkMt4a2eBrR KceQ== X-Gm-Message-State: AOAM533mQDpK4i0E42aqLHLCnefrjicLGCp8rNX3Nr7Sip/m3X9UaPTm hees8pr1YHC7aEumg+rfsP4= X-Google-Smtp-Source: ABdhPJxRCjxAoGlWdRIW6Oj8xz2ri71YJVQnEgFasE3kMNBOfZWQ65DiEYFCvQ3qjpKPcAaJZhmXrA== X-Received: by 2002:ac2:4c08:: with SMTP id t8mr95028lfq.281.1635369539813; Wed, 27 Oct 2021 14:18:59 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 36/45] mfd: tps6586x: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:06 +0300 Message-Id: <20211027211715.12671-37-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/tps6586x.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index c9303d3d6602..9033ed936d1e 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -461,9 +462,10 @@ static const struct regmap_config tps6586x_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static struct device *tps6586x_dev; -static void tps6586x_power_off(void) +static void tps6586x_power_off(void *data) { + struct device *tps6586x_dev = data; + if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT)) return; @@ -540,6 +542,16 @@ static int tps6586x_i2c_probe(struct i2c_client *client, return ret; } + if (pdata->pm_off) { + ret = devm_register_simple_power_off_handler(&client->dev, + tps6586x_power_off, + &client->dev); + if (ret) { + dev_err(&client->dev, + "failed to register power-off handler: %d\n", ret); + return ret; + } + } if (client->irq) { ret = tps6586x_irq_init(tps6586x, client->irq, @@ -564,11 +576,6 @@ static int tps6586x_i2c_probe(struct i2c_client *client, goto err_add_devs; } - if (pdata->pm_off && !pm_power_off) { - tps6586x_dev = &client->dev; - pm_power_off = tps6586x_power_off; - } - return 0; err_add_devs: From patchwork Wed Oct 27 21:17:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 320C2C433EF for ; Wed, 27 Oct 2021 21:28:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB813610CB for ; Wed, 27 Oct 2021 21:28:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB813610CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217352.377465 (Exim 4.92) (envelope-from ) id 1mfqTM-0001Xa-Tj; Wed, 27 Oct 2021 21:28:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217352.377465; Wed, 27 Oct 2021 21:28:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTM-0001VV-9s; Wed, 27 Oct 2021 21:28:36 +0000 Received: by outflank-mailman (input) for mailman id 217352; Wed, 27 Oct 2021 21:28:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqN3-0000sJ-Eh for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:22:05 +0000 Received: from mail-lf1-x12e.google.com (unknown [2a00:1450:4864:20::12e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 65faa95e-9d9e-4589-b672-ba4175121473; Wed, 27 Oct 2021 21:19:02 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id x27so9006560lfu.5 for ; Wed, 27 Oct 2021 14:19:02 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:19:01 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 65faa95e-9d9e-4589-b672-ba4175121473 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IkN5RxNvfWU6udxIv0HqPwHPsreqVVHZYAiW4uOSdQE=; b=EBSN3i6pBzJ/QX6b7hWJ61FbfkEkrcOrflTwto+4KX4or46ACVz9Tr/1pugxTtiHmi G7CMVOoidyYK0g+Vg4pJnm/bKfolm8lIe6sk0vITgUl/0On7GAe1avC+nPdsUhal8n/2 2LfBGzyZF4kisF1H8Fy3oqJJlA7mP+5FCx9jGZBePen+YJxCg52jU7glSS7bDwelermJ QOk39GQqnkcumTBHd2mHERoDOJXwlx4KsuyCu/MObr6DT96WNWvs0v/iyAkBnjjhRCxD gw7GTseQp5qiH+atTqu6Rg9n+NmY0IzLKdyAE4sSGNY6W234A5z05GeGyvCsr57AR1H6 zVgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IkN5RxNvfWU6udxIv0HqPwHPsreqVVHZYAiW4uOSdQE=; b=QQRK7uNfkfXqzh/2+qQB2MBTUpYfY33zA5szHcVFIkXZkR0RvDa8Tuz3JK8x6ySli9 eVRGuLNRWtkyZYfGkhVaPgixrOkMdiN9DO4/Vg0p7aO/4jRO7dBUmg7vTAhGleHCS0W/ DtfzuiJxJnpm/NliR9eU3OuIvXPBNwbxbm+NnOEZFdYo8epCKQKr31KWpU76Jl9i/vq1 6llItVoOnjKUOESZEEve4RRWAYdTNEghGVqW9AdNAbXSCpZcOi3e5fWDvDJPrDuEEXPO Jy1sxBH6dZ0fM6/TZyr/A84UyjIht9NoK9JuzPZwJ+RfFdartxC6cXMxTrzyivSSgXeK 6vqw== X-Gm-Message-State: AOAM533yRwLzsgkPHU9agHgQM72/9qu/2LVgrf9CagaeHQ/CWo4fsrwD ytPEBubdFEq5l68D2yfMXJM= X-Google-Smtp-Source: ABdhPJxsr/pRUcPc/yvXJw9vQsQsBRCfPMRUucvUkltufw5utcaA8e0PD5R7U1W5XHhl0HmaGsY5xg== X-Received: by 2002:a05:6512:aca:: with SMTP id n10mr150724lfu.66.1635369541621; Wed, 27 Oct 2021 14:19:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 37/45] mfd: tps65910: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:07 +0300 Message-Id: <20211027211715.12671-38-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/tps65910.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index 6e105cca27d4..8fab30dc84e5 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -429,9 +430,9 @@ struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, } #endif -static struct i2c_client *tps65910_i2c_client; -static void tps65910_power_off(void) +static void tps65910_power_off(void *data) { + struct i2c_client *tps65910_i2c_client = data; struct tps65910 *tps65910; tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev); @@ -503,9 +504,15 @@ static int tps65910_i2c_probe(struct i2c_client *i2c, tps65910_ck32k_init(tps65910, pmic_plat_data); tps65910_sleepinit(tps65910, pmic_plat_data); - if (pmic_plat_data->pm_off && !pm_power_off) { - tps65910_i2c_client = i2c; - pm_power_off = tps65910_power_off; + if (pmic_plat_data->pm_off) { + ret = devm_register_simple_power_off_handler(&i2c->dev, + tps65910_power_off, + i2c); + if (ret) { + dev_err(&i2c->dev, + "failed to register power-off handler: %d\n", ret); + return ret; + } } ret = devm_mfd_add_devices(tps65910->dev, -1, From patchwork Wed Oct 27 21:17:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 850BEC43217 for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F55B610EA for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F55B610EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217281.377279 (Exim 4.92) (envelope-from ) id 1mfqSe-0000tG-KR; Wed, 27 Oct 2021 21:27:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217281.377279; Wed, 27 Oct 2021 21:27:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSe-0000qC-7d; Wed, 27 Oct 2021 21:27:52 +0000 Received: by outflank-mailman (input) for mailman id 217281; Wed, 27 Oct 2021 21:27:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqND-0000sJ-Ey for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:22:15 +0000 Received: from mail-lj1-x231.google.com (unknown [2a00:1450:4864:20::231]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ff658b29-29e8-4a31-ab27-c640fd96d1ac; Wed, 27 Oct 2021 21:19:04 +0000 (UTC) Received: by mail-lj1-x231.google.com with SMTP id 17so3841722ljq.0 for ; Wed, 27 Oct 2021 14:19:04 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:19:03 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ff658b29-29e8-4a31-ab27-c640fd96d1ac DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mu7tO95vXROZ9xbCJkoDzGl64HT6xR31EdIoyaMnKtk=; b=kPE91xXN+stBc0ha+PSjaOkkNGKlDTid0pZMJS4/z0xuWbbpv+/mX7oe8gzrFGsnxt knUKantyHU6PWIePiCnlFQ4UN8ZQdQP1oXKoJzSLIKv1lTDAhiLZjpDPc+aijhkrEZAj Xd8HN8BgZu0o5hpIxMQVtpuABAaRE4DHHXJZzo4Dy3xXk62gjG4MyDoYUHzKrSYuupRB lCz2OE27nWCjWUb+PHoI0yIS0mi3esed5R8cO+FhwY/2Rv4/jyVsNkj3xtgaoN5/YStc dCcP9WUacf6ElBGM42XMwNMMkAZqDoGVD/aHJJj9Cz/Tk9wj2JFlAJdIXkKMwT6cvxA3 e31g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mu7tO95vXROZ9xbCJkoDzGl64HT6xR31EdIoyaMnKtk=; b=OWKFoUhWj90xmynbKzk3p4ZGwVeB7PunJvv2FX2kQToVbg/8bfGMZK9JnheeQBZg85 c7vsd2obubGPEN2cyAvIF9hDywbjd6cT8yjA2v2wawF3fxX0pJuVeaF4dIyc+OrgO1aC 6CPUP33yFZTtE3kJm54CeGcxBab0GvDONSDgVvUlf2w8RUrc7ZrTa7P1M+qPqZ0qzNXN krh4M/eTfT47nwFKNLcmVmJsxeqXZnfGB0ppLhqQPqy4hNyL7TyNir/zcBd6zgdQpoOh G8xXbaZBCruzK3g0MZ/oPopKwqn07rV6O41zwULXSDV7DZU0Z/7gWnVMxXBUxbHSk76k mS/w== X-Gm-Message-State: AOAM530vDxhtg/vif7zKvrUjSQiDMITFpfdcYCQAmHVOh9UuTNVUqgb0 O4vFUDMXMX4EVQMhNIrECQ8= X-Google-Smtp-Source: ABdhPJx+pRFjcRYPR1om8nKBpIgAHoRaPbEg7vS4nL7YKN3yH6zq2Ajomu3cvpnY+yAbJLhjtqI1TQ== X-Received: by 2002:a2e:bb98:: with SMTP id y24mr344716lje.168.1635369543476; Wed, 27 Oct 2021 14:19:03 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 38/45] mfd: max77620: Use devm_register_simple_power_off_handler() Date: Thu, 28 Oct 2021 00:17:08 +0300 Message-Id: <20211027211715.12671-39-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_simple_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Nexus 7 Android tablet can be powered off using MAX77663 PMIC and using a special bootloader command. At first the bootloader option should be tried, it will have a higher priority than of PMIC that uses default priority. Signed-off-by: Dmitry Osipenko --- drivers/mfd/max77620.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c index fec2096474ad..29487ccc191a 100644 --- a/drivers/mfd/max77620.c +++ b/drivers/mfd/max77620.c @@ -31,11 +31,10 @@ #include #include #include +#include #include #include -static struct max77620_chip *max77620_scratch; - static const struct resource gpio_resources[] = { DEFINE_RES_IRQ(MAX77620_IRQ_TOP_GPIO), }; @@ -483,13 +482,13 @@ static int max77620_read_es_version(struct max77620_chip *chip) return ret; } -static void max77620_pm_power_off(void) +static void max77620_pm_power_off(void *data) { - struct max77620_chip *chip = max77620_scratch; + struct max77620_chip *chip = data; regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG1, - MAX77620_ONOFFCNFG1_SFT_RST, - MAX77620_ONOFFCNFG1_SFT_RST); + MAX77620_ONOFFCNFG1_SFT_RST, + MAX77620_ONOFFCNFG1_SFT_RST); } static int max77620_probe(struct i2c_client *client, @@ -566,9 +565,13 @@ static int max77620_probe(struct i2c_client *client, } pm_off = of_device_is_system_power_controller(client->dev.of_node); - if (pm_off && !pm_power_off) { - max77620_scratch = chip; - pm_power_off = max77620_pm_power_off; + if (pm_off) { + ret = devm_register_simple_power_off_handler(chip->dev, + max77620_pm_power_off, + chip); + if (ret < 0) + dev_err(chip->dev, + "Failed to register power-off handler: %d\n", ret); } return 0; From patchwork Wed Oct 27 21:17:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3162C433EF for ; Wed, 27 Oct 2021 21:28:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9606560E74 for ; Wed, 27 Oct 2021 21:28:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9606560E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217337.377414 (Exim 4.92) (envelope-from ) id 1mfqTD-0007zc-Gq; Wed, 27 Oct 2021 21:28:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217337.377414; Wed, 27 Oct 2021 21:28:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqTD-0007zK-Bm; Wed, 27 Oct 2021 21:28:27 +0000 Received: by outflank-mailman (input) for mailman id 217337; Wed, 27 Oct 2021 21:28:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqNI-0000sJ-F3 for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:22:20 +0000 Received: from mail-lj1-x232.google.com (unknown [2a00:1450:4864:20::232]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3fd14165-1c51-4e97-b6e8-86c09a0d6493; Wed, 27 Oct 2021 21:19:06 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id q16so7020585ljg.3 for ; Wed, 27 Oct 2021 14:19:06 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:19:05 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3fd14165-1c51-4e97-b6e8-86c09a0d6493 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3OlHSqJ+90NzTUoF0ScIJd6Gu2h2samNuNJcsiL1Jk8=; b=TlGsLZtcrVzUb7sAOhif3p7pVw8LafC2xLy1EDPy1NIwJl5MQQvmHy2JQZYszcOE8Z bpdCDmyEM5D03Couzbs3VVZUIdamWSCPF0yzl5vvizBqtDssLI1790jRM+TPIcawNrlD 8STEeq0OEOHvy2rX7OXiOWUq9V+Wbq3xZg3vhjF/dealnvdRkEuGDx5b0mmtoBXsa4Tg 7gFUHQvvLRw3QjAUV5dCuqij4emeiEy4r7tFICkEZrQaaXXABdfN2M8h/mxrxQbImqYG GaGzMOCXHjG+QuAc4Dq0gK0PotuHucIYhVqvi35iVuJc+hGZhg1h00rdw0kra8k/EpLO luJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3OlHSqJ+90NzTUoF0ScIJd6Gu2h2samNuNJcsiL1Jk8=; b=BN39/gDvZoVTgRGs+6aS1GMtwC3mp+mHjKiuRx0k01hIFramQi8QPCaokCyA+gk8D3 8p0O873nUDe6e60YTN4GO08B3izGzxbSbivg5p7TqUU5MCG1E0FNVJxY2E0PZd0O2CND bCILcLm4o72t8GnE+BsAjr1Oewzm/msueKLh2A4oQX4KnCSslYwyduGHJsqvBx6WZdAi dD/u7EWuSJDZNlnpwkns+YGcuNT3CasS2um8Z42A45RjQXXryR1NnPKaw5zWCUdI5AMW Wwv0BVwh4o7s0HLnDI+ZjGZDobN0SikzfOUaVIlX/GMGILB2koBfnkcT605E5bmHu4bK w88g== X-Gm-Message-State: AOAM531NpLun6zaWfxagMpY5KG9iXCQr7gfeenakzmKV6mK20aFmRJat yP4mNPwMpMCZlPb4bdRnM2M= X-Google-Smtp-Source: ABdhPJzDbMhKltt/cJ4cLHVC7lvSJKFFWBp4i2pL/KBXA4D8sI4Ihh3wNKVdm9xKvnEcHeY8d+ELCw== X-Received: by 2002:a2e:b0e2:: with SMTP id h2mr336408ljl.522.1635369545290; Wed, 27 Oct 2021 14:19:05 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 39/45] mfd: dm355evm_msp: Use devm_register_trivial_power_off_handler() Date: Thu, 28 Oct 2021 00:17:09 +0300 Message-Id: <20211027211715.12671-40-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_trivial_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/dm355evm_msp.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 54fb6cbd2aa0..5ee830f65589 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -375,11 +376,10 @@ static void dm355evm_power_off(void) dm355evm_command(MSP_COMMAND_POWEROFF); } -static int dm355evm_msp_remove(struct i2c_client *client) +static void dm355evm_msp_remove(void *data) { - pm_power_off = NULL; + /* FIXME remove children ... */ msp430 = NULL; - return 0; } static int @@ -392,6 +392,11 @@ dm355evm_msp_probe(struct i2c_client *client, const struct i2c_device_id *id) return -EBUSY; msp430 = client; + status = devm_add_action_or_reset(&client->dev, dm355evm_msp_remove, + NULL); + if (status < 0) + goto fail; + /* display revision status; doubles as sanity check */ status = dm355evm_msp_read(DM355EVM_MSP_FIRMREV); if (status < 0) @@ -416,13 +421,15 @@ dm355evm_msp_probe(struct i2c_client *client, const struct i2c_device_id *id) goto fail; /* PM hookup */ - pm_power_off = dm355evm_power_off; + status = devm_register_trivial_power_off_handler(&client->dev, + dm355evm_power_off); + if (status) + dev_err(&client->dev, "failed to register power-off handler: %d", + status); return 0; fail: - /* FIXME remove children ... */ - dm355evm_msp_remove(client); return status; } @@ -436,7 +443,6 @@ static struct i2c_driver dm355evm_msp_driver = { .driver.name = "dm355evm_msp", .id_table = dm355evm_msp_ids, .probe = dm355evm_msp_probe, - .remove = dm355evm_msp_remove, }; static int __init dm355evm_msp_init(void) From patchwork Wed Oct 27 21:17:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06C30C433F5 for ; Wed, 27 Oct 2021 21:28:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AC18960E74 for ; Wed, 27 Oct 2021 21:28:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AC18960E74 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217278.377273 (Exim 4.92) (envelope-from ) id 1mfqSe-0000l5-4m; Wed, 27 Oct 2021 21:27:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217278.377273; Wed, 27 Oct 2021 21:27:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqSd-0000jW-QJ; Wed, 27 Oct 2021 21:27:51 +0000 Received: by outflank-mailman (input) for mailman id 217278; Wed, 27 Oct 2021 21:27:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mfqNS-0000sJ-FF for xen-devel@lists.xenproject.org; Wed, 27 Oct 2021 21:22:30 +0000 Received: from mail-lj1-x22c.google.com (unknown [2a00:1450:4864:20::22c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 75304b2b-e4b2-4f61-96e2-041fe02a1904; Wed, 27 Oct 2021 21:19:08 +0000 (UTC) Received: by mail-lj1-x22c.google.com with SMTP id i26so5091804ljg.7 for ; Wed, 27 Oct 2021 14:19:08 -0700 (PDT) Received: from localhost.localdomain (46-138-41-28.dynamic.spd-mgts.ru. [46.138.41.28]) by smtp.gmail.com with ESMTPSA id d7sm104336ljl.18.2021.10.27.14.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:19:06 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 75304b2b-e4b2-4f61-96e2-041fe02a1904 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IyeKRcg+jY+d7mV074g++I9amtFxwmtCwLh3hlXwjuE=; b=QnkHqeqzRHJ5AsPp67EWmABUOzsGTZSEBDGiay4nrsnQYbRzqAwsk2Smx/z5LQ/pzF rdPrmuGWIQsGZY0bghrDq1od6/1Zl94Y7Qb1GFsmOOrt3AmEW7aEpgHOlwWIuWg9pF6h Oq2ibAnCelRGtOXc03WYR55PI40ZligMz8SFKQbuKJzels1J9jjvQqZYNvv/xzelX9Df 3ooSIaYPCZ69IQLFRxzA4xs/vR6PqnP/beBugw1fOkkPovapvfxOsncNdJLVW4zeoK8b skyzHaRP9ZlGt9pP4tePYITTWnPX31LYoVXuqb9igbxjWGO6dkZHNW0xRIrqWzuV8p7l c4kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IyeKRcg+jY+d7mV074g++I9amtFxwmtCwLh3hlXwjuE=; b=yskBtUYTkO7vMc3nH96aWtDfWa/j2vhawnvPdCDsnad9aYEb2lFjMe4J3ITK2IC90U 1Ygw3EfOcJFkfPOCXgbV5JHjXhEzY3rPQV6tRDaoGiqqZrTfTS3TKlHVttkgfwWUeA8H nFO9t21dbUy/S5ih6+SPhyk0FCv9JhNA24fnivHd+cmjDQ2IdYlOYQKs/o+ASPWVSNvA fjgXZZT8PRCoVnrZn7H9+VmyVBt7v14+t38l+KK4rUjtDuSCdAj5oyD5aP7AzHDBlq8e 44DBwxJqFqxquWt06I0QT9vdtL3ajfBPO2bz1FdwjDLZDJ5hVceeUWhi95z8sbBWCRyv Hm2A== X-Gm-Message-State: AOAM533CLgVHPhUSs2arwTkSYcJ5jFPVw/1L6BhxPYZZlcXbMERj6nOb ExUo7bkPlSpOtCdvtHbR3so= X-Google-Smtp-Source: ABdhPJy4ahVYxTGf2Y3bPKsNGZG7BdaFjyQVV1JaKCPUvFr94r9L7duD8TnIWNPTqCXGHbJewLuL1g== X-Received: by 2002:a05:651c:1256:: with SMTP id h22mr358353ljh.348.1635369547137; Wed, 27 Oct 2021 14:19:07 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Andy Shevchenko , Ulf Hansson Cc: Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 40/45] mfd: twl4030: Use devm_register_trivial_power_off_handler() Date: Thu, 28 Oct 2021 00:17:10 +0300 Message-Id: <20211027211715.12671-41-digetx@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211027211715.12671-1-digetx@gmail.com> References: <20211027211715.12671-1-digetx@gmail.com> MIME-Version: 1.0 Use devm_register_trivial_power_off_handler() that replaces global pm_power_off variable and allows to register multiple power-off handlers. Signed-off-by: Dmitry Osipenko --- drivers/mfd/twl4030-power.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 6b36932263ba..72df4735d628 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -923,7 +924,7 @@ static int twl4030_power_probe(struct platform_device *pdev) } /* Board has to be wired properly to use this feature */ - if (twl4030_power_use_poweroff(pdata, node) && !pm_power_off) { + if (twl4030_power_use_poweroff(pdata, node)) { /* Default for SEQ_OFFSYNC is set, lets ensure this */ err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, TWL4030_PM_MASTER_CFG_P123_TRANSITION); @@ -939,7 +940,12 @@ static int twl4030_power_probe(struct platform_device *pdev) } } - pm_power_off = twl4030_power_off; + err = devm_register_trivial_power_off_handler(&pdev->dev, + twl4030_power_off); + if (err) { + dev_err(&pdev->dev, "Failed to register power-off handler\n"); + goto relock; + } } relock: