boot: fix bootdev_list()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 30 Jul 2023 14:29:25 +0000 (16:29 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 2 Aug 2023 18:05:57 +0000 (12:05 -0600)
uclass_get_device_by_name() is meant to return 0 or a negative error code.
simple_itoa() cannot handle negative numbers.

This leads to output like:

    => bootdev list -p

    Seq  Probed  Status  Uclass    Name
    ---  ------  ------  --------  ------------------
      c   [   ]  18446744073709551614  spi_flash spi.bin@0.bootdev

Convert the status to a positive number. Now we get

    Seq  Probed  Status  Uclass    Name
    ---  ------  ------  --------  ------------------
      c   [   ]       2  spi_flash spi.bin@0.bootdev

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
boot/bootdev-uclass.c

index 9660ff7..3f2c8d7 100644 (file)
@@ -216,7 +216,7 @@ void bootdev_list(bool probe)
        for (i = 0; dev; i++) {
                printf("%3x   [ %c ]  %6s  %-9.9s %s\n", dev_seq(dev),
                       device_active(dev) ? '+' : ' ',
-                      ret ? simple_itoa(ret) : "OK",
+                      ret ? simple_itoa(-ret) : "OK",
                       dev_get_uclass_name(dev_get_parent(dev)), dev->name);
                if (probe)
                        ret = uclass_next_device_check(&dev);