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

@ -1823,7 +1823,7 @@ static int part_delete(struct stm32prog_data *data,
* need to switch to associated hwpart 1 or 2 * need to switch to associated hwpart 1 or 2
*/ */
if (part->part_id < 0) if (part->part_id < 0)
if (blk_select_hwpart_devnum(IF_TYPE_MMC, if (blk_select_hwpart_devnum(UCLASS_MMC,
part->dev->dev_id, part->dev->dev_id,
-part->part_id)) -part->part_id))
return -1; return -1;
@ -1832,7 +1832,7 @@ static int part_delete(struct stm32prog_data *data,
/* return to user partition */ /* return to user partition */
if (part->part_id < 0) if (part->part_id < 0)
blk_select_hwpart_devnum(IF_TYPE_MMC, blk_select_hwpart_devnum(UCLASS_MMC,
part->dev->dev_id, 0); part->dev->dev_id, 0);
if (blks != blks_size) { if (blks != blks_size) {
ret = -1; ret = -1;

View File

@ -211,7 +211,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
return -EINVAL; return -EINVAL;
} }
if (part != mmc_get_blk_desc(mmc)->hwpart) { if (part != mmc_get_blk_desc(mmc)->hwpart) {
if (blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part)) { if (blk_select_hwpart_devnum(UCLASS_MMC, dev, part)) {
puts("MMC partition switch failed\n"); puts("MMC partition switch failed\n");
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
@ -239,7 +239,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
out: out:
/* Switch back to regular eMMC user partition */ /* Switch back to regular eMMC user partition */
blk_select_hwpart_devnum(IF_TYPE_MMC, 0, 0); blk_select_hwpart_devnum(UCLASS_MMC, 0, 0);
return ret; return ret;
} }

View File

@ -122,7 +122,7 @@ static int __bcb_load(int devnum, const char *partp)
char *endp; char *endp;
int part, ret; int part, ret;
desc = blk_get_devnum_by_type(IF_TYPE_MMC, devnum); desc = blk_get_devnum_by_type(UCLASS_MMC, devnum);
if (!desc) { if (!desc) {
ret = -ENODEV; ret = -ENODEV;
goto err_read_fail; goto err_read_fail;
@ -287,7 +287,7 @@ static int __bcb_store(void)
u64 cnt; u64 cnt;
int ret; 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) { if (!desc) {
ret = -ENODEV; ret = -ENODEV;
goto err; 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[]) 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 #else
original_part = mmc_get_blk_desc(mmc)->hwpart; original_part = mmc_get_blk_desc(mmc)->hwpart;
#endif #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) 0)
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
ret = cp->cmd(cmdtp, flag, argc, argv); ret = cp->cmd(cmdtp, flag, argc, argv);
/* Return to original partition */ /* 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) 0)
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
return ret; return ret;
@ -530,7 +530,7 @@ static int do_mmc_part(struct cmd_tbl *cmdtp, int flag,
if (!mmc) if (!mmc)
return CMD_RET_FAILURE; 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) { if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) {
part_print(mmc_dev); part_print(mmc_dev);
return CMD_RET_SUCCESS; return CMD_RET_SUCCESS;
@ -580,7 +580,7 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag,
if (!mmc) if (!mmc)
return CMD_RET_FAILURE; 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", printf("switch to partitions #%d, %s\n",
part, (!ret) ? "OK" : "ERROR"); part, (!ret) ? "OK" : "ERROR");
if (ret) if (ret)

View File

@ -412,7 +412,7 @@ static size_t usb_read_file(const char *file_name)
} }
/* Try to recognize storage devices immediately */ /* Try to recognize storage devices immediately */
blk_first_device(IF_TYPE_USB, &dev); blk_first_device(UCLASS_USB, &dev);
if (!dev) { if (!dev) {
printf("Error: USB storage device not found\n"); printf("Error: USB storage device not found\n");
return 0; 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) { if (strncmp(argv[1], "deta", 4) == 0) {
struct udevice *udev; struct udevice *udev;
ret = blk_get_device(IF_TYPE_NVME, nvme_curr_dev, ret = blk_get_device(UCLASS_NVME, nvme_curr_dev,
&udev); &udev);
if (ret < 0) if (ret < 0)
return CMD_RET_FAILURE; 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( 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[]) 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); &pvblock_curr_device);
} }

View File

@ -27,7 +27,7 @@ int sata_remove(int devnum)
struct udevice *dev; struct udevice *dev;
int rc; int rc;
blk_unbind_all(IF_TYPE_SATA); blk_unbind_all(UCLASS_AHCI);
rc = uclass_find_device(UCLASS_AHCI, devnum, &dev); rc = uclass_find_device(UCLASS_AHCI, devnum, &dev);
if (!rc && !dev) if (!rc && !dev)
@ -111,7 +111,7 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc,
sata_curr_device = 0; 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( 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( 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) if (strncmp(argv[1], "stor", 4) == 0)
return usb_stor_info(); 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 #else
return CMD_RET_USAGE; return CMD_RET_USAGE;
#endif /* CONFIG_USB_STORAGE */ #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 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( U_BOOT_CMD(

View File

@ -71,7 +71,7 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
/* try to recognize storage devices immediately */ /* try to recognize storage devices immediately */
scsi_scan(false); scsi_scan(false);
stor_dev = blk_get_devnum_by_type(IF_TYPE_SCSI, 0); stor_dev = blk_get_devnum_by_type(UCLASS_SCSI, 0);
if (!stor_dev) if (!stor_dev)
return -ENODEV; return -ENODEV;

View File

@ -41,7 +41,7 @@ int spl_usb_load(struct spl_image_info *spl_image,
/* try to recognize storage devices immediately */ /* try to recognize storage devices immediately */
usb_stor_curr_dev = usb_stor_scan(1); usb_stor_curr_dev = usb_stor_scan(1);
stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev); stor_dev = blk_get_devnum_by_type(UCLASS_USB, usb_stor_curr_dev);
if (!stor_dev) if (!stor_dev)
return -ENODEV; return -ENODEV;

View File

@ -144,7 +144,7 @@ int usb_stor_info(void)
#if CONFIG_IS_ENABLED(BLK) #if CONFIG_IS_ENABLED(BLK)
struct udevice *dev; struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev); for (blk_first_device(UCLASS_USB, &dev);
dev; dev;
blk_next_device(&dev)) { blk_next_device(&dev)) {
struct blk_desc *desc = dev_get_uclass_plat(dev); struct blk_desc *desc = dev_get_uclass_plat(dev);
@ -219,7 +219,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
snprintf(str, sizeof(str), "lun%d", lun); snprintf(str, sizeof(str), "lun%d", lun);
ret = blk_create_devicef(udev->dev, "usb_storage_blk", str, ret = blk_create_devicef(udev->dev, "usb_storage_blk", str,
IF_TYPE_USB, usb_max_devs, 512, 0, UCLASS_USB, usb_max_devs, 512, 0,
&dev); &dev);
if (ret) { if (ret) {
debug("Cannot bind driver\n"); debug("Cannot bind driver\n");
@ -279,7 +279,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
blkdev = &usb_dev_desc[usb_max_devs]; blkdev = &usb_dev_desc[usb_max_devs];
memset(blkdev, '\0', sizeof(struct blk_desc)); memset(blkdev, '\0', sizeof(struct blk_desc));
blkdev->if_type = IF_TYPE_USB; blkdev->if_type = UCLASS_USB;
blkdev->devnum = usb_max_devs; blkdev->devnum = usb_max_devs;
blkdev->part_type = PART_TYPE_UNKNOWN; blkdev->part_type = PART_TYPE_UNKNOWN;
blkdev->target = 0xff; blkdev->target = 0xff;
@ -1578,7 +1578,7 @@ U_BOOT_DRIVER(usb_storage_blk) = {
#else #else
U_BOOT_LEGACY_BLK(usb) = { U_BOOT_LEGACY_BLK(usb) = {
.if_typename = "usb", .if_typename = "usb",
.if_type = IF_TYPE_USB, .if_type = UCLASS_USB,
.max_devs = USB_MAX_STOR_DEV, .max_devs = USB_MAX_STOR_DEV,
.desc = usb_dev_desc, .desc = usb_dev_desc,
}; };

View File

@ -121,34 +121,34 @@ void dev_print (struct blk_desc *dev_desc)
} }
switch (dev_desc->if_type) { switch (dev_desc->if_type) {
case IF_TYPE_SCSI: case UCLASS_SCSI:
printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n", printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
dev_desc->target,dev_desc->lun, dev_desc->target,dev_desc->lun,
dev_desc->vendor, dev_desc->vendor,
dev_desc->product, dev_desc->product,
dev_desc->revision); dev_desc->revision);
break; break;
case IF_TYPE_IDE: case UCLASS_IDE:
case IF_TYPE_SATA: case UCLASS_AHCI:
printf ("Model: %s Firm: %s Ser#: %s\n", printf ("Model: %s Firm: %s Ser#: %s\n",
dev_desc->vendor, dev_desc->vendor,
dev_desc->revision, dev_desc->revision,
dev_desc->product); dev_desc->product);
break; break;
case IF_TYPE_MMC: case UCLASS_MMC:
case IF_TYPE_USB: case UCLASS_USB:
case IF_TYPE_NVME: case UCLASS_NVME:
case IF_TYPE_PVBLOCK: case UCLASS_PVBLOCK:
case IF_TYPE_HOST: case UCLASS_ROOT:
printf ("Vendor: %s Rev: %s Prod: %s\n", printf ("Vendor: %s Rev: %s Prod: %s\n",
dev_desc->vendor, dev_desc->vendor,
dev_desc->revision, dev_desc->revision,
dev_desc->product); dev_desc->product);
break; break;
case IF_TYPE_VIRTIO: case UCLASS_VIRTIO:
printf("%s VirtIO Block Device\n", dev_desc->vendor); printf("%s VirtIO Block Device\n", dev_desc->vendor);
break; break;
case IF_TYPE_UNKNOWN: case UCLASS_INVALID:
puts("device type unknown\n"); puts("device type unknown\n");
return; return;
default: default:
@ -246,34 +246,34 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
CONFIG_IS_ENABLED(EFI_PARTITION) CONFIG_IS_ENABLED(EFI_PARTITION)
puts ("\nPartition Map for "); puts ("\nPartition Map for ");
switch (dev_desc->if_type) { switch (dev_desc->if_type) {
case IF_TYPE_IDE: case UCLASS_IDE:
puts ("IDE"); puts ("IDE");
break; break;
case IF_TYPE_SATA: case UCLASS_AHCI:
puts ("SATA"); puts ("SATA");
break; break;
case IF_TYPE_SCSI: case UCLASS_SCSI:
puts ("SCSI"); puts ("SCSI");
break; break;
case IF_TYPE_USB: case UCLASS_USB:
puts ("USB"); puts ("USB");
break; break;
case IF_TYPE_MMC: case UCLASS_MMC:
puts ("MMC"); puts ("MMC");
break; break;
case IF_TYPE_HOST: case UCLASS_ROOT:
puts ("HOST"); puts ("HOST");
break; break;
case IF_TYPE_NVME: case UCLASS_NVME:
puts ("NVMe"); puts ("NVMe");
break; break;
case IF_TYPE_PVBLOCK: case UCLASS_PVBLOCK:
puts("PV BLOCK"); puts("PV BLOCK");
break; break;
case IF_TYPE_VIRTIO: case UCLASS_VIRTIO:
puts("VirtIO"); puts("VirtIO");
break; break;
case IF_TYPE_EFI_MEDIA: case UCLASS_EFI_MEDIA:
puts("EFI"); puts("EFI");
break; break;
default: default:
@ -405,7 +405,7 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
* Always should be done, otherwise hw partition 0 will return * Always should be done, otherwise hw partition 0 will return
* stale data after displaying a non-zero hw partition. * stale data after displaying a non-zero hw partition.
*/ */
if ((*dev_desc)->if_type == IF_TYPE_MMC) if ((*dev_desc)->if_type == UCLASS_MMC)
part_init(*dev_desc); part_init(*dev_desc);
} }
@ -760,17 +760,17 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
char *devtype; char *devtype;
switch (dev_desc->if_type) { switch (dev_desc->if_type) {
case IF_TYPE_IDE: case UCLASS_IDE:
case IF_TYPE_SATA: case UCLASS_AHCI:
devtype = "hd"; devtype = "hd";
break; break;
case IF_TYPE_SCSI: case UCLASS_SCSI:
devtype = "sd"; devtype = "sd";
break; break;
case IF_TYPE_USB: case UCLASS_USB:
devtype = "usbd"; devtype = "usbd";
break; break;
case IF_TYPE_MMC: case UCLASS_MMC:
devtype = "mmcsd"; devtype = "mmcsd";
break; break;
default: default:

View File

@ -748,7 +748,7 @@ UEFI block IO driver
The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL. The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
When connected it creates a new U-Boot block IO device with interface type When connected it creates a new U-Boot block IO device with interface type
IF_TYPE_EFI_LOADER, adds child controllers mapping the partitions, and installs UCLASS_EFI_LOADER, adds child controllers mapping the partitions, and installs
the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
software iPXE to boot from iSCSI network drives [4]. software iPXE to boot from iSCSI network drives [4].

View File

@ -880,7 +880,7 @@ int dwc_ahsata_scan(struct udevice *dev)
device_find_first_child(dev, &blk); device_find_first_child(dev, &blk);
if (!blk) { if (!blk) {
ret = blk_create_devicef(dev, "dwc_ahsata_blk", "blk", ret = blk_create_devicef(dev, "dwc_ahsata_blk", "blk",
IF_TYPE_SATA, -1, 512, 0, &blk); UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) { if (ret) {
debug("Can't create device\n"); debug("Can't create device\n");
return ret; return ret;

View File

@ -888,7 +888,7 @@ static int fsl_ata_probe(struct udevice *dev)
for (i = 0; i < nr_ports; i++) { for (i = 0; i < nr_ports; i++) {
snprintf(sata_name, sizeof(sata_name), "fsl_sata%d", i); snprintf(sata_name, sizeof(sata_name), "fsl_sata%d", i);
ret = blk_create_devicef(dev, "sata_fsl_blk", sata_name, ret = blk_create_devicef(dev, "sata_fsl_blk", sata_name,
IF_TYPE_SATA, -1, 512, 0, &blk); UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) { if (ret) {
debug("Can't create device\n"); debug("Can't create device\n");
return ret; return ret;

View File

@ -79,7 +79,7 @@ int __sata_initialize(void)
for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) { for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc)); memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc));
sata_dev_desc[i].if_type = IF_TYPE_SATA; sata_dev_desc[i].if_type = UCLASS_AHCI;
sata_dev_desc[i].devnum = i; sata_dev_desc[i].devnum = i;
sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN; sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
sata_dev_desc[i].type = DEV_TYPE_HARDDISK; sata_dev_desc[i].type = DEV_TYPE_HARDDISK;

View File

@ -1076,7 +1076,7 @@ static int sata_mv_probe(struct udevice *dev)
for (i = 0; i < nr_ports; i++) { for (i = 0; i < nr_ports; i++) {
ret = blk_create_devicef(dev, "sata_mv_blk", "blk", ret = blk_create_devicef(dev, "sata_mv_blk", "blk",
IF_TYPE_SATA, -1, 512, 0, &blk); UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) { if (ret) {
debug("Can't create device\n"); debug("Can't create device\n");
continue; continue;

View File

@ -730,7 +730,7 @@ static int sil_pci_probe(struct udevice *dev)
for (i = sata_info.portbase; i < sata_info.maxport; i++) { for (i = sata_info.portbase; i < sata_info.maxport; i++) {
snprintf(sata_name, sizeof(sata_name), "sil_sata%d", i); snprintf(sata_name, sizeof(sata_name), "sil_sata%d", i);
ret = blk_create_devicef(dev, "sata_sil_blk", sata_name, ret = blk_create_devicef(dev, "sata_sil_blk", sata_name,
IF_TYPE_SATA, -1, 512, 0, &blk); UCLASS_AHCI, -1, 512, 0, &blk);
if (ret) { if (ret) {
debug("Can't create device\n"); debug("Can't create device\n");
return ret; return ret;

View File

@ -21,31 +21,17 @@ static struct {
enum uclass_id id; enum uclass_id id;
const char *name; const char *name;
} if_typename_str[] = { } if_typename_str[] = {
{ IF_TYPE_IDE, "ide" }, { UCLASS_IDE, "ide" },
{ IF_TYPE_SCSI, "scsi" }, { UCLASS_SCSI, "scsi" },
{ IF_TYPE_USB, "usb" }, { UCLASS_USB, "usb" },
{ IF_TYPE_MMC, "mmc" }, { UCLASS_MMC, "mmc" },
{ IF_TYPE_SCSI, "sata" }, { UCLASS_AHCI, "sata" },
{ IF_TYPE_HOST, "host" }, { UCLASS_ROOT, "host" },
{ IF_TYPE_NVME, "nvme" }, { UCLASS_NVME, "nvme" },
{ IF_TYPE_EFI_MEDIA, "efi" }, { UCLASS_EFI_MEDIA, "efi" },
{ IF_TYPE_EFI_LOADER, "efiloader" }, { UCLASS_EFI_LOADER, "efiloader" },
{ IF_TYPE_VIRTIO, "virtio" }, { UCLASS_VIRTIO, "virtio" },
{ IF_TYPE_PVBLOCK, "pvblock" }, { UCLASS_PVBLOCK, "pvblock" },
};
static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
[IF_TYPE_IDE] = UCLASS_IDE,
[IF_TYPE_SCSI] = UCLASS_SCSI,
[IF_TYPE_USB] = UCLASS_MASS_STORAGE,
[IF_TYPE_MMC] = UCLASS_MMC,
[IF_TYPE_SATA] = UCLASS_AHCI,
[IF_TYPE_HOST] = UCLASS_ROOT,
[IF_TYPE_NVME] = UCLASS_NVME,
[IF_TYPE_EFI_MEDIA] = UCLASS_EFI_MEDIA,
[IF_TYPE_EFI_LOADER] = UCLASS_EFI_LOADER,
[IF_TYPE_VIRTIO] = UCLASS_VIRTIO,
[IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK,
}; };
static enum if_type if_typename_to_iftype(const char *if_typename) static enum if_type if_typename_to_iftype(const char *if_typename)
@ -57,12 +43,32 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
return if_typename_str[i].id; return if_typename_str[i].id;
} }
return IF_TYPE_UNKNOWN; return UCLASS_INVALID;
} }
static enum uclass_id if_type_to_uclass_id(enum if_type if_type) static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
{ {
return if_type_uclass_id[if_type]; /*
* This strange adjustment is used because we use UCLASS_MASS_STORAGE
* for USB storage devices, so need to return this as the uclass to
* use for USB. In fact USB_UCLASS is for USB controllers, not
* peripherals.
*
* The name of the UCLASS_MASS_STORAGE uclass driver is
* "usb_mass_storage", but we want to use "usb" in things like the
* 'part list' command and when showing interfaces.
*
* So for now we have this one-way conversion.
*
* The fix for this is possibly to:
* - rename UCLASS_MASS_STORAGE name to "usb"
* - rename UCLASS_USB name to "usb_ctlr"
* - use UCLASS_MASS_STORAGE instead of UCLASS_USB in if_typename_str
*/
if (if_type == UCLASS_USB)
return UCLASS_MASS_STORAGE;
return if_type;
} }
const char *blk_get_if_type_name(enum if_type if_type) const char *blk_get_if_type_name(enum if_type if_type)
@ -70,7 +76,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
int i; int i;
for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) { for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
if ((int)if_typename_str[i].id == if_type) if (if_typename_str[i].id == if_type)
return if_typename_str[i].name; return if_typename_str[i].name;
} }
@ -105,7 +111,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
int ret; int ret;
type = if_typename_to_iftype(if_typename); type = if_typename_to_iftype(if_typename);
if (type == IF_TYPE_UNKNOWN) { if (type == UCLASS_INVALID) {
debug("%s: Unknown interface type '%s'\n", __func__, debug("%s: Unknown interface type '%s'\n", __func__,
if_typename); if_typename);
return NULL; return NULL;

View File

@ -94,7 +94,7 @@ static int efi_media_bind(struct udevice *dev)
struct udevice *blk; struct udevice *blk;
int ret; int ret;
ret = blk_create_devicef(dev, "efi_block", "blk", IF_TYPE_EFI_MEDIA, ret = blk_create_devicef(dev, "efi_block", "blk", UCLASS_EFI_MEDIA,
dev_seq(dev), plat->blkio->media->block_size, dev_seq(dev), plat->blkio->media->block_size,
plat->blkio->media->last_block, &blk); plat->blkio->media->last_block, &blk);
if (ret) { if (ret) {

View File

@ -537,7 +537,7 @@ static void ide_ident(struct blk_desc *dev_desc)
/* Select device /* Select device
*/ */
ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
dev_desc->if_type = IF_TYPE_IDE; dev_desc->if_type = UCLASS_IDE;
#ifdef CONFIG_ATAPI #ifdef CONFIG_ATAPI
retries = 0; retries = 0;
@ -752,7 +752,7 @@ void ide_init(void)
for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) { for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
ide_dev_desc[i].if_type = IF_TYPE_IDE; ide_dev_desc[i].if_type = UCLASS_IDE;
ide_dev_desc[i].devnum = i; ide_dev_desc[i].devnum = i;
ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN; ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
ide_dev_desc[i].blksz = 0; ide_dev_desc[i].blksz = 0;
@ -1110,7 +1110,7 @@ static int ide_probe(struct udevice *udev)
if (!blksz) if (!blksz)
continue; continue;
ret = blk_create_devicef(udev, "ide_blk", name, ret = blk_create_devicef(udev, "ide_blk", name,
IF_TYPE_IDE, i, UCLASS_IDE, i,
blksz, size, &blk_dev); blksz, size, &blk_dev);
if (ret) if (ret)
return ret; return ret;
@ -1144,7 +1144,7 @@ UCLASS_DRIVER(ide) = {
#else #else
U_BOOT_LEGACY_BLK(ide) = { U_BOOT_LEGACY_BLK(ide) = {
.if_typename = "ide", .if_typename = "ide",
.if_type = IF_TYPE_IDE, .if_type = UCLASS_IDE,
.max_devs = CONFIG_SYS_IDE_MAXDEVICE, .max_devs = CONFIG_SYS_IDE_MAXDEVICE,
.desc = ide_dev_desc, .desc = ide_dev_desc,
}; };

View File

@ -98,7 +98,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
int ret, fd; int ret, fd;
/* Remove and unbind the old device, if any */ /* Remove and unbind the old device, if any */
ret = blk_get_device(IF_TYPE_HOST, devnum, &dev); ret = blk_get_device(UCLASS_ROOT, devnum, &dev);
if (ret == 0) { if (ret == 0) {
ret = device_remove(dev, DM_REMOVE_NORMAL); ret = device_remove(dev, DM_REMOVE_NORMAL);
if (ret) if (ret)
@ -135,7 +135,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
} }
} }
ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str, ret = blk_create_device(gd->dm_root, "sandbox_host_blk", str,
IF_TYPE_HOST, devnum, 512, UCLASS_ROOT, devnum, 512,
os_lseek(fd, 0, OS_SEEK_END) / 512, &dev); os_lseek(fd, 0, OS_SEEK_END) / 512, &dev);
if (ret) if (ret)
goto err_file; goto err_file;
@ -150,7 +150,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
goto err_file; goto err_file;
} }
desc = blk_get_devnum_by_type(IF_TYPE_HOST, devnum); desc = blk_get_devnum_by_type(UCLASS_ROOT, devnum);
desc->removable = removable; desc->removable = removable;
snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot"); snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot");
snprintf(desc->product, BLK_PRD_SIZE, "hostfile"); snprintf(desc->product, BLK_PRD_SIZE, "hostfile");
@ -192,7 +192,7 @@ int host_dev_bind(int dev, char *filename, bool removable)
} }
struct blk_desc *blk_dev = &host_dev->blk_dev; struct blk_desc *blk_dev = &host_dev->blk_dev;
blk_dev->if_type = IF_TYPE_HOST; blk_dev->if_type = UCLASS_ROOT;
blk_dev->priv = host_dev; blk_dev->priv = host_dev;
blk_dev->blksz = 512; blk_dev->blksz = 512;
blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz; blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
@ -216,7 +216,7 @@ int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
struct udevice *dev; struct udevice *dev;
int ret; int ret;
ret = blk_get_device(IF_TYPE_HOST, devnum, &dev); ret = blk_get_device(UCLASS_ROOT, devnum, &dev);
if (ret) if (ret)
return ret; return ret;
*blk_devp = dev_get_uclass_plat(dev); *blk_devp = dev_get_uclass_plat(dev);
@ -263,7 +263,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
#else #else
U_BOOT_LEGACY_BLK(sandbox_host) = { U_BOOT_LEGACY_BLK(sandbox_host) = {
.if_typename = "host", .if_typename = "host",
.if_type = IF_TYPE_HOST, .if_type = UCLASS_ROOT,
.max_devs = SANDBOX_HOST_MAX_DEVICES, .max_devs = SANDBOX_HOST_MAX_DEVICES,
.get_dev = host_get_dev_err, .get_dev = host_get_dev_err,
}; };

View File

@ -52,7 +52,7 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
if (dfu->data.mmc.hw_partition >= 0) { if (dfu->data.mmc.hw_partition >= 0) {
part_num_bkp = mmc_get_blk_desc(mmc)->hwpart; part_num_bkp = mmc_get_blk_desc(mmc)->hwpart;
ret = blk_select_hwpart_devnum(IF_TYPE_MMC, ret = blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num, dfu->data.mmc.dev_num,
dfu->data.mmc.hw_partition); dfu->data.mmc.hw_partition);
if (ret) if (ret)
@ -77,14 +77,14 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
if (n != blk_count) { if (n != blk_count) {
pr_err("MMC operation failed"); pr_err("MMC operation failed");
if (dfu->data.mmc.hw_partition >= 0) if (dfu->data.mmc.hw_partition >= 0)
blk_select_hwpart_devnum(IF_TYPE_MMC, blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num, dfu->data.mmc.dev_num,
part_num_bkp); part_num_bkp);
return -EIO; return -EIO;
} }
if (dfu->data.mmc.hw_partition >= 0) { if (dfu->data.mmc.hw_partition >= 0) {
ret = blk_select_hwpart_devnum(IF_TYPE_MMC, ret = blk_select_hwpart_devnum(UCLASS_MMC,
dfu->data.mmc.dev_num, dfu->data.mmc.dev_num,
part_num_bkp); part_num_bkp);
if (ret) if (ret)

View File

@ -290,7 +290,7 @@ struct mmc *find_mmc_device(int dev_num)
struct udevice *dev, *mmc_dev; struct udevice *dev, *mmc_dev;
int ret; int ret;
ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev); ret = blk_find_device(UCLASS_MMC, dev_num, &dev);
if (ret) { if (ret) {
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
@ -308,12 +308,12 @@ struct mmc *find_mmc_device(int dev_num)
int get_mmc_num(void) int get_mmc_num(void)
{ {
return max((blk_find_max_devnum(IF_TYPE_MMC) + 1), 0); return max((blk_find_max_devnum(UCLASS_MMC) + 1), 0);
} }
int mmc_get_next_devnum(void) int mmc_get_next_devnum(void)
{ {
return blk_find_max_devnum(IF_TYPE_MMC); return blk_find_max_devnum(UCLASS_MMC);
} }
int mmc_get_blk(struct udevice *dev, struct udevice **blkp) int mmc_get_blk(struct udevice *dev, struct udevice **blkp)
@ -411,7 +411,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
/* Use the fixed index with aliases node's index */ /* Use the fixed index with aliases node's index */
debug("%s: alias devnum=%d\n", __func__, dev_seq(dev)); debug("%s: alias devnum=%d\n", __func__, dev_seq(dev));
ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC, ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
dev_seq(dev), 512, 0, &bdev); dev_seq(dev), 512, 0, &bdev);
if (ret) { if (ret) {
debug("Cannot create block device\n"); debug("Cannot create block device\n");

View File

@ -132,7 +132,7 @@ static struct mmc mmc_static = {
.dsr_imp = 0, .dsr_imp = 0,
.dsr = 0xffffffff, .dsr = 0xffffffff,
.block_dev = { .block_dev = {
.if_type = IF_TYPE_MMC, .if_type = UCLASS_MMC,
.removable = 1, .removable = 1,
.devnum = 0, .devnum = 0,
.block_read = mmc_bread, .block_read = mmc_bread,
@ -194,7 +194,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
mmc->dsr = 0xffffffff; mmc->dsr = 0xffffffff;
/* Setup the universal parts of the block interface just once */ /* Setup the universal parts of the block interface just once */
bdesc = mmc_get_blk_desc(mmc); bdesc = mmc_get_blk_desc(mmc);
bdesc->if_type = IF_TYPE_MMC; bdesc->if_type = UCLASS_MMC;
bdesc->removable = 1; bdesc->removable = 1;
bdesc->devnum = mmc_get_next_devnum(); bdesc->devnum = mmc_get_next_devnum();
bdesc->block_read = mmc_bread; bdesc->block_read = mmc_bread;
@ -254,7 +254,7 @@ static int mmc_get_dev(int dev, struct blk_desc **descp)
U_BOOT_LEGACY_BLK(mmc) = { U_BOOT_LEGACY_BLK(mmc) = {
.if_typename = "mmc", .if_typename = "mmc",
.if_type = IF_TYPE_MMC, .if_type = UCLASS_MMC,
.max_devs = -1, .max_devs = -1,
.get_dev = mmc_get_dev, .get_dev = mmc_get_dev,
.select_hwpart = mmc_select_hwpartp, .select_hwpart = mmc_select_hwpartp,

View File

@ -85,7 +85,7 @@ ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt)
if (!mmc) if (!mmc)
return -1; return -1;
err = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_num, err = blk_select_hwpart_devnum(UCLASS_MMC, dev_num,
block_dev->hwpart); block_dev->hwpart);
if (err < 0) if (err < 0)
return -1; return -1;
@ -203,7 +203,7 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
if (!mmc) if (!mmc)
return 0; return 0;
err = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_num, block_dev->hwpart); err = blk_select_hwpart_devnum(UCLASS_MMC, dev_num, block_dev->hwpart);
if (err < 0) if (err < 0)
return 0; return 0;

View File

@ -880,7 +880,7 @@ int nvme_init(struct udevice *udev)
sprintf(name, "blk#%d", i); sprintf(name, "blk#%d", i);
/* The real blksz and size will be set by nvme_blk_probe() */ /* The real blksz and size will be set by nvme_blk_probe() */
ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME, ret = blk_create_devicef(udev, "nvme-blk", name, UCLASS_NVME,
-1, 512, 0, &ns_udev); -1, 512, 0, &ns_udev);
if (ret) if (ret)
goto free_id; goto free_id;

View File

@ -456,7 +456,7 @@ static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
{ {
dev_desc->lba = 0; dev_desc->lba = 0;
dev_desc->blksz = 0; dev_desc->blksz = 0;
dev_desc->if_type = IF_TYPE_SCSI; dev_desc->if_type = UCLASS_SCSI;
dev_desc->devnum = devnum; dev_desc->devnum = devnum;
dev_desc->part_type = PART_TYPE_UNKNOWN; dev_desc->part_type = PART_TYPE_UNKNOWN;
@ -574,7 +574,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
* block devices created * block devices created
*/ */
snprintf(str, sizeof(str), "id%dlun%d", id, lun); snprintf(str, sizeof(str), "id%dlun%d", id, lun);
ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1, ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1,
bd.blksz, bd.lba, &bdev); bd.blksz, bd.lba, &bdev);
if (ret) { if (ret) {
debug("Can't create device\n"); debug("Can't create device\n");
@ -638,7 +638,7 @@ int scsi_scan(bool verbose)
if (verbose) if (verbose)
printf("scanning bus for devices...\n"); printf("scanning bus for devices...\n");
blk_unbind_all(IF_TYPE_SCSI); blk_unbind_all(UCLASS_SCSI);
ret = uclass_get(UCLASS_SCSI, &uc); ret = uclass_get(UCLASS_SCSI, &uc);
if (ret) if (ret)
@ -707,7 +707,7 @@ U_BOOT_DRIVER(scsi_blk) = {
#else #else
U_BOOT_LEGACY_BLK(scsi) = { U_BOOT_LEGACY_BLK(scsi) = {
.if_typename = "scsi", .if_typename = "scsi",
.if_type = IF_TYPE_SCSI, .if_type = UCLASS_SCSI,
.max_devs = SCSI_MAX_DEVICE, .max_devs = SCSI_MAX_DEVICE,
.desc = scsi_dev_desc, .desc = scsi_dev_desc,
}; };

View File

@ -48,7 +48,7 @@ static void release_mmc(struct optee_private *priv)
if (!priv->rpmb_mmc) if (!priv->rpmb_mmc)
return; return;
rc = blk_select_hwpart_devnum(IF_TYPE_MMC, priv->rpmb_dev_id, rc = blk_select_hwpart_devnum(UCLASS_MMC, priv->rpmb_dev_id,
priv->rpmb_original_part); priv->rpmb_original_part);
if (rc) if (rc)
debug("%s: blk_select_hwpart_devnum() failed: %d\n", debug("%s: blk_select_hwpart_devnum() failed: %d\n",
@ -88,7 +88,7 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id)
priv->rpmb_original_part = mmc_get_blk_desc(mmc)->hwpart; priv->rpmb_original_part = mmc_get_blk_desc(mmc)->hwpart;
rc = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_id, MMC_PART_RPMB); rc = blk_select_hwpart_devnum(UCLASS_MMC, dev_id, MMC_PART_RPMB);
if (rc) { if (rc) {
debug("Device id %d: cannot select RPMB partition: %d\n", debug("Device id %d: cannot select RPMB partition: %d\n",
dev_id, rc); dev_id, rc);

View File

@ -75,14 +75,14 @@ static int virtio_blk_bind(struct udevice *dev)
struct blk_desc *desc = dev_get_uclass_plat(dev); struct blk_desc *desc = dev_get_uclass_plat(dev);
int devnum; int devnum;
desc->if_type = IF_TYPE_VIRTIO; desc->if_type = UCLASS_VIRTIO;
/* /*
* Initialize the devnum to -ENODEV. This is to make sure that * Initialize the devnum to -ENODEV. This is to make sure that
* blk_next_free_devnum() works as expected, since the default * blk_next_free_devnum() works as expected, since the default
* value 0 is a valid devnum. * value 0 is a valid devnum.
*/ */
desc->devnum = -ENODEV; desc->devnum = -ENODEV;
devnum = blk_next_free_devnum(IF_TYPE_VIRTIO); devnum = blk_next_free_devnum(UCLASS_VIRTIO);
if (devnum < 0) if (devnum < 0)
return devnum; return devnum;
desc->devnum = devnum; desc->devnum = devnum;

View File

@ -665,14 +665,14 @@ static int pvblock_blk_bind(struct udevice *udev)
struct blk_desc *desc = dev_get_uclass_plat(udev); struct blk_desc *desc = dev_get_uclass_plat(udev);
int devnum; int devnum;
desc->if_type = IF_TYPE_PVBLOCK; desc->if_type = UCLASS_PVBLOCK;
/* /*
* Initialize the devnum to -ENODEV. This is to make sure that * Initialize the devnum to -ENODEV. This is to make sure that
* blk_next_free_devnum() works as expected, since the default * blk_next_free_devnum() works as expected, since the default
* value 0 is a valid devnum. * value 0 is a valid devnum.
*/ */
desc->devnum = -ENODEV; desc->devnum = -ENODEV;
devnum = blk_next_free_devnum(IF_TYPE_PVBLOCK); devnum = blk_next_free_devnum(UCLASS_PVBLOCK);
if (devnum < 0) if (devnum < 0)
return devnum; return devnum;
desc->devnum = devnum; desc->devnum = devnum;
@ -804,7 +804,7 @@ static void print_pvblock_devices(void)
const char *class_name; const char *class_name;
class_name = uclass_get_name(UCLASS_PVBLOCK); class_name = uclass_get_name(UCLASS_PVBLOCK);
for (blk_first_device(IF_TYPE_PVBLOCK, &udev); udev; for (blk_first_device(UCLASS_PVBLOCK, &udev); udev;
blk_next_device(&udev), first = false) { blk_next_device(&udev), first = false) {
struct blk_desc *desc = dev_get_uclass_plat(udev); struct blk_desc *desc = dev_get_uclass_plat(udev);

4
env/mmc.c vendored
View File

@ -143,7 +143,7 @@ static int mmc_set_env_part(struct mmc *mmc, uint part)
int dev = mmc_get_env_dev(); int dev = mmc_get_env_dev();
int ret = 0; int ret = 0;
ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part); ret = blk_select_hwpart_devnum(UCLASS_MMC, dev, part);
if (ret) if (ret)
puts("MMC partition switch failed\n"); puts("MMC partition switch failed\n");
@ -179,7 +179,7 @@ static void fini_mmc_for_env(struct mmc *mmc)
#ifdef CONFIG_SYS_MMC_ENV_PART #ifdef CONFIG_SYS_MMC_ENV_PART
int dev = mmc_get_env_dev(); int dev = mmc_get_env_dev();
blk_select_hwpart_devnum(IF_TYPE_MMC, dev, env_mmc_orig_hwpart); blk_select_hwpart_devnum(UCLASS_MMC, dev, env_mmc_orig_hwpart);
#endif #endif
} }

View File

@ -7,6 +7,7 @@
#ifndef BLK_H #ifndef BLK_H
#define BLK_H #define BLK_H
#include <dm/uclass-id.h>
#include <efi.h> #include <efi.h>
#ifdef CONFIG_SYS_64BIT_LBA #ifdef CONFIG_SYS_64BIT_LBA
@ -27,22 +28,7 @@ static inline bool blk_enabled(void)
} }
/* Interface types: */ /* Interface types: */
enum if_type { #define if_type uclass_id
IF_TYPE_UNKNOWN = 0,
IF_TYPE_IDE,
IF_TYPE_SCSI,
IF_TYPE_USB,
IF_TYPE_MMC,
IF_TYPE_SATA,
IF_TYPE_HOST,
IF_TYPE_NVME,
IF_TYPE_EFI_LOADER,
IF_TYPE_PVBLOCK,
IF_TYPE_VIRTIO,
IF_TYPE_EFI_MEDIA,
IF_TYPE_COUNT, /* Number of interface types */
};
#define BLK_VEN_SIZE 40 #define BLK_VEN_SIZE 40
#define BLK_PRD_SIZE 20 #define BLK_PRD_SIZE 20

View File

@ -767,7 +767,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
/** /**
* mmc_bind() - Set up a new MMC device ready for probing * mmc_bind() - Set up a new MMC device ready for probing
* *
* A child block device is bound with the IF_TYPE_MMC interface type. This * A child block device is bound with the UCLASS_MMC interface type. This
* allows the device to be used with CONFIG_BLK * allows the device to be used with CONFIG_BLK
* *
* @dev: MMC device to set up * @dev: MMC device to set up

View File

@ -128,7 +128,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
if (!obj) if (!obj)
return -ENOENT; return -ENOENT;
devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER); devnum = blk_find_max_devnum(UCLASS_EFI_LOADER);
if (devnum == -ENODEV) if (devnum == -ENODEV)
devnum = 0; devnum = 0;
else if (devnum < 0) else if (devnum < 0)
@ -140,7 +140,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
sprintf(name, "efiblk#%d", devnum); sprintf(name, "efiblk#%d", devnum);
/* Create driver model udevice for the EFI block io device */ /* Create driver model udevice for the EFI block io device */
ret = blk_create_device(parent, "efi_blk", name, IF_TYPE_EFI_LOADER, ret = blk_create_device(parent, "efi_blk", name, UCLASS_EFI_LOADER,
devnum, io->media->block_size, devnum, io->media->block_size,
(lbaint_t)io->media->last_block, &bdev); (lbaint_t)io->media->last_block, &bdev);
if (ret) if (ret)

View File

@ -640,7 +640,7 @@ static int efi_disk_probe(void *ctx, struct event *event)
* has already created an efi_disk at this moment. * has already created an efi_disk at this moment.
*/ */
desc = dev_get_uclass_plat(dev); desc = dev_get_uclass_plat(dev);
if (desc->if_type != IF_TYPE_EFI_LOADER) { if (desc->if_type != UCLASS_EFI_LOADER) {
ret = efi_disk_create_raw(dev); ret = efi_disk_create_raw(dev);
if (ret) if (ret)
return -1; return -1;
@ -675,7 +675,7 @@ static int efi_disk_delete_raw(struct udevice *dev)
return -1; return -1;
desc = dev_get_uclass_plat(dev); desc = dev_get_uclass_plat(dev);
if (desc->if_type != IF_TYPE_EFI_LOADER) { if (desc->if_type != UCLASS_EFI_LOADER) {
diskobj = container_of(handle, struct efi_disk_obj, header); diskobj = container_of(handle, struct efi_disk_obj, header);
efi_free_pool(diskobj->dp); efi_free_pool(diskobj->dp);
} }

View File

@ -25,19 +25,19 @@ static int dm_test_blk_base(struct unit_test_state *uts)
/* Create two, one the parent of the other */ /* Create two, one the parent of the other */
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test", ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
IF_TYPE_HOST, 1, 512, 2, &blk1)); UCLASS_ROOT, 1, 512, 2, &blk1));
ut_assertok(blk_create_device(blk1, "sandbox_host_blk", "test", ut_assertok(blk_create_device(blk1, "sandbox_host_blk", "test",
IF_TYPE_HOST, 3, 512, 2, &blk3)); UCLASS_ROOT, 3, 512, 2, &blk3));
/* Check we can find them */ /* Check we can find them */
ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev)); ut_asserteq(-ENODEV, blk_get_device(UCLASS_ROOT, 0, &dev));
ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev)); ut_assertok(blk_get_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk1, dev); ut_asserteq_ptr(blk1, dev);
ut_assertok(blk_get_device(IF_TYPE_HOST, 3, &dev)); ut_assertok(blk_get_device(UCLASS_ROOT, 3, &dev));
ut_asserteq_ptr(blk3, dev); ut_asserteq_ptr(blk3, dev);
/* Check we can iterate */ /* Check we can iterate */
ut_assertok(blk_first_device(IF_TYPE_HOST, &dev)); ut_assertok(blk_first_device(UCLASS_ROOT, &dev));
ut_asserteq_ptr(blk1, dev); ut_asserteq_ptr(blk1, dev);
ut_assertok(blk_next_device(&dev)); ut_assertok(blk_next_device(&dev));
ut_asserteq_ptr(blk3, dev); ut_asserteq_ptr(blk3, dev);
@ -79,7 +79,7 @@ static int dm_test_blk_usb(struct unit_test_state *uts)
ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc)); ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));
/* The parent should be a block device */ /* The parent should be a block device */
ut_assertok(blk_get_device(IF_TYPE_USB, 0, &dev)); ut_assertok(blk_get_device(UCLASS_USB, 0, &dev));
ut_asserteq_ptr(usb_dev, dev_get_parent(dev)); ut_asserteq_ptr(usb_dev, dev_get_parent(dev));
/* Check we have one block device for each mass storage device */ /* Check we have one block device for each mass storage device */
@ -101,14 +101,14 @@ static int dm_test_blk_find(struct unit_test_state *uts)
struct udevice *blk, *dev; struct udevice *blk, *dev;
ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test", ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
IF_TYPE_HOST, 1, 512, 2, &blk)); UCLASS_ROOT, 1, 512, 2, &blk));
ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev)); ut_asserteq(-ENODEV, blk_find_device(UCLASS_ROOT, 0, &dev));
ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev)); ut_assertok(blk_find_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk, dev); ut_asserteq_ptr(blk, dev);
ut_asserteq(false, device_active(dev)); ut_asserteq(false, device_active(dev));
/* Now activate it */ /* Now activate it */
ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev)); ut_assertok(blk_get_device(UCLASS_ROOT, 1, &dev));
ut_asserteq_ptr(blk, dev); ut_asserteq_ptr(blk, dev);
ut_asserteq(true, device_active(dev)); ut_asserteq(true, device_active(dev));
@ -134,7 +134,7 @@ static int dm_test_blk_devnum(struct unit_test_state *uts)
/* Check that the bblock device is attached */ /* Check that the bblock device is attached */
ut_assertok(uclass_get_device_by_seq(UCLASS_MMC, i, &mmc_dev)); ut_assertok(uclass_get_device_by_seq(UCLASS_MMC, i, &mmc_dev));
ut_assertok(blk_find_device(IF_TYPE_MMC, i, &dev)); ut_assertok(blk_find_device(UCLASS_MMC, i, &dev));
parent = dev_get_parent(dev); parent = dev_get_parent(dev);
ut_asserteq_ptr(parent, mmc_dev); ut_asserteq_ptr(parent, mmc_dev);
ut_asserteq(trailing_strtol(mmc_dev->name), i); ut_asserteq(trailing_strtol(mmc_dev->name), i);