blk: Use hex indices for the device name

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 <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-06-25 07:11:00 -06:00
parent 1c71a3f024
commit d40e88a868
2 changed files with 2 additions and 2 deletions

View File

@@ -822,7 +822,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",