diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-19 15:51:58 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-20 13:37:47 +0100 |
commit | bf7f7f399c128d2a6e0d61c15d4d1769b2db4cb1 (patch) | |
tree | 6b2594aaa7dcc1c591072f43b5cc514491a31202 /common | |
parent | 287bd01a6a2600f784c15d9f45cf48051df9bc7c (diff) | |
download | barebox-bf7f7f399c128d2a6e0d61c15d4d1769b2db4cb1.tar.gz barebox-bf7f7f399c128d2a6e0d61c15d4d1769b2db4cb1.tar.xz |
bootsource: add function to get device_node we booted from
We have a relation between the bootsource and the corresponding
device_node. Add a function to get the device_node we booted from.
This is already open coded in of_fixup_bootargs_bootsource(),
use the newly created function for it.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20240219145159.1962618-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/bootsource.c | 16 | ||||
-rw-r--r-- | common/oftree.c | 7 |
2 files changed, 17 insertions, 6 deletions
diff --git a/common/bootsource.c b/common/bootsource.c index da528a5b9b..6808c9c51d 100644 --- a/common/bootsource.c +++ b/common/bootsource.c @@ -108,6 +108,22 @@ char *bootsource_get_alias_name(void) return basprintf("%s%d", stem, bootsource_instance); } +struct device_node *bootsource_of_node_get(struct device_node *root) +{ + struct device_node *np; + char *alias_name; + + alias_name = bootsource_get_alias_name(); + if (!alias_name) + return NULL; + + np = of_find_node_by_alias(root, alias_name); + + free(alias_name); + + return np; +} + void bootsource_set_alias_name(const char *name) { bootsource_alias_name = name; diff --git a/common/oftree.c b/common/oftree.c index 51eebd36bd..c12b3cfb16 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -124,14 +124,10 @@ void of_print_cmdline(struct device_node *root) static int of_fixup_bootargs_bootsource(struct device_node *root, struct device_node *chosen) { - char *alias_name = bootsource_get_alias_name(); struct device_node *bootsource; int ret = 0; - if (!alias_name) - return 0; - - bootsource = of_find_node_by_alias(root, alias_name); + bootsource = bootsource_of_node_get(root); /* * If kernel DTB doesn't have the appropriate alias set up, * give up and exit early. No error is reported. @@ -140,7 +136,6 @@ static int of_fixup_bootargs_bootsource(struct device_node *root, ret = of_set_property(chosen, "bootsource", bootsource->full_name, strlen(bootsource->full_name) + 1, true); - free(alias_name); return ret; } |