]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
blk: Switch over to using uclass IDs
authorSimon Glass <sjg@chromium.org>
Fri, 12 Aug 2022 01:34:59 +0000 (19:34 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 16 Sep 2022 15:05:16 +0000 (11:05 -0400)
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>
41 files changed:
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
board/toradex/common/tdx-cfg-block.c
cmd/bcb.c
cmd/ide.c
cmd/mmc.c
cmd/mvebu/bubt.c
cmd/nvme.c
cmd/pvblock.c
cmd/sata.c
cmd/scsi.c
cmd/usb.c
cmd/virtio.c
common/spl/spl_sata.c
common/spl/spl_usb.c
common/usb_storage.c
disk/part.c
doc/develop/uefi/uefi.rst
drivers/ata/dwc_ahsata.c
drivers/ata/fsl_sata.c
drivers/ata/sata.c
drivers/ata/sata_mv.c
drivers/ata/sata_sil.c
drivers/block/blk-uclass.c
drivers/block/efi_blk.c
drivers/block/ide.c
drivers/block/sandbox.c
drivers/dfu/dfu_mmc.c
drivers/mmc/mmc-uclass.c
drivers/mmc/mmc_legacy.c
drivers/mmc/mmc_write.c
drivers/nvme/nvme.c
drivers/scsi/scsi.c
drivers/tee/optee/rpmb.c
drivers/virtio/virtio_blk.c
drivers/xen/pvblock.c
env/mmc.c
include/blk.h
include/mmc.h
lib/efi_driver/efi_block_device.c
lib/efi_loader/efi_disk.c
test/dm/blk.c

index c391b6c7abb5bc385076bfd329f7a8cbfb4e0d3b..a720d0ba717ce2ce52b0786c89655eb12d60561a 100644 (file)
@@ -1823,7 +1823,7 @@ static int part_delete(struct stm32prog_data *data,
                 * need to switch to associated hwpart 1 or 2
                 */
                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->part_id))
                                return -1;
@@ -1832,7 +1832,7 @@ static int part_delete(struct stm32prog_data *data,
 
                /* return to user partition */
                if (part->part_id < 0)
-                       blk_select_hwpart_devnum(IF_TYPE_MMC,
+                       blk_select_hwpart_devnum(UCLASS_MMC,
                                                 part->dev->dev_id, 0);
                if (blks != blks_size) {
                        ret = -1;
index 22c67c6e3887bdab4a51399a751464af4435fc12..11f4d5e14a868380e009c5d8f23c2c21cd3fd44b 100644 (file)
@@ -211,7 +211,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
                return -EINVAL;
        }
        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");
                        ret = -ENODEV;
                        goto out;
@@ -239,7 +239,7 @@ static int tdx_cfg_block_mmc_storage(u8 *config_block, int write)
 
 out:
        /* 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;
 }
index 1bbd1fae99860184d4216695e1032e2fe0322d8f..8b87aa062fe395cad4513978fd596dbe92a38090 100644 (file)
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -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;
index b78c38e1590d78702831c506471afa56e33ad482..6739f0b12d1a5f335253277511280242adf0bd2b 100644 (file)
--- a/cmd/ide.c
+++ b/cmd/ide.c
@@ -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[])
index 7bd4cd9e016d98c18653d1bebf7d8e26cdd8ca21..0f1f4e0a71da80204d404cfdf45611e1cea0f9a1 100644 (file)
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -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)
index 2136af64163c0fa13c491d620bdaf2804dd29c24..825d4beb899c7e3eb5b3e58508b506a76d4314bc 100644 (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;
index e715c570a384abc5011254ce7da3691ae96bcf6f..09d5f438fb1a112fd75da207fc139c5ee8d91197 100644 (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(
index 56ce8b18d511cd10ef5798e05a4e2d6778ea8aef..1b604c37373c5de86b20b8f796aa289d429547f8 100644 (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);
 }
 
index 76da1906b7fb412d78f8df0b9879adb2fb3db7d5..9c9fe111d12f2b7fe071b02c7c666a5e8389247b 100644 (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(
index 5f710d28957484fc49cea77aad9ba1dd10d36045..4549995ba73c4b5f2bf5034442d79c18ce47f256 100644 (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(
index 3d873765250f2e537c37afecc29f123411c5ccea..2ba056982c38cf74121065da12bf8226f9660700 100644 (file)
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -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 */
index ea3ed2e631e477bb00fae705dd8423d572d35433..ec87d4f02c93ccc412a234741776fe7c79d53b48 100644 (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(
index 1351d78612a5142803fc6d12c184e903a9055c99..ea9f1756c0a2e559f4af8df9cea57daacae612db 100644 (file)
@@ -71,7 +71,7 @@ static int spl_sata_load_image(struct spl_image_info *spl_image,
 
        /* try to recognize storage devices immediately */
        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)
                return -ENODEV;
 
index ccf01c8276b473cb7842c6846a38b3c51b0d62db..63c00f872b69e198325208ea5dd0390a526a30a3 100644 (file)
@@ -41,7 +41,7 @@ int spl_usb_load(struct spl_image_info *spl_image,
 
        /* try to recognize storage devices immediately */
        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)
                return -ENODEV;
 
index eaa31374ef73364775fb0a13a8296cc46882122e..7d420160cd51f7b72795b9fd7030b3b8c4219f0f 100644 (file)
@@ -144,7 +144,7 @@ int usb_stor_info(void)
 #if CONFIG_IS_ENABLED(BLK)
        struct udevice *dev;
 
-       for (blk_first_device(IF_TYPE_USB, &dev);
+       for (blk_first_device(UCLASS_USB, &dev);
             dev;
             blk_next_device(&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);
                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);
                if (ret) {
                        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];
                memset(blkdev, '\0', sizeof(struct blk_desc));
-               blkdev->if_type = IF_TYPE_USB;
+               blkdev->if_type = UCLASS_USB;
                blkdev->devnum = usb_max_devs;
                blkdev->part_type = PART_TYPE_UNKNOWN;
                blkdev->target = 0xff;
@@ -1578,7 +1578,7 @@ U_BOOT_DRIVER(usb_storage_blk) = {
 #else
 U_BOOT_LEGACY_BLK(usb) = {
        .if_typename    = "usb",
-       .if_type        = IF_TYPE_USB,
+       .if_type        = UCLASS_USB,
        .max_devs       = USB_MAX_STOR_DEV,
        .desc           = usb_dev_desc,
 };
index 2bcc6f4f40370e5ae0bc0aafb9786f8a38ecc53b..75aff7eba5ac796ceced89f661dcb6965a2d42c6 100644 (file)
@@ -121,34 +121,34 @@ void dev_print (struct blk_desc *dev_desc)
        }
 
        switch (dev_desc->if_type) {
-       case IF_TYPE_SCSI:
+       case UCLASS_SCSI:
                printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
                        dev_desc->target,dev_desc->lun,
                        dev_desc->vendor,
                        dev_desc->product,
                        dev_desc->revision);
                break;
-       case IF_TYPE_IDE:
-       case IF_TYPE_SATA:
+       case UCLASS_IDE:
+       case UCLASS_AHCI:
                printf ("Model: %s Firm: %s Ser#: %s\n",
                        dev_desc->vendor,
                        dev_desc->revision,
                        dev_desc->product);
                break;
-       case IF_TYPE_MMC:
-       case IF_TYPE_USB:
-       case IF_TYPE_NVME:
-       case IF_TYPE_PVBLOCK:
-       case IF_TYPE_HOST:
+       case UCLASS_MMC:
+       case UCLASS_USB:
+       case UCLASS_NVME:
+       case UCLASS_PVBLOCK:
+       case UCLASS_ROOT:
                printf ("Vendor: %s Rev: %s Prod: %s\n",
                        dev_desc->vendor,
                        dev_desc->revision,
                        dev_desc->product);
                break;
-       case IF_TYPE_VIRTIO:
+       case UCLASS_VIRTIO:
                printf("%s VirtIO Block Device\n", dev_desc->vendor);
                break;
-       case IF_TYPE_UNKNOWN:
+       case UCLASS_INVALID:
                puts("device type unknown\n");
                return;
        default:
@@ -246,34 +246,34 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
        CONFIG_IS_ENABLED(EFI_PARTITION)
        puts ("\nPartition Map for ");
        switch (dev_desc->if_type) {
-       case IF_TYPE_IDE:
+       case UCLASS_IDE:
                puts ("IDE");
                break;
-       case IF_TYPE_SATA:
+       case UCLASS_AHCI:
                puts ("SATA");
                break;
-       case IF_TYPE_SCSI:
+       case UCLASS_SCSI:
                puts ("SCSI");
                break;
-       case IF_TYPE_USB:
+       case UCLASS_USB:
                puts ("USB");
                break;
-       case IF_TYPE_MMC:
+       case UCLASS_MMC:
                puts ("MMC");
                break;
-       case IF_TYPE_HOST:
+       case UCLASS_ROOT:
                puts ("HOST");
                break;
-       case IF_TYPE_NVME:
+       case UCLASS_NVME:
                puts ("NVMe");
                break;
-       case IF_TYPE_PVBLOCK:
+       case UCLASS_PVBLOCK:
                puts("PV BLOCK");
                break;
-       case IF_TYPE_VIRTIO:
+       case UCLASS_VIRTIO:
                puts("VirtIO");
                break;
-       case IF_TYPE_EFI_MEDIA:
+       case UCLASS_EFI_MEDIA:
                puts("EFI");
                break;
        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
                 * 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);
        }
 
@@ -760,17 +760,17 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
        char *devtype;
 
        switch (dev_desc->if_type) {
-       case IF_TYPE_IDE:
-       case IF_TYPE_SATA:
+       case UCLASS_IDE:
+       case UCLASS_AHCI:
                devtype = "hd";
                break;
-       case IF_TYPE_SCSI:
+       case UCLASS_SCSI:
                devtype = "sd";
                break;
-       case IF_TYPE_USB:
+       case UCLASS_USB:
                devtype = "usbd";
                break;
-       case IF_TYPE_MMC:
+       case UCLASS_MMC:
                devtype = "mmcsd";
                break;
        default:
index 941e427093fc2a0727bc185c0d9081188eab1693..cd8470695307bf6ccc18fc94b094606a8dac594f 100644 (file)
@@ -748,7 +748,7 @@ UEFI block IO driver
 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
-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
 software iPXE to boot from iSCSI network drives [4].
 
index 1a2c3c2fe7078c977895e44db50a11ff44e129fb..167b5a395f5876c850fd5a58756c634d41541ae8 100644 (file)
@@ -880,7 +880,7 @@ int dwc_ahsata_scan(struct udevice *dev)
        device_find_first_child(dev, &blk);
        if (!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) {
                        debug("Can't create device\n");
                        return ret;
index 6db4247368eb7ee7d5dbe0c815146b47f645d02d..972101b29ce586a0db7f271cf4c49da04f0e8224 100644 (file)
@@ -888,7 +888,7 @@ static int fsl_ata_probe(struct udevice *dev)
        for (i = 0; i < nr_ports; i++) {
                snprintf(sata_name, sizeof(sata_name), "fsl_sata%d", i);
                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) {
                        debug("Can't create device\n");
                        return ret;
index 0e6c8cdd4222b0eb97dd29cec711e6bdc1a37fdb..604c721cfdcff23d807669aae4457fc52da6459b 100644 (file)
@@ -79,7 +79,7 @@ int __sata_initialize(void)
 
        for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
                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].part_type = PART_TYPE_UNKNOWN;
                sata_dev_desc[i].type = DEV_TYPE_HARDDISK;
index a187796dfcdf0e8bedfd5622509313c99508891f..18c7a66db1bff992b5a678c9b7150ed3490051fe 100644 (file)
@@ -1076,7 +1076,7 @@ static int sata_mv_probe(struct udevice *dev)
 
        for (i = 0; i < nr_ports; i++) {
                ret = blk_create_devicef(dev, "sata_mv_blk", "blk",
-                                        IF_TYPE_SATA, -1, 512, 0, &blk);
+                                        UCLASS_AHCI, -1, 512, 0, &blk);
                if (ret) {
                        debug("Can't create device\n");
                        continue;
index 706515457224b4ca3c8961c382c1059bf058ce62..b5e150d568ba3f7a1368dfff5bbd28e8c0bfe394 100644 (file)
@@ -730,7 +730,7 @@ static int sil_pci_probe(struct udevice *dev)
        for (i = sata_info.portbase; i < sata_info.maxport; i++) {
                snprintf(sata_name, sizeof(sata_name), "sil_sata%d", i);
                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) {
                        debug("Can't create device\n");
                        return ret;
index a68158c3f2548949c2a1c967fa3da40d52e4c3d0..436af764f9183264f304643aee4fc58fbf3c07af 100644 (file)
@@ -21,31 +21,17 @@ static struct {
        enum uclass_id id;
        const char *name;
 } if_typename_str[] = {
-       { IF_TYPE_IDE, "ide" },
-       { IF_TYPE_SCSI, "scsi" },
-       { IF_TYPE_USB, "usb" },
-       { IF_TYPE_MMC,  "mmc" },
-       { IF_TYPE_SCSI, "sata" },
-       { IF_TYPE_HOST, "host" },
-       { IF_TYPE_NVME, "nvme" },
-       { IF_TYPE_EFI_MEDIA, "efi" },
-       { IF_TYPE_EFI_LOADER, "efiloader" },
-       { IF_TYPE_VIRTIO, "virtio" },
-       { IF_TYPE_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,
+       { UCLASS_IDE, "ide" },
+       { UCLASS_SCSI, "scsi" },
+       { UCLASS_USB, "usb" },
+       { UCLASS_MMC,  "mmc" },
+       { UCLASS_AHCI, "sata" },
+       { UCLASS_ROOT, "host" },
+       { UCLASS_NVME, "nvme" },
+       { UCLASS_EFI_MEDIA, "efi" },
+       { UCLASS_EFI_LOADER, "efiloader" },
+       { UCLASS_VIRTIO, "virtio" },
+       { UCLASS_PVBLOCK, "pvblock" },
 };
 
 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_TYPE_UNKNOWN;
+       return UCLASS_INVALID;
 }
 
 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)
@@ -70,7 +76,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
        int 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;
        }
 
@@ -105,7 +111,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
        int ret;
 
        type = if_typename_to_iftype(if_typename);
-       if (type == IF_TYPE_UNKNOWN) {
+       if (type == UCLASS_INVALID) {
                debug("%s: Unknown interface type '%s'\n", __func__,
                      if_typename);
                return NULL;
index 9d25ecbf37ff6ed87138d593821f5b45ebca11bc..917a19f6025460be78a5a8c017039f9157674057 100644 (file)
@@ -94,7 +94,7 @@ static int efi_media_bind(struct udevice *dev)
        struct udevice *blk;
        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,
                                 plat->blkio->media->last_block, &blk);
        if (ret) {
index 6bc48e3402ec5582b06507c3b329ab67dd8b8db9..73da29ad552b010c343a6b184df75417a30d5eed 100644 (file)
@@ -537,7 +537,7 @@ static void ide_ident(struct blk_desc *dev_desc)
        /* Select 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
 
        retries = 0;
@@ -752,7 +752,7 @@ void ide_init(void)
 
        for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
                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].part_type = PART_TYPE_UNKNOWN;
                ide_dev_desc[i].blksz = 0;
@@ -1110,7 +1110,7 @@ static int ide_probe(struct udevice *udev)
                        if (!blksz)
                                continue;
                        ret = blk_create_devicef(udev, "ide_blk", name,
-                                                IF_TYPE_IDE, i,
+                                                UCLASS_IDE, i,
                                                 blksz, size, &blk_dev);
                        if (ret)
                                return ret;
@@ -1144,7 +1144,7 @@ UCLASS_DRIVER(ide) = {
 #else
 U_BOOT_LEGACY_BLK(ide) = {
        .if_typename    = "ide",
-       .if_type        = IF_TYPE_IDE,
+       .if_type        = UCLASS_IDE,
        .max_devs       = CONFIG_SYS_IDE_MAXDEVICE,
        .desc           = ide_dev_desc,
 };
index 1388498a1d34ecce5dad57adf794e811dedfdd69..2de12e0a93ea1041c75d8ab9c67e26837f08f566 100644 (file)
@@ -98,7 +98,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
        int ret, fd;
 
        /* 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) {
                ret = device_remove(dev, DM_REMOVE_NORMAL);
                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,
-                               IF_TYPE_HOST, devnum, 512,
+                               UCLASS_ROOT, devnum, 512,
                                os_lseek(fd, 0, OS_SEEK_END) / 512, &dev);
        if (ret)
                goto err_file;
@@ -150,7 +150,7 @@ int host_dev_bind(int devnum, char *filename, bool removable)
                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;
        snprintf(desc->vendor, BLK_VEN_SIZE, "U-Boot");
        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;
-       blk_dev->if_type = IF_TYPE_HOST;
+       blk_dev->if_type = UCLASS_ROOT;
        blk_dev->priv = host_dev;
        blk_dev->blksz = 512;
        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;
        int ret;
 
-       ret = blk_get_device(IF_TYPE_HOST, devnum, &dev);
+       ret = blk_get_device(UCLASS_ROOT, devnum, &dev);
        if (ret)
                return ret;
        *blk_devp = dev_get_uclass_plat(dev);
@@ -263,7 +263,7 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
 #else
 U_BOOT_LEGACY_BLK(sandbox_host) = {
        .if_typename    = "host",
-       .if_type        = IF_TYPE_HOST,
+       .if_type        = UCLASS_ROOT,
        .max_devs       = SANDBOX_HOST_MAX_DEVICES,
        .get_dev        = host_get_dev_err,
 };
index a91da972d46efffa51f0d43ad58bf26e90a72ee8..f5832083ba1a521053254b5fc1e223999b631935 100644 (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) {
                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.hw_partition);
                if (ret)
@@ -77,14 +77,14 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
        if (n != blk_count) {
                pr_err("MMC operation failed");
                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,
                                                 part_num_bkp);
                return -EIO;
        }
 
        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,
                                               part_num_bkp);
                if (ret)
index 688bdc06d4267fff8641e218396006a66b1987e9..b1bd4ae1bc86e8a5c7ce7ae37c7bbf3d4c872187 100644 (file)
@@ -290,7 +290,7 @@ struct mmc *find_mmc_device(int dev_num)
        struct udevice *dev, *mmc_dev;
        int ret;
 
-       ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
+       ret = blk_find_device(UCLASS_MMC, dev_num, &dev);
 
        if (ret) {
 #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)
 {
-       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)
 {
-       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)
@@ -411,8 +411,8 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
        /* Use the fixed index with aliases node's index */
        debug("%s: alias devnum=%d\n", __func__, dev_seq(dev));
 
-       ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
-                       dev_seq(dev), 512, 0, &bdev);
+       ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
+                                dev_seq(dev), 512, 0, &bdev);
        if (ret) {
                debug("Cannot create block device\n");
                return ret;
index a05da6c2e882f97e0fbf44cfdf210c98bd36d91a..4e0891e5dfe0665415932f158d9acada4aa0221a 100644 (file)
@@ -132,7 +132,7 @@ static struct mmc mmc_static = {
        .dsr_imp                = 0,
        .dsr                    = 0xffffffff,
        .block_dev = {
-               .if_type        = IF_TYPE_MMC,
+               .if_type        = UCLASS_MMC,
                .removable      = 1,
                .devnum         = 0,
                .block_read     = mmc_bread,
@@ -194,7 +194,7 @@ struct mmc *mmc_create(const struct mmc_config *cfg, void *priv)
        mmc->dsr = 0xffffffff;
        /* Setup the universal parts of the block interface just once */
        bdesc = mmc_get_blk_desc(mmc);
-       bdesc->if_type = IF_TYPE_MMC;
+       bdesc->if_type = UCLASS_MMC;
        bdesc->removable = 1;
        bdesc->devnum = mmc_get_next_devnum();
        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) = {
        .if_typename    = "mmc",
-       .if_type        = IF_TYPE_MMC,
+       .if_type        = UCLASS_MMC,
        .max_devs       = -1,
        .get_dev        = mmc_get_dev,
        .select_hwpart  = mmc_select_hwpartp,
index eab94c7b6070b6d561ff004f9ee73ead32d41f4f..5b7aeeb0121f68c4dffa8d2d270b00d328067ba1 100644 (file)
@@ -85,7 +85,7 @@ ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt)
        if (!mmc)
                return -1;
 
-       err = blk_select_hwpart_devnum(IF_TYPE_MMC, dev_num,
+       err = blk_select_hwpart_devnum(UCLASS_MMC, dev_num,
                                       block_dev->hwpart);
        if (err < 0)
                return -1;
@@ -203,7 +203,7 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
        if (!mmc)
                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)
                return 0;
 
index 31cf70063306a69662707b8b1f8b03d8919aab1e..3510f797e00269e3cd6b9993194c9c9b6b2f7293 100644 (file)
@@ -880,7 +880,7 @@ int nvme_init(struct udevice *udev)
                sprintf(name, "blk#%d", i);
 
                /* 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);
                if (ret)
                        goto free_id;
index 78d729d809d73fbbd0ffaa15e9234f6989a364c1..99be5aef877d949142ef0a9998c5ae3118dc944c 100644 (file)
@@ -456,7 +456,7 @@ static void scsi_init_dev_desc(struct blk_desc *dev_desc, int devnum)
 {
        dev_desc->lba = 0;
        dev_desc->blksz = 0;
-       dev_desc->if_type = IF_TYPE_SCSI;
+       dev_desc->if_type = UCLASS_SCSI;
        dev_desc->devnum = devnum;
        dev_desc->part_type = PART_TYPE_UNKNOWN;
 
@@ -574,8 +574,8 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        * block devices created
        */
        snprintf(str, sizeof(str), "id%dlun%d", id, lun);
-       ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1,
-                       bd.blksz, bd.lba, &bdev);
+       ret = blk_create_devicef(dev, "scsi_blk", str, UCLASS_SCSI, -1,
+                                bd.blksz, bd.lba, &bdev);
        if (ret) {
                debug("Can't create device\n");
                return ret;
@@ -638,7 +638,7 @@ int scsi_scan(bool verbose)
        if (verbose)
                printf("scanning bus for devices...\n");
 
-       blk_unbind_all(IF_TYPE_SCSI);
+       blk_unbind_all(UCLASS_SCSI);
 
        ret = uclass_get(UCLASS_SCSI, &uc);
        if (ret)
@@ -707,7 +707,7 @@ U_BOOT_DRIVER(scsi_blk) = {
 #else
 U_BOOT_LEGACY_BLK(scsi) = {
        .if_typename    = "scsi",
-       .if_type        = IF_TYPE_SCSI,
+       .if_type        = UCLASS_SCSI,
        .max_devs       = SCSI_MAX_DEVICE,
        .desc           = scsi_dev_desc,
 };
index cf5e0a08e619b295aa8b4ac70766da3cdbadd23f..5bc13757ea8d72930a84e7001223fbe847b542c3 100644 (file)
@@ -48,7 +48,7 @@ static void release_mmc(struct optee_private *priv)
        if (!priv->rpmb_mmc)
                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);
        if (rc)
                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;
 
-       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) {
                debug("Device id %d: cannot select RPMB partition: %d\n",
                      dev_id, rc);
index 3ff74f4a9759efe48fc5ec622782c091d7825f24..9710b79117c87cd2f2839df6e1d8c274935de6e1 100644 (file)
@@ -75,14 +75,14 @@ static int virtio_blk_bind(struct udevice *dev)
        struct blk_desc *desc = dev_get_uclass_plat(dev);
        int devnum;
 
-       desc->if_type = IF_TYPE_VIRTIO;
+       desc->if_type = UCLASS_VIRTIO;
        /*
         * Initialize the devnum to -ENODEV. This is to make sure that
         * blk_next_free_devnum() works as expected, since the default
         * value 0 is a valid devnum.
         */
        desc->devnum = -ENODEV;
-       devnum = blk_next_free_devnum(IF_TYPE_VIRTIO);
+       devnum = blk_next_free_devnum(UCLASS_VIRTIO);
        if (devnum < 0)
                return devnum;
        desc->devnum = devnum;
index c25c3ea4fffff35602ee44fb2f9aed29bdbf7c46..1090e528d0239b86fcde606068b1c41f9168691e 100644 (file)
@@ -665,14 +665,14 @@ static int pvblock_blk_bind(struct udevice *udev)
        struct blk_desc *desc = dev_get_uclass_plat(udev);
        int devnum;
 
-       desc->if_type = IF_TYPE_PVBLOCK;
+       desc->if_type = UCLASS_PVBLOCK;
        /*
         * Initialize the devnum to -ENODEV. This is to make sure that
         * blk_next_free_devnum() works as expected, since the default
         * value 0 is a valid devnum.
         */
        desc->devnum = -ENODEV;
-       devnum = blk_next_free_devnum(IF_TYPE_PVBLOCK);
+       devnum = blk_next_free_devnum(UCLASS_PVBLOCK);
        if (devnum < 0)
                return devnum;
        desc->devnum = devnum;
@@ -804,7 +804,7 @@ static void print_pvblock_devices(void)
        const char *class_name;
 
        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) {
                struct blk_desc *desc = dev_get_uclass_plat(udev);
 
index 0c498d9a46b51b9661327a5c9cef1b61a006ae4d..c28f4c6c6dc0f474d397eda1f76ac73e10d1d4a7 100644 (file)
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -143,7 +143,7 @@ static int mmc_set_env_part(struct mmc *mmc, uint part)
        int dev = mmc_get_env_dev();
        int ret = 0;
 
-       ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
+       ret = blk_select_hwpart_devnum(UCLASS_MMC, dev, part);
        if (ret)
                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
        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
 }
 
index cc30e3861fa084942230fd5f675b64c9052770ae..548cd09d6bb297664acbabf08b545472180d1017 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef BLK_H
 #define BLK_H
 
+#include <dm/uclass-id.h>
 #include <efi.h>
 
 #ifdef CONFIG_SYS_64BIT_LBA
@@ -27,22 +28,7 @@ static inline bool blk_enabled(void)
 }
 
 /* Interface types: */
-enum if_type {
-       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 if_type uclass_id
 
 #define BLK_VEN_SIZE           40
 #define BLK_PRD_SIZE           20
index f519d869725dfc6f9a3bc289a75b978654e80ecb..027e8bcc73a6b5af26b7b0fa994fa32b3d06eaf8 100644 (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
  *
- * 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
  *
  * @dev:       MMC device to set up
index d57d281f850a96ac52ffdeca3964355d2ee80b3d..3177ab67b81b1362d13ac99b369a4531a6fc9491 100644 (file)
@@ -128,7 +128,7 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
        if (!obj)
                return -ENOENT;
 
-       devnum = blk_find_max_devnum(IF_TYPE_EFI_LOADER);
+       devnum = blk_find_max_devnum(UCLASS_EFI_LOADER);
        if (devnum == -ENODEV)
                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);
 
        /* 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,
                                (lbaint_t)io->media->last_block, &bdev);
        if (ret)
index a34ca46a11eae61d8a94b306e95634f95234071b..819dcb4f131b25f653dc970ff0b7b0aa7a164fc4 100644 (file)
@@ -640,7 +640,7 @@ static int efi_disk_probe(void *ctx, struct event *event)
         * has already created an efi_disk at this moment.
         */
        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);
                if (ret)
                        return -1;
@@ -675,7 +675,7 @@ static int efi_disk_delete_raw(struct udevice *dev)
                return -1;
 
        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);
                efi_free_pool(diskobj->dp);
        }
index 85c3a3bd45ccc0be1726d80f0948c6f9773cbf5d..35bd5318f0bd703d21672314c1e21984b7ec785c 100644 (file)
@@ -25,19 +25,19 @@ static int dm_test_blk_base(struct unit_test_state *uts)
 
        /* Create two, one the parent of the other */
        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",
-                                     IF_TYPE_HOST, 3, 512, 2, &blk3));
+                                     UCLASS_ROOT, 3, 512, 2, &blk3));
 
        /* Check we can find them */
-       ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
-       ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
+       ut_asserteq(-ENODEV, blk_get_device(UCLASS_ROOT, 0, &dev));
+       ut_assertok(blk_get_device(UCLASS_ROOT, 1, &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);
 
        /* 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_assertok(blk_next_device(&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));
 
        /* 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));
 
        /* 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;
 
        ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
-                                     IF_TYPE_HOST, 1, 512, 2, &blk));
-       ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev));
-       ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev));
+                                     UCLASS_ROOT, 1, 512, 2, &blk));
+       ut_asserteq(-ENODEV, blk_find_device(UCLASS_ROOT, 0, &dev));
+       ut_assertok(blk_find_device(UCLASS_ROOT, 1, &dev));
        ut_asserteq_ptr(blk, dev);
        ut_asserteq(false, device_active(dev));
 
        /* 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(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 */
                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);
                ut_asserteq_ptr(parent, mmc_dev);
                ut_asserteq(trailing_strtol(mmc_dev->name), i);