blk: Switch over to using uclass IDs

We currently have an if_type (interface type) and a uclass id. These are
closely related and we don't need to have both.

Drop the if_type values and use the uclass ones instead.

Maintain the existing, subtle, one-way conversion between UCLASS_USB and
UCLASS_MASS_STORAGE for now, and add a comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2022-08-11 19:34:59 -06:00
committed by Tom Rini
parent adbfe8edc3
commit e33a5c6be5
41 changed files with 151 additions and 159 deletions

View File

@@ -122,7 +122,7 @@ static int __bcb_load(int devnum, const char *partp)
char *endp;
int part, ret;
desc = blk_get_devnum_by_type(IF_TYPE_MMC, devnum);
desc = blk_get_devnum_by_type(UCLASS_MMC, devnum);
if (!desc) {
ret = -ENODEV;
goto err_read_fail;
@@ -287,7 +287,7 @@ static int __bcb_store(void)
u64 cnt;
int ret;
desc = blk_get_devnum_by_type(IF_TYPE_MMC, bcb_dev);
desc = blk_get_devnum_by_type(UCLASS_MMC, bcb_dev);
if (!desc) {
ret = -ENODEV;
goto err;

View File

@@ -37,7 +37,7 @@ int do_ide(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
}
return blk_common_cmd(argc, argv, IF_TYPE_IDE, &curr_device);
return blk_common_cmd(argc, argv, UCLASS_IDE, &curr_device);
}
int do_diskboot(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])

View File

@@ -331,13 +331,13 @@ static int do_mmcrpmb(struct cmd_tbl *cmdtp, int flag,
#else
original_part = mmc_get_blk_desc(mmc)->hwpart;
#endif
if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) !=
if (blk_select_hwpart_devnum(UCLASS_MMC, curr_device, MMC_PART_RPMB) !=
0)
return CMD_RET_FAILURE;
ret = cp->cmd(cmdtp, flag, argc, argv);
/* Return to original partition */
if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, original_part) !=
if (blk_select_hwpart_devnum(UCLASS_MMC, curr_device, original_part) !=
0)
return CMD_RET_FAILURE;
return ret;
@@ -530,7 +530,7 @@ static int do_mmc_part(struct cmd_tbl *cmdtp, int flag,
if (!mmc)
return CMD_RET_FAILURE;
mmc_dev = blk_get_devnum_by_type(IF_TYPE_MMC, curr_device);
mmc_dev = blk_get_devnum_by_type(UCLASS_MMC, curr_device);
if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) {
part_print(mmc_dev);
return CMD_RET_SUCCESS;
@@ -580,7 +580,7 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag,
if (!mmc)
return CMD_RET_FAILURE;
ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
ret = blk_select_hwpart_devnum(UCLASS_MMC, dev, part);
printf("switch to partitions #%d, %s\n",
part, (!ret) ? "OK" : "ERROR");
if (ret)

View File

@@ -412,7 +412,7 @@ static size_t usb_read_file(const char *file_name)
}
/* Try to recognize storage devices immediately */
blk_first_device(IF_TYPE_USB, &dev);
blk_first_device(UCLASS_USB, &dev);
if (!dev) {
printf("Error: USB storage device not found\n");
return 0;

View File

@@ -28,7 +28,7 @@ static int do_nvme(struct cmd_tbl *cmdtp, int flag, int argc,
if (strncmp(argv[1], "deta", 4) == 0) {
struct udevice *udev;
ret = blk_get_device(IF_TYPE_NVME, nvme_curr_dev,
ret = blk_get_device(UCLASS_NVME, nvme_curr_dev,
&udev);
if (ret < 0)
return CMD_RET_FAILURE;
@@ -39,7 +39,7 @@ static int do_nvme(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
return blk_common_cmd(argc, argv, IF_TYPE_NVME, &nvme_curr_dev);
return blk_common_cmd(argc, argv, UCLASS_NVME, &nvme_curr_dev);
}
U_BOOT_CMD(

View File

@@ -14,7 +14,7 @@ static int pvblock_curr_device;
int do_pvblock(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
return blk_common_cmd(argc, argv, IF_TYPE_PVBLOCK,
return blk_common_cmd(argc, argv, UCLASS_PVBLOCK,
&pvblock_curr_device);
}

View File

@@ -27,7 +27,7 @@ int sata_remove(int devnum)
struct udevice *dev;
int rc;
blk_unbind_all(IF_TYPE_SATA);
blk_unbind_all(UCLASS_AHCI);
rc = uclass_find_device(UCLASS_AHCI, devnum, &dev);
if (!rc && !dev)
@@ -111,7 +111,7 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc,
sata_curr_device = 0;
}
return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device);
return blk_common_cmd(argc, argv, UCLASS_AHCI, &sata_curr_device);
}
U_BOOT_CMD(

View File

@@ -50,7 +50,7 @@ static int do_scsi(struct cmd_tbl *cmdtp, int flag, int argc,
}
}
return blk_common_cmd(argc, argv, IF_TYPE_SCSI, &scsi_curr_dev);
return blk_common_cmd(argc, argv, UCLASS_SCSI, &scsi_curr_dev);
}
U_BOOT_CMD(

View File

@@ -719,7 +719,7 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info();
return blk_common_cmd(argc, argv, IF_TYPE_USB, &usb_stor_curr_dev);
return blk_common_cmd(argc, argv, UCLASS_USB, &usb_stor_curr_dev);
#else
return CMD_RET_USAGE;
#endif /* CONFIG_USB_STORAGE */

View File

@@ -40,7 +40,7 @@ static int do_virtio(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_SUCCESS;
}
return blk_common_cmd(argc, argv, IF_TYPE_VIRTIO, &virtio_curr_dev);
return blk_common_cmd(argc, argv, UCLASS_VIRTIO, &virtio_curr_dev);
}
U_BOOT_CMD(