mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <>
To: Barebox List <>
Cc: Ahmad Fatoum <>
Subject: [PATCH] power: reset: reboot-mode: Fix resetting to normal mode
Date: Thu, 10 Mar 2022 22:12:07 +0100	[thread overview]
Message-ID: <> (raw)

To clear the reboot mode for next reboot during registration of a reboot
mode driver we call reboot->write() with a zero initialized u32 array
with a single entry. This is wrong for two reasons. First the array is
too short, for i.MX6 we need to entries. Then it is assumed that the
magic to write to the register is '0' for normal boot, but it could be
an arbitrary value.

To fix this pick the index of the normal boot entry and pass the
corresponding magic values to reboot->write(). While at it only do
this when a normal boot entry actually exists.

Signed-off-by: Sascha Hauer <>
 drivers/power/reset/reboot-mode.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index d9b51dfea6..01709e0019 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -127,7 +127,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot,
 	const char *alias;
 	size_t nmodes = 0;
 	int i = 0;
-	int ret;
+	int ret, normal = -1;
 	for_each_property_of_node(np, prop) {
 		u32 magic;
@@ -171,6 +171,9 @@ int reboot_mode_register(struct reboot_mode_driver *reboot,
 			goto error;
+		if (!strcmp(*mode, "normal"))
+			normal = i;
 		reboot_mode_print(reboot, *mode, magic);
@@ -187,7 +190,8 @@ int reboot_mode_register(struct reboot_mode_driver *reboot,
 	reboot_mode_add_param(reboot->dev, "", reboot);
 	/* clear mode for next reboot */
-	reboot->write(reboot, &(u32) { 0 });
+	if (normal >= 0)
+		reboot->write(reboot, &reboot->magics[normal]);
 	if (!reboot->priority)
 		reboot->priority = REBOOT_MODE_DEFAULT_PRIORITY;

barebox mailing list

                 reply	other threads:[~2022-03-10 21:13 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:

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

  git send-email \ \ \ \ \

* 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