]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Adjust dump-sorting to get stats only when needed
authorSimon Glass <sjg@chromium.org>
Wed, 20 Sep 2023 02:05:48 +0000 (20:05 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 4 Oct 2023 15:25:20 +0000 (09:25 -0600)
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>
drivers/core/dump.c

index 4023b390f54255dd2ecc43c273ff1dbb238a4db7..841124830ee78928bd9793cacf0f1a9d4530e6ef 100644 (file)
@@ -90,9 +90,8 @@ static void dm_dump_tree_single(struct udevice *dev, bool sort)
        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");