mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] sandbox: power: register power device without a DT node
Date: Mon, 28 Sep 2026 12:41:45 +0200	[thread overview]
Message-ID: <20260928104149.1193875-1-a.fatoum@pengutronix.de> (raw)

Since the power driver probes from device tree, sandbox has no poweroff
or restart handler when started with a --dtb that lacks a
barebox,sandbox-power node.
The poweroff and reset commands will then end up in hang(), which spins
at 100% CPU until the process is killed.

Let's register the device ourselves when the device tree has no such
node.

Fixes: d2748c1ae720 ("sandbox: poweroff: migrate to driver probed from device tree")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/board/power.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 9caaea5be2f0..a95e25b57215 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -2,6 +2,8 @@
 
 #include <common.h>
 #include <driver.h>
+#include <init.h>
+#include <of.h>
 #include <poweroff.h>
 #include <restart.h>
 #include <mach/linux.h>
@@ -68,6 +70,9 @@ static int sandbox_power_probe(struct device *dev)
 	if (IS_ENABLED(CONFIG_SANDBOX_REEXEC))
 		restart_handler_register(&power->rst_reexec);
 
+	if (!dev->of_node)
+		return 0;
+
 	power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
 						     "reset-source");
 	if (IS_ERR(power->reset_source_cell)) {
@@ -100,3 +105,18 @@ static struct driver sandbox_power_drv = {
 	.probe = sandbox_power_probe,
 };
 coredevice_platform_driver(sandbox_power_drv);
+
+/*
+ * A device tree passed with --dtb need not have a sandbox-power node.
+ * Without one, poweroff and reset end in hang(), which busy-loops forever,
+ * so register the device ourselves in this case.
+ */
+static int sandbox_power_fallback(void)
+{
+	if (!of_find_compatible_node(NULL, NULL, "barebox,sandbox-power"))
+		add_generic_device("sandbox-power", DEVICE_ID_SINGLE, NULL, 0,
+				   0, 0, NULL);
+
+	return 0;
+}
+coredevice_initcall(sandbox_power_fallback);
-- 
2.47.3




                 reply	other threads:[~2026-09-28 11:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260928104149.1193875-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox