summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-12-29 21:19:26 -0700
committerSimon Glass <sjg@chromium.org>2020-01-07 16:02:39 -0700
commit8d6320cc4d5cd01e2e7fd01dd635e360cf0a1699 (patch)
treef66bb23f1ed29ebfd925ee921e2fa975fefb2a6f /drivers
parentdc12ebbbdb765153805d2b17d18edf5fe0813d5a (diff)
dm: devres: Add tests
The devres functionality has very few users in U-Boot, but it still should have tests. Add a few basic tests of the main functions. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/devres.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/core/devres.c b/drivers/core/devres.c
index 9c04499c6d..36a8b1eb5f 100644
--- a/drivers/core/devres.c
+++ b/drivers/core/devres.c
@@ -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
/*