summaryrefslogtreecommitdiff
path: root/scripts/dtc/livetree.c
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@foss.st.com>2025-03-28 17:31:15 +0100
committerTom Rini <trini@konsulko.com>2025-04-10 11:58:08 -0600
commit088bbc1efa8c1efe8e2714b9640055ce984aec93 (patch)
treec8d4dc514a3a7a02f33124ea53f692ea1c271a30 /scripts/dtc/livetree.c
parent684aea3132031b124d8e54c9aa99a244b81d3a49 (diff)
dtc: introduce label relative path references
Since introduction of OF_UPSTREAM flag, U-Boot's dtc must be able to compile Kernel's device tree. Since kernel commit 7de129f5389b ("ARM: dts: stm32: stm32mp151a-prtt1l: Fix QSPI configuration"), label relative path references has been introduced. These label relative path references is not supported by current U-Boot dtc version 1.5.0: (see mailing list discussion [1]). In order to support such label relative patch references adds following commit from upstream DTC tree: commit 651410e54cb9 ("util: introduce xstrndup helper") commit ec7986e682cf ("dtc: introduce label relative path references") [1] https://lore.kernel.org/all/20250115144428.GZ3476@bill-the-cat/T/ Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Tom Rini <trini@konsulko.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'scripts/dtc/livetree.c')
-rw-r--r--scripts/dtc/livetree.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index ba06ef348be..4cfc2adccdd 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -583,12 +583,39 @@ struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
struct node *get_node_by_ref(struct node *tree, const char *ref)
{
+ struct node *target = tree;
+ const char *label = NULL, *path = NULL;
+
if (streq(ref, "/"))
return tree;
- else if (ref[0] == '/')
- return get_node_by_path(tree, ref);
+
+ if (ref[0] == '/')
+ path = ref;
else
- return get_node_by_label(tree, ref);
+ label = ref;
+
+ if (label) {
+ const char *slash = strchr(label, '/');
+ char *buf = NULL;
+
+ if (slash) {
+ buf = xstrndup(label, slash - label);
+ label = buf;
+ path = slash + 1;
+ }
+
+ target = get_node_by_label(tree, label);
+
+ free(buf);
+
+ if (!target)
+ return NULL;
+ }
+
+ if (path)
+ target = get_node_by_path(target, path);
+
+ return target;
}
cell_t get_node_phandle(struct node *root, struct node *node)