util.c 1.0 KB

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