[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231117161006.87734-2-afd@ti.com>
Date: Fri, 17 Nov 2023 10:10:02 -0600
From: Andrew Davis <afd@...com>
To: Mark Rutland <mark.rutland@....com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>,
Sebastian Reichel <sre@...nel.org>,
Karol Gugala <kgugala@...micro.com>,
Mateusz Holenko <mholenko@...micro.com>,
Gabriel Somlo <gsomlo@...il.com>,
Joel Stanley <joel@....id.au>, Mark Brown <broonie@...nel.org>,
Orson Zhai <orsonzhai@...il.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
Chunyan Zhang <zhang.lyra@...il.com>,
Lee Jones <lee@...nel.org>,
Dmitry Osipenko <dmitry.osipenko@...labora.com>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-pm@...r.kernel.org>,
<linux-spi@...r.kernel.org>, Andrew Davis <afd@...com>
Subject: [PATCH RFC 1/5] kernel/reboot: Deprecate register_restart_handler()
There are now two ways to add a handler to the restart_handler_list.
Two ways to do the same thing is bad design, so let's unify on using
the new method register_sys_off_handler() everywhere.
Reasons:
* The other register_*_handler functions take a callback, this old
API takes a notifier_block, which makes it confusing with the
register_*_notifier class of functions.
* register_sys_off_handler (new API) is a more unified API allowing for
registering several system off types.
* The new API has more helpers built around it now, including devm and
platform helpers.
* The new API manages the struct notifier_block for us, simplifying using
code.
Mark register_restart_handler() as deprecated to try to warn off new users
while we finish converting the remaining existing users.
Signed-off-by: Andrew Davis <afd@...com>
---
include/linux/reboot.h | 8 ++++++--
kernel/reboot.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index c4cc3b89ced1f..c5fff3157b191 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -46,8 +46,12 @@ extern int unregister_reboot_notifier(struct notifier_block *);
extern 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 *);
+/*
+ * This function is deprecated, use register_sys_off_handler(SYS_OFF_MODE_RESTART)
+ * or devm_register_restart_handler() instead.
+ */
+extern int __deprecated register_restart_handler(struct notifier_block *);
+extern int __deprecated unregister_restart_handler(struct notifier_block *);
extern void do_kernel_restart(char *cmd);
/*
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 395a0ea3c7a8a..768ce97829f41 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -189,6 +189,9 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list);
*
* Currently always returns zero, as atomic_notifier_chain_register()
* always returns zero.
+ *
+ * This function is deprecated, use register_sys_off_handler(SYS_OFF_MODE_RESTART)
+ * or devm_register_restart_handler() instead.
*/
int register_restart_handler(struct notifier_block *nb)
{
--
2.39.2
Powered by blists - more mailing lists