From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Osipenko Date: Fri, 06 May 2022 14:10:24 +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: >>>> + POWEROFF_PREPARE, >>>> +}; >>>> + >>>> +/** >>>> + * struct power_off_data - Power-off callback argument >>>> + * >>>> + * @cb_data: Callback data. >>>> + */ >>>> +struct power_off_data { >>>> + void *cb_data; >>>> +}; >>>> + >>>> +/** >>>> + * struct power_off_prep_data - Power-off preparation callback argument >>>> + * >>>> + * @cb_data: Callback data. >>>> + */ >>>> +struct power_off_prep_data { >>>> + void *cb_data; >>>> +}; >>> Why does this need to be a separate data type? >> To allow us extend the "struct power_off_prep_data" with more parameters >> later on without a need to update each driver with the new arguments. > I'm not really sure what you mean here. Can you give an example? > The restart callbacks use more than the cb_data and we have: struct restart_data { void *cb_data; const char *cmd; bool stop_chain; enum reboot_mode mode; }; If we'll ever need to extended struct power_off_data similarly to the restart_data, then we will need to update all the power-off callbacks instead of adding a new field to the power_off_data. Hence, for example, if you'll want to extend power_off_data with "enum poweroff_mode mode", then for each driver you'll need to do this change: -power_off(void *cb_data) +power_off(void *cb_data, enum poweroff_mode mode) and you won't need to do that using struct power_off_data. Why do we need this? Because I saw in the past people changing kernel APIs that way when they wanted to add new arguments and then needed to update every call site around the kernel. -- Best regards, Dmitry