[PATCH 1/4] kernel/reboot: Deprecate register_restart_handler()
Andrew Davis
afd at ti.com
Tue Jan 23 08:44:40 PST 2024
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 at ti.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 abcdde4df6979..186291e9bf3bb 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 22c16e2564cca..38d6933fe892e 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -197,6 +197,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
More information about the linux-arm-kernel
mailing list