mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART)
@ 2026-10-26  9:20 David Yang
  0 siblings, 0 replies; only message in thread
From: David Yang @ 2026-10-26  9:20 UTC (permalink / raw)
  To: linux-pm; +Cc: David Yang, Sebastian Reichel, Feng Kan, linux-kernel

The driver registers its restart handler but never unregisters it:
there is no remove callback and the notifier block lives in the
devm-allocated context. After unbind the freed notifier stays on the
handler list and the next reboot oopses on it, observed on a
Hi3798MV100 board (PC is at 0x0, LR is at notifier_call_chain).

Use the device-managed registration, which unregisters the handler on
driver unbind; the DT-configured priority is passed through. This
mirrors the conversion of the syscon-poweroff sibling.

Fixes: 09fb07bcaf52 ("power: reset: Add generic SYSCON register mapped reset")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/power/reset/syscon-reboot.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 60e855cae68e..348a9550e9e3 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -31,16 +31,12 @@ struct syscon_reboot_context {
 
 	const struct reboot_data *rd; /* from of match data, if any */
 	struct reboot_mode_bits catchall; /* from DT */
-
-	struct notifier_block restart_handler;
 };
 
-static int syscon_restart_handle(struct notifier_block *this,
-					unsigned long mode, void *cmd)
+static int syscon_restart_handle(struct sys_off_data *data)
 {
-	struct syscon_reboot_context *ctx =
-			container_of(this, struct syscon_reboot_context,
-					restart_handler);
+	struct syscon_reboot_context *ctx = data->cb_data;
+	unsigned int mode = data->mode;
 	const struct reboot_mode_bits *mode_bits;
 
 	if (ctx->rd) {
@@ -113,11 +109,11 @@ static int syscon_reboot_probe(struct platform_device *pdev)
 		}
 	}
 
-	ctx->restart_handler.notifier_call = syscon_restart_handle;
-	ctx->restart_handler.priority = priority;
-	err = register_restart_handler(&ctx->restart_handler);
+	err = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART,
+					    priority, syscon_restart_handle,
+					    ctx);
 	if (err)
-		dev_err(dev, "can't register restart notifier (err=%d)\n", err);
+		dev_err(dev, "can't register restart handler (err=%d)\n", err);
 
 	return err;
 }
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-26  9:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26  9:20 [PATCH] power: reset: syscon-reboot: Use devm_register_sys_off_handler(RESTART) David Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®