All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Davis <afd@ti.com>
To: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sebastian Reichel <sre@kernel.org>,
	Karol Gugala <kgugala@antmicro.com>,
	Mateusz Holenko <mholenko@antmicro.com>,
	Gabriel Somlo <gsomlo@gmail.com>, Joel Stanley <joel@jms.id.au>,
	Mark Brown <broonie@kernel.org>, Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>, Lee Jones <lee@kernel.org>,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<linux-spi@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH 1/4] kernel/reboot: Deprecate register_restart_handler()
Date: Tue, 23 Jan 2024 10:44:40 -0600	[thread overview]
Message-ID: <20240123164443.394642-2-afd@ti.com> (raw)
In-Reply-To: <20240123164443.394642-1-afd@ti.com>

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@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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Davis <afd@ti.com>
To: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sebastian Reichel <sre@kernel.org>,
	Karol Gugala <kgugala@antmicro.com>,
	Mateusz Holenko <mholenko@antmicro.com>,
	Gabriel Somlo <gsomlo@gmail.com>, Joel Stanley <joel@jms.id.au>,
	Mark Brown <broonie@kernel.org>, Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>, Lee Jones <lee@kernel.org>,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<linux-spi@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH 1/4] kernel/reboot: Deprecate register_restart_handler()
Date: Tue, 23 Jan 2024 10:44:40 -0600	[thread overview]
Message-ID: <20240123164443.394642-2-afd@ti.com> (raw)
In-Reply-To: <20240123164443.394642-1-afd@ti.com>

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@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


  reply	other threads:[~2024-01-23 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 16:44 [PATCH 0/4] Deprecate register_restart_handler() Andrew Davis
2024-01-23 16:44 ` Andrew Davis
2024-01-23 16:44 ` Andrew Davis [this message]
2024-01-23 16:44   ` [PATCH 1/4] kernel/reboot: " Andrew Davis
2024-01-23 16:44 ` [PATCH 2/4] drivers/soc/litex: Use devm_register_restart_handler() Andrew Davis
2024-01-23 16:44   ` Andrew Davis
2024-01-23 16:44 ` [PATCH 3/4] firmware: psci: Use register_sys_off_handler(SYS_OFF_MODE_RESTART) Andrew Davis
2024-01-23 16:44   ` Andrew Davis
2024-01-23 16:44 ` [PATCH 4/4] firmware: ti_sci: Use devm_register_restart_handler() Andrew Davis
2024-01-23 16:44   ` Andrew Davis
2024-01-23 21:44   ` Gabriel L. Somlo
2024-01-23 21:44     ` Gabriel L. Somlo
2024-01-29  2:16   ` kernel test robot
2024-01-29  2:16     ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240123164443.394642-2-afd@ti.com \
    --to=afd@ti.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=broonie@kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=gsomlo@gmail.com \
    --cc=joel@jms.id.au \
    --cc=kgugala@antmicro.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mholenko@antmicro.com \
    --cc=orsonzhai@gmail.com \
    --cc=sre@kernel.org \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.