1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2017 Google, Inc
6 * Support for a 'live' (as opposed to flat) device tree
16 * of_live_build() - build a live (hierarchical) tree from a flat DT
18 * @fdt_blob: Input tree to convert
19 * @rootp: Returns live tree that was created
20 * Return: 0 if OK, -ve on error
22 int of_live_build(const void *fdt_blob, struct device_node **rootp);
25 * unflatten_device_tree() - create tree of device_nodes from flat blob
27 * Note that this allocates a single block of memory, pointed to by *mynodes.
28 * To free the tree, use free(*mynodes)
30 * unflattens a device-tree, creating the
31 * tree of struct device_node. It also fills the "name" and "type"
32 * pointers of the nodes so the normal device-tree walking functions
34 * @blob: The blob to expand
35 * @mynodes: The device_node tree created by the call
36 * Return: 0 if OK, -ve on error
38 int unflatten_device_tree(const void *blob, struct device_node **mynodes);
41 * of_live_free() - Dispose of a livetree
43 * This frees memory used by the tree, after which @root becomes invalid and
46 * @root: Tree to dispose
48 void of_live_free(struct device_node *root);
51 * of_live_create_empty() - Create a new, empty tree
53 * @rootp: Returns the root node of the created tree
54 * Return: 0 if OK, -ENOMEM if out of memory
56 int of_live_create_empty(struct device_node **rootp);
59 * of_live_flatten() - Create an FDT from a hierarchical tree
61 * @root: Root node of tree to convert
62 * @buf: Buffer to return the tree (inited by this function)
63 * Return: 0 if OK, -ENOMEM if out of memory
65 int of_live_flatten(const struct device_node *root, struct abuf *buf);