fdt_empty_tree.c 641 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
  2. /*
  3. * libfdt - Flat Device Tree manipulation
  4. * Copyright (C) 2012 David Gibson, IBM Corporation.
  5. */
  6. #include "libfdt_env.h"
  7. #include <fdt.h>
  8. #include <libfdt.h>
  9. #include "libfdt_internal.h"
  10. int fdt_create_empty_tree(void *buf, int bufsize)
  11. {
  12. int err;
  13. err = fdt_create(buf, bufsize);
  14. if (err)
  15. return err;
  16. err = fdt_finish_reservemap(buf);
  17. if (err)
  18. return err;
  19. err = fdt_begin_node(buf, "");
  20. if (err)
  21. return err;
  22. err = fdt_end_node(buf);
  23. if (err)
  24. return err;
  25. err = fdt_finish(buf);
  26. if (err)
  27. return err;
  28. return fdt_open_into(buf, buf, bufsize);
  29. }