dm: core: Adjust dump-sorting to get stats only when needed
If we are not sorting the tree we don't need to get the stats. Adjust the
code to avoid the wasted time.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 4023b39..8411248 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -90,9 +90,8 @@
int dev_count, uclasses;
struct udevice **devs = NULL;
- dm_get_stats(&dev_count, &uclasses);
-
if (sort) {
+ dm_get_stats(&dev_count, &uclasses);
devs = calloc(dev_count, sizeof(struct udevice *));
if (!devs) {
printf("(out of memory)\n");