fdt_empty_tree.c revision 238737
1169691Skan/* 2169691Skan * libfdt - Flat Device Tree manipulation 3169691Skan * Copyright (C) 2012 David Gibson, IBM Corporation. 4169691Skan * 5169691Skan * libfdt is dual licensed: you can use it either under the terms of 6169691Skan * the GPL, or the BSD license, at your option. 7169691Skan * 8169691Skan * a) This library is free software; you can redistribute it and/or 9169691Skan * modify it under the terms of the GNU General Public License as 10169691Skan * published by the Free Software Foundation; either version 2 of the 11169691Skan * License, or (at your option) any later version. 12169691Skan * 13169691Skan * This library is distributed in the hope that it will be useful, 14169691Skan * but WITHOUT ANY WARRANTY; without even the implied warranty of 15169691Skan * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16169691Skan * GNU General Public License for more details. 17169691Skan * 18169691Skan * You should have received a copy of the GNU General Public 19169691Skan * License along with this library; if not, write to the Free 20169691Skan * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21169691Skan * MA 02110-1301 USA 22169691Skan * 23169691Skan * Alternatively, 24169691Skan * 25169691Skan * b) Redistribution and use in source and binary forms, with or 26169691Skan * without modification, are permitted provided that the following 27169691Skan * conditions are met: 28169691Skan * 29169691Skan * 1. Redistributions of source code must retain the above 30169691Skan * copyright notice, this list of conditions and the following 31169691Skan * disclaimer. 32169691Skan * 2. Redistributions in binary form must reproduce the above 33169691Skan * copyright notice, this list of conditions and the following 34169691Skan * disclaimer in the documentation and/or other materials 35169691Skan * provided with the distribution. 36169691Skan * 37169691Skan * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 38169691Skan * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 39169691Skan * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 40169691Skan * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41169691Skan * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 42169691Skan * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43169691Skan * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44169691Skan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45169691Skan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46169691Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 47169691Skan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 48169691Skan * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 49169691Skan * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 50169691Skan */ 51169691Skan#include "libfdt_env.h" 52169691Skan 53169691Skan#include <fdt.h> 54169691Skan#include <libfdt.h> 55169691Skan 56169691Skan#include "libfdt_internal.h" 57169691Skan 58169691Skanint fdt_create_empty_tree(void *buf, int bufsize) 59169691Skan{ 60169691Skan int err; 61169691Skan 62169691Skan err = fdt_create(buf, bufsize); 63169691Skan if (err) 64169691Skan return err; 65169691Skan 66169691Skan err = fdt_finish_reservemap(buf); 67169691Skan if (err) 68169691Skan return err; 69169691Skan 70 err = fdt_begin_node(buf, ""); 71 if (err) 72 return err; 73 74 err = fdt_end_node(buf); 75 if (err) 76 return err; 77 78 err = fdt_finish(buf); 79 if (err) 80 return err; 81 82 return fdt_open_into(buf, buf, bufsize); 83} 84 85