diff options
| author | Simon Glass <[email protected]> | 2023-09-26 08:14:40 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-10-06 14:38:12 -0400 |
| commit | e0c3c21d8ba1a0abbb7effee6c5a952f3e65a03d (patch) | |
| tree | 305d7d79cd9b6776bcccfd3e4911784bff9fa60f /lib/of_live.c | |
| parent | 9bf78a5add522dfc3f192eb97fb38d829174d6c7 (diff) | |
dm: core: Add a function to create an empty tree
Provide a function to create a new, empty tree.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'lib/of_live.c')
| -rw-r--r-- | lib/of_live.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/of_live.c b/lib/of_live.c index 25f7af61061..e4eee385547 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; +} |
