[PATCH 2/2] dm: core: Adjust dump-sorting to get stats only when needed

Simon Glass sjg at chromium.org
Wed Sep 20 04:05:48 CEST 2023


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 at chromium.org>
---

(no changes since v1)

 drivers/core/dump.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index 3e77832a3a00..bf95c0f52379 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -91,14 +91,14 @@ void dm_dump_tree(bool sort)
 
 	root = dm_root();
 	if (root) {
-		int dev_count, uclasses;
 		struct udevice **devs = NULL;
 
-		dm_get_stats(&dev_count, &uclasses);
-
 		printf(" Class     Index  Probed  Driver                Name\n");
 		printf("-----------------------------------------------------------\n");
 		if (sort) {
+			int dev_count, uclasses;
+
+			dm_get_stats(&dev_count, &uclasses);
 			devs = calloc(dev_count, sizeof(struct udevice *));
 			if (!devs) {
 				printf("(out of memory)\n");
-- 
2.42.0.459.ge4e396fd5e-goog



More information about the U-Boot mailing list