It is confusing to use decimal values in device names. For example, with
virtio:

  => dm tree
  ...
  pci           5  [ + ]   pci_bridge_drv        |   |-- pci_0:1.5
    virtio        5  [ + ]   virtio-pci.m          |   |   `-- virtio-pci.m#5
   blk           0  [ + ]   virtio-blk            |   |       |-- virtio-blk#5
   partition     0  [ + ]   blk_partition         |   |       |   |-- 
virtio-blk#5:1
   partition     1  [ + ]   blk_partition         |   |       |   |-- 
virtio-blk#5:14
   partition     2  [ + ]   blk_partition         |   |       |   |-- 
virtio-blk#5:15
   partition     3  [ + ]   blk_partition         |   |       |   `-- 
virtio-blk#5:16
   bootdev       2  [ + ]   virtio_bootdev        |   |       `-- 
virtio-blk#5.bootdev
   pci           6  [ + ]   pci_bridge_drv        |   |-- pci_0:1.6
   ...
  => ls virtio 0:14
  ** Invalid partition 20 **
  Couldn't find partition virtio 0:14

Fix this by using hex for both the block-device number and the partition.

Signed-off-by: Simon Glass <[email protected]>
---

 drivers/block/blk-uclass.c     | 2 +-
 drivers/virtio/virtio-uclass.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 73c24fd9176..47ab60994c1 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -798,7 +798,7 @@ static int part_create_block_devices(struct udevice 
*blk_dev)
        for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
                if (part_get_info(desc, part, &info))
                        continue;
-               snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name,
+               snprintf(devname, sizeof(devname), "%s:%x", blk_dev->name,
                         part);
 
                ret = device_bind_driver(blk_dev, "blk_partition",
diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index c36e9e9b3a7..927f05e2ccd 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -230,7 +230,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
                return 0;
        }
 
-       snprintf(dev_name, sizeof(dev_name), "%s#%d", name, dev_seq(udev));
+       snprintf(dev_name, sizeof(dev_name), "%s#%x", name, dev_seq(udev));
        str = strdup(dev_name);
        if (!str)
                return -ENOMEM;
-- 
2.43.0

Reply via email to