1238737Simp/*
2238737Simp * libfdt - Flat Device Tree manipulation
3238737Simp * Copyright (C) 2012 David Gibson, IBM Corporation.
4238737Simp *
5238737Simp * libfdt is dual licensed: you can use it either under the terms of
6238737Simp * the GPL, or the BSD license, at your option.
7238737Simp *
8238737Simp *  a) This library is free software; you can redistribute it and/or
9238737Simp *     modify it under the terms of the GNU General Public License as
10238737Simp *     published by the Free Software Foundation; either version 2 of the
11238737Simp *     License, or (at your option) any later version.
12238737Simp *
13238737Simp *     This library is distributed in the hope that it will be useful,
14238737Simp *     but WITHOUT ANY WARRANTY; without even the implied warranty of
15238737Simp *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16238737Simp *     GNU General Public License for more details.
17238737Simp *
18238737Simp *     You should have received a copy of the GNU General Public
19238737Simp *     License along with this library; if not, write to the Free
20238737Simp *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21238737Simp *     MA 02110-1301 USA
22238737Simp *
23238737Simp * Alternatively,
24238737Simp *
25238737Simp *  b) Redistribution and use in source and binary forms, with or
26238737Simp *     without modification, are permitted provided that the following
27238737Simp *     conditions are met:
28238737Simp *
29238737Simp *     1. Redistributions of source code must retain the above
30238737Simp *        copyright notice, this list of conditions and the following
31238737Simp *        disclaimer.
32238737Simp *     2. Redistributions in binary form must reproduce the above
33238737Simp *        copyright notice, this list of conditions and the following
34238737Simp *        disclaimer in the documentation and/or other materials
35238737Simp *        provided with the distribution.
36238737Simp *
37238737Simp *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
38238737Simp *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
39238737Simp *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
40238737Simp *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41238737Simp *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
42238737Simp *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43238737Simp *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44238737Simp *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45238737Simp *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46238737Simp *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47238737Simp *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
48238737Simp *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49238737Simp *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50238737Simp */
51238737Simp#include "libfdt_env.h"
52238737Simp
53238737Simp#include <fdt.h>
54238737Simp#include <libfdt.h>
55238737Simp
56238737Simp#include "libfdt_internal.h"
57238737Simp
58238737Simpint fdt_create_empty_tree(void *buf, int bufsize)
59238737Simp{
60238737Simp	int err;
61238737Simp
62238737Simp	err = fdt_create(buf, bufsize);
63238737Simp	if (err)
64238737Simp		return err;
65238737Simp
66238737Simp	err = fdt_finish_reservemap(buf);
67238737Simp	if (err)
68238737Simp		return err;
69238737Simp
70238737Simp	err = fdt_begin_node(buf, "");
71238737Simp	if (err)
72238737Simp		return err;
73238737Simp
74238737Simp	err =  fdt_end_node(buf);
75238737Simp	if (err)
76238737Simp		return err;
77238737Simp
78238737Simp	err = fdt_finish(buf);
79238737Simp	if (err)
80238737Simp		return err;
81238737Simp
82238737Simp	return fdt_open_into(buf, buf, bufsize);
83238737Simp}
84238737Simp
85