[PATCH] fixup! bootsource: add optional read of /chosen/bootsource

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Apr 10 04:25:30 PDT 2025


bootsource: read out /chosen/bootsource earlier

While late initcall is early enough for shell scripts to see a correct
$bootsource, it's usually too late for board code.

As device trees are registered in core_initcall usually, let's parse the
property at postcore time instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/of/base.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 324565068771..8184b284099e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -3592,29 +3592,28 @@ const char *of_get_machine_compatible(void)
 }
 EXPORT_SYMBOL(of_get_machine_compatible);
 
-static void of_init_bootsource(void)
+static int of_init_early_vars(void)
 {
 	struct device_node *bootsource;
 
 	if (!IS_ENABLED(CONFIG_BAREBOX_DT_2ND))
-		return;
+		return 0;
 
 	bootsource = of_find_node_by_chosen("bootsource", NULL);
-	if (!bootsource)
-		return;
+	if (bootsource)
+		bootsource_of_node_set(bootsource);
 
-	bootsource_of_node_set(bootsource);
+	return 0;
 }
+postcore_initcall(of_init_early_vars);
 
-static int of_init_vars(void)
+static int of_init_late_vars(void)
 {
 	const char *name;
 
 	name = of_get_machine_compatible();
 	barebox_set_hostname_no_overwrite(name ?: "barebox");
 
-	of_init_bootsource();
-
 	return 0;
 }
-late_initcall(of_init_vars);
+late_initcall(of_init_late_vars);
-- 
2.39.5




More information about the barebox mailing list