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: 12588313 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 06B7AC41535 for ; Wed, 27 Oct 2021 21:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E21D2610CA for ; Wed, 27 Oct 2021 21:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244325AbhJ0VUc (ORCPT ); Wed, 27 Oct 2021 17:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244280AbhJ0VUW (ORCPT ); Wed, 27 Oct 2021 17:20:22 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3D6C061745; Wed, 27 Oct 2021 14:17:56 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id bp15so9011349lfb.4; Wed, 27 Oct 2021 14:17:56 -0700 (PDT) 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=XyLdzePTQPe5d5wLqwUMFXhC6n8RjbMnozPHNiHYcxfxWeB4Fm2JhABLYcGHA9HgwE rNiNU6DSH/kI8yY5YAAslvoXUaDZDOYlbEZCI0bhE9bi7ZDcAfYofTZfUtURZnvGkszT Td6a0s9tUqOSMpy4USyd9dtpqLO4RB1UBWURuHzZPR+O6G4+yE1ztPaXQgVvF/31+CH5 BZcOjy4+MU4N61sjq19xXYanvC/m9BAJom017+8opjttclZlEZKM4Dx/caaf0Hxw05t4 m66efkFeG0bFdQGE83hxKDOWGC6yfkLKI+adLeSy+SiLJqehpkGAiZDpsAiSv1j8eS/K wojQ== X-Gm-Message-State: AOAM533nfqN0Si5OzRpJmAUWWXypBjShmwWT1aXXMAdI4LzPPqnwme+z 1sUnQNomyxnoeYXPB34tqx4= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588303 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 27BF0C433FE for ; Wed, 27 Oct 2021 21:18:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A87861108 for ; Wed, 27 Oct 2021 21:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244335AbhJ0VUd (ORCPT ); Wed, 27 Oct 2021 17:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235594AbhJ0VUY (ORCPT ); Wed, 27 Oct 2021 17:20:24 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7ED8C061348; Wed, 27 Oct 2021 14:17:57 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id c28so8884713lfv.13; Wed, 27 Oct 2021 14:17:57 -0700 (PDT) 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=ADb0TPjlLpgbCSFF0VyAibL6TGJbBgUPBAzakbfhWHDpINkpQGCNVRikFND+zsLJic LiM2PkB754d+vbjzK+j6R46zpUP7jH0HswBi29OZ0AhJk5FCzFmcmtB+h78wmUFj0/1F QVyVIlsnyLIy5EkJsLcnvz6JAJr6sY6F5LoIKzKA8tF6YffLAZXM/nYPEYc8GXaZmRC9 84f6DEaFsRLRyrufKMCP5H5wHt2nO82afRhOjOBBDXmFxWoHvlTSNYW9toY7GplelBby 1c5j9CUQ+n1GELUWu0c+NEfPHj83t9QvCFVpUZaXdpTH1wRukWNteETrcK2pIvIQvo0F 80CQ== X-Gm-Message-State: AOAM530NvOip+WqUu9lvqmu5SWastDPeajUMTCUcAVDeiiNQ3Vgz4AjG ox1mz6ScRArORzzDsOn66pw= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588305 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 C8B67C433EF for ; Wed, 27 Oct 2021 21:18:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A774A611AD for ; Wed, 27 Oct 2021 21:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244352AbhJ0VUf (ORCPT ); Wed, 27 Oct 2021 17:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244290AbhJ0VU2 (ORCPT ); Wed, 27 Oct 2021 17:20:28 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26C0C061225; Wed, 27 Oct 2021 14:17:59 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id bi35so8955846lfb.9; Wed, 27 Oct 2021 14:17:59 -0700 (PDT) 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=WusnbDq8scAfF6uljTABSszEJsfU9tAsFlQ//2ykxPG0ip3r+6RmlFHZem6LU/rQoT L9hjXnnC7B7kQAf7LyS154mF/O9IkONvi/wbCdZPub1UCL0xR3suypowzng4/ontBBne z24eETrhY+BETRByrlwQx8QQoindv0kqJYXJ/o0AHxYYO/dXKmwJ6AUZGgRIDmE48Y47 nXQy4Y8Vm2viI86U1D5fQAejHLY7kC7+65ixpgtxgSSvDDfeXgojjQ+3GifEi+7WXFOC fRySBZs3C+WL7gHqYjbJFvcy98Bg+pN2lL1X9ewpjdkVOfObgqO3+fenCUJVXdy0u6sF lbqQ== X-Gm-Message-State: AOAM532slO0L+8YW+J7M9XVcNPFblBFj81zH0xfL0a3KNFUxk8JpXsIF cIxjFE68/ytKqJPwdh+rUnw= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588307 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 38767C4321E for ; Wed, 27 Oct 2021 21:18:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26125610A6 for ; Wed, 27 Oct 2021 21:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244369AbhJ0VUg (ORCPT ); Wed, 27 Oct 2021 17:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244279AbhJ0VU3 (ORCPT ); Wed, 27 Oct 2021 17:20:29 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05FECC06122B; Wed, 27 Oct 2021 14:18:01 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id u5so6963766ljo.8; Wed, 27 Oct 2021 14:18:01 -0700 (PDT) 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=Zxyi27DIfAtJNCvBTL6xs8EugS2mUGGu84PQVamzZJntD5tlG/ept1OxI55stFR1b4 YSRxvHdrPFwUNWBjFxHswpxfSxfVgE/2LzqWAablRWEWD77LddOFuMW5hSVLNkh1vp4B fIC9w49ZEGMVY9nyyS3YLD69WJdgzQrQZe8rDbGezn7shIf0PbGbL5HXgJxDgkuhme+j 88kqj5sSOeBX6px1kOQ08BLex6rZRblGyXVF5XqPsT46sJn5eRGW+MMqrjW4DRk4dGX9 diqa8Cq6azyXqAV+P6L+Gki49s2vnyzD/xAqeBs+USmjtmtwq8hM5GUXn0ZL+OtAUnm3 r1iw== X-Gm-Message-State: AOAM532z7Ra8GgipbdWgz4A4ULaI/W39PPhb4eAxymfEVXqgUldGu4Z4 FG6216tKgMlWE1MPRi2TnyQ= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588315 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 5DAC5C433EF for ; Wed, 27 Oct 2021 21:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42502610C7 for ; Wed, 27 Oct 2021 21:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244597AbhJ0VVP (ORCPT ); Wed, 27 Oct 2021 17:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244303AbhJ0VU3 (ORCPT ); Wed, 27 Oct 2021 17:20:29 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A620EC061745; Wed, 27 Oct 2021 14:18:03 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id f3so803531lfu.12; Wed, 27 Oct 2021 14:18:03 -0700 (PDT) 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=U20ivDQwPCbYsfj9u1nt9yIAxHAUWd6+0MZj+RkD5Boi8OC550GbYlsfggopQApCSp 80adqRwpYlNOasBV1fAZz1aoHxwhedMwfPeAz+AtlFstVXuhbkux/WUwZjdx8e0cSI/p z1YrRq92yc2QPScqgx47eI6VndxMrHiC9buop91TsmFTki7LsAoTBGx7g0vV76kqg++E 6/JkYZufSbAnH1xIWOogGUB5N6Nylfnc6pEn2qtlf8NQ/3NDvix6DMnSK3rkN7AqSduV qWVCc/+1qaMEB/5GnspLAnNQxFF0kGlRbo+bAj1R7nExDZ88ejRE/5wlmYxUNZTt3GvG yotg== X-Gm-Message-State: AOAM533O7w1dYBuMoH7+TOfmWWCMiLEUs+qr9hoSGpN9oaS54OywWVS1 IQbrX/GPUFpjLI+Jb6aT1i0= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588317 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 B97E3C4332F for ; Wed, 27 Oct 2021 21:18:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4AF3610C7 for ; Wed, 27 Oct 2021 21:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244608AbhJ0VVQ (ORCPT ); Wed, 27 Oct 2021 17:21:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244318AbhJ0VUb (ORCPT ); Wed, 27 Oct 2021 17:20:31 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E2DDC061767; Wed, 27 Oct 2021 14:18:05 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id bp15so9012015lfb.4; Wed, 27 Oct 2021 14:18:05 -0700 (PDT) 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=3c9xsRLj1vOzgH/l9+UGfkD8BYkecAwoSSwPvbmezZsaeolGVnwTM59+EWwcaedK93 olxQ1BfS00Hxhj0ES/+E+Ha3Jo6fVaKUKDyxQRTqV9VxKWHZQiZoofDiBM26VU94xlst GEIw6XvtrYNX+3lBKIx0oqvf4gF+mxJ5sTk0lwGLKqahI8FLTOQxJukcTvExrQ0kk3Q1 F4YmJKUl6DxnD/XZ9qFD/mIMhL5eiB0+7rTiPD65piWL85f9rNw6Dnus5IJIWzTIINqA tLKx+Vbyq0qbJQWX9wzyjipDUetTxTJqehYn9iVGpHkkLW+WD/9LgTmy+NHGLE5X/Irn Q/hQ== X-Gm-Message-State: AOAM5302iJo1dClCKmlrXXYeXK7avc/g11ixDkVINvqwDo3YlxJ6SucV VR64kz/WX5+ahHdw8R2pS78= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588309 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 EDEA9C43219 for ; Wed, 27 Oct 2021 21:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D85B0610CB for ; Wed, 27 Oct 2021 21:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244380AbhJ0VUi (ORCPT ); Wed, 27 Oct 2021 17:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244339AbhJ0VUd (ORCPT ); Wed, 27 Oct 2021 17:20:33 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AFD0C0613B9; Wed, 27 Oct 2021 14:18:07 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 17so3838054ljq.0; Wed, 27 Oct 2021 14:18:07 -0700 (PDT) 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=Xgk+1Cye6rD8mhh4pthoT6SBCTq0Pj2t2mKKx/9luDkV8Zs9bd4H7oitxaNRQch/Lg raSJFs7QON570Z4wfURLmdSJPhBWG+8rnjr4tO7i3Gf4rs7jBXir1vVmZnWnF4ch5p0U 662MXVTTJo6XGeDamV2rW/oK7GuaGfoMC0aI8zsN/URQtfrMR1z5T9gvsOR4hD0B3Psf YpW8HKVCBxnCJoWtDbmj1Kcq+Bk4O4OkioUkSMiXZCchjjxljVty1ouaslzf+obCW7i+ 8asF+ZRqj+6en9F0Kw29iMmSnlYqszuM+vahggWivgSFojIxV8PZqpj9iheFkEPO22f+ K3gQ== X-Gm-Message-State: AOAM530fNa3G76mI70+glbmiPg1f0dB0JurvOTUoLt0qYuDAHZClFL+T lx1yt0O42j+VvQTqYkBG/WQ= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588319 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 E063FC433FE for ; Wed, 27 Oct 2021 21:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC48E60E73 for ; Wed, 27 Oct 2021 21:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244621AbhJ0VVS (ORCPT ); Wed, 27 Oct 2021 17:21:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244354AbhJ0VUg (ORCPT ); Wed, 27 Oct 2021 17:20:36 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AED1C061570; Wed, 27 Oct 2021 14:18:09 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 205so6949317ljf.9; Wed, 27 Oct 2021 14:18:09 -0700 (PDT) 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=Mg9Ve6Vcwh6+QTWl7bVAaW+S4L7n557zD/pEiCPg3eZlSZHfpr3akUthBuYP4+D+w8 Bd4qX8DJNHYk+CuO3A+JU5+1IQxqW7sfBuZ6TE8UFeklWPTInXqOkbERCx5g3pa3jbMm lA7d+gHjzeRYi0UNNsVVR/aH035Yc0WSsmwgmafzfPLKMWbmKLUFJ+MepREPibTLuQAu zZzNO1B8lFLCU9Y2BTlknUNkek4fU8U3aSPazIm8ZIQAYwTJirIkKw4AiKjGCTM0GEkZ zewjICmyBzNrVac+VVqKVxxl53SLwcm5rdVb1YPi0Yq9HAatJwaQ3ZUQ2zl+V5hiQjvW DB2Q== X-Gm-Message-State: AOAM5300kn1s+mkbRNjEkeOs7Y6s/sd2rIaNHpRSsmJ45tid7ioYA9AI sqoQfG9u7vRTzauX13Dp1M8= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588311 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 75240C433FE for ; Wed, 27 Oct 2021 21:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FF86610CA for ; Wed, 27 Oct 2021 21:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244401AbhJ0VUl (ORCPT ); Wed, 27 Oct 2021 17:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244372AbhJ0VUh (ORCPT ); Wed, 27 Oct 2021 17:20:37 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF26C061745; Wed, 27 Oct 2021 14:18:11 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id y26so8913057lfa.11; Wed, 27 Oct 2021 14:18:11 -0700 (PDT) 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=BVfXQzKEY8ycQcUFPk9jiPxhejew3+VWP+kXK8+ZFYDyR4shVKHRAxAsXKfZcjAJ/C uOfLpaMEOs+puyJnbOvrEb4RRy2E/0IEX7MX6/BA4dmEoqIJOc1ce4lh2teq6XhYS2kr zTuVjj/dTV/VOXPrZOMHng7VKEk7UXx8wxIcvhuU+J4kPePkkHPFa4A+Il6aNr44tdxD cGc+RM8wr97afE5P5NyokcKWGBlfGlLAX8a0CTr8BH7eCAgWU40q1whcu6wVIPuSgvxQ Up5M6oMhfTfVeejwUWXbt7DYxzqJedpLiuwxbc6QVq3UcLLBTljnZ7XCZJjvYXI8p0E0 plmQ== X-Gm-Message-State: AOAM533xDdWGAncftFUJLJgaT34tczBoxfX3VZckQXkXPhD/rem7UrIn JA0Dg5QeRr4NuhUb2rTF+hM= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588321 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 F2369C433F5 for ; Wed, 27 Oct 2021 21:19:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6C71610CA for ; Wed, 27 Oct 2021 21:19:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232192AbhJ0VVU (ORCPT ); Wed, 27 Oct 2021 17:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244384AbhJ0VUj (ORCPT ); Wed, 27 Oct 2021 17:20:39 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B66C061745; Wed, 27 Oct 2021 14:18:13 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id u5so6964540ljo.8; Wed, 27 Oct 2021 14:18:12 -0700 (PDT) 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=wbUnRIcpHJ+gltwZsDMAo9hbnsDSxQzFryjtbcNlAdjBkTbcfYsSwlMmFYAh4kqOyB lXSa2yix5iAY8OZYDiJKnfMJ2nsGdK1BXQ+h6u1ShwgDmS2b/MthgDuXCupr/kBq+fMW KFM48bHgtbN0082eS75T0yIp2eUEQtBzlIcZRNj95Irh/kmNaIGDQ8NhHhWpNqxP2aT4 7Q/QkD2x8TnHxkDUxNfcH57ILWp9dodVb+QHBO8GRM7aP2Xfg0mKnSCgxZtfGQY6F7Z4 IjZyc3gSQjK35ABtTJ28VWYXxC3s30+8OBAu8R1V/n93whPdH8PyLPUgh/96r/BLlEdD rO6g== X-Gm-Message-State: AOAM532dkPUImRYwpCA0ccjvNJ/4Av5pYCc1rS+yIvNdJ3hvSEUuTcd4 iypo3zGLL3wLoUEzAH4CSwg= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588323 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 5FD37C433FE for ; Wed, 27 Oct 2021 21:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48422610C7 for ; Wed, 27 Oct 2021 21:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244640AbhJ0VVV (ORCPT ); Wed, 27 Oct 2021 17:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244407AbhJ0VUm (ORCPT ); Wed, 27 Oct 2021 17:20:42 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8510C061225; Wed, 27 Oct 2021 14:18:14 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id l13so8989063lfg.6; Wed, 27 Oct 2021 14:18:14 -0700 (PDT) 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=EHI89tbpTUUYvM1JMpBCxV3xpNgnL3bdnoD4UKKGqFoDALSJ4L7vU+WaFQWJGjVmOm HjODhgWvZZUVc1SRwArILe6sw/TOW4PP1/imob9ruI9tnN/S43ik2/asJWEsXL+o+ztb C34Mhh/bEoeKRdzeM18wSrrr0IfqX43swWmm3HL+Hwd4+7k4OXpKjED30koLYtSQLZUu i0DFMdqF42HMajjD0R+u84zLayx7pXudI7Bv4KJftGMLmwrPE1FwKlxkbIrftiv6RA7p 77z2rFrHDT37QP7Xe6qXoZpCvUNWWaSHTcmQBtaDE61LR7P+5AVI0t4tZr4vjUt4L8EN 1ufw== X-Gm-Message-State: AOAM531mmx3bVZIxN7jKn96Z5pFBOhI75wKCKOtrfaL8ryrEQQ3Q5C+4 EympZjH6aC1ZM2p7+hsoQlI= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588327 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 60F53C43217 for ; Wed, 27 Oct 2021 21:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44240610C7 for ; Wed, 27 Oct 2021 21:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231651AbhJ0VVd (ORCPT ); Wed, 27 Oct 2021 17:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244285AbhJ0VUn (ORCPT ); Wed, 27 Oct 2021 17:20:43 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C82C7C061767; Wed, 27 Oct 2021 14:18:16 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id bi35so8957098lfb.9; Wed, 27 Oct 2021 14:18:16 -0700 (PDT) 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=Hz2VMSoUFXqsYUhbpsexdFmEqO2SPaxLm2OBGSeTwjyL+yPF3IopSku7KMFUSF1WXm L7PMUNhb+IRjkQPm824pbU1Jum26eYfWTFkMOZIveJEhsvCt6uj8F7HeeLhWXKLMIq4M 1Nvws8kBwkehx8WMK7grmc4K3YR2H/RHhm63nGEgSh2LvuXxrHYv2aG1dR5Omyzlk/Qi S0gMjuMLwm/HOwiyWDbFTwmxA8WLSlzap6OpyGPVNKG9/0fDv87S1de94XyFw6RVMGKH uuaEXLTjmBivB/aE4xSsEvZ/U/NmjIkgeEgZpAbhEw3Yqp2cC8ulD8SkormgU3vkAoX0 xRvQ== X-Gm-Message-State: AOAM532fizatyFQnJ/y3DQWcdEVsSWBmvolIw7LJabG+Hy9j6I0GHTCp zbpBsDnveD7BM8cvp8JUU/w= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588325 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 974B0C433F5 for ; Wed, 27 Oct 2021 21:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DF06610C7 for ; Wed, 27 Oct 2021 21:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244278AbhJ0VVf (ORCPT ); Wed, 27 Oct 2021 17:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244419AbhJ0VUq (ORCPT ); Wed, 27 Oct 2021 17:20:46 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC01CC061228; Wed, 27 Oct 2021 14:18:18 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id l13so8989350lfg.6; Wed, 27 Oct 2021 14:18:18 -0700 (PDT) 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=MglOSCqAp2nkonAUAHEFoTTIDXPBbeWFlQT697tM23aRik+64WJrEo4E/2aOp1s/Zr OYg3C01S6nBn/2SWzKgsSPqkaTJRhce1N5sXYwrwbMJer4vynHkBzlxFJ2bbaN9f7Px+ j9+psW4SggtMdqDRp/JXV8uf/y6ZHTIwBQQJ0zaoPEcvp6MTIH8rcLoElKMqxykx4a0h gDcUTWcFiItMdK7L7J9Aay8wypVxzJqzSDGQnyZpvKbycR6eONWc+F7tN+IiofEXm+pK xJuPM1CJJjylfe0Yr/EYc2dw/qCxJ/CwJAUPj7zGu3+lSbJ3AXnVjgJ3qdcg7YTRbNyw B9mQ== X-Gm-Message-State: AOAM531kqjnuAXh9LlqtyJjWsY8cYYfRYDWl8vPLHAIuvgKirGfeAXva IT2XbD28/WeDvbUJ2rioFPY= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588329 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 73F86C433FE for ; Wed, 27 Oct 2021 21:19:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DF25610CA for ; Wed, 27 Oct 2021 21:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244319AbhJ0VVg (ORCPT ); Wed, 27 Oct 2021 17:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241055AbhJ0VUq (ORCPT ); Wed, 27 Oct 2021 17:20:46 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8606BC06122A; Wed, 27 Oct 2021 14:18:20 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id u21so8956161lff.8; Wed, 27 Oct 2021 14:18:20 -0700 (PDT) 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=YJwQmX/M6TDNppqDPstaQBXoJU9JFFOAZ4eSF/w20y07QVwWocJc8/Ovk21fFN5aoc 54k18fZBKBPNLESaSacHyVdzwn/zgtTS1U+X/sjsiz6ooxFO7bIbJlAwz18YcT5zQeba jBSM+ridL2sMmS02ffHxf/lT9ASFpWal7mTfZ9Aq1QX4lbBxZtb+zWAgNdSUEc06ZbG7 sv0VqibsBoRGgQTG0RxggZiA4LqXeTdTsNbOrCyHmXvkHLA6ohvG61i5IYt79O8Naswe JNC7PrqEQVndKpxgRQlIg80wwEWfwlmlUegFME02LPgdrgdTL+U20EEzoM8Ed15fAoyF IhuA== X-Gm-Message-State: AOAM530PS0Z1m9tBuITaX47mSX0pGIdv29ycWIDmz+TbZDmaxHvZ/rXI ODyqyOVkxlrVCMf4iGtFHi0= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588331 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 01399C4332F for ; Wed, 27 Oct 2021 21:19:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E552B610EA for ; Wed, 27 Oct 2021 21:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241170AbhJ0VVv (ORCPT ); Wed, 27 Oct 2021 17:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244471AbhJ0VU4 (ORCPT ); Wed, 27 Oct 2021 17:20:56 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E7ABC061243; Wed, 27 Oct 2021 14:18:22 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id bq11so8954700lfb.10; Wed, 27 Oct 2021 14:18:22 -0700 (PDT) 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=eWzNyfhdIzdMdwNCFTu0yEX1dHc68lEjvmqkMcQyMgwwai6GL8IGJyO9xl0lmd8bbb ynQy+x+crDosNxOGLjTHRg0+cyZfh3lTUMr7WoweHyOu1m05HNf07YBrKRteeQhvhaGj mZRTpX9cfUkSzeGDm6MnUgyWNaFIldW6kmOsk5VxWyLwSICBqlRgW0b2RSHcgPPZcl9o eVV0DU2sQsTxvme+AjHJg1Vsz4syeOo1EwMiOh3EpRyye/6KRYfy/dnanaypbo1wTEOP s5Gm1WGmu+5GDZWGpVielEGVBh3RKU52eKGLnVVtUgBLl7vfCHFh0Ob1BRq01z5frdk/ FOeQ== X-Gm-Message-State: AOAM533SN7oxcPcWIlN2zaQwIaAzJYWN6Kt2wCudzdyWGLt79UTNd8EY 0aHLU85WLMVCvA0OofnIMZQ= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588333 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 53EB6C433FE for ; Wed, 27 Oct 2021 21:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4141D610C7 for ; Wed, 27 Oct 2021 21:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234126AbhJ0VWC (ORCPT ); Wed, 27 Oct 2021 17:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244487AbhJ0VU6 (ORCPT ); Wed, 27 Oct 2021 17:20:58 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C47C061230; Wed, 27 Oct 2021 14:18:24 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id s19so6943083ljj.11; Wed, 27 Oct 2021 14:18:24 -0700 (PDT) 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=aG+uBMZFg8N0YZ0oEpwDlPm46DrKyRiAX6OQTp4BKGxemuPd3+4L0iHmxljsCYgYhM JkWO34VVoZCgo4jNM3pwX8tK6Ynq+OiMiKHtSD2qIp6U4Ly6wwPRW7mQOqa9VW9RSxcv 2IaJmXsmqgs+h40z89VFOJI5lmHjQ/3Ps3W6oUFfr7Hviq5HlyjiNEx16UDN1mQQFlcA utSWnsfAlkZ1OXpDGnbLcDHVHPHRfoy+qeVrV16GnANBYbAhia0he0drI7GyZUTe2tRO U8NtB6IJmMxA/S+f/xfo1HvXvywb3iA13pdWjUuixgFEvvvMFKJIPiJmP0Xy6oYiQXRw pzjg== X-Gm-Message-State: AOAM531yhpQulrM3r4Ufc1GYz+NNrQmiQj7A+0pAYsUzi/hV3UH4RlxO lQ+ChGM9dzfNUsYOZF/xMcg= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588335 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 E8E41C433F5 for ; Wed, 27 Oct 2021 21:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5993610F8 for ; Wed, 27 Oct 2021 21:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244489AbhJ0VWC (ORCPT ); Wed, 27 Oct 2021 17:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244491AbhJ0VU6 (ORCPT ); Wed, 27 Oct 2021 17:20:58 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26741C061236; Wed, 27 Oct 2021 14:18:26 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id u5so6965517ljo.8; Wed, 27 Oct 2021 14:18:26 -0700 (PDT) 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=PUiT6eRC8CXKXXImEEoHs+LAi8oXfdl9cqflGHVD0i2btPXjcy6a/fajAYxldtLSq6 xCNUW5N53UGZJn9rwJQNtU7R5GuR2OtkNRi5FQot8I41Q8MSFyGQhSgtW+Zfg8CMknEJ ftCJwlOwxxRVg5uSSOsBKpGABKHFjM2qfQysEzSw/QrwEQCk3JHayeCyfK/5z5KLqk2I lKgmivqBb9wDOpxeMnFzJMDTPOhBuk7Ntb6OOCSn6wwa/JWlchJcHaEkqey2IiIEi9QM 8opWqkLlxNxrPkGsMeMkp0Y2foG8mrc8jZrY/MfBSWuNhhuJZD6XkFETUIPj0A3wMld1 e83w== X-Gm-Message-State: AOAM530zuIPgL0ZoHcUOGUy4TXdRg+dg69G3kO+cXANx3XTnoD0AyTtG VgCG10WAuy9I6dkV6RRFYTg= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588337 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 9039AC433F5 for ; Wed, 27 Oct 2021 21:20:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7866E610CA for ; Wed, 27 Oct 2021 21:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241071AbhJ0VWm (ORCPT ); Wed, 27 Oct 2021 17:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244575AbhJ0VVM (ORCPT ); Wed, 27 Oct 2021 17:21:12 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3E3C06118B; Wed, 27 Oct 2021 14:18:27 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id d23so5637879ljj.10; Wed, 27 Oct 2021 14:18:27 -0700 (PDT) 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=SS7ePQk+dxXycLCsxOA2TRnFD4LEFP3J8QzupCIhs3T6pem699ztDiJArigp3y45h7 doiLTijN+faN9AREIhxcHfUCvVe0ZSemBt1W9IjeCgTNu9CHr3+TIEsfsu2jn+epRmhk ++rmearHuco4deYs0SjAfOEhfgDksg+Q6jhJ0xbh/ugam+G6Ws+nkLm3ADDwqvNlnT6n QGNz5z1LBk2JwLyUk7ZhAP9B21ET6pmSsrt6e/7QfPuGqMfKxGnEnrRbyNcFWkcot1Zg FouHOx3okzQQUX/lEDAPZhyPGBc5ZchnahImPNV50ABzO4cHCC/N+ouffrt9RNJ/x3jB /PyQ== X-Gm-Message-State: AOAM5305huWMHnU9/wdtYOLZqEV2AzTceIXs9O3kudrODT9Z5VXZ3Wdy QgKHcYhOJvcLUfrS4u5HiZE= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588339 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 A190BC4332F for ; Wed, 27 Oct 2021 21:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C54F610EA for ; Wed, 27 Oct 2021 21:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244282AbhJ0VXk (ORCPT ); Wed, 27 Oct 2021 17:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241055AbhJ0VVt (ORCPT ); Wed, 27 Oct 2021 17:21:49 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A34BC079785; Wed, 27 Oct 2021 14:18:30 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id bp15so9013633lfb.4; Wed, 27 Oct 2021 14:18:29 -0700 (PDT) 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=TosW2/5vCHexvNy3aBzYQxqtJLclsQa4KwekhNZkXJOHY00LnrNpgGK0hfhupAuGU9 aHNlxP63H+pDHuw8MU1NmRcjShfidzpG5w+NSQoKb7NAav+D7AT99UHvDdjC292eMOsc E/5grQS7btTi+V2diwR94xz9pwdSPz/kczt9CNjdDu0+397DjDTauS7B8hwhWUzn670S o3tGRWtO6vYYS371epi5SMUse9WWRiRaN727vvWy2ktL7T48buRfxddgimiX6K7bv/rj W179bq1/Ppr/cG+v+vXt7LYC3y4WdYI2H8nKQ4PRnQ9Zlh9TRnbS7FIVCIfRHjhGRO8s tNfA== X-Gm-Message-State: AOAM533DFh0VNzH5fE/DnFPeaQCDq8mlSV9bkfeiMT+IO2g5CCKmhKcj Bn35Ksq0rKVXyhq/S/5ok7Q= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588341 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 5602EC433F5 for ; Wed, 27 Oct 2021 21:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 450F0610F8 for ; Wed, 27 Oct 2021 21:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244304AbhJ0VXm (ORCPT ); Wed, 27 Oct 2021 17:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244440AbhJ0VVu (ORCPT ); Wed, 27 Oct 2021 17:21:50 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D116AC079788; Wed, 27 Oct 2021 14:18:31 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id l13so8990302lfg.6; Wed, 27 Oct 2021 14:18:31 -0700 (PDT) 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=YiwkrX0/CdJJMkUSuyfecdARhViLhEieQM6nBhUrNuCzP89MGs5dHeZvVbQyqnb0RG azD24FB2ZFtTiZdMC/StFsEWjwTJ39ZnEjwPe7LU2q4U0QfySFcFsULMZ4hatAOxySCT Cl42GIF4xKUEcqa7QbSspKKyP+w7DqttOyJ5utQfsxNlJoUyyCs1SHqTobfG+GzoJsRi n4BwntRrevcZB3OA4iBUdbrJP6WaptfWhIjTht6qnUEM/tR4e2hZTVYY9qEmxPcItL7E kekrsQQ4XrrcV971DPpLcmG46EHSK2gn4G1/Tpek4CSfpD1p+Mzj9DsgOG73VprwSD7+ 611Q== X-Gm-Message-State: AOAM5303bkkbz4w7MwyZc1BWgl1PWZYk3oFyZPM+Fg6optWVusrq3jyw +peCqufVAYXEf04d16KbP3s= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588343 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 01745C43219 for ; Wed, 27 Oct 2021 21:21:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E20F6610F8 for ; Wed, 27 Oct 2021 21:21:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241305AbhJ0VXn (ORCPT ); Wed, 27 Oct 2021 17:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244467AbhJ0VVv (ORCPT ); Wed, 27 Oct 2021 17:21:51 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD468C0613B9; Wed, 27 Oct 2021 14:18:33 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id u21so8957092lff.8; Wed, 27 Oct 2021 14:18:33 -0700 (PDT) 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=ngvaviDilbK7UsIBWmw60SAgjELf/UjvGwHhezvwRzLKIVbXwu49KpTrcElZlz8tXF kQTVh7ALc4hPMU3Zng+uTctcKlNA1VdWwPSKzuuVedab8Z+JaKbJjDOBC15BQiOQNEn1 mVok8kzZxwn4RIagHmEvlc0uskELx3kfJd0AwNxd/73VKlf3Tat3TkG4hgs7mhH5ki6+ klsZz2LF5BOTdb6YNzYSP5JX5HRFfk9xJ0y+HmtD8yGZbjIhUEyWjtIKSPpIBYZSRL+B L7YvbZYHpGhpwZ2TcLGH66iMHg/7NGDRtx5bEdNp4aGvxmUZ4rrnPI+M/TuKFvElxV9r 5Dsg== X-Gm-Message-State: AOAM530LTi5zk6HiDLcmM/uPhGpcPbuVkpT77f29XPa1z531PCylnuBB 0p0v/CePPyCcarwa4KEWju4= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588345 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 7980FC433EF for ; Wed, 27 Oct 2021 21:21:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 661C9610F8 for ; Wed, 27 Oct 2021 21:21:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239214AbhJ0VXy (ORCPT ); Wed, 27 Oct 2021 17:23:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244461AbhJ0VVw (ORCPT ); Wed, 27 Oct 2021 17:21:52 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C0AC07978D; Wed, 27 Oct 2021 14:18:35 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id c28so8887472lfv.13; Wed, 27 Oct 2021 14:18:35 -0700 (PDT) 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=RQdarPVv8BgXWVqYfAUFSDDspyuRd5pXaItCuokMKbzh0Hwal7PPa8LWxYco1qEVbP 9+rBO+LMCX1ZE4GyBCDcdh9AGXsZIOy2n4zrELDcDIjqqsXnzVdHh8xagMgbl2Pt3Pdn VuzQweTTrjYSOsKl42rL9vPA1Myb5PSef1OFeSN1LQ24pDcXYTeAGk3jJhbavyUTxUxG l7tB30jhdTWgUnxdVtBiwMnmOOiGxT5y482h2iCXQP9nW7rtCiHmKJKtI+XF5M+XfcvD B6Kj29MHLl+ONGkuMFz4JKNp0rvwRyH/4GWwAZKRAHjca7FZU/s5a/hrtOepcT/W8poi 4+ag== X-Gm-Message-State: AOAM532Mjqqr58wwGgYnH57GFEX2GjoUQwBsRciB5Gfqjo+dCQq5p9M8 QoN5M68/e/PccpB5eRpxNig= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588347 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 597A3C433F5 for ; Wed, 27 Oct 2021 21:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43CD961107 for ; Wed, 27 Oct 2021 21:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241146AbhJ0VYN (ORCPT ); Wed, 27 Oct 2021 17:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244544AbhJ0VWp (ORCPT ); Wed, 27 Oct 2021 17:22:45 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49EF5C0432C6; Wed, 27 Oct 2021 14:18:37 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id bp15so9014103lfb.4; Wed, 27 Oct 2021 14:18:37 -0700 (PDT) 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=ADMc0chHW5n+H5eKujckA+Bo50ein/UoSz7YRe3KTWR/bFqnjMH0wfiSP1RSuMjYq8 Xipi68k3HcDAkmzauObv7Z+0UnD5pOfgUcGe6yGJIkfq5K4RMKuSyKXiHnSp5UDSk+eN B09VRseQbrmnNbIGTM8q+ZwENDDUo4/oo2tG5tXZZ/OZIF381adQL5GE1AQ6Hu5Yy8RT ruwSHDPqpZyra1LoK241puSwxWme4Su02f3x73RJtSHEjhuolwSCrYbvddTtTuRB+GrR WCL2FQR36Tszl7r9iJDT8hS0xqkPWdmEntV2MH9JyTL5kzODsyCLXCgxZobtM8PrfrOY /QFw== X-Gm-Message-State: AOAM532bbAe1WHB13IRLECiGXenCBpr/Xlvmg7ktfYcziEV+NQoUMqOk 6UCvNyXg8/sHPZXzgzjAZRs= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588351 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 0E5E4C433FE for ; Wed, 27 Oct 2021 21:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1CC7610F8 for ; Wed, 27 Oct 2021 21:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241461AbhJ0VY0 (ORCPT ); Wed, 27 Oct 2021 17:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237121AbhJ0VXf (ORCPT ); Wed, 27 Oct 2021 17:23:35 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B19C0432C4; Wed, 27 Oct 2021 14:18:39 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id s19so6944119ljj.11; Wed, 27 Oct 2021 14:18:39 -0700 (PDT) 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=Bd6Zw+u/xaPxbaaPSZJtfBmSEa9503cfi6kdlw3Hc0AQMw0tjlCYQc71xDyS6tCNJY tzZYhCoXXll3+ne170KDCXMjw5ppgq4c9SQ3CM9tTJrh/fjPqesOI3Vun3RE/MaEkmUk t8F3IEZVwoBwarQAEKj6CN+g8MFziGC0iUhGMZBWYQybtPvJ0++VXxoJjveFOFaW0Lng HW+00TrcVghflPnS73EQvj/knFcdXx7Er//wQRg7B8/cnhznY1tRdVSL612ENcwDYv1n SNop4MofC8jgfdWzyxbRMWyUobMUUoL2q1uUtRrsNZDFaLbBVhoS8LEdeRc0tYOh51/i bcXw== X-Gm-Message-State: AOAM530Vne3hMD0SxMzEaEUs+koFOV5SUnccQmpXQQvLjGlmYCIt9uz8 3kOG2VdcRoMwsVhhnuiZ4gs= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12588349 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 783F0C18E7C for ; Wed, 27 Oct 2021 21:22:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58C14610EA for ; Wed, 27 Oct 2021 21:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241424AbhJ0VYZ (ORCPT ); Wed, 27 Oct 2021 17:24:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238904AbhJ0VXf (ORCPT ); Wed, 27 Oct 2021 17:23:35 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A922C0432CC; Wed, 27 Oct 2021 14:18:41 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id b32so5810585lfv.0; Wed, 27 Oct 2021 14:18:41 -0700 (PDT) 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=ss23/14gvwwJvYM34ibI/ZgbUmpHxVjzq3uUOBHaqko=; b=arwhy2EzVRFeFixUch4iOYgWEx15do0VgxAfdqV0D/m7TKP9iKYpnGzKHPc/i8aFQC 696TXg56UlUupf+0+RULAffCTRlP8iUn1mFqCgape3sBElIYYn3vwgHjtN2bztkR/yaz 5XVeuFkp92H0x78xi/Heckb4RKbtEPv+wOARiARvxCIQqcVNpwpOqlLJtRckQaDgVOF7 skIGftczMYqZ1vyVBJ3tsSBqPsOUSX9T5P10sVT2ED2dp7t8+MxfkB66wM+xzBA5lfYi IRYhj0tnB8GrulFr808wNLi8EcEAMFxyf0xL4I35lWHzPaQq0/pqp97SuSICmC8JFF01 uymg== 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=ss23/14gvwwJvYM34ibI/ZgbUmpHxVjzq3uUOBHaqko=; b=P+hZHiEWfv6uRXeSLPCgb3dBPd2ZZLQ6KTcbdw+K7GjdfhCzLKwNtDkqs5sQKXJ7SI BxRXulihJ5l+UQAfVLg/zR3yr4M8FrFSTqz1FU3aphuUIWAeupIDdkvA6/R9R1pWBLXy 9KTvh1J7OyPVPXmzVX2EALGWiQmMVGOpDYxEjuRRFP7UdDpE3fgtt9vEIxOEGK7zYlZE feyM7gl5QwIkoeec4TZJ8hYAcXqNTzCp55o0ucjqbbGChdI4y3oQkKbyhPaVVLKJIt6p M0g4Zz9E0E+1JaFbxbAP6p1tx7EZKoxRymyivLhqmnVHsk2RTjhBgH4QHvoNGwB1QLPO i03Q== X-Gm-Message-State: AOAM5331H8T58qOtHlJI9uxY97jztkVrvtfSvImeaDVOy3hn7INiu4L2 HqX3s0YMMhcrUe8loZ31nd8= X-Google-Smtp-Source: ABdhPJwimcGthRahpfEG00zaldcVjrnfSz4ndztOCehFVrD6lb951uJJXEFJ6kDGLgjZU1iMb9PE8Q== X-Received: by 2002:a05:6512:1047:: with SMTP id c7mr83192lfb.589.1635369519432; Wed, 27 Oct 2021 14:18:39 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 14:18:39 -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 25/45] reboot: Remove pm_power_off_prepare() Date: Thu, 28 Oct 2021 00:16:55 +0300 Message-Id: <20211027211715.12671-26-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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org All pm_power_off_prepare() users were converted to power-handler API. Remove the obsolete callback. Signed-off-by: Dmitry Osipenko --- include/linux/pm.h | 1 - kernel/reboot.c | 11 ----------- 2 files changed, 12 deletions(-) diff --git a/include/linux/pm.h b/include/linux/pm.h index 1d8209c09686..d9bf1426f81e 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -20,7 +20,6 @@ * Callbacks for platform drivers to implement. */ extern void (*pm_power_off)(void); -extern void (*pm_power_off_prepare)(void); struct device; /* we have a circular dep with device.h */ #ifdef CONFIG_VT_CONSOLE_SLEEP diff --git a/kernel/reboot.c b/kernel/reboot.c index 779429726616..9895bb56cee4 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -48,13 +48,6 @@ int reboot_cpu; enum reboot_type reboot_type = BOOT_ACPI; int reboot_force; -/* - * If set, this is used for preparing the system to power off. - */ - -void (*pm_power_off_prepare)(void); -EXPORT_SYMBOL_GPL(pm_power_off_prepare); - /** * emergency_restart - reboot the system * @@ -866,10 +859,6 @@ void do_kernel_power_off(void) 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); } 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: 12588353 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 E42D4C4167E for ; Wed, 27 Oct 2021 21:22:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4ED560F5A for ; Wed, 27 Oct 2021 21:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230114AbhJ0VY2 (ORCPT ); Wed, 27 Oct 2021 17:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241312AbhJ0VXj (ORCPT ); Wed, 27 Oct 2021 17:23:39 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E47C0432D2; Wed, 27 Oct 2021 14:18:42 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id bp15so9014571lfb.4; Wed, 27 Oct 2021 14:18:42 -0700 (PDT) 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=pgU1f2oLo4rCuhwZg+HHW5Iiywkj+aNPfHuL2e8gQx1zi3aLvTgCzPu49g9/W2C/Yl 5Zh+jq1/zyKMKxGvUJOqR6gHm+ePpslPa1gM/bTTGfjovb2Gu9pBoDBn25KJLc/nlNRg tjyNxsr0i57UIANPgS+3dEc8dbA7HA8TF43769G3ULDLele5UBoSnoXx1WfThVdOLw5I zLkrW7taTg0xiT3NPNtbrB+dHT8OqGTGLVoHhkuJYnPHPuignXSM+dcbuHx5OvYGDBpd 7hrwUIN3UimX3KGcCFOasBAcicI9Orh+uWweRqV1DWP4Xc25g8nsPPjO5d9hhm9wVY1N 4U/Q== X-Gm-Message-State: AOAM531ZX8tVeuRjffFJHB1mszEZVS6+ZzEefYyD09QVh26JBfFEz+fZ dObXkvzbUFtQ7bPYX9yhyAk= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588355 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 BED4AC433F5 for ; Wed, 27 Oct 2021 21:22:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8D77610C7 for ; Wed, 27 Oct 2021 21:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240065AbhJ0VY4 (ORCPT ); Wed, 27 Oct 2021 17:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236274AbhJ0VYJ (ORCPT ); Wed, 27 Oct 2021 17:24:09 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCEB9C0432D6; Wed, 27 Oct 2021 14:18:44 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id y26so8915758lfa.11; Wed, 27 Oct 2021 14:18:44 -0700 (PDT) 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=AVO+/vlfCQ20nsufuVN8h0TlDxDqllUNl6p+3teclMHshqWF0YlK54NDb/mf5smCbe SImScaYOH9DRjkGXKmMSKAWZpso9GJ9iqF5lVh3nQEEH7Jb4etgeaUpzkKhNDcP0ue8+ 2/r5RMdD0bUfHufmpianyv0Pyn9y2gHh4axgNLRGkeflOIk3ndD5x0ni2Gl+ZU4i2/ja QSQKnv6NAIaimT2f6wR5sy00spUBWukM+Y5MwnC6reW9E7J5mdmy40y9k+gXeBlWltJI qeiWXq57gxJRud/1rEPwvM5FffvmkZXtjEQDYpuzR/mi1MKchdFIRP73GlJyqz/y/nzI 14rQ== X-Gm-Message-State: AOAM532odDhY5tPoqZLh1ItaYCYOJYG4egx+tDV7uUwCz6jCX8+zaeWb MCpK2fyJG+IGun4d1gN55Gc= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588359 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 4ACF2C43217 for ; Wed, 27 Oct 2021 21:23:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 355E46115A for ; Wed, 27 Oct 2021 21:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241330AbhJ0VZa (ORCPT ); Wed, 27 Oct 2021 17:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241173AbhJ0VYU (ORCPT ); Wed, 27 Oct 2021 17:24:20 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F6DEC0432D9; Wed, 27 Oct 2021 14:18:46 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id k13so6922074ljj.12; Wed, 27 Oct 2021 14:18:46 -0700 (PDT) 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=VrDLGVFXQu0zoAGOKShZDVAbKBIEf6RxC0crUfZo6Sg4X6UD5TJcVgitzAlWcb10p9 9HBmP2wq4sc0/wooO6rX7XexeHPzfpRil9FgJZuB2V2+jy5Ks16+NgkJz8GlmUDLNKtZ GmvWYeNyD3X5Kg2jNLwIxqdF6Duq0lXMDiWY5HnPjjdfjZALF+ArqiIHNVprDaIb0kPJ tEdM4lC157LfoJk2e4I40knOdObqBuR0V2t21KgesOvKWnDRkh8WztbRnoVwL6ZJW6ak OGN4Z5c7nriqXOaRIDohV23WPg8XFgU0+Iqpv5L8c5QQqLHJv5hT9gNLpzQTyQRPdzjI 9Q2w== X-Gm-Message-State: AOAM532mvKuBAsT9vXm18MDirplYVzv7Kxw0+C+megXRXwkKWx6G98Cs TjFzxExpTAmyfqXOoPjfu9w= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588357 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 CD22DC433F5 for ; Wed, 27 Oct 2021 21:23:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2F166109E for ; Wed, 27 Oct 2021 21:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241319AbhJ0VZ3 (ORCPT ); Wed, 27 Oct 2021 17:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241181AbhJ0VYU (ORCPT ); Wed, 27 Oct 2021 17:24:20 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D950C06122A; Wed, 27 Oct 2021 14:18:48 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id j2so9016174lfg.3; Wed, 27 Oct 2021 14:18:48 -0700 (PDT) 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=fwy9dH9CHv+Ow9BtWYaZ0GSWGKlXqXS94k5WXkdAevuWiFHA6gGkVG6Hrmh0RXBo2V C+UZvfp3/cd6MEKDRiDbeuRSPjMqVsbu5MgGiT93y3mKzEQFlVVVeHHjq4hA5jIr5Ooy 43Q3zXB0ac5qmsSwEDx3xGYKBcRnSRjwkd/jImehPR/0/2UgrBf2pmItbR+P092GoLLs WSmtrb5CqHk/J6E+uSiq5Ra4PauTjR7SYYkCox6rJnpGSs4SE8xBSszTBTI4xc/le6Mt 5v+nQCZAfZ8/SUiz7Z9vEwpMGh+WOWrDdyqs9Fiv8QMv1j00d3KW/d4J7cAN/cuNjPEf nSmw== X-Gm-Message-State: AOAM533uRov04WuqxJlVws2g3MIrDxfXuZH7VIpRfx44u4itTEJY36G9 9LYHK06jwcALa1tbyObQFXQ= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588361 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 8959EC43217 for ; Wed, 27 Oct 2021 21:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 723196109E for ; Wed, 27 Oct 2021 21:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241457AbhJ0VZc (ORCPT ); Wed, 27 Oct 2021 17:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234550AbhJ0VYU (ORCPT ); Wed, 27 Oct 2021 17:24:20 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E22FC0432DB; Wed, 27 Oct 2021 14:18:50 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id j2so9016302lfg.3; Wed, 27 Oct 2021 14:18:50 -0700 (PDT) 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=GLTVabvHRgoUlmbC2qHtqkDVDvW3jksnlunk5UGnamviIvFF5gox0gG+4iFOCJ1HVG dUNllC9JDFm6T26jLtFYRBwBlaHlbM6ic2I2Qj9rl3eQcJZ7uHRNQTkPtoBsq/Qbenu5 NgtSTX5YYOmNqrmpWcfla16fsabfndGLx9h3vcpS9vrLOPaHdMPYaG0loXoyyGdB7sV/ ZrLbD5J0sejGeGO805T+Kfk0I4QE1RoWceKhobwag0QaaTkrvmNopBjohQuXRReL1fDA 0rQ5dM/voRfpQ/5DYtsg+DuLOULyoKdLkR2pDB4C7CyRFDX0ethL0i72GWy0qejhBwcs vbpg== X-Gm-Message-State: AOAM530RoTjxFvaNZkOQ3M23r5UW5b9tWnXqAdINl5SYzuf6WWpfy6Bg 96lc59PMMqp+MqaIXEgJC9s= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588363 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 98398C433EF for ; Wed, 27 Oct 2021 21:23:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8529B610CA for ; Wed, 27 Oct 2021 21:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241482AbhJ0VZd (ORCPT ); Wed, 27 Oct 2021 17:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241322AbhJ0VYY (ORCPT ); Wed, 27 Oct 2021 17:24:24 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E62C06122B; Wed, 27 Oct 2021 14:18:52 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id x27so9005783lfu.5; Wed, 27 Oct 2021 14:18:52 -0700 (PDT) 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=WLlUGoInLqaiBg23maEMLGX20Hdf3sJDvkPaj8rA/56aXl9s0dM6IwEgSSrlYndHaC 8GRHOidoT+UyyWKQWgQYs79KafPZMD4rgXSKRQZSCmlIYqzcR63QoXvoh6kufYoDLDJu b7kdIScCm1Lv9PcitNh07AUOuN/s7Zw37pnKjCw0oa52M9VO7TOmlE0nIm0Iz5K2hXUb YtQoMC/w6IMVk9gk/JTHZ1r/1afpXbrQj8Dhz3+FxYb0P7SCtsN1wvNkXRY91R/sIobI qvZVe7wwfVDVYTvvrgLUwIdEH0B+kA1HRaO3RjvheAfHiuQWo02/imSn/QYfiHH+IH+k qpuA== X-Gm-Message-State: AOAM531geusyO+FT8H9w1GN4AQ+9Jg3SSWQhAmDmLhm/WtPnNxYINUPR ivCM5cVOibPZIbz6AoKctYI= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588365 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 6EBCDC433EF for ; Wed, 27 Oct 2021 21:23:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57CF8610EA for ; Wed, 27 Oct 2021 21:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241522AbhJ0VZe (ORCPT ); Wed, 27 Oct 2021 17:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241345AbhJ0VYY (ORCPT ); Wed, 27 Oct 2021 17:24:24 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16815C0432DE; Wed, 27 Oct 2021 14:18:54 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id j9so8980268lfu.7; Wed, 27 Oct 2021 14:18:54 -0700 (PDT) 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=g94owpKKRRPcgJfPyB2QZFBBLd2nSYMvzLFLDXCJGylerSJTxf9CghzBWfzthzxZNp NLTQ2XYkyUZgIyuHGHdAlx+sWvU3z/hEqgQ8pHHNyL69tZwONzGup43tBqJxnwNq9jXv 6Ckc38CpFY9FNP6n5rOr6UaeZFh2nU4dx8cPCTFG2mc6I3Z/Femq0RSufUuHM1CN4Q8i wU71TviYGbXjTcWtoRdZHTGzy4h8VKcUYM1f7rl4RjROG7zirWxlEboDx05gxkPML1PC xK3pGqkeXq/U3O2ohaC+xPtVNYanoaI3lVIxGL7VaJZS+3r1ZVZkSYPk1RQl+F6NXZEQ /UrQ== X-Gm-Message-State: AOAM532iXolfbnxXjteiHZAYKM8888fX5FDIKuSLYkNItj1AzwiOxYDY y6XbKrh/nMg45jhwsUzJwLgm7JpxQ9E= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588367 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 504FBC433FE for ; Wed, 27 Oct 2021 21:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3922E6109E for ; Wed, 27 Oct 2021 21:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240195AbhJ0V02 (ORCPT ); Wed, 27 Oct 2021 17:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234416AbhJ0VYz (ORCPT ); Wed, 27 Oct 2021 17:24:55 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4452C0432E4; Wed, 27 Oct 2021 14:18:55 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id q16so7019892ljg.3; Wed, 27 Oct 2021 14:18:55 -0700 (PDT) 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=LHMUt+bqb6vsWNgOhYiUjpd7PIZxB2t67atX224q3pezrfYCTNPkC9MrIiypDcYWbL IJvNMmPaeYD280I9BFuqGDntsCjSN+Fj2h8wV8m3M2rZiZ/g3/MtWy0427x1uqoWgr8V ZXrD237LdoWeXIwp9zkDWbV6QgjLelPBjBnnYJshVafrJkkXARethz4rTP4LAQjdj6ZQ LpEXy5hLZ1iJHfXKlumjZzBKBqNKQAiSGPUqecWJMvnKjHV69UBLBEuvkaRsBjL8iXu2 AzNp0zX5Vg5T5ij5EatYO2P/9+N2jBfTrBqBk3wgmAO1FBmrPX3P2+8VNHDy5F9KdZPy W8+w== X-Gm-Message-State: AOAM5335WwrGkjE4jxOrZ8U8BUnIpzDVKuScM+W8kJrnaapx440BGe3L UKLeMaC7551sO3PVpxCRIeU= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588369 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 74A1CC433F5 for ; Wed, 27 Oct 2021 21:24:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 609606109E for ; Wed, 27 Oct 2021 21:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239418AbhJ0V0x (ORCPT ); Wed, 27 Oct 2021 17:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239511AbhJ0VZK (ORCPT ); Wed, 27 Oct 2021 17:25:10 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1920C0432E7; Wed, 27 Oct 2021 14:18:57 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id d23so5639691ljj.10; Wed, 27 Oct 2021 14:18:57 -0700 (PDT) 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=fQAkdG2Paf8UWsphSCXjx4tY1FvxN2Mp+rzGG3cg+HVCovfiDTlx4jZetfe0S7s5U1 CYg/BBse9tgktxPVJDr0K/T+SAEsu9qcp5DnemrHke0Tpj4XpGVCevs5krTG5UBLdt/V uDn+oiXwNo0VXeaB7ydtqGTqTCX/7SrKVnQkQkWnrWo0+Y9iUMxIaOzAHcQl42NdmFHe ni4qmBcxywEufuq56NOr7AhkGHFwTK1k4KPuMeNdZon7iVvJvwbjRPjbUJNH7IZjWqnd MBqdh+bkumos58LsjJ6T6X9U1dZT+Nre5K/wP6ErNirB9lFEB4dkd+ouQl7W45X9wfdI 3tnw== X-Gm-Message-State: AOAM531BHL5bMwpo6Fr3oIuBPzf7HDVxYGlDOLtDXQ49MUWNUwechcS5 lGOYPwEaU/ojDGyL2mNJRR4= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588737 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 391B0C433EF for ; Wed, 27 Oct 2021 21:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2085760231 for ; Wed, 27 Oct 2021 21:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240073AbhJ0V10 (ORCPT ); Wed, 27 Oct 2021 17:27:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239903AbhJ0VZW (ORCPT ); Wed, 27 Oct 2021 17:25:22 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2BDC0432ED; Wed, 27 Oct 2021 14:18:59 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id u21so8959212lff.8; Wed, 27 Oct 2021 14:18:59 -0700 (PDT) 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=dlk8G6a/OXTvdm9kZIKCGG7EVGMe24Hbd6KVARrZQBhz/G6+Sir0LJIejOsdZ5Di0x wVIES+JoLJRpQHN+RfdgLM4CLgLBe8aw34bU1f6OyYko/7H6lasE0Tg2kkOrb70Asw9h MJw+nirNXkMx98TefHNoFkDXM2eLgCRqZgb2k9uVPcMAbpjZheXTvv6JZ56FZSqrgjqX nvag1ykqMXmBvy5mavmxYfINqAP1aX4Qj6YbNs6lAhK5Jg41wSgRMGKtpF5sZRkSO1eS ubt52X/IqVK5XoR/OPgCbrOIs91Znld7n9WWjjj76pIZaukHEsn3kJB+zVrNbHe96TcY nfSA== X-Gm-Message-State: AOAM530J54wgU0CvDmaD11R+i6Lr2jRntdgXdrwTVZhm+CI6XBuyh6LD yvqOU8JH91Z94MrpOuJMv6U= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588739 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 F32F7C4332F for ; Wed, 27 Oct 2021 21:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF25660231 for ; Wed, 27 Oct 2021 21:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241052AbhJ0V11 (ORCPT ); Wed, 27 Oct 2021 17:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239509AbhJ0VZX (ORCPT ); Wed, 27 Oct 2021 17:25:23 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77344C0432EF; Wed, 27 Oct 2021 14:19:01 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id l13so8992443lfg.6; Wed, 27 Oct 2021 14:19:01 -0700 (PDT) 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=B03G/XWiH3GQCxOxQWBVnv5++vGhRxJSu/sHE9VI8qVHv9lmvCyopjcULC973WdLAO dTENpQQCPGbxZ7ze+5YiaXjWxbBkxddZzPWmofrleVv/mrnCnWDk0BgAC5X7RkyLw6Dx cvFhJPOLyWiq43/nHAvI+zi5sQNRpjgKsHHbrBG2QH+YWLLsg+bUuzdhysZPPHmIPBPl fgHYoPYzegsM/u9fFywWSk4YQ3OGwc8y3T5823wVpw7wIoEHDrV+F4lk2H+9Y5QqBr1c zq7ZQqJcJL91qkdREv/NTlEZ3eKPy/bPbNtYzloEjHOWoSE+y4HgWMGPj0U2q3KGaa9j U6kA== X-Gm-Message-State: AOAM532ASm8uENMc/LuahDIY3EYiMYx3Ey8nDa7yNbrOQuNTRWLnhy7Z C3ymLoyDGbZkHViN/uHUDtY= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588741 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 8FD7CC433FE for ; Wed, 27 Oct 2021 21:25:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B36D6109E for ; Wed, 27 Oct 2021 21:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241419AbhJ0V12 (ORCPT ); Wed, 27 Oct 2021 17:27:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241083AbhJ0VZZ (ORCPT ); Wed, 27 Oct 2021 17:25:25 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A4EAC0432F1; Wed, 27 Oct 2021 14:19:03 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f3so807958lfu.12; Wed, 27 Oct 2021 14:19:03 -0700 (PDT) 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=dk0Ua7+8vaAoPepoSXkiaUeoUIMShuW8Ciklf1yf+kTYGqe4w3RNARZDJ1p/VdRWvy /D14aFGSt29SRagZZc6Tkq7Xgs4G0u446KNGKk2jsuqin4vME569Mn6rkNlRaf3UntNb 4n5m6DSfJa/CXMvQJeV6WWX1Ee02rykPts63fj5ydSxTzyUiP93ulHQrI1XJ4vPkEOGm xpw1nLTVKkCaB/vgtySUzPnGA0jFSusBXEDmDe3vEFhSJA+Bmhm918Afr2R7kIPplgq8 olHwljieylALp93mftJpq+4iVhqfbmZ1z+qVDYkAywKv4PZ7D6HrVjAOND0kMh1OYz3J Au3A== X-Gm-Message-State: AOAM5318yMVDZxqH8fqZBYL6jdnCQEN28gtJe4IWp7cnCuK7Q300Dd0Q I6uI1IaPTvUhOapxSVi0MwY= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588745 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 BAA20C4332F for ; Wed, 27 Oct 2021 21:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A98FE610CA for ; Wed, 27 Oct 2021 21:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241627AbhJ0V1n (ORCPT ); Wed, 27 Oct 2021 17:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241208AbhJ0VZ2 (ORCPT ); Wed, 27 Oct 2021 17:25:28 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184B3C0432F4; Wed, 27 Oct 2021 14:19:05 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id s19so6945790ljj.11; Wed, 27 Oct 2021 14:19:05 -0700 (PDT) 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=VKbLBmB2+WXU92YcEI4YUPhNoNjmlqc9o6RUYF5WTOLDYZO1qpRn5k8wcJYKf7DyXV MJo1/ELHYe6RYh9ujbwXi14dXhgIg6LB1SofTv7AUA3XgDXstA3p6W2yE6cTPZth3MIT yXjQNKAQVJ5jvWEpjcqxBAcvAjE+E7QwS4LjQIWnZ/OyLF6wIsz9+4/HAyHGpj/0mSqk /lQfmrLPUGvs2yQCqyOUyreZhG+l4wiFPaxiCuGXBhyx7Ynpqt2lCRCYKRhBpJX9fNtw nClX7x0Lyad/Vy66kAyEILXknDL80u+tbX/qEqLvepVV5QR2IAUcjGPJKqFD3oO5JLIF Rmqw== X-Gm-Message-State: AOAM532VLfst8oM+N1/qDEHbtZgcOxVLwCHHZzOtrJd3wzgAagv6O9UA Gv/rxej/fXGJ0INVtJIo2tk= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588743 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 5A329C43217 for ; Wed, 27 Oct 2021 21:25:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 417A160231 for ; Wed, 27 Oct 2021 21:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241593AbhJ0V1m (ORCPT ); Wed, 27 Oct 2021 17:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241255AbhJ0VZ2 (ORCPT ); Wed, 27 Oct 2021 17:25:28 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB063C0432F7; Wed, 27 Oct 2021 14:19:06 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id h11so7032494ljk.1; Wed, 27 Oct 2021 14:19:06 -0700 (PDT) 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=6eRm/yH4uKwzVBusC+BubrYhiUqmHSMgN+xIU10SkaLqZQ6UhwTixA9F5p7HCf8hJX BtKiglbu+s9lKyiLsXwPYJ0YFa+/sb/JKbUqG4iosT+DYghpkfPFTN8oTx4kXPpfPqUX BZzcK5lQmcOIlSjnAozEdBL/4waX82mrhMVQoHabZlzGHhME3ey570ll/4Vk94W1ibwd W6iP7eXhRmjKxnZpK+tu0X4vCO1Dibj3oD4ijyIKQOBDxAKdRc1+dIw4bDwby+fDXp4P IGN5OlYbg5NYg5CyXrMoEKwApCIgNjbyNGm20p8wjEpuqdO9tlJFopXRX0eb+1yqhQB/ aKGw== X-Gm-Message-State: AOAM532PJfWISP/N1/cuottR4XrInzLbhIHHrtyD4WiShr6hjTHTm7Z+ 2814HwxygRkqPakxwrOV2Iw= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: 12588747 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 5E1DCC4321E for ; Wed, 27 Oct 2021 21:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4437D60231 for ; Wed, 27 Oct 2021 21:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbhJ0V2v (ORCPT ); Wed, 27 Oct 2021 17:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238835AbhJ0V03 (ORCPT ); Wed, 27 Oct 2021 17:26:29 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE80C0432F9; Wed, 27 Oct 2021 14:19:08 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id k13so6923473ljj.12; Wed, 27 Oct 2021 14:19:08 -0700 (PDT) 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=P+FvQtAjfrSxOJdF3ox1OD/AFFDCb4BBTFHs+sIwx4Tg1NH/p152DjZWRbqZ4iGNOZ 3YNfL6qEcqDb63vp2swmwsekwRyRuexZtrEjetuPMYzTm9WFKrHnAgGTn+K7YoVtWqjV MBMA+FBpMaVNTboPoW+KQDw1VoN2mlXEM+F7xTnOxk74Lay/J3pZdc3VbrSyl3hE3TKZ 0Y6nam+vgj5chMb3rh0G/DYMaHSkwPanCfb1QfPbTw7L1VlMSIHIppx9mz3Z4xm6bYIF 9T/eAx0hYmDzpyvbEiZPVmU0y3PX3FIBS4O5ZhylVsP8r2AcGQaRBLbZm2IY1L/Is32Y e0cQ== X-Gm-Message-State: AOAM530ENqCjhOkOZ4bgt6TTYEM/biJvqM2B22GjmfAvx2RPT70lMwDq /NKVL6rcVOHvMB/Ud7j1vXI= 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) 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) 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 Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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: