path: root/common
diff options
authorAhmad Fatoum <>2021-04-14 15:00:43 +0200
committerSascha Hauer <>2021-05-26 07:52:50 +0200
commite56c6a21bc9ef22762c47aacd1bf582a46750c1e (patch)
tree1d41e59005cee298e4309fd00c76bad5c161cfad /common
parent5a8cc197456fe3d7a15c672b9bd46f49d3b934dc (diff)
of: fix up /chosen node even when there are no bootargs
Currently the /chosen fixups of "reset-source", "reset-source-instance", "reset-source-device" and "bootsource" do not happen if no bootargs are available. Fix that by moving the actual bootargs fixup to a dedicated function of_write_bootargs() and only return there early on empty bootargs, but still perform the /chosen fixups mentioned above. Signed-off-by: Ahmad Fatoum <> [bst: dropped new line deletions and modified string comparison, moved of_write_bootargs() call to original position, add commit message] Signed-off-by: Bastian Krause <> Link: Signed-off-by: Sascha Hauer <>
Diffstat (limited to 'common')
1 files changed, 13 insertions, 7 deletions
diff --git a/common/oftree.c b/common/oftree.c
index d92a3ca904..8b6d1755ac 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -161,16 +161,12 @@ static void watchdog_build_bootargs(struct watchdog *watchdog, struct device_nod
-static int of_fixup_bootargs(struct device_node *root, void *unused)
+static int of_write_bootargs(struct device_node *node)
- struct device_node *node;
const char *str;
- int err;
- int instance = reset_source_get_instance();
- struct device_d *dev;
- watchdog_build_bootargs(boot_get_enabled_watchdog(), root);
+ watchdog_build_bootargs(boot_get_enabled_watchdog(), of_get_parent(node));
str = linux_bootargs_get();
if (!str)
@@ -180,13 +176,23 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
if (strlen(str) == 0)
return 0;
+ return of_property_write_string(node, "bootargs", str);
+static int of_fixup_bootargs(struct device_node *root, void *unused)
+ struct device_node *node;
+ int err;
+ int instance = reset_source_get_instance();
+ struct device_d *dev;
node = of_create_node(root, "/chosen");
if (!node)
return -ENOMEM;
of_property_write_string(node, "barebox-version", release_string);
- err = of_property_write_string(node, "bootargs", str);
+ err = of_write_bootargs(node);
if (err)
return err;