From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Osipenko Date: Fri, 06 May 2022 14:46:57 +0000 Subject: Re: [PATCH v7 04/20] kernel: Add combined power-off+restart handler call chain API Message-Id: List-Id: References: <20220411233832.391817-1-dmitry.osipenko@collabora.com> <20220411233832.391817-5-dmitry.osipenko@collabora.com> <990621e7-9f8a-8b4a-02ec-fd6c1e1f48ff@collabora.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Rafael J. Wysocki" Cc: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , 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 , the arch/x86 maintainers , "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Linux Kernel Mailing List , linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, "open list:BROADCOM NVRAM DRIVER" , linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, Linux-sh list , xen-devel@lists.xenproject.org, ACPI Devel Maling List , Linux PM , linux-tegra On 4/20/22 21:47, Rafael J. Wysocki wrote: >>>> +/** >>>> + * devm_register_prioritized_power_off_handler - Register prioritized power-off callback >>>> + * @dev: Device that registers callback >>>> + * @priority: Callback's priority >>>> + * @callback: Callback function >>>> + * @cb_data: Callback's argument >>>> + * >>>> + * Registers resource-managed power-off callback with a given priority. >>>> + * It will be called as last step of the power-off sequence. Callbacks >>>> + * chaining is disabled, i.e. further lower priority callbacks won't >>>> + * be executed if this @callback will fail to execute. >>>> + * >>>> + * Returns zero on success, or error code on failure. >>> What's the case in which this should be used instead of registering a >>> full sys_off handler? >> There are a lot of drivers that just want to register power-off handler >> with a non-default priority and don't need to stop the chain or do >> anything else special. This is a convinient helper for them. >> >> Please note that the callback here takes only the cb_data for the >> argument, while sys_off uses "struct power_off_data". >> >> Similar for the reset of the convinient helpers. > So if there is a way to do this, why would anyone prefer to use the > full sys_off handler at all? There are couple occurrences around kernel where there is no device available for the devm_ functions, like this for example [1]. [1] https://gitlab.collabora.com/dmitry.osipenko/linux-kernel-rd/-/commit/184dfd3983e774d3cf9050dc5b4ec23a662a9551 -- Best regards, Dmitry