From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] state: suppress state overwrite warning for barebox DT
Date: Mon, 13 Apr 2026 12:02:43 +0200 [thread overview]
Message-ID: <20260413100243.1456951-1-a.fatoum@barebox.org> (raw)
Nowadays, the root != of_get_root_node() check always evaluates to true,
because fixups are never applied onto the barebox live tree directly,
but at a copy. This was necessary to allow repeated fixups, e.g. by
of_diff - + or with multiple boot targets.
The check was useful to have though to differentiate between the case
that the barebox DT is passed to Linux (where it's benign that the state
node is overwritten) or the Linux DT having a state node (which can
mislead as the kernel will be overwritten).
barebox already handles $properties specially in that it refuses to
create them when unflattening and silently drops them when flattening.
This allows associating data with a node for the duration it's
unflattened in barebox memory.
Make use of this by marking the barebox live tree's root node as such,
so even it's duplicates don't trigger the warning while external DTs
would.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/state/state.c | 2 +-
drivers/of/base.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/state/state.c b/common/state/state.c
index 9bec8ceea762..b421b43da539 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -453,7 +453,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
* will be overwritten. Warn about this so people do not wonder why
* changes in the kernels state node do not have any effect.
*/
- if (root != of_get_root_node())
+ if (!of_property_read_bool(root, "$barebox,root-node"))
dev_warn(&state->dev, "Warning: Kernel devicetree contains state node, replacing it\n");
} else {
char *of_path, *c;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 460b5e2f4bbf..5297894f60b0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2084,6 +2084,7 @@ int of_set_root_node(struct device_node *node)
of_chosen = of_find_node_by_path("/chosen");
of_property_read_string(root_node, "model", &of_model);
+ of_property_write_bool(root_node, "$barebox,root-node", true);
if (of_model)
barebox_set_model(of_model);
--
2.47.3
next reply other threads:[~2026-04-13 10:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 10:02 Ahmad Fatoum [this message]
2026-04-13 11:22 ` 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=20260413100243.1456951-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--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