dm: devres: Add tests
[oweals/u-boot.git] / drivers / core / devres.c
index 9c04499c6d5b0bd6c0042d69a47b6c2d6e1bba7a..36a8b1eb5f8cfcb0e1456d2d61f7e7a21dcb76ff 100644 (file)
@@ -223,6 +223,19 @@ void dm_dump_devres(void)
        if (root)
                dump_resources(root, 0);
 }
+
+void devres_get_stats(const struct udevice *dev, struct devres_stats *stats)
+{
+       struct devres *dr;
+
+       stats->allocs = 0;
+       stats->total_size = 0;
+       list_for_each_entry(dr, &dev->devres_head, entry) {
+               stats->allocs++;
+               stats->total_size += dr->size;
+       }
+}
+
 #endif
 
 /*