fdt_empty_tree.c revision 9537
19537Satgutier@umich.edu/* 29537Satgutier@umich.edu * libfdt - Flat Device Tree manipulation 39537Satgutier@umich.edu * Copyright (C) 2012 David Gibson, IBM Corporation. 49537Satgutier@umich.edu * 59537Satgutier@umich.edu * Redistribution and use in source and binary forms, with or 69537Satgutier@umich.edu * without modification, are permitted provided that the following 79537Satgutier@umich.edu * conditions are met: 89537Satgutier@umich.edu * 99537Satgutier@umich.edu * 1. Redistributions of source code must retain the above 109537Satgutier@umich.edu * copyright notice, this list of conditions and the following 119537Satgutier@umich.edu * disclaimer. 129537Satgutier@umich.edu * 2. Redistributions in binary form must reproduce the above 139537Satgutier@umich.edu * copyright notice, this list of conditions and the following 149537Satgutier@umich.edu * disclaimer in the documentation and/or other materials 159537Satgutier@umich.edu * provided with the distribution. 169537Satgutier@umich.edu * 179537Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 189537Satgutier@umich.edu * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 199537Satgutier@umich.edu * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 209537Satgutier@umich.edu * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 219537Satgutier@umich.edu * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 229537Satgutier@umich.edu * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 239537Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 249537Satgutier@umich.edu * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 259537Satgutier@umich.edu * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 269537Satgutier@umich.edu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 279537Satgutier@umich.edu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 289537Satgutier@umich.edu * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 299537Satgutier@umich.edu * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 309537Satgutier@umich.edu */ 319537Satgutier@umich.edu#include <fdt.h> 329537Satgutier@umich.edu#include <libfdt.h> 339537Satgutier@umich.edu 349537Satgutier@umich.edu#include "libfdt_env.h" 359537Satgutier@umich.edu#include "libfdt_internal.h" 369537Satgutier@umich.edu 379537Satgutier@umich.eduint fdt_create_empty_tree(void *buf, int bufsize) 389537Satgutier@umich.edu{ 399537Satgutier@umich.edu int err; 409537Satgutier@umich.edu 419537Satgutier@umich.edu err = fdt_create(buf, bufsize); 429537Satgutier@umich.edu if (err) 439537Satgutier@umich.edu return err; 449537Satgutier@umich.edu 459537Satgutier@umich.edu err = fdt_finish_reservemap(buf); 469537Satgutier@umich.edu if (err) 479537Satgutier@umich.edu return err; 489537Satgutier@umich.edu 499537Satgutier@umich.edu err = fdt_begin_node(buf, ""); 509537Satgutier@umich.edu if (err) 519537Satgutier@umich.edu return err; 529537Satgutier@umich.edu 539537Satgutier@umich.edu err = fdt_end_node(buf); 549537Satgutier@umich.edu if (err) 559537Satgutier@umich.edu return err; 569537Satgutier@umich.edu 579537Satgutier@umich.edu err = fdt_finish(buf); 589537Satgutier@umich.edu if (err) 599537Satgutier@umich.edu return err; 609537Satgutier@umich.edu 619537Satgutier@umich.edu return fdt_open_into(buf, buf, bufsize); 629537Satgutier@umich.edu} 639537Satgutier@umich.edu 64