[PATCH] state: suppress state overwrite warning for barebox DT

Ahmad Fatoum a.fatoum at barebox.org
Mon Apr 13 03:02:43 PDT 2026


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 at 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




More information about the barebox mailing list