util.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2013 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <dm/util.h>
  8. #include <libfdt.h>
  9. #include <vsprintf.h>
  10. #ifdef CONFIG_DM_WARN
  11. void dm_warn(const char *fmt, ...)
  12. {
  13. va_list args;
  14. va_start(args, fmt);
  15. vprintf(fmt, args);
  16. va_end(args);
  17. }
  18. #endif
  19. int list_count_items(struct list_head *head)
  20. {
  21. struct list_head *node;
  22. int count = 0;
  23. list_for_each(node, head)
  24. count++;
  25. return count;
  26. }
  27. bool dm_fdt_pre_reloc(const void *blob, int offset)
  28. {
  29. if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
  30. return true;
  31. #ifdef CONFIG_TPL_BUILD
  32. if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  33. return true;
  34. #elif defined(CONFIG_SPL_BUILD)
  35. if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
  36. return true;
  37. #else
  38. /*
  39. * In regular builds individual spl and tpl handling both
  40. * count as handled pre-relocation for later second init.
  41. */
  42. if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
  43. fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  44. return true;
  45. #endif
  46. return false;
  47. }