SPDX: Convert all of our single license tags to Linux Kernel style
[oweals/u-boot.git] / drivers / core / devres.c
index f235c1bcfddb4b3c2c6128b69dc5fedab9001e08..f2a19ec61b1967b7db76ef6ef556bbebd394632f 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  *
  * Based on the original work in Linux by
  * Copyright (c) 2006  SUSE Linux Products GmbH
  * Copyright (c) 2006  Tejun Heo <teheo@suse.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -13,6 +12,8 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <dm/device.h>
+#include <dm/root.h>
+#include <dm/util.h>
 
 /**
  * struct devres - Bookkeeping info for managed device resource
@@ -195,6 +196,33 @@ void devres_release_all(struct udevice *dev)
        release_nodes(dev, &dev->devres_head, false);
 }
 
+#ifdef CONFIG_DEBUG_DEVRES
+static void dump_resources(struct udevice *dev, int depth)
+{
+       struct devres *dr;
+       struct udevice *child;
+
+       printf("- %s\n", dev->name);
+
+       list_for_each_entry(dr, &dev->devres_head, entry)
+               printf("    %p (%lu byte) %s  %s\n", dr,
+                      (unsigned long)dr->size, dr->name,
+                      dr->probe ? "PROBE" : "BIND");
+
+       list_for_each_entry(child, &dev->child_head, sibling_node)
+               dump_resources(child, depth + 1);
+}
+
+void dm_dump_devres(void)
+{
+       struct udevice *root;
+
+       root = dm_root();
+       if (root)
+               dump_resources(root, 0);
+}
+#endif
+
 /*
  * Managed kmalloc/kfree
  */