diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2012-06-01 14:12:38 +1000 |
---|---|---|
committer | Jon Loeliger <jdl@jdl.com> | 2012-06-03 09:16:17 -0500 |
commit | be6026838e45b67800ac803f4ad8cca3cde57d6d (patch) | |
tree | c2f2576729dcb0b5187956cb77a3f6c1a85c1838 /tests/rw_tree1.c | |
parent | cbf1410eab4b7ce7be1b15f985ef71bfc1f5886d (diff) | |
download | dtc-be6026838e45b67800ac803f4ad8cca3cde57d6d.zip dtc-be6026838e45b67800ac803f4ad8cca3cde57d6d.tar.gz dtc-be6026838e45b67800ac803f4ad8cca3cde57d6d.tar.bz2 |
libfdt: Add helper function to create a trivial, empty tree
The libfdt read/write functions are now usable enough that it's become a
moderately common pattern to use them to build and manipulate a device
tree from scratch. For example, we do so ourself in our rw_tree1 testcase,
and qemu is starting to use this model when building device trees for some
targets such as e500.
However, the read/write functions require some sort of valid tree to begin
with, so this necessitates either having a trivial canned dtb to begin with
or, more commonly, creating an empty tree using the serial-write functions
first.
This patch adds a helper function which uses the serial-write functions to
create a trivial, empty but complete and valid tree in a supplied buffer,
ready for manipulation with the read/write functions.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests/rw_tree1.c')
-rw-r--r-- | tests/rw_tree1.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c index f4965ec..103a24d 100644 --- a/tests/rw_tree1.c +++ b/tests/rw_tree1.c @@ -57,17 +57,7 @@ int main(int argc, char *argv[]) fdt = xmalloc(SPACE); /* First create empty tree with SW */ - CHECK(fdt_create(fdt, SPACE)); - - CHECK(fdt_finish_reservemap(fdt)); - CHECK(fdt_begin_node(fdt, "")); - CHECK(fdt_end_node(fdt)); - CHECK(fdt_finish(fdt)); - - verbose_printf("Built empty tree, totalsize = %d\n", - fdt_totalsize(fdt)); - - CHECK(fdt_open_into(fdt, fdt, SPACE)); + CHECK(fdt_create_empty_tree(fdt, SPACE)); CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_1, TEST_SIZE_1)); CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2)); |