mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH 2/7] sandbox: power: handle missing stickypage gracefully
Date: Mon, 24 Apr 2023 14:18:00 +0200	[thread overview]
Message-ID: <20230424121805.150434-2-ahmad@a3f.at> (raw)
In-Reply-To: <20230424121805.150434-1-ahmad@a3f.at>

To enable simulation of $global.system.reset in sandbox, the power
driver writes the reset-source into the stickypage for readout during
subsequent barebox startup. This is an optional feature, so it should
happen before watchdog registration, but not break watchdog operation if
not available.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/sandbox/board/power.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 51f0968447c4..4adc8d7455fc 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -5,7 +5,7 @@
 #include <poweroff.h>
 #include <restart.h>
 #include <mach/linux.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
 #include <linux/nvmem-consumer.h>
 
 struct sandbox_power {
@@ -18,7 +18,8 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
 {
 	struct sandbox_power *power = container_of(poweroff, struct sandbox_power, poweroff);
 
-	nvmem_cell_write(power->reset_source_cell, &(u8) { RESET_POR }, 1);
+	sandbox_save_reset_source(power->reset_source_cell, RESET_POR);
+
 	linux_exit();
 }
 
@@ -29,11 +30,9 @@ static void sandbox_rst_hang(struct restart_handler *rst)
 
 static void sandbox_rst_reexec(struct restart_handler *rst)
 {
-	u8 reason = RESET_RST;
 	struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec);
 
-	if (!IS_ERR(power->reset_source_cell))
-		WARN_ON(nvmem_cell_write(power->reset_source_cell, &reason, 1) <= 0);
+	sandbox_save_reset_source(power->reset_source_cell, RESET_RST);
 
 	linux_reexec();
 }
@@ -69,7 +68,10 @@ static int sandbox_power_probe(struct device *dev)
 	power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
 						     "reset-source");
 	if (IS_ERR(power->reset_source_cell)) {
-		dev_warn(dev, "No reset source info available: %pe\n", power->reset_source_cell);
+		if (PTR_ERR(power->reset_source_cell) != -EPROBE_DEFER)
+			dev_warn(dev, "No reset source info available: %pe\n",
+				 power->reset_source_cell);
+		power->reset_source_cell = NULL;
 		return 0;
 	}
 
-- 
2.38.4




  reply	other threads:[~2023-04-24 12:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: " Ahmad Fatoum
2023-04-24 12:18 ` Ahmad Fatoum [this message]
2023-04-24 12:18 ` [PATCH 3/7] sandbox: hostfile: don't warn on failed hostfile fixup Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 4/7] treewide: drop trailing space Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 5/7] driver: be explicit about supported #feature-cells Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 6/7] featctrl: drop useless NULL check Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 7/7] sandbox: hostfile: add feature controller support Ahmad Fatoum
2023-05-02  9:34 ` [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Sascha Hauer

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=20230424121805.150434-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --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