aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-09-26 08:14:40 -0600
committerTom Rini <trini@konsulko.com>2023-10-06 14:38:12 -0400
commite0c3c21d8ba1a0abbb7effee6c5a952f3e65a03d (patch)
tree305d7d79cd9b6776bcccfd3e4911784bff9fa60f /lib
parent9bf78a5add522dfc3f192eb97fb38d829174d6c7 (diff)
downloadu-boot-e0c3c21d8ba1a0abbb7effee6c5a952f3e65a03d.tar.gz
dm: core: Add a function to create an empty tree
Provide a function to create a new, empty tree. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/of_live.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/of_live.c b/lib/of_live.c
index 25f7af6106..e4eee38554 100644
--- a/lib/of_live.c
+++ b/lib/of_live.c
@@ -336,3 +336,22 @@ void of_live_free(struct device_node *root)
/* the tree is stored as a contiguous block of memory */
free(root);
}
+
+int of_live_create_empty(struct device_node **rootp)
+{
+ struct device_node *root;
+
+ root = calloc(1, sizeof(struct device_node));
+ if (!root)
+ return -ENOMEM;
+ root->name = strdup("");
+ if (!root->name) {
+ free(root);
+ return -ENOMEM;
+ }
+ root->type = "<NULL>";
+ root->full_name = "";
+ *rootp = root;
+
+ return 0;
+}