All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/24] blk: Rationalise the block interface
@ 2022-08-12  1:34 Simon Glass
  2022-08-12  1:34 ` [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS Simon Glass
                   ` (24 more replies)
  0 siblings, 25 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Alexander Graf, Alexandru Gagniuc, Alexey Brodkin,
	Alper Nebi Yasak, Anastasiia Lukianenko, Andrew Davis,
	Andrew Scull, Ashok Reddy Soma, Aswath Govindraju, Bharat Gooty,
	Bin Meng, Chris Morgan, Denys Drozdov, Francesco Dolcini,
	Gary Bisson, Heiko Schocher, Huang Jianan, Ilias Apalodimas,
	Jaehoon Chung, Jens Wiklander, Joe Hershberger, Judy Wang,
	Loic Poulain, Lukasz Majewski, Marcel Ziswiler, Marek Behún,
	Marek Vasut, Mark Kettenis, Markus Niebel, Masahisa Kojima,
	Max Merchel, Michal Simek, Oleksandr Andrushchenko,
	Oleksandr Suvorov, Oleksii Bidnichenko, Ovidiu Panait,
	Pali Rohár, Patrice Chotard, Patrick Delaunay, Peng Fan,
	Philippe Reynes, Philippe Schenker, Ramon Fried,
	Rayagonda Kokatanur, Ricardo Salveti, Rick Chen, Sean Anderson,
	Stefan Roese, Tony Dinh, TsiChung Liew, Wolfgang Denk, Ye Li,
	Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32

The block interface has two separate implementations, one using driver
model and one not. The latter is really only needed for SPL, where
size constraints allegedly don't allow use of driver model. Of course
we still need space for filesystems and other code, so it isn't clear
that driver model is anything more than the straw that breaks the
camel's back.

The driver model version uses a uclass ID for the interface time, but
converts back and forth between that and if_type, which is the legacy
type.

The HAVE_BLOCK_DEVICE define is mostly a hangover from the old days.
At present its main purpose is to enable the legacy block implementation
in SPL.

Finally the use of 'select' to enable BLK does not work very well. It
causes kconfig errors when another option depends on BLK and it is
not recommended by the kconfig style guide.

This series aims to clean things up:
- Enable BLK based on whether different media types are used, but still
  allow boards to disable it
- Rename HAVE_BLOCK_DEVICE to indicates its real purpose
- Drop if_type and use the uclass instead
- Drop some obsolete if_type values

An issue not resolved by this series is that the sandbox host interface
does not actually have a device. At present it uses the root device, which
was convenience for the driver model conversion but not really correct. It
should be possible to clean this up, in a future series.

Another minor issue is the use of UCLASS_USB for a mass-storage device.
This has been the case for a while and is not addresed by this series,
other than to add a comment.

Note that this test relies on Tom Rini's series to drop various boards
including warp and cm_t335

Finally, a patch is included to make binman put fake files in a
subdirectory, since repeated runs of certain boards can cause unrelated
failues (e.g. chromebook_coral) when fake files are left around.

Changes in v2:
- Update commit message
- Fix SPL_PARTITIONS too
- Add SATA also
- Refer to a suffix, not a prefix
- Add new patch to handle UCLASS_EFI_MEDIA in dev_print()
- Add new patch to drop ifname field from struct efi_disk_obj
- Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()

Simon Glass (24):
  disk: Correct help for TPL_PARTITIONS
  blk: Enable CONFIG_BLK for all media
  ata: Fix an instance of SPL_SATA_SUPPORT
  sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig
  disk: Use Makefile to omit partition drivers
  blk: Use a function for whether block devices are available
  cmd: Drop use of HAVE_BLOCK_DEVICE
  blk: Drop unnecessary #ifdef in in blk_legacy
  blk: Rename HAVE_BLOCK_DEVICE
  blk: Select SPL_LEGACY_BLOCK automatically
  blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs
  blk: Hide the BLK and SPL_LEGACY_BLOCK options
  blk: Drop IF_TYPE_DOC
  ide: Use a flag for an ATAPI device
  blk: Drop IF_TYPE_ATAPI
  blk: Drop IF_TYPE_SD
  blk: Rename var in blk_get_devnum_by_typename()
  blk: Rewrite if_type to name functions
  efi: Correct assumption about if_type
  blk: Switch over to using uclass IDs
  disk: Handle UCLASS_EFI_MEDIA in dev_print()
  blk: Drop if_type
  efi: Drop ifname field from struct efi_disk_obj
  blk: Rename if_type to uclass_id

 arch/Kconfig                                  |   1 -
 arch/arm/Kconfig                              |   1 -
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    |   4 +-
 board/st/common/stm32mp_dfu.c                 |   2 +-
 board/toradex/common/tdx-cfg-block.c          |   4 +-
 cmd/Kconfig                                   |   5 -
 cmd/Makefile                                  |   2 +-
 cmd/bcb.c                                     |   4 +-
 cmd/blk_common.c                              |  18 +-
 cmd/ide.c                                     |   2 +-
 cmd/lsblk.c                                   |   2 +-
 cmd/mmc.c                                     |  10 +-
 cmd/mvebu/bubt.c                              |   2 +-
 cmd/nvme.c                                    |   4 +-
 cmd/pvblock.c                                 |   2 +-
 cmd/sata.c                                    |   4 +-
 cmd/scsi.c                                    |   2 +-
 cmd/usb.c                                     |   2 +-
 cmd/virtio.c                                  |   2 +-
 common/spl/Kconfig                            |   2 -
 common/spl/spl_sata.c                         |   2 +-
 common/spl/spl_usb.c                          |   2 +-
 common/usb_storage.c                          |  10 +-
 configs/M5253DEMO_defconfig                   |   1 +
 configs/axm_defconfig                         |   1 -
 configs/bcm968380gerg_ram_defconfig           |   1 -
 .../gardena-smart-gateway-mt7688_defconfig    |   1 -
 configs/nsim_hs38_defconfig                   |   1 -
 configs/qemu-ppce500_defconfig                |   1 -
 disk/Kconfig                                  |   8 +-
 disk/Makefile                                 |   4 +
 disk/disk-uclass.c                            |  11 +-
 disk/part.c                                   | 161 ++++++-------
 disk/part_amiga.c                             |   4 -
 disk/part_dos.c                               |   4 -
 disk/part_efi.c                               |   3 -
 disk/part_iso.c                               |   3 -
 disk/part_mac.c                               |   3 -
 doc/develop/driver-model/migration.rst        |   2 +-
 doc/develop/uefi/uefi.rst                     |   2 +-
 doc/usage/partitions.rst                      |   2 +-
 drivers/Makefile                              |   3 +-
 drivers/ata/Kconfig                           |   4 +-
 drivers/ata/dwc_ahsata.c                      |   2 +-
 drivers/ata/fsl_sata.c                        |   2 +-
 drivers/ata/sata.c                            |   2 +-
 drivers/ata/sata_mv.c                         |   2 +-
 drivers/ata/sata_sil.c                        |   2 +-
 drivers/block/Kconfig                         |  20 +-
 drivers/block/Makefile                        |   2 +-
 drivers/block/blk-uclass.c                    | 219 +++++++++---------
 drivers/block/blk_legacy.c                    |  60 +++--
 drivers/block/efi_blk.c                       |   2 +-
 drivers/block/ide.c                           |  16 +-
 drivers/block/sandbox.c                       |  14 +-
 drivers/dfu/dfu_mmc.c                         |   6 +-
 drivers/mmc/Kconfig                           |   1 -
 drivers/mmc/mmc-uclass.c                      |  12 +-
 drivers/mmc/mmc_legacy.c                      |   8 +-
 drivers/mmc/mmc_write.c                       |   4 +-
 drivers/net/fsl_enetc.c                       |  12 +-
 drivers/net/fsl_enetc.h                       |   2 +-
 drivers/nvme/Kconfig                          |   2 -
 drivers/nvme/nvme.c                           |   2 +-
 drivers/scsi/Kconfig                          |   2 -
 drivers/scsi/scsi.c                           |  12 +-
 drivers/tee/optee/rpmb.c                      |   4 +-
 drivers/virtio/Kconfig                        |   1 -
 drivers/virtio/virtio_blk.c                   |   4 +-
 drivers/xen/Kconfig                           |   1 -
 drivers/xen/pvblock.c                         |   6 +-
 env/mmc.c                                     |   4 +-
 fs/fat/fat.c                                  |   4 +-
 include/blk.h                                 | 141 +++++------
 include/efi_api.h                             |   4 +-
 include/efi_loader.h                          |   4 +-
 include/mmc.h                                 |   2 +-
 lib/efi_driver/efi_block_device.c             |   4 +-
 lib/efi_loader/Kconfig                        |   1 -
 lib/efi_loader/efi_device_path.c              |   2 +-
 lib/efi_loader/efi_device_path_to_text.c      |   4 +-
 lib/efi_loader/efi_disk.c                     |  28 ++-
 lib/efi_loader/efi_net.c                      |   2 +-
 lib/efi_loader/efi_var_file.c                 |   4 +-
 test/dm/blk.c                                 |  24 +-
 85 files changed, 444 insertions(+), 515 deletions(-)

-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-09-16 19:37   ` Tom Rini
  2022-08-12  1:34 ` [PATCH v2 02/24] blk: Enable CONFIG_BLK for all media Simon Glass
                   ` (23 subsequent siblings)
  24 siblings, 1 reply; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Pali Rohár, Stefan Roese

Fix a few typos in this help text. Fix a typo in SPL_PARTITIONS while
we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Update commit message
- Fix SPL_PARTITIONS too

 disk/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/disk/Kconfig b/disk/Kconfig
index 81d8867ed7f..c9b9dbaf1a6 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -24,7 +24,7 @@ config SPL_PARTITIONS
 	select SPL_STRTO
 	help
 	  Enable this for base partition support in SPL. The required
-	  partition table types shold be enabled separately. This add a
+	  partition table types shold be enabled separately. This adds a
 	  small amount of size to SPL, typically 500 bytes.
 
 config TPL_PARTITIONS
@@ -32,9 +32,9 @@ config TPL_PARTITIONS
 	select TPL_SPRINTF
 	select TPL_STRTO
 	help
-	  Enable this for base partition support in SPL. The required
-	  partition table types shold be enabled separately. This add a
-	  small amount of size to SPL, typically 500 bytes.
+	  Enable this for base partition support in TPL. The required
+	  partition table types shold be enabled separately. This adds a
+	  small amount of size to TPL, typically 500 bytes.
 
 config MAC_PARTITION
 	bool "Enable Apple's MacOS partition table"
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 02/24] blk: Enable CONFIG_BLK for all media
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
  2022-08-12  1:34 ` [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 03/24] ata: Fix an instance of SPL_SATA_SUPPORT Simon Glass
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Bharat Gooty,
	Bin Meng, Michal Simek, Pali Rohár, Rayagonda Kokatanur,
	Stefan Roese, TsiChung Liew

Enable this option on all boards which support block devices. Drop the
related depencies on BLK since these are not needed anymore.

Disable BLOCK_CACHE on M5253DEMO as this causes a build error.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add SATA also

 arch/arm/Kconfig            | 1 -
 configs/M5253DEMO_defconfig | 1 +
 drivers/ata/Kconfig         | 1 -
 drivers/block/Kconfig       | 3 ++-
 drivers/nvme/Kconfig        | 1 -
 drivers/scsi/Kconfig        | 1 -
 drivers/virtio/Kconfig      | 1 -
 7 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 949ebb46ba2..3cb949af165 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1016,7 +1016,6 @@ config ARCH_NPCM
 config ARCH_APPLE
 	bool "Apple SoCs"
 	select ARM64
-	select BLK
 	select CLK
 	select CMD_USB
 	select DM
diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
index 79382eb0fe4..a73aca082c3 100644
--- a/configs/M5253DEMO_defconfig
+++ b/configs/M5253DEMO_defconfig
@@ -25,6 +25,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_FAT=y
 CONFIG_MAC_PARTITION=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+# CONFIG_BLOCK_CACHE is not set
 CONFIG_SYS_IDE_MAXBUS=1
 CONFIG_SYS_ATA_STRIDE=4
 CONFIG_SYS_ATA_DATA_OFFSET=0xA0
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 7715c403656..7d2315bd4a2 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,7 +9,6 @@ config AHCI
 
 config SATA
 	bool "Support SATA controllers"
-	depends on BLK
 	select HAVE_BLOCK_DEVICE
 	help
 	  This enables support for SATA (Serial Advanced Technology
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index b5b482086af..df242df9c5f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,7 +1,8 @@
 config BLK
 	bool "Support block devices"
 	depends on DM
-	default y if DM_MMC || DM_USB
+	default y if MMC || USB || SCSI || NVME || IDE || AHCI || SATA
+	default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
 	help
 	  Enable support for block devices, such as SCSI, MMC and USB
 	  flash sticks. These provide a block-level interface which permits
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 0cb465160bb..2a103ab5ed7 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,7 +4,6 @@
 
 config NVME
 	bool "NVM Express device support"
-	depends on BLK
 	select HAVE_BLOCK_DEVICE
 	help
 	  This option enables support for NVM Express devices.
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index c400e2de16a..19872fb52d8 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -10,7 +10,6 @@ config SCSI
 
 config DM_SCSI
 	bool "Support SCSI controllers with driver model"
-	depends on BLK
 	help
 	  This option enables the SCSI (Small Computer System Interface) uclass
 	  which supports SCSI and SATA HDDs. For every device configuration
diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 586263ec884..852f6735b60 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -64,7 +64,6 @@ config VIRTIO_NET
 config VIRTIO_BLK
 	bool "virtio block driver"
 	depends on VIRTIO
-	depends on BLK
 	help
 	  This is the virtual block driver for virtio. It can be used with
 	  QEMU based targets.
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 03/24] ata: Fix an instance of SPL_SATA_SUPPORT
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
  2022-08-12  1:34 ` [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS Simon Glass
  2022-08-12  1:34 ` [PATCH v2 02/24] blk: Enable CONFIG_BLK for all media Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 04/24] sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig Simon Glass
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Pali Rohár,
	Stefan Roese

The _SUPPORT suffix should be dropped. This happened because the rename
was applied around the same time as this new option, so did not include
renaming the new option.

The relevant commits are:

   f7560376ae sata: Rename SATA_SUPPORT to SATA
   73059529b2 ata: ahci-pci: Add new option CONFIG_SPL_AHCI_PCI

Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Refer to a suffix, not a prefix

 drivers/ata/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 7d2315bd4a2..70e6bd321a6 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -47,7 +47,7 @@ config SPL_AHCI_PCI
 	bool "Support for PCI-based AHCI controller for SPL"
 	depends on SPL
 	depends on SPL_PCI
-	depends on SPL_SATA_SUPPORT && DM_SCSI
+	depends on SPL_SATA && DM_SCSI
 
 config DWC_AHCI
 	bool "Enable Synopsys DWC AHCI driver support"
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 04/24] sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (2 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 03/24] ata: Fix an instance of SPL_SATA_SUPPORT Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 05/24] disk: Use Makefile to omit partition drivers Simon Glass
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Michal Simek,
	Rick Chen, Sean Anderson

This is not needed as it is implied or selected by other options anyway.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 6495e780fec..d3c5d86fb5b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -144,7 +144,6 @@ config SANDBOX
 	select DM_SPI
 	select DM_SPI_FLASH
 	select GZIP_COMPRESSED
-	select HAVE_BLOCK_DEVICE
 	select LZO
 	select OF_BOARD_SETUP
 	select PCI_ENDPOINT
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 05/24] disk: Use Makefile to omit partition drivers
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (3 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 04/24] sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 06/24] blk: Use a function for whether block devices are available Simon Glass
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Andrew Scull, Jaehoon Chung, Mark Kettenis, Peng Fan,
	Philippe Reynes, Wolfgang Denk, Ye Li

At present these files have an #ifdef covering the whole file. Move the
condition to the Makefile instead.

Add BLK to the condition since future patches will adjust things so that
HAVE_BLOCK_DEVICE is only for SPL, but the partition drivers are needed
in U-Boot proper too.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 disk/Makefile     | 4 ++++
 disk/part_amiga.c | 4 ----
 disk/part_dos.c   | 4 ----
 disk/part_efi.c   | 3 ---
 disk/part_iso.c   | 3 ---
 disk/part_mac.c   | 3 ---
 drivers/Makefile  | 1 +
 7 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/disk/Makefile b/disk/Makefile
index ec148832b33..458e21e3fb7 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -9,8 +9,12 @@ obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += part.o
 ifdef CONFIG_$(SPL_TPL_)BLK
 obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
 endif
+
+# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
+ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
 obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
 obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
 obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
 obj-$(CONFIG_$(SPL_TPL_)AMIGA_PARTITION) += part_amiga.o
 obj-$(CONFIG_$(SPL_TPL_)EFI_PARTITION)   += part_efi.o
+endif
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index ac7ada54781..45d3a704866 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -11,8 +11,6 @@
 #include "part_amiga.h"
 #include <part.h>
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 #undef AMIGA_DEBUG
 
 #ifdef AMIGA_DEBUG
@@ -387,5 +385,3 @@ U_BOOT_PART_TYPE(amiga) = {
 	.print		= part_print_amiga,
 	.test		= part_test_amiga,
 };
-
-#endif
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 94fae7166d7..a94702c5f34 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -23,8 +23,6 @@
 #include "part_dos.h"
 #include <part.h>
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 #define DOS_PART_DEFAULT_SECTOR 512
 
 /* should this be configurable? It looks like it's not very common at all
@@ -518,5 +516,3 @@ U_BOOT_PART_TYPE(dos) = {
 	.print		= part_print_ptr(part_print_dos),
 	.test		= part_test_dos,
 };
-
-#endif
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 5090efd1192..ad94504ed90 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -28,8 +28,6 @@
 #include <linux/ctype.h>
 #include <u-boot/crc.h>
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* GUID for basic data partitons */
 #if CONFIG_IS_ENABLED(EFI_PARTITION)
 static const efi_guid_t partition_basic_data_guid = PARTITION_BASIC_DATA_GUID;
@@ -1204,4 +1202,3 @@ U_BOOT_PART_TYPE(a_efi) = {
 	.print		= part_print_ptr(part_print_efi),
 	.test		= part_test_efi,
 };
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
diff --git a/disk/part_iso.c b/disk/part_iso.c
index 1061f341d35..4cd619bf46d 100644
--- a/disk/part_iso.c
+++ b/disk/part_iso.c
@@ -12,8 +12,6 @@
 #include <asm/unaligned.h>
 #include "part_iso.h"
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* #define	ISO_PART_DEBUG */
 
 #ifdef	ISO_PART_DEBUG
@@ -241,4 +239,3 @@ U_BOOT_PART_TYPE(iso) = {
 	.print		= part_print_iso,
 	.test		= part_test_iso,
 };
-#endif
diff --git a/disk/part_mac.c b/disk/part_mac.c
index e01ae745661..ae8263f755a 100644
--- a/disk/part_mac.c
+++ b/disk/part_mac.c
@@ -20,8 +20,6 @@
 #include "part_mac.h"
 #include <part.h>
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-
 /* stdlib.h causes some compatibility problems; should fixe these! -- wd */
 #ifndef __ldiv_t_defined
 typedef struct {
@@ -247,4 +245,3 @@ U_BOOT_PART_TYPE(mac) = {
 	.print		= part_print_mac,
 	.test		= part_test_mac,
 };
-#endif
diff --git a/drivers/Makefile b/drivers/Makefile
index eba9940231f..f2154e15d6a 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_SPL_USB_HOST) += usb/host/
 obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
 obj-$(CONFIG_SPL_SATA) += ata/ scsi/
 obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
+obj-$(CONFIG_SPL_BLK) += block/
 obj-$(CONFIG_SPL_THERMAL) += thermal/
 
 endif
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 06/24] blk: Use a function for whether block devices are available
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (4 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 05/24] disk: Use Makefile to omit partition drivers Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 07/24] cmd: Drop use of HAVE_BLOCK_DEVICE Simon Glass
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Marcel Ziswiler, Masahisa Kojima, Oleksandr Suvorov,
	Oleksii Bidnichenko, Ricardo Salveti, Sean Anderson, schspa

At present we use HAVE_BLOCK_DEVICE to indicate when block devices are
available.

This is a very strange option, since it partially duplicates the BLK
option used by driver model. It also covers both U-Boot proper and SPL,
even though one might have block devices and another not.

As a first step towards correcting this, create a new inline function
called blk_enabled() which indicates if block devices are available.
This cannot be used in Makefiles, or #if clauses, but can be used in C
code.

A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to
decide if block devices are needed, since we must consider the legacy
block interface, enabled by HAVE_BLOCK_DEVICE

Update a few places where it can be used and drop some unnecessary #if
checks around some functions in disk/part.c - rely on the compiler's
dead-code elimination instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 disk/part.c                | 80 ++++++++++++++++----------------------
 drivers/block/blk-uclass.c |  3 +-
 fs/fat/fat.c               |  2 +-
 include/blk.h              |  5 +++
 4 files changed, 40 insertions(+), 50 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 79955c7fb00..9594bb432c4 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,12 +54,13 @@ static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
 	return NULL;
 }
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
 	struct blk_desc *dev_desc;
 	int ret;
 
+	if (!blk_enabled())
+		return NULL;
 	dev_desc = blk_get_devnum_by_typename(ifname, dev);
 	if (!dev_desc) {
 		debug("%s: No device for iface '%s', dev %d\n", __func__,
@@ -78,21 +79,11 @@ static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 
 struct blk_desc *blk_get_dev(const char *ifname, int dev)
 {
-	return get_dev_hwpart(ifname, dev, 0);
-}
-#else
-struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
-{
-	return NULL;
-}
+	if (!blk_enabled())
+		return NULL;
 
-struct blk_desc *blk_get_dev(const char *ifname, int dev)
-{
-	return NULL;
+	return get_dev_hwpart(ifname, dev, 0);
 }
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 
 /* ------------------------------------------------------------------------- */
 /*
@@ -228,9 +219,6 @@ void dev_print (struct blk_desc *dev_desc)
 		puts ("            Capacity: not available\n");
 	}
 }
-#endif
-
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 
 void part_init(struct blk_desc *dev_desc)
 {
@@ -325,38 +313,36 @@ void part_print(struct blk_desc *dev_desc)
 		drv->print(dev_desc);
 }
 
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
-
 int part_get_info(struct blk_desc *dev_desc, int part,
 		       struct disk_partition *info)
 {
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 	struct part_driver *drv;
 
+	if (blk_enabled()) {
 #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
-	/* The common case is no UUID support */
-	info->uuid[0] = 0;
+		/* The common case is no UUID support */
+		info->uuid[0] = 0;
 #endif
 #ifdef CONFIG_PARTITION_TYPE_GUID
-	info->type_guid[0] = 0;
+		info->type_guid[0] = 0;
 #endif
 
-	drv = part_driver_lookup_type(dev_desc);
-	if (!drv) {
-		debug("## Unknown partition table type %x\n",
-		      dev_desc->part_type);
-		return -EPROTONOSUPPORT;
-	}
-	if (!drv->get_info) {
-		PRINTF("## Driver %s does not have the get_info() method\n",
-		       drv->name);
-		return -ENOSYS;
-	}
-	if (drv->get_info(dev_desc, part, info) == 0) {
-		PRINTF("## Valid %s partition found ##\n", drv->name);
-		return 0;
+		drv = part_driver_lookup_type(dev_desc);
+		if (!drv) {
+			debug("## Unknown partition table type %x\n",
+			      dev_desc->part_type);
+			return -EPROTONOSUPPORT;
+		}
+		if (!drv->get_info) {
+			PRINTF("## Driver %s does not have the get_info() method\n",
+			       drv->name);
+			return -ENOSYS;
+		}
+		if (drv->get_info(dev_desc, part, info) == 0) {
+			PRINTF("## Valid %s partition found ##\n", drv->name);
+			return 0;
+		}
 	}
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
 
 	return -ENOENT;
 }
@@ -424,15 +410,15 @@ int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
 		goto cleanup;
 	}
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
-	/*
-	 * Updates the partition table for the specified hw partition.
-	 * 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)
-		part_init(*dev_desc);
-#endif
+	if (blk_enabled()) {
+		/*
+		 * Updates the partition table for the specified hw partition.
+		 * 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)
+			part_init(*dev_desc);
+	}
 
 cleanup:
 	free(dup_str);
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 21c5209bb63..1a6e8f8c29d 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -743,8 +743,7 @@ int blk_unbind_all(int if_type)
 
 static int blk_post_probe(struct udevice *dev)
 {
-	if (CONFIG_IS_ENABLED(PARTITIONS) &&
-	    IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) {
+	if (CONFIG_IS_ENABLED(PARTITIONS) && blk_enabled()) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
 		part_init(desc);
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index df9ea2c028f..c64e253abd4 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1144,7 +1144,7 @@ int file_fat_detectfs(void)
 		return 1;
 	}
 
-	if (IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) {
+	if (blk_enabled()) {
 		printf("Interface:  %s\n", blk_get_if_type_name(cur_dev->if_type));
 		printf("  Device %d: ", cur_dev->devnum);
 		dev_print(cur_dev);
diff --git a/include/blk.h b/include/blk.h
index 9503369db83..332481a90b8 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -21,6 +21,11 @@ typedef ulong lbaint_t;
 
 struct udevice;
 
+static inline bool blk_enabled(void)
+{
+	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE);
+}
+
 /* Interface types: */
 enum if_type {
 	IF_TYPE_UNKNOWN = 0,
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 07/24] cmd: Drop use of HAVE_BLOCK_DEVICE
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (5 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 06/24] blk: Use a function for whether block devices are available Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 08/24] blk: Drop unnecessary #ifdef in in blk_legacy Simon Glass
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Ashok Reddy Soma,
	Chris Morgan, Huang Jianan, Ilias Apalodimas, Masahisa Kojima,
	Michal Simek, Ovidiu Panait, Pali Rohár, Ramon Fried

This condition is not needed for these commands, since BLK is enabled for
all boards which use block devices and commands are not available in SPL,
so even if SPL_BLK is not enabled, it doesn't affect commands.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 cmd/Kconfig  | 5 -----
 cmd/Makefile | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 7d19706a8ec..e5ea4e188ab 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1082,7 +1082,6 @@ config CMD_PWM
 config CMD_GPT
 	bool "GPT (GUID Partition Table) command"
 	select EFI_PARTITION
-	select HAVE_BLOCK_DEVICE
 	select PARTITION_UUIDS
 	imply RANDOM_UUID
 	help
@@ -1194,7 +1193,6 @@ config CMD_LSBLK
 config CMD_MBR
 	bool "MBR (Master Boot Record) command"
 	select DOS_PARTITION
-	select HAVE_BLOCK_DEVICE
 	help
 	  Enable the 'mbr' command to ready and write MBR (Master Boot Record)
 	  style partition tables.
@@ -1326,7 +1324,6 @@ config CMD_OSD
 config CMD_PART
 	bool "part"
 	depends on PARTITIONS
-	select HAVE_BLOCK_DEVICE
 	select PARTITION_UUIDS
 	help
 	  Read and display information about the partition table on
@@ -1457,7 +1454,6 @@ config CMD_UNIVERSE
 config CMD_USB
 	bool "usb"
 	depends on USB_HOST
-	select HAVE_BLOCK_DEVICE
 	help
 	  USB support.
 
@@ -1497,7 +1493,6 @@ config CMD_PVBLOCK
 config CMD_VIRTIO
 	bool "virtio"
 	depends on VIRTIO
-	depends on HAVE_BLOCK_DEVICE
 	default y if VIRTIO
 	help
 	  VirtIO block device support
diff --git a/cmd/Makefile b/cmd/Makefile
index 5e43a1e022e..9314640b674 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -18,7 +18,7 @@ obj-$(CONFIG_CMD_AES) += aes.o
 obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
 obj-$(CONFIG_CMD_ADC) += adc.o
 obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o
+obj-$(CONFIG_BLK) += blk_common.o
 obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o
 obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o
 obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 08/24] blk: Drop unnecessary #ifdef in in blk_legacy
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (6 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 07/24] cmd: Drop use of HAVE_BLOCK_DEVICE Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE Simon Glass
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Tom Rini, Heinrich Schuchardt, Simon Glass

We can rely on the compiler to eliminate any dead code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/block/blk_legacy.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index df9a3597545..bd8a17df6a9 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -70,7 +70,6 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
 	return drv->get_dev(devnum, descp);
 }
 
-#ifdef CONFIG_HAVE_BLOCK_DEVICE
 int blk_list_part(enum if_type if_type)
 {
 	struct blk_driver *drv;
@@ -174,7 +173,6 @@ int blk_show_device(enum if_type if_type, int devnum)
 
 	return 0;
 }
-#endif /* CONFIG_HAVE_BLOCK_DEVICE */
 
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 {
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (7 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 08/24] blk: Drop unnecessary #ifdef in in blk_legacy Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-09-14  1:42   ` AKASHI Takahiro
  2022-08-12  1:34 ` [PATCH v2 10/24] blk: Select SPL_LEGACY_BLOCK automatically Simon Glass
                   ` (15 subsequent siblings)
  24 siblings, 1 reply; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Alexander Graf, Alexandru Gagniuc, Alexey Brodkin,
	Alper Nebi Yasak, Anastasiia Lukianenko, Andrew Davis,
	Andrew Scull, Bin Meng, Heiko Schocher, Ilias Apalodimas,
	Jaehoon Chung, Mark Kettenis, Masahisa Kojima, Michal Simek,
	Oleksandr Andrushchenko, Pali Rohár, Peng Fan,
	Philippe Reynes, Stefan Roese, Wolfgang Denk, Ye Li

This option is fact really related to SPL. For U-Boot proper we always use
driver model for block devices, so CONFIG_BLK is enabled if block devices
are in use.

It is only for SPL that we have two cases:

- SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
- SPL_BLK is not enabled, in which case (if we need block devices) we must
  use blk_legacy.c

Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
different enough from BLK and SPL_BLK that there should be no confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/Kconfig                             | 4 ++--
 configs/axm_defconfig                          | 2 +-
 configs/bcm968380gerg_ram_defconfig            | 2 +-
 configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
 configs/nsim_hs38_defconfig                    | 2 +-
 configs/qemu-ppce500_defconfig                 | 2 +-
 disk/Makefile                                  | 4 ++--
 disk/disk-uclass.c                             | 3 +--
 doc/develop/driver-model/migration.rst         | 2 +-
 drivers/Makefile                               | 2 +-
 drivers/ata/Kconfig                            | 2 +-
 drivers/block/Kconfig                          | 8 ++++----
 drivers/block/Makefile                         | 2 +-
 drivers/mmc/Kconfig                            | 2 +-
 drivers/nvme/Kconfig                           | 2 +-
 drivers/scsi/Kconfig                           | 2 +-
 drivers/xen/Kconfig                            | 2 +-
 include/blk.h                                  | 2 +-
 lib/efi_loader/Kconfig                         | 2 +-
 19 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ee98810e9e9..4c3e74ae5eb 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
 config SPL_MMC
 	bool "Support MMC"
 	depends on MMC
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  Enable support for MMC (Multimedia Card) within SPL. This enables
 	  the MMC protocol implementation and allows any enabled drivers to
@@ -1318,7 +1318,7 @@ config SPL_THERMAL
 
 config SPL_USB_HOST
 	bool "Support USB host drivers"
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  Enable access to USB (Universal Serial Bus) host devices so that
 	  SPL can load U-Boot from a connected USB peripheral, such as a USB
diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index a5f60bd8d0c..c42fb37d6c9 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM=y
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GPIO=y
diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
index 0475535e991..246add6029c 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_NET is not set
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BCM6345_GPIO=y
 CONFIG_LED=y
 CONFIG_LED_BCM6328=y
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
index b9ee281be9f..fdfab14d53e 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 3c3d1812a79..3f23fc4189f 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_DM_ETH=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
index 034f7e6935b..3241f5520eb 100644
--- a/configs/qemu-ppce500_defconfig
+++ b/configs/qemu-ppce500_defconfig
@@ -40,7 +40,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
 CONFIG_BLK=y
-CONFIG_HAVE_BLOCK_DEVICE=y
+CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_LBA48=y
 CONFIG_CHIP_SELECTS_PER_CTRL=0
 CONFIG_MPC8XXX_GPIO=y
diff --git a/disk/Makefile b/disk/Makefile
index 458e21e3fb7..45588cf66e4 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -10,8 +10,8 @@ ifdef CONFIG_$(SPL_TPL_)BLK
 obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
 endif
 
-# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
-ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
+# Must have BLK or SPL_LEGACY_BLOCK to support partitions
+ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_SPL_LEGACY_BLOCK),)
 obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
 obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
 obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
index f3fb942a6b9..9351a5cfa68 100644
--- a/disk/disk-uclass.c
+++ b/disk/disk-uclass.c
@@ -27,8 +27,7 @@ int part_create_block_devices(struct udevice *blk_dev)
 	struct udevice *dev;
 	int ret;
 
-	if (!CONFIG_IS_ENABLED(PARTITIONS) ||
-	    !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
+	if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
 		return 0;
 
 	if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst
index 5a604369258..742fea5515c 100644
--- a/doc/develop/driver-model/migration.rst
+++ b/doc/develop/driver-model/migration.rst
@@ -57,7 +57,7 @@ In concert with maintainers migrating their block device usage to the
 appropriate DM driver, CONFIG_BLK needs to be set as well.  The final deadline
 here coincides with the final deadline for migration of the various block
 subsystems.  At this point we will be able to audit and correct the logic in
-Kconfig around using CONFIG_PARTITIONS and CONFIG_HAVE_BLOCK_DEVICE and make
+Kconfig around using CONFIG_PARTITIONS and CONFIG_SPL_LEGACY_BLOCK and make
 use of CONFIG_BLK / CONFIG_SPL_BLK as needed.
 
 CONFIG_DM_SPI / CONFIG_DM_SPI_FLASH
diff --git a/drivers/Makefile b/drivers/Makefile
index f2154e15d6a..9d9f69a3c9a 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -59,7 +59,7 @@ obj-$(CONFIG_SPL_WATCHDOG) += watchdog/
 obj-$(CONFIG_SPL_USB_HOST) += usb/host/
 obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
 obj-$(CONFIG_SPL_SATA) += ata/ scsi/
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
+obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
 obj-$(CONFIG_SPL_BLK) += block/
 obj-$(CONFIG_SPL_THERMAL) += thermal/
 
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 70e6bd321a6..c3f2ac058a3 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,7 +9,7 @@ config AHCI
 
 config SATA
 	bool "Support SATA controllers"
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  This enables support for SATA (Serial Advanced Technology
 	  Attachment), a serial bus standard for connecting to hard drives and
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index df242df9c5f..5a0c434058a 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -11,7 +11,7 @@ config BLK
 	  be partitioned into several areas, called 'partitions' in U-Boot.
 	  A filesystem can be placed in each partition.
 
-config HAVE_BLOCK_DEVICE
+config SPL_LEGACY_BLOCK
 	bool "Enable Legacy Block Device"
 	help
 	  Some devices require block support whether or not DM is enabled
@@ -109,7 +109,7 @@ endif  # EFI_MEDIA
 
 config IDE
 	bool "Support IDE controllers"
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  Enables support for IDE (Integrated Drive Electronics) hard drives.
 	  This allows access to raw blocks and filesystems on an IDE drive
@@ -222,7 +222,7 @@ endif  # IDE
 
 config LBA48
 	bool "Enable LBA support for disks larger than 137GB"
-	depends on HAVE_BLOCK_DEVICE
+	depends on SPL_LEGACY_BLOCK
 	help
 	  Set this to enable support for disks larger than 137GB.
 	  Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
@@ -231,7 +231,7 @@ config LBA48
 
 config SYS_64BIT_LBA
 	bool "Enable 64bit number of blocks on a block device"
-	depends on HAVE_BLOCK_DEVICE
+	depends on SPL_LEGACY_BLOCK
 	help
 	  Make the block subsystem use 64bit sector addresses, rather than the
 	  default of 32bit.
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index b221a7c6eea..f48d3e12140 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -6,7 +6,7 @@
 obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_$(SPL_)BLK
-obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_legacy.o
+obj-$(CONFIG_SPL_LEGACY_BLOCK) += blk_legacy.o
 endif
 
 ifndef CONFIG_SPL_BUILD
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index c5e1a1b0981..d45ad1a541d 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -3,7 +3,7 @@ menu "MMC Host controller Support"
 config MMC
 	bool "MMC/SD/SDIO card support"
 	default ARM || PPC || SANDBOX
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	select DM_MMC if DM
 	help
 	  This selects MultiMediaCard, Secure Digital and Secure
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 2a103ab5ed7..7b6d54615f8 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,7 +4,7 @@
 
 config NVME
 	bool "NVM Express device support"
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  This option enables support for NVM Express devices.
 	  It supports basic functions of NVMe (read/write).
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 19872fb52d8..4d643816fcc 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1,6 +1,6 @@
 config SCSI
 	bool "Support SCSI controllers"
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  This enables support for SCSI (Small Computer System Interface),
 	  a parallel interface widely used with storage peripherals such as
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 6ad2a936682..20db2c53065 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -2,7 +2,7 @@ config PVBLOCK
 	bool "Xen para-virtualized block device"
 	depends on DM
 	select BLK
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	help
 	  This driver implements the front-end of the Xen virtual
 	  block device driver. It communicates with a back-end driver
diff --git a/include/blk.h b/include/blk.h
index 332481a90b8..5bdffe74015 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -23,7 +23,7 @@ struct udevice;
 
 static inline bool blk_enabled(void)
 {
-	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE);
+	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
 }
 
 /* Interface types: */
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index e3f2402d0e8..5feafc16820 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -20,7 +20,7 @@ config EFI_LOADER
 	select EVENT_DYNAMIC
 	select LIB_UUID
 	imply PARTITION_UUIDS
-	select HAVE_BLOCK_DEVICE
+	select SPL_LEGACY_BLOCK
 	select REGEX
 	imply FAT
 	imply FAT_WRITE
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 10/24] blk: Select SPL_LEGACY_BLOCK automatically
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (8 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 11/24] blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs Simon Glass
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Alexandru Gagniuc,
	Alper Nebi Yasak, Anastasiia Lukianenko, Andrew Davis, Bin Meng,
	Ilias Apalodimas, Jaehoon Chung, Michal Simek,
	Oleksandr Andrushchenko, Pali Rohár, Peng Fan, Stefan Roese

Selecting this option can be handled in the Kconfig option itself, as it
is with BLK. Update this an drop the various 'select' clauses.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/spl/Kconfig     |  2 --
 drivers/ata/Kconfig    |  1 -
 drivers/block/Kconfig  | 11 +++++++----
 drivers/mmc/Kconfig    |  1 -
 drivers/nvme/Kconfig   |  1 -
 drivers/scsi/Kconfig   |  1 -
 drivers/xen/Kconfig    |  1 -
 lib/efi_loader/Kconfig |  1 -
 8 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 4c3e74ae5eb..759fb468d1a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -792,7 +792,6 @@ config SPL_DM_MAILBOX
 config SPL_MMC
 	bool "Support MMC"
 	depends on MMC
-	select SPL_LEGACY_BLOCK
 	help
 	  Enable support for MMC (Multimedia Card) within SPL. This enables
 	  the MMC protocol implementation and allows any enabled drivers to
@@ -1318,7 +1317,6 @@ config SPL_THERMAL
 
 config SPL_USB_HOST
 	bool "Support USB host drivers"
-	select SPL_LEGACY_BLOCK
 	help
 	  Enable access to USB (Universal Serial Bus) host devices so that
 	  SPL can load U-Boot from a connected USB peripheral, such as a USB
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c3f2ac058a3..a063b221cd1 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -9,7 +9,6 @@ config AHCI
 
 config SATA
 	bool "Support SATA controllers"
-	select SPL_LEGACY_BLOCK
 	help
 	  This enables support for SATA (Serial Advanced Technology
 	  Attachment), a serial bus standard for connecting to hard drives and
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 5a0c434058a..e82a779e6b8 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -13,8 +13,14 @@ config BLK
 
 config SPL_LEGACY_BLOCK
 	bool "Enable Legacy Block Device"
+	depends on SPL && !DM_SPL
+	default y if SPL_MMC || SPL_USB_STORAGE || SCSI || NVME || IDE
+	default y if SPL_AHCI_PCI
 	help
-	  Some devices require block support whether or not DM is enabled
+	  Some devices require block support whether or not DM is enabled. This
+	  is only supported in SPL. With this, the blk uclass is not used, but
+	  instead a legacy implementation of block devices is used, with all
+	  devices consisting of 'struct blk_desc' records.
 
 config SPL_BLK
 	bool "Support block devices in SPL"
@@ -109,7 +115,6 @@ endif  # EFI_MEDIA
 
 config IDE
 	bool "Support IDE controllers"
-	select SPL_LEGACY_BLOCK
 	help
 	  Enables support for IDE (Integrated Drive Electronics) hard drives.
 	  This allows access to raw blocks and filesystems on an IDE drive
@@ -222,7 +227,6 @@ endif  # IDE
 
 config LBA48
 	bool "Enable LBA support for disks larger than 137GB"
-	depends on SPL_LEGACY_BLOCK
 	help
 	  Set this to enable support for disks larger than 137GB.
 	  Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
@@ -231,7 +235,6 @@ config LBA48
 
 config SYS_64BIT_LBA
 	bool "Enable 64bit number of blocks on a block device"
-	depends on SPL_LEGACY_BLOCK
 	help
 	  Make the block subsystem use 64bit sector addresses, rather than the
 	  default of 32bit.
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index d45ad1a541d..0679b7d9235 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -3,7 +3,6 @@ menu "MMC Host controller Support"
 config MMC
 	bool "MMC/SD/SDIO card support"
 	default ARM || PPC || SANDBOX
-	select SPL_LEGACY_BLOCK
 	select DM_MMC if DM
 	help
 	  This selects MultiMediaCard, Secure Digital and Secure
diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
index 7b6d54615f8..73edb355160 100644
--- a/drivers/nvme/Kconfig
+++ b/drivers/nvme/Kconfig
@@ -4,7 +4,6 @@
 
 config NVME
 	bool "NVM Express device support"
-	select SPL_LEGACY_BLOCK
 	help
 	  This option enables support for NVM Express devices.
 	  It supports basic functions of NVMe (read/write).
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 4d643816fcc..ad484ce8e88 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1,6 +1,5 @@
 config SCSI
 	bool "Support SCSI controllers"
-	select SPL_LEGACY_BLOCK
 	help
 	  This enables support for SCSI (Small Computer System Interface),
 	  a parallel interface widely used with storage peripherals such as
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 20db2c53065..0ee74d036c7 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -2,7 +2,6 @@ config PVBLOCK
 	bool "Xen para-virtualized block device"
 	depends on DM
 	select BLK
-	select SPL_LEGACY_BLOCK
 	help
 	  This driver implements the front-end of the Xen virtual
 	  block device driver. It communicates with a back-end driver
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 5feafc16820..4305839e5ec 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -20,7 +20,6 @@ config EFI_LOADER
 	select EVENT_DYNAMIC
 	select LIB_UUID
 	imply PARTITION_UUIDS
-	select SPL_LEGACY_BLOCK
 	select REGEX
 	imply FAT
 	imply FAT_WRITE
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 11/24] blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (9 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 10/24] blk: Select SPL_LEGACY_BLOCK automatically Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 12/24] blk: Hide the BLK and SPL_LEGACY_BLOCK options Simon Glass
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Alexander Graf,
	Alexey Brodkin, Bin Meng, Heiko Schocher, Philippe Reynes,
	Stefan Roese

This is defined automatically when needed, so drop it from the few
defconfig files that define it manually.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 configs/axm_defconfig                          | 1 -
 configs/bcm968380gerg_ram_defconfig            | 1 -
 configs/gardena-smart-gateway-mt7688_defconfig | 1 -
 configs/nsim_hs38_defconfig                    | 1 -
 configs/qemu-ppce500_defconfig                 | 1 -
 5 files changed, 5 deletions(-)

diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index c42fb37d6c9..89220d80852 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -80,7 +80,6 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SPL_DM=y
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_CLK=y
 CONFIG_CLK_AT91=y
 CONFIG_AT91_GPIO=y
diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
index 246add6029c..29f317d85f9 100644
--- a/configs/bcm968380gerg_ram_defconfig
+++ b/configs/bcm968380gerg_ram_defconfig
@@ -42,7 +42,6 @@ CONFIG_CMD_NAND=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 # CONFIG_NET is not set
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BCM6345_GPIO=y
 CONFIG_LED=y
 CONFIG_LED_BCM6328=y
diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
index fdfab14d53e..992e8509993 100644
--- a/configs/gardena-smart-gateway-mt7688_defconfig
+++ b/configs/gardena-smart-gateway-mt7688_defconfig
@@ -78,7 +78,6 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 # CONFIG_DM_DEVICE_REMOVE is not set
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
index 3f23fc4189f..6196cd94819 100644
--- a/configs/nsim_hs38_defconfig
+++ b/configs/nsim_hs38_defconfig
@@ -30,7 +30,6 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_DM_ETH=y
 CONFIG_DM_SERIAL=y
 CONFIG_DEBUG_UART_SHIFT=2
diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
index 3241f5520eb..7793edac90b 100644
--- a/configs/qemu-ppce500_defconfig
+++ b/configs/qemu-ppce500_defconfig
@@ -40,7 +40,6 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
 CONFIG_BLK=y
-CONFIG_SPL_LEGACY_BLOCK=y
 CONFIG_LBA48=y
 CONFIG_CHIP_SELECTS_PER_CTRL=0
 CONFIG_MPC8XXX_GPIO=y
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 12/24] blk: Hide the BLK and SPL_LEGACY_BLOCK options
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (10 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 11/24] blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 13/24] blk: Drop IF_TYPE_DOC Simon Glass
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Michal Simek, Stefan Roese

We don't want boards to be able to change these. They can be handled
as dependencies of options that need them, such as SPL_MMC. There is no
point in enabling the block interface without any storage devices to
create a block device.

Hide both options from the 'menuconfig' display and deny their use in
defconfig files.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/block/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e82a779e6b8..707e2bcd238 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -1,5 +1,5 @@
 config BLK
-	bool "Support block devices"
+	bool # "Support block devices"
 	depends on DM
 	default y if MMC || USB || SCSI || NVME || IDE || AHCI || SATA
 	default y if EFI_MEDIA || VIRTIO_BLK || PVBLOCK
@@ -12,7 +12,7 @@ config BLK
 	  A filesystem can be placed in each partition.
 
 config SPL_LEGACY_BLOCK
-	bool "Enable Legacy Block Device"
+	bool # "Enable Legacy Block Device"
 	depends on SPL && !DM_SPL
 	default y if SPL_MMC || SPL_USB_STORAGE || SCSI || NVME || IDE
 	default y if SPL_AHCI_PCI
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 13/24] blk: Drop IF_TYPE_DOC
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (11 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 12/24] blk: Hide the BLK and SPL_LEGACY_BLOCK options Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 14/24] ide: Use a flag for an ATAPI device Simon Glass
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Masahisa Kojima, Sean Anderson, schspa

This doesn't seem to be used for anything and it isn't clear what it is.
It dates from the first U-Boot commit.

Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 disk/part.c                | 9 ---------
 drivers/block/blk-uclass.c | 2 --
 include/blk.h              | 1 -
 3 files changed, 12 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 9594bb432c4..5f64da54e54 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -150,9 +150,6 @@ void dev_print (struct blk_desc *dev_desc)
 	case IF_TYPE_VIRTIO:
 		printf("%s VirtIO Block Device\n", dev_desc->vendor);
 		break;
-	case IF_TYPE_DOC:
-		puts("device type DOC\n");
-		return;
 	case IF_TYPE_UNKNOWN:
 		puts("device type unknown\n");
 		return;
@@ -266,9 +263,6 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
 	case IF_TYPE_USB:
 		puts ("USB");
 		break;
-	case IF_TYPE_DOC:
-		puts ("DOC");
-		break;
 	case IF_TYPE_MMC:
 		puts ("MMC");
 		break;
@@ -782,9 +776,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
 	case IF_TYPE_USB:
 		devtype = "usbd";
 		break;
-	case IF_TYPE_DOC:
-		devtype = "docd";
-		break;
 	case IF_TYPE_MMC:
 	case IF_TYPE_SD:
 		devtype = "mmcsd";
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 1a6e8f8c29d..f16cb279d4e 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -22,7 +22,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[IF_TYPE_SCSI]		= "scsi",
 	[IF_TYPE_ATAPI]		= "atapi",
 	[IF_TYPE_USB]		= "usb",
-	[IF_TYPE_DOC]		= "doc",
 	[IF_TYPE_MMC]		= "mmc",
 	[IF_TYPE_SD]		= "sd",
 	[IF_TYPE_SATA]		= "sata",
@@ -39,7 +38,6 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
 	[IF_TYPE_ATAPI]		= UCLASS_INVALID,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
-	[IF_TYPE_DOC]		= UCLASS_INVALID,
 	[IF_TYPE_MMC]		= UCLASS_MMC,
 	[IF_TYPE_SD]		= UCLASS_INVALID,
 	[IF_TYPE_SATA]		= UCLASS_AHCI,
diff --git a/include/blk.h b/include/blk.h
index 5bdffe74015..1898ebdda54 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -33,7 +33,6 @@ enum if_type {
 	IF_TYPE_SCSI,
 	IF_TYPE_ATAPI,
 	IF_TYPE_USB,
-	IF_TYPE_DOC,
 	IF_TYPE_MMC,
 	IF_TYPE_SD,
 	IF_TYPE_SATA,
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 14/24] ide: Use a flag for an ATAPI device
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (12 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 13/24] blk: Drop IF_TYPE_DOC Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 15/24] blk: Drop IF_TYPE_ATAPI Simon Glass
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Stefan Roese

Rather than setting a different interface type, use a flag to indicate
that a device is ATAPI.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/block/ide.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 3270a9f032f..6bc48e3402e 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -525,8 +525,8 @@ static void ide_ident(struct blk_desc *dev_desc)
 {
 	unsigned char c;
 	hd_driveid_t iop;
-
 #ifdef CONFIG_ATAPI
+	bool is_atapi = false;
 	int retries = 0;
 #endif
 	int device;
@@ -550,7 +550,7 @@ static void ide_ident(struct blk_desc *dev_desc)
 		    (ide_inb(device, ATA_CYL_LOW) == 0x14) &&
 		    (ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
 			/* ATAPI Signature found */
-			dev_desc->if_type = IF_TYPE_ATAPI;
+			is_atapi = true;
 			/*
 			 * Start Ident Command
 			 */
@@ -623,7 +623,7 @@ static void ide_ident(struct blk_desc *dev_desc)
 		dev_desc->removable = 0;
 
 #ifdef CONFIG_ATAPI
-	if (dev_desc->if_type == IF_TYPE_ATAPI) {
+	if (is_atapi) {
 		atapi_inquiry(dev_desc);
 		return;
 	}
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 15/24] blk: Drop IF_TYPE_ATAPI
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (13 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 14/24] ide: Use a flag for an ATAPI device Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 16/24] blk: Drop IF_TYPE_SD Simon Glass
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Marcel Ziswiler, Masahisa Kojima, Oleksii Bidnichenko,
	Sean Anderson, schspa

This is not really needed since it does the same things as IDE. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 disk/part.c                | 5 -----
 drivers/block/blk-uclass.c | 2 --
 include/blk.h              | 1 -
 3 files changed, 8 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 5f64da54e54..a5c1d7a0aec 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -128,7 +128,6 @@ void dev_print (struct blk_desc *dev_desc)
 			dev_desc->product,
 			dev_desc->revision);
 		break;
-	case IF_TYPE_ATAPI:
 	case IF_TYPE_IDE:
 	case IF_TYPE_SATA:
 		printf ("Model: %s Firm: %s Ser#: %s\n",
@@ -257,9 +256,6 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
 	case IF_TYPE_SCSI:
 		puts ("SCSI");
 		break;
-	case IF_TYPE_ATAPI:
-		puts ("ATAPI");
-		break;
 	case IF_TYPE_USB:
 		puts ("USB");
 		break;
@@ -767,7 +763,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
 	switch (dev_desc->if_type) {
 	case IF_TYPE_IDE:
 	case IF_TYPE_SATA:
-	case IF_TYPE_ATAPI:
 		devtype = "hd";
 		break;
 	case IF_TYPE_SCSI:
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index f16cb279d4e..57230e9bab7 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -20,7 +20,6 @@
 static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[IF_TYPE_IDE]		= "ide",
 	[IF_TYPE_SCSI]		= "scsi",
-	[IF_TYPE_ATAPI]		= "atapi",
 	[IF_TYPE_USB]		= "usb",
 	[IF_TYPE_MMC]		= "mmc",
 	[IF_TYPE_SD]		= "sd",
@@ -36,7 +35,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
 	[IF_TYPE_IDE]		= UCLASS_IDE,
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
-	[IF_TYPE_ATAPI]		= UCLASS_INVALID,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
 	[IF_TYPE_MMC]		= UCLASS_MMC,
 	[IF_TYPE_SD]		= UCLASS_INVALID,
diff --git a/include/blk.h b/include/blk.h
index 1898ebdda54..c7461f9f35a 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -31,7 +31,6 @@ enum if_type {
 	IF_TYPE_UNKNOWN = 0,
 	IF_TYPE_IDE,
 	IF_TYPE_SCSI,
-	IF_TYPE_ATAPI,
 	IF_TYPE_USB,
 	IF_TYPE_MMC,
 	IF_TYPE_SD,
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 16/24] blk: Drop IF_TYPE_SD
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (14 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 15/24] blk: Drop IF_TYPE_ATAPI Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 17/24] blk: Rename var in blk_get_devnum_by_typename() Simon Glass
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Marcel Ziswiler, Masahisa Kojima, Oleksii Bidnichenko, schspa

This is not really needed since it does the same things as MMC. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 disk/part.c                | 2 --
 drivers/block/blk-uclass.c | 2 --
 include/blk.h              | 1 -
 3 files changed, 5 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index a5c1d7a0aec..2bcc6f4f403 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -135,7 +135,6 @@ void dev_print (struct blk_desc *dev_desc)
 			dev_desc->revision,
 			dev_desc->product);
 		break;
-	case IF_TYPE_SD:
 	case IF_TYPE_MMC:
 	case IF_TYPE_USB:
 	case IF_TYPE_NVME:
@@ -772,7 +771,6 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
 		devtype = "usbd";
 		break;
 	case IF_TYPE_MMC:
-	case IF_TYPE_SD:
 		devtype = "mmcsd";
 		break;
 	default:
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 57230e9bab7..2fa6a7e6883 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -22,7 +22,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[IF_TYPE_SCSI]		= "scsi",
 	[IF_TYPE_USB]		= "usb",
 	[IF_TYPE_MMC]		= "mmc",
-	[IF_TYPE_SD]		= "sd",
 	[IF_TYPE_SATA]		= "sata",
 	[IF_TYPE_HOST]		= "host",
 	[IF_TYPE_NVME]		= "nvme",
@@ -37,7 +36,6 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
 	[IF_TYPE_SCSI]		= UCLASS_SCSI,
 	[IF_TYPE_USB]		= UCLASS_MASS_STORAGE,
 	[IF_TYPE_MMC]		= UCLASS_MMC,
-	[IF_TYPE_SD]		= UCLASS_INVALID,
 	[IF_TYPE_SATA]		= UCLASS_AHCI,
 	[IF_TYPE_HOST]		= UCLASS_ROOT,
 	[IF_TYPE_NVME]		= UCLASS_NVME,
diff --git a/include/blk.h b/include/blk.h
index c7461f9f35a..cc30e3861fa 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -33,7 +33,6 @@ enum if_type {
 	IF_TYPE_SCSI,
 	IF_TYPE_USB,
 	IF_TYPE_MMC,
-	IF_TYPE_SD,
 	IF_TYPE_SATA,
 	IF_TYPE_HOST,
 	IF_TYPE_NVME,
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 17/24] blk: Rename var in blk_get_devnum_by_typename()
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (15 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 16/24] blk: Drop IF_TYPE_SD Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 18/24] blk: Rewrite if_type to name functions Simon Glass
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro

At present we use a variable with the same name as the enum. Change this
since we plan to #define the enum to uclass_id.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/block/blk-uclass.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 2fa6a7e6883..3738517d8d0 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -90,21 +90,21 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 {
 	enum uclass_id uclass_id;
-	enum if_type if_type;
+	enum if_type type;
 	struct udevice *dev;
 	struct uclass *uc;
 	int ret;
 
-	if_type = if_typename_to_iftype(if_typename);
-	if (if_type == IF_TYPE_UNKNOWN) {
+	type = if_typename_to_iftype(if_typename);
+	if (type == IF_TYPE_UNKNOWN) {
 		debug("%s: Unknown interface type '%s'\n", __func__,
 		      if_typename);
 		return NULL;
 	}
-	uclass_id = if_type_to_uclass_id(if_type);
+	uclass_id = if_type_to_uclass_id(type);
 	if (uclass_id == UCLASS_INVALID) {
 		debug("%s: Unknown uclass for interface type'\n",
-		      if_typename_str[if_type]);
+		      if_typename_str[type]);
 		return NULL;
 	}
 
@@ -115,7 +115,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
 		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
-		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
+		      type, devnum, dev->name, desc->if_type, desc->devnum);
 		if (desc->devnum != devnum)
 			continue;
 
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 18/24] blk: Rewrite if_type to name functions
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (16 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 17/24] blk: Rename var in blk_get_devnum_by_typename() Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 19/24] efi: Correct assumption about if_type Simon Glass
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro

These are currently using a simple array lookup in one direction, and
relying on if_type being sequential.

With the move to uclass IDs this needs to change. Update the code to
prepare for the new way. This patch is intended to introduce no
functional change.

The returning of "(none)" from blk_get_if_type_name() is handling a case
that should not happen in either case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 drivers/block/blk-uclass.c | 45 +++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 3738517d8d0..a68158c3f25 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -17,18 +17,21 @@
 #include <dm/uclass-internal.h>
 #include <linux/err.h>
 
-static const char *if_typename_str[IF_TYPE_COUNT] = {
-	[IF_TYPE_IDE]		= "ide",
-	[IF_TYPE_SCSI]		= "scsi",
-	[IF_TYPE_USB]		= "usb",
-	[IF_TYPE_MMC]		= "mmc",
-	[IF_TYPE_SATA]		= "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 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] = {
@@ -49,10 +52,9 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
 {
 	int i;
 
-	for (i = 0; i < IF_TYPE_COUNT; i++) {
-		if (if_typename_str[i] &&
-		    !strcmp(if_typename, if_typename_str[i]))
-			return i;
+	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+		if (!strcmp(if_typename, if_typename_str[i].name))
+			return if_typename_str[i].id;
 	}
 
 	return IF_TYPE_UNKNOWN;
@@ -65,7 +67,14 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
 
 const char *blk_get_if_type_name(enum if_type if_type)
 {
-	return if_typename_str[if_type];
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
+		if ((int)if_typename_str[i].id == if_type)
+			return if_typename_str[i].name;
+	}
+
+	return "(none)";
 }
 
 struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
@@ -104,7 +113,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 	uclass_id = if_type_to_uclass_id(type);
 	if (uclass_id == UCLASS_INVALID) {
 		debug("%s: Unknown uclass for interface type'\n",
-		      if_typename_str[type]);
+		      blk_get_if_type_name(type));
 		return NULL;
 	}
 
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 19/24] efi: Correct assumption about if_type
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (17 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 18/24] blk: Rewrite if_type to name functions Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:34 ` [PATCH v2 20/24] blk: Switch over to using uclass IDs Simon Glass
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, Alexander Graf,
	Ilias Apalodimas

efi_set_blk_dev_to_system_partition() assumes that 0 is an invalid
if_type. This is true now but is about to be false. Fix this bug to avoid
a test failure.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 lib/efi_loader/efi_var_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 76a2ff9e412..994e66392fb 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -38,7 +38,7 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
 	char part_str[PART_STR_LEN];
 	int r;
 
-	if (!efi_system_partition.if_type) {
+	if (efi_system_partition.if_type == UCLASS_INVALID) {
 		log_err("No EFI system partition\n");
 		return EFI_DEVICE_ERROR;
 	}
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 20/24] blk: Switch over to using uclass IDs
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (18 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 19/24] efi: Correct assumption about if_type Simon Glass
@ 2022-08-12  1:34 ` Simon Glass
  2022-08-12  1:35 ` [PATCH v2 21/24] disk: Handle UCLASS_EFI_MEDIA in dev_print() Simon Glass
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:34 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Anastasiia Lukianenko, Andrew Scull, Aswath Govindraju, Bin Meng,
	Denys Drozdov, Francesco Dolcini, Gary Bisson, Ilias Apalodimas,
	Jaehoon Chung, Jens Wiklander, Joe Hershberger, Judy Wang,
	Loic Poulain, Lukasz Majewski, Marcel Ziswiler, Marek Behún,
	Marek Vasut, Masahisa Kojima, Max Merchel,
	Oleksandr Andrushchenko, Oleksii Bidnichenko, Pali Rohár,
	Patrice Chotard, Patrick Delaunay, Peng Fan, Philippe Schenker,
	Sean Anderson, Stefan Roese, Tony Dinh, Wolfgang Denk,
	Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32

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>
---

(no changes since v1)

 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    |  4 +-
 board/toradex/common/tdx-cfg-block.c          |  4 +-
 cmd/bcb.c                                     |  4 +-
 cmd/ide.c                                     |  2 +-
 cmd/mmc.c                                     |  8 +--
 cmd/mvebu/bubt.c                              |  2 +-
 cmd/nvme.c                                    |  4 +-
 cmd/pvblock.c                                 |  2 +-
 cmd/sata.c                                    |  4 +-
 cmd/scsi.c                                    |  2 +-
 cmd/usb.c                                     |  2 +-
 cmd/virtio.c                                  |  2 +-
 common/spl/spl_sata.c                         |  2 +-
 common/spl/spl_usb.c                          |  2 +-
 common/usb_storage.c                          |  8 +--
 disk/part.c                                   | 52 +++++++--------
 doc/develop/uefi/uefi.rst                     |  2 +-
 drivers/ata/dwc_ahsata.c                      |  2 +-
 drivers/ata/fsl_sata.c                        |  2 +-
 drivers/ata/sata.c                            |  2 +-
 drivers/ata/sata_mv.c                         |  2 +-
 drivers/ata/sata_sil.c                        |  2 +-
 drivers/block/blk-uclass.c                    | 64 ++++++++++---------
 drivers/block/efi_blk.c                       |  2 +-
 drivers/block/ide.c                           |  8 +--
 drivers/block/sandbox.c                       | 12 ++--
 drivers/dfu/dfu_mmc.c                         |  6 +-
 drivers/mmc/mmc-uclass.c                      | 10 +--
 drivers/mmc/mmc_legacy.c                      |  6 +-
 drivers/mmc/mmc_write.c                       |  4 +-
 drivers/nvme/nvme.c                           |  2 +-
 drivers/scsi/scsi.c                           | 10 +--
 drivers/tee/optee/rpmb.c                      |  4 +-
 drivers/virtio/virtio_blk.c                   |  4 +-
 drivers/xen/pvblock.c                         |  6 +-
 env/mmc.c                                     |  4 +-
 include/blk.h                                 | 18 +-----
 include/mmc.h                                 |  2 +-
 lib/efi_driver/efi_block_device.c             |  4 +-
 lib/efi_loader/efi_disk.c                     |  4 +-
 test/dm/blk.c                                 | 24 +++----
 41 files changed, 151 insertions(+), 159 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index c391b6c7abb..a720d0ba717 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -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;
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 22c67c6e388..11f4d5e14a8 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -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;
 }
diff --git a/cmd/bcb.c b/cmd/bcb.c
index 1bbd1fae998..8b87aa062fe 100644
--- 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;
diff --git a/cmd/ide.c b/cmd/ide.c
index b78c38e1590..6739f0b12d1 100644
--- 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[])
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 7bd4cd9e016..0f1f4e0a71d 100644
--- 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)
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index 2136af64163..825d4beb899 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -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;
diff --git a/cmd/nvme.c b/cmd/nvme.c
index e715c570a38..09d5f438fb1 100644
--- a/cmd/nvme.c
+++ b/cmd/nvme.c
@@ -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(
diff --git a/cmd/pvblock.c b/cmd/pvblock.c
index 56ce8b18d51..1b604c37373 100644
--- a/cmd/pvblock.c
+++ b/cmd/pvblock.c
@@ -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);
 }
 
diff --git a/cmd/sata.c b/cmd/sata.c
index 76da1906b7f..9c9fe111d12 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -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(
diff --git a/cmd/scsi.c b/cmd/scsi.c
index 5f710d28957..4549995ba73 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -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(
diff --git a/cmd/usb.c b/cmd/usb.c
index 3d873765250..2ba056982c3 100644
--- 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 */
diff --git a/cmd/virtio.c b/cmd/virtio.c
index ea3ed2e631e..ec87d4f02c9 100644
--- a/cmd/virtio.c
+++ b/cmd/virtio.c
@@ -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(
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 1351d78612a..ea9f1756c0a 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -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;
 
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index ccf01c8276b..63c00f872b6 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -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;
 
diff --git a/common/usb_storage.c b/common/usb_storage.c
index eaa31374ef7..7d420160cd5 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -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,
 };
diff --git a/disk/part.c b/disk/part.c
index 2bcc6f4f403..75aff7eba5a 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -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:
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index 941e427093f..cd847069530 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -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].
 
diff --git a/drivers/ata/dwc_ahsata.c b/drivers/ata/dwc_ahsata.c
index 1a2c3c2fe70..167b5a395f5 100644
--- a/drivers/ata/dwc_ahsata.c
+++ b/drivers/ata/dwc_ahsata.c
@@ -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;
diff --git a/drivers/ata/fsl_sata.c b/drivers/ata/fsl_sata.c
index 6db4247368e..972101b29ce 100644
--- a/drivers/ata/fsl_sata.c
+++ b/drivers/ata/fsl_sata.c
@@ -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;
diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index 0e6c8cdd422..604c721cfdc 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -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;
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index a187796dfcd..18c7a66db1b 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -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;
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 70651545722..b5e150d568b 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -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;
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index a68158c3f25..436af764f91 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -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;
diff --git a/drivers/block/efi_blk.c b/drivers/block/efi_blk.c
index 9d25ecbf37f..917a19f6025 100644
--- a/drivers/block/efi_blk.c
+++ b/drivers/block/efi_blk.c
@@ -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) {
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 6bc48e3402e..73da29ad552 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -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,
 };
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 1388498a1d3..2de12e0a93e 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -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,
 };
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index a91da972d46..f5832083ba1 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -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)
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 688bdc06d42..b1bd4ae1bc8 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -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;
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index a05da6c2e88..4e0891e5dfe 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -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,
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index eab94c7b607..5b7aeeb0121 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -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;
 
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index a305305885e..f92509deb92 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -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;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 78d729d809d..99be5aef877 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -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,
 };
diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c
index cf5e0a08e61..5bc13757ea8 100644
--- a/drivers/tee/optee/rpmb.c
+++ b/drivers/tee/optee/rpmb.c
@@ -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);
diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
index 3ff74f4a975..9710b79117c 100644
--- a/drivers/virtio/virtio_blk.c
+++ b/drivers/virtio/virtio_blk.c
@@ -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;
diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c
index c25c3ea4fff..1090e528d02 100644
--- a/drivers/xen/pvblock.c
+++ b/drivers/xen/pvblock.c
@@ -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);
 
diff --git a/env/mmc.c b/env/mmc.c
index 0c498d9a46b..c28f4c6c6dc 100644
--- 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
 }
 
diff --git a/include/blk.h b/include/blk.h
index cc30e3861fa..548cd09d6bb 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -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
diff --git a/include/mmc.h b/include/mmc.h
index f519d869725..027e8bcc73a 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -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
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index 5baa6f87a37..6737350b02e 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -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)
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 1d700b2a6be..2e905f61840 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -652,7 +652,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;
@@ -687,7 +687,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);
 	}
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 85c3a3bd45c..35bd5318f0b 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -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);
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 21/24] disk: Handle UCLASS_EFI_MEDIA in dev_print()
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (19 preceding siblings ...)
  2022-08-12  1:34 ` [PATCH v2 20/24] blk: Switch over to using uclass IDs Simon Glass
@ 2022-08-12  1:35 ` Simon Glass
  2022-08-12  1:35 ` [PATCH v2 22/24] blk: Drop if_type Simon Glass
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:35 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Sean Anderson, schspa

This is currently missing. Add it.

Fix the code style for the function while we are here.

Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add new patch to handle UCLASS_EFI_MEDIA in dev_print()

 disk/part.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/disk/part.c b/disk/part.c
index 75aff7eba5a..5705c229d59 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -111,7 +111,7 @@ static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by,
 	return bc_quot * mul_by + ((bc_rem * mul_by) >> right_shift);
 }
 
-void dev_print (struct blk_desc *dev_desc)
+void dev_print(struct blk_desc *dev_desc)
 {
 	lba512_t lba512; /* number of blocks if 512bytes block size */
 
@@ -148,6 +148,9 @@ void dev_print (struct blk_desc *dev_desc)
 	case UCLASS_VIRTIO:
 		printf("%s VirtIO Block Device\n", dev_desc->vendor);
 		break;
+	case UCLASS_EFI_MEDIA:
+		printf("EFI media Block Device %d\n", dev_desc->devnum);
+		break;
 	case UCLASS_INVALID:
 		puts("device type unknown\n");
 		return;
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 22/24] blk: Drop if_type
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (20 preceding siblings ...)
  2022-08-12  1:35 ` [PATCH v2 21/24] disk: Handle UCLASS_EFI_MEDIA in dev_print() Simon Glass
@ 2022-08-12  1:35 ` Simon Glass
  2022-09-13 16:27   ` Heinrich Schuchardt
  2022-08-12  1:35 ` [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj Simon Glass
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:35 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Ilias Apalodimas, Masahisa Kojima

Use the uclass ID instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 cmd/blk_common.c           |  2 +-
 drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
 drivers/block/blk_legacy.c | 20 +++++++++----------
 include/blk.h              | 41 ++++++++++++++++++--------------------
 include/efi_loader.h       |  2 +-
 5 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 4e442f2918b..369c5ae4bbe 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -12,7 +12,7 @@
 #include <blk.h>
 #include <command.h>
 
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 		   int *cur_devnump)
 {
 	const char *if_name = blk_get_if_type_name(if_type);
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 436af764f91..a9a85aa37f3 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -34,7 +34,7 @@ static struct {
 	{ UCLASS_PVBLOCK, "pvblock" },
 };
 
-static enum if_type if_typename_to_iftype(const char *if_typename)
+static enum uclass_id if_typename_to_iftype(const char *if_typename)
 {
 	int i;
 
@@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
 	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 uclass_id if_type)
 {
 	/*
 	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
@@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
 	return if_type;
 }
 
-const char *blk_get_if_type_name(enum if_type if_type)
+const char *blk_get_if_type_name(enum uclass_id if_type)
 {
 	int i;
 
@@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
 	return "(none)";
 }
 
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
 {
 	struct blk_desc *desc;
 	struct udevice *dev;
@@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
 struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 {
 	enum uclass_id uclass_id;
-	enum if_type type;
+	enum uclass_id type;
 	struct udevice *dev;
 	struct uclass *uc;
 	int ret;
@@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
  * with a higher device number, -ENOENT if there is no such device but there
  * is one with a higher number, or other -ve on other error.
  */
-static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
+static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
 {
 	bool found_more = false;
 	struct udevice *dev;
@@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
 	return found_more ? -ENOENT : -ENODEV;
 }
 
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
 {
 	struct udevice *dev;
 	int ret;
@@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
 	return blk_select_hwpart(dev, hwpart);
 }
 
-int blk_list_part(enum if_type if_type)
+int blk_list_part(enum uclass_id if_type)
 {
 	struct blk_desc *desc;
 	int devnum, ok;
@@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
 	return 0;
 }
 
-int blk_print_part_devnum(enum if_type if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id if_type, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
@@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
 	return 0;
 }
 
-void blk_list_devices(enum if_type if_type)
+void blk_list_devices(enum uclass_id if_type)
 {
 	struct blk_desc *desc;
 	int ret;
@@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
 	}
 }
 
-int blk_print_device_num(enum if_type if_type, int devnum)
+int blk_print_device_num(enum uclass_id if_type, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
@@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
 	return 0;
 }
 
-int blk_show_device(enum if_type if_type, int devnum)
+int blk_show_device(enum uclass_id if_type, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
@@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
 	return 0;
 }
 
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer)
 {
 	struct blk_desc *desc;
@@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
 	return n;
 }
 
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer)
 {
 	struct blk_desc *desc;
@@ -525,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
 	return uclass_get_name(device_get_uclass_id(parent));
 };
 
-int blk_find_max_devnum(enum if_type if_type)
+int blk_find_max_devnum(enum uclass_id if_type)
 {
 	struct udevice *dev;
 	int max_devnum = -ENODEV;
@@ -545,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
 	return max_devnum;
 }
 
-int blk_next_free_devnum(enum if_type if_type)
+int blk_next_free_devnum(enum uclass_id if_type)
 {
 	int ret;
 
@@ -631,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
 	return count;
 }
 
-static int blk_claim_devnum(enum if_type if_type, int devnum)
+static int blk_claim_devnum(enum uclass_id if_type, int devnum)
 {
 	struct udevice *dev;
 	struct uclass *uc;
diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index bd8a17df6a9..8c6f9cb208e 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
 	return NULL;
 }
 
-const char *blk_get_if_type_name(enum if_type if_type)
+const char *blk_get_if_type_name(enum uclass_id if_type)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 
@@ -70,7 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
 	return drv->get_dev(devnum, descp);
 }
 
-int blk_list_part(enum if_type if_type)
+int blk_list_part(enum uclass_id if_type)
 {
 	struct blk_driver *drv;
 	struct blk_desc *desc;
@@ -97,7 +97,7 @@ int blk_list_part(enum if_type if_type)
 	return 0;
 }
 
-int blk_print_part_devnum(enum if_type if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id if_type, int devnum)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
@@ -115,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
 	return 0;
 }
 
-void blk_list_devices(enum if_type if_type)
+void blk_list_devices(enum uclass_id if_type)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
@@ -133,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
 	}
 }
 
-int blk_print_device_num(enum if_type if_type, int devnum)
+int blk_print_device_num(enum uclass_id if_type, int devnum)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
@@ -150,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
 	return 0;
 }
 
-int blk_show_device(enum if_type if_type, int devnum)
+int blk_show_device(enum uclass_id if_type, int devnum)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
@@ -174,7 +174,7 @@ int blk_show_device(enum if_type if_type, int devnum)
 	return 0;
 }
 
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
@@ -214,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 	return desc;
 }
 
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
@@ -234,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
 	return n;
 }
 
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
@@ -249,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
 	return desc->block_write(desc, start, blkcnt, buffer);
 }
 
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
 {
 	struct blk_driver *drv = blk_driver_lookup_type(if_type);
 	struct blk_desc *desc;
diff --git a/include/blk.h b/include/blk.h
index 548cd09d6bb..279f9ea4a9d 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -27,9 +27,6 @@ static inline bool blk_enabled(void)
 	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
 }
 
-/* Interface types: */
-#define if_type uclass_id
-
 #define BLK_VEN_SIZE		40
 #define BLK_PRD_SIZE		20
 #define BLK_REV_SIZE		8
@@ -57,7 +54,7 @@ struct blk_desc {
 	 * TODO: With driver model we should be able to use the parent
 	 * device's uclass instead.
 	 */
-	enum if_type	if_type;	/* type of the interface */
+	enum uclass_id	if_type;	/* type of the interface */
 	int		devnum;		/* device number */
 	unsigned char	part_type;	/* partition type */
 	unsigned char	target;		/* target SCSI ID */
@@ -282,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
  * This function does not activate the device. The device will be returned
  * whether or not it is activated.
  *
- * @if_type:	Interface type (enum if_type_t)
+ * @if_type:	Interface type (enum uclass_id_t)
  * @devnum:	Device number (specific to each interface type)
  * @devp:	the device, if found
  * Return: 0 if found, -ENODEV if no device found, or other -ve error value
@@ -292,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
 /**
  * blk_get_device() - Find and probe a block device ready for use
  *
- * @if_type:	Interface type (enum if_type_t)
+ * @if_type:	Interface type (enum uclass_id_t)
  * @devnum:	Device number (specific to each interface type)
  * @devp:	the device, if found
  * Return: 0 if found, -ENODEV if no device found, or other -ve error value
@@ -330,7 +327,7 @@ int blk_next_device(struct udevice **devp);
  * @parent:	Parent of the new device
  * @drv_name:	Driver name to use for the block device
  * @name:	Name for the device
- * @if_type:	Interface type (enum if_type_t)
+ * @if_type:	Interface type (enum uclass_id_t)
  * @devnum:	Device number, specific to the interface type, or -1 to
  *		allocate the next available number
  * @blksz:	Block size of the device in bytes (typically 512)
@@ -347,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
  * @parent:	Parent of the new device
  * @drv_name:	Driver name to use for the block device
  * @name:	Name for the device (parent name is prepended)
- * @if_type:	Interface type (enum if_type_t)
+ * @if_type:	Interface type (enum uclass_id_t)
  * @devnum:	Device number, specific to the interface type, or -1 to
  *		allocate the next available number
  * @blksz:	Block size of the device in bytes (typically 512)
@@ -390,7 +387,7 @@ int blk_unbind_all(int if_type);
  * Return: maximum device number found, or -ENODEV if none, or other -ve on
  * error
  */
-int blk_find_max_devnum(enum if_type if_type);
+int blk_find_max_devnum(enum uclass_id if_type);
 
 /**
  * blk_next_free_devnum() - get the next device number for an interface type
@@ -401,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
  * @if_type:	Interface type to scan
  * Return: next device number safe to use, or -ve on error
  */
-int blk_next_free_devnum(enum if_type if_type);
+int blk_next_free_devnum(enum uclass_id if_type);
 
 /**
  * blk_select_hwpart() - select a hardware partition
@@ -496,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
  */
 struct blk_driver {
 	const char *if_typename;
-	enum if_type if_type;
+	enum uclass_id if_type;
 	int max_devs;
 	struct blk_desc *desc;
 	/**
@@ -557,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
  * @devnum:	Device number
  * Return: point to block device descriptor, or NULL if not found
  */
-struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
 
 /**
  * blk_get_devnum_by_type() - Get a block device by type name, and number
@@ -594,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
  * @if_type:	Block device type
  * Return: 0 if OK, -ENODEV if there is none of that type
  */
-int blk_list_part(enum if_type if_type);
+int blk_list_part(enum uclass_id if_type);
 
 /**
  * blk_list_devices() - list the block devices of a given type
@@ -604,7 +601,7 @@ int blk_list_part(enum if_type if_type);
  *
  * @if_type:	Block device type
  */
-void blk_list_devices(enum if_type if_type);
+void blk_list_devices(enum uclass_id if_type);
 
 /**
  * blk_show_device() - show information about a given block device
@@ -615,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
  * @devnum:	Device number
  * Return: 0 if OK, -ENODEV for invalid device number
  */
-int blk_show_device(enum if_type if_type, int devnum);
+int blk_show_device(enum uclass_id if_type, int devnum);
 
 /**
  * blk_print_device_num() - show information about a given block device
@@ -628,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
  * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
  * device is not connected
  */
-int blk_print_device_num(enum if_type if_type, int devnum);
+int blk_print_device_num(enum uclass_id if_type, int devnum);
 
 /**
  * blk_print_part_devnum() - print the partition information for a device
@@ -638,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
  * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
  * the interface type is not supported, other -ve on other error
  */
-int blk_print_part_devnum(enum if_type if_type, int devnum);
+int blk_print_part_devnum(enum uclass_id if_type, int devnum);
 
 /**
  * blk_read_devnum() - read blocks from a device
@@ -649,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
  * @buffer:	Address to write data to
  * Return: number of blocks read, or -ve error number on error
  */
-ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer);
 
 /**
@@ -661,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
  * @buffer:	Address to read data from
  * Return: number of blocks written, or -ve error number on error
  */
-ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer);
 
 /**
@@ -675,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
  * @hwpart:	Partition number to select
  * Return: 0 if OK, -ve on error
  */
-int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
+int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
 
 /**
  * blk_get_if_type_name() - Get the name of an interface type
@@ -683,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
  * @if_type: Interface type to check
  * Return: name of interface, or NULL if none
  */
-const char *blk_get_if_type_name(enum if_type if_type);
+const char *blk_get_if_type_name(enum uclass_id if_type);
 
 /**
  * blk_common_cmd() - handle common commands with block devices
@@ -694,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
  * @cur_devnump: Current device number for this interface type
  * Return: 0 if OK, CMD_RET_ERROR on error
  */
-int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 		   int *cur_devnump);
 
 enum blk_flag_t {
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 3a63a1f75fd..ae58efb0036 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
 
 /* EFI system partition */
 extern struct efi_system_partition {
-	enum if_type if_type;
+	enum uclass_id if_type;
 	int devnum;
 	u8 part;
 } efi_system_partition;
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (21 preceding siblings ...)
  2022-08-12  1:35 ` [PATCH v2 22/24] blk: Drop if_type Simon Glass
@ 2022-08-12  1:35 ` Simon Glass
  2022-09-13 16:17   ` Heinrich Schuchardt
  2022-08-12  1:35 ` [PATCH v2 24/24] blk: Rename if_type to uclass_id Simon Glass
  2022-08-12 13:51 ` [PATCH v2 00/24] blk: Rationalise the block interface Johan Jonker
  24 siblings, 1 reply; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:35 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Alexander Graf, Ilias Apalodimas

This is not used, so drop it.

Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add new patch to drop ifname field from struct efi_disk_obj

 lib/efi_loader/efi_disk.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 2e905f61840..ad543bc117e 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -40,7 +40,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
 struct efi_disk_obj {
 	struct efi_object header;
 	struct efi_block_io ops;
-	const char *ifname;
 	int dev_index;
 	struct efi_block_io_media media;
 	struct efi_device_path *dp;
@@ -476,7 +475,6 @@ static efi_status_t efi_disk_add_dev(
 			return ret;
 	}
 	diskobj->ops = block_io_disk_template;
-	diskobj->ifname = if_typename;
 	diskobj->dev_index = dev_index;
 
 	/* Fill in EFI IO Media info (for read/write callbacks) */
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [PATCH v2 24/24] blk: Rename if_type to uclass_id
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (22 preceding siblings ...)
  2022-08-12  1:35 ` [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj Simon Glass
@ 2022-08-12  1:35 ` Simon Glass
  2022-09-13 16:03   ` Tom Rini
  2022-09-14  1:22   ` AKASHI Takahiro
  2022-08-12 13:51 ` [PATCH v2 00/24] blk: Rationalise the block interface Johan Jonker
  24 siblings, 2 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-12  1:35 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, Simon Glass, AKASHI Takahiro,
	Anastasiia Lukianenko, Aswath Govindraju, Bin Meng,
	Ilias Apalodimas, Jaehoon Chung, Joe Hershberger,
	Lukasz Majewski, Marcel Ziswiler, Marek Vasut, Markus Niebel,
	Masahisa Kojima, Max Merchel, Oleksandr Andrushchenko,
	Oleksandr Suvorov, Oleksii Bidnichenko, Patrice Chotard,
	Patrick Delaunay, Peng Fan, Ramon Fried, Ricardo Salveti,
	Sean Anderson, Stefan Roese, Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32

Use the word 'uclass' instead of 'if_type' to complete the conversion.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()

 board/st/common/stm32mp_dfu.c            |   2 +-
 cmd/blk_common.c                         |  18 +--
 cmd/lsblk.c                              |   2 +-
 cmd/mmc.c                                |   2 +-
 common/usb_storage.c                     |   6 +-
 disk/disk-uclass.c                       |   8 +-
 disk/part.c                              |  12 +-
 doc/usage/partitions.rst                 |   2 +-
 drivers/ata/sata.c                       |   2 +-
 drivers/block/blk-uclass.c               | 145 +++++++++++------------
 drivers/block/blk_legacy.c               |  58 ++++-----
 drivers/block/ide.c                      |   8 +-
 drivers/block/sandbox.c                  |   6 +-
 drivers/mmc/mmc-uclass.c                 |   2 +-
 drivers/mmc/mmc_legacy.c                 |   8 +-
 drivers/net/fsl_enetc.c                  |  12 +-
 drivers/net/fsl_enetc.h                  |   2 +-
 drivers/scsi/scsi.c                      |   6 +-
 drivers/virtio/virtio_blk.c              |   2 +-
 drivers/xen/pvblock.c                    |   2 +-
 fs/fat/fat.c                             |   2 +-
 include/blk.h                            | 116 +++++++++---------
 include/efi_api.h                        |   4 +-
 include/efi_loader.h                     |   4 +-
 lib/efi_loader/efi_device_path.c         |   2 +-
 lib/efi_loader/efi_device_path_to_text.c |   4 +-
 lib/efi_loader/efi_disk.c                |  26 ++--
 lib/efi_loader/efi_net.c                 |   2 +-
 lib/efi_loader/efi_var_file.c            |   4 +-
 29 files changed, 234 insertions(+), 235 deletions(-)

diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index fa48b2a35ee..0096f71dfc1 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -37,7 +37,7 @@ static void board_get_alt_info_mmc(struct udevice *dev, char *buf)
 	if (!desc)
 		return;
 
-	name = blk_get_if_type_name(desc->if_type);
+	name = blk_get_uclass_name(desc->uclass_id);
 	devnum = desc->devnum;
 	len = strlen(buf);
 
diff --git a/cmd/blk_common.c b/cmd/blk_common.c
index 369c5ae4bbe..75a072caf51 100644
--- a/cmd/blk_common.c
+++ b/cmd/blk_common.c
@@ -12,10 +12,10 @@
 #include <blk.h>
 #include <command.h>
 
-int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
 		   int *cur_devnump)
 {
-	const char *if_name = blk_get_if_type_name(if_type);
+	const char *if_name = blk_get_uclass_name(uclass_id);
 
 	switch (argc) {
 	case 0:
@@ -23,16 +23,16 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 		return CMD_RET_USAGE;
 	case 2:
 		if (strncmp(argv[1], "inf", 3) == 0) {
-			blk_list_devices(if_type);
+			blk_list_devices(uclass_id);
 			return 0;
 		} else if (strncmp(argv[1], "dev", 3) == 0) {
-			if (blk_print_device_num(if_type, *cur_devnump)) {
+			if (blk_print_device_num(uclass_id, *cur_devnump)) {
 				printf("\nno %s devices available\n", if_name);
 				return CMD_RET_FAILURE;
 			}
 			return 0;
 		} else if (strncmp(argv[1], "part", 4) == 0) {
-			if (blk_list_part(if_type))
+			if (blk_list_part(uclass_id))
 				printf("\nno %s partition table available\n",
 				       if_name);
 			return 0;
@@ -42,7 +42,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 		if (strncmp(argv[1], "dev", 3) == 0) {
 			int dev = (int)dectoul(argv[2], NULL);
 
-			if (!blk_show_device(if_type, dev)) {
+			if (!blk_show_device(uclass_id, dev)) {
 				*cur_devnump = dev;
 				printf("... is now current device\n");
 			} else {
@@ -52,7 +52,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 		} else if (strncmp(argv[1], "part", 4) == 0) {
 			int dev = (int)dectoul(argv[2], NULL);
 
-			if (blk_print_part_devnum(if_type, dev)) {
+			if (blk_print_part_devnum(uclass_id, dev)) {
 				printf("\n%s device %d not available\n",
 				       if_name, dev);
 				return CMD_RET_FAILURE;
@@ -71,7 +71,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 			printf("\n%s read: device %d block # "LBAFU", count %lu ... ",
 			       if_name, *cur_devnump, blk, cnt);
 
-			n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
+			n = blk_read_devnum(uclass_id, *cur_devnump, blk, cnt,
 					    (ulong *)addr);
 
 			printf("%ld blocks read: %s\n", n,
@@ -86,7 +86,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
 			printf("\n%s write: device %d block # "LBAFU", count %lu ... ",
 			       if_name, *cur_devnump, blk, cnt);
 
-			n = blk_write_devnum(if_type, *cur_devnump, blk, cnt,
+			n = blk_write_devnum(uclass_id, *cur_devnump, blk, cnt,
 					     (ulong *)addr);
 
 			printf("%ld blocks written: %s\n", n,
diff --git a/cmd/lsblk.c b/cmd/lsblk.c
index 6a1c8f5ef40..d214dafc3be 100644
--- a/cmd/lsblk.c
+++ b/cmd/lsblk.c
@@ -36,7 +36,7 @@ static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
 				continue;
 			desc = dev_get_uclass_plat(udev);
 			printf("%c %s %u", i ? ',' : ':',
-			       blk_get_if_type_name(desc->if_type),
+			       blk_get_uclass_name(desc->uclass_id),
 			       desc->devnum);
 			i++;
 		}
diff --git a/cmd/mmc.c b/cmd/mmc.c
index 0f1f4e0a71d..6718e99ea7d 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -154,7 +154,7 @@ static struct mmc *__init_mmc_device(int dev, bool force_init,
 
 #ifdef CONFIG_BLOCK_CACHE
 	struct blk_desc *bd = mmc_get_blk_desc(mmc);
-	blkcache_invalidate(bd->if_type, bd->devnum);
+	blkcache_invalidate(bd->uclass_id, bd->devnum);
 #endif
 
 	return mmc;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 7d420160cd5..e59c819bac5 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -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 = UCLASS_USB;
+		blkdev->uclass_id = UCLASS_USB;
 		blkdev->devnum = usb_max_devs;
 		blkdev->part_type = PART_TYPE_UNKNOWN;
 		blkdev->target = 0xff;
@@ -1577,8 +1577,8 @@ U_BOOT_DRIVER(usb_storage_blk) = {
 };
 #else
 U_BOOT_LEGACY_BLK(usb) = {
-	.if_typename	= "usb",
-	.if_type	= UCLASS_USB,
+	.uclass_idname	= "usb",
+	.uclass_id	= UCLASS_USB,
 	.max_devs	= USB_MAX_STOR_DEV,
 	.desc		= usb_dev_desc,
 };
diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
index 9351a5cfa68..551f8b1dca4 100644
--- a/disk/disk-uclass.c
+++ b/disk/disk-uclass.c
@@ -191,12 +191,12 @@ unsigned long dev_read(struct udevice *dev, lbaint_t start,
 		start_in_disk += part->gpt_part_info.start;
 	}
 
-	if (blkcache_read(block_dev->if_type, block_dev->devnum,
+	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
 			  start_in_disk, blkcnt, block_dev->blksz, buffer))
 		return blkcnt;
 	blks_read = ops->read(dev, start, blkcnt, buffer);
 	if (blks_read == blkcnt)
-		blkcache_fill(block_dev->if_type, block_dev->devnum,
+		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
 			      start_in_disk, blkcnt, block_dev->blksz, buffer);
 
 	return blks_read;
@@ -216,7 +216,7 @@ unsigned long dev_write(struct udevice *dev, lbaint_t start,
 	if (!ops->write)
 		return -ENOSYS;
 
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 
 	return ops->write(dev, start, blkcnt, buffer);
 }
@@ -235,7 +235,7 @@ unsigned long dev_erase(struct udevice *dev, lbaint_t start,
 	if (!ops->erase)
 		return -ENOSYS;
 
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 
 	return ops->erase(dev, start, blkcnt);
 }
diff --git a/disk/part.c b/disk/part.c
index 5705c229d59..d73318c8ffe 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -120,7 +120,7 @@ void dev_print(struct blk_desc *dev_desc)
 		return;
 	}
 
-	switch (dev_desc->if_type) {
+	switch (dev_desc->uclass_id) {
 	case UCLASS_SCSI:
 		printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
 			dev_desc->target,dev_desc->lun,
@@ -155,7 +155,7 @@ void dev_print(struct blk_desc *dev_desc)
 		puts("device type unknown\n");
 		return;
 	default:
-		printf("Unhandled device type: %i\n", dev_desc->if_type);
+		printf("Unhandled device type: %i\n", dev_desc->uclass_id);
 		return;
 	}
 	puts ("            Type: ");
@@ -225,7 +225,7 @@ void part_init(struct blk_desc *dev_desc)
 	const int n_ents = ll_entry_count(struct part_driver, part_driver);
 	struct part_driver *entry;
 
-	blkcache_invalidate(dev_desc->if_type, dev_desc->devnum);
+	blkcache_invalidate(dev_desc->uclass_id, dev_desc->devnum);
 
 	dev_desc->part_type = PART_TYPE_UNKNOWN;
 	for (entry = drv; entry != drv + n_ents; entry++) {
@@ -248,7 +248,7 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
 	CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
 	CONFIG_IS_ENABLED(EFI_PARTITION)
 	puts ("\nPartition Map for ");
-	switch (dev_desc->if_type) {
+	switch (dev_desc->uclass_id) {
 	case UCLASS_IDE:
 		puts ("IDE");
 		break;
@@ -408,7 +408,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 == UCLASS_MMC)
+		if ((*dev_desc)->uclass_id == UCLASS_MMC)
 			part_init(*dev_desc);
 	}
 
@@ -762,7 +762,7 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
 {
 	char *devtype;
 
-	switch (dev_desc->if_type) {
+	switch (dev_desc->uclass_id) {
 	case UCLASS_IDE:
 	case UCLASS_AHCI:
 		devtype = "hd";
diff --git a/doc/usage/partitions.rst b/doc/usage/partitions.rst
index 2c1a12b6bf5..628469bbec9 100644
--- a/doc/usage/partitions.rst
+++ b/doc/usage/partitions.rst
@@ -20,7 +20,7 @@ generic syntax.
 interface
         The interface used to access the partition's device, like ``mmc`` or
         ``scsi``. For a full list of supported interfaces, consult the
-        ``if_typename_str`` array in ``drivers/block/blk-uclass.c``
+        ``uclass_idname_str`` array in ``drivers/block/blk-uclass.c``
 
 devnum
         The device number. This defaults to 0.
diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index 604c721cfdc..ce3e9b5a400 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -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 = UCLASS_AHCI;
+		sata_dev_desc[i].uclass_id = 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;
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index a9a85aa37f3..f8157c8d6ae 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -20,7 +20,7 @@
 static struct {
 	enum uclass_id id;
 	const char *name;
-} if_typename_str[] = {
+} uclass_idname_str[] = {
 	{ UCLASS_IDE, "ide" },
 	{ UCLASS_SCSI, "scsi" },
 	{ UCLASS_USB, "usb" },
@@ -34,19 +34,19 @@ static struct {
 	{ UCLASS_PVBLOCK, "pvblock" },
 };
 
-static enum uclass_id if_typename_to_iftype(const char *if_typename)
+static enum uclass_id uclass_idname_to_iftype(const char *uclass_idname)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
-		if (!strcmp(if_typename, if_typename_str[i].name))
-			return if_typename_str[i].id;
+	for (i = 0; i < ARRAY_SIZE(uclass_idname_str); i++) {
+		if (!strcmp(uclass_idname, uclass_idname_str[i].name))
+			return uclass_idname_str[i].id;
 	}
 
 	return UCLASS_INVALID;
 }
 
-static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
+static enum uclass_id conv_uclass_id(enum uclass_id uclass_id)
 {
 	/*
 	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
@@ -65,31 +65,30 @@ static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
 	 *    - rename UCLASS_USB name to "usb_ctlr"
 	 *    - use UCLASS_MASS_STORAGE instead of UCLASS_USB in if_typename_str
 	 */
-	if (if_type == UCLASS_USB)
+	if (uclass_id == UCLASS_USB)
 		return UCLASS_MASS_STORAGE;
-
-	return if_type;
+	return uclass_id;
 }
 
-const char *blk_get_if_type_name(enum uclass_id if_type)
+const char *blk_get_uclass_name(enum uclass_id uclass_id)
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
-		if (if_typename_str[i].id == if_type)
-			return if_typename_str[i].name;
+	for (i = 0; i < ARRAY_SIZE(uclass_idname_str); i++) {
+		if (uclass_idname_str[i].id == uclass_id)
+			return uclass_idname_str[i].name;
 	}
 
 	return "(none)";
 }
 
-struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum)
 {
 	struct blk_desc *desc;
 	struct udevice *dev;
 	int ret;
 
-	ret = blk_get_device(if_type, devnum, &dev);
+	ret = blk_get_device(uclass_id, devnum, &dev);
 	if (ret)
 		return NULL;
 	desc = dev_get_uclass_plat(dev);
@@ -102,7 +101,7 @@ struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
  * name in a local table. This gives us an interface type which we can match
  * against the uclass of the block device's parent.
  */
-struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
+struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname, int devnum)
 {
 	enum uclass_id uclass_id;
 	enum uclass_id type;
@@ -110,16 +109,16 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 	struct uclass *uc;
 	int ret;
 
-	type = if_typename_to_iftype(if_typename);
+	type = uclass_idname_to_iftype(uclass_idname);
 	if (type == UCLASS_INVALID) {
 		debug("%s: Unknown interface type '%s'\n", __func__,
-		      if_typename);
+		      uclass_idname);
 		return NULL;
 	}
-	uclass_id = if_type_to_uclass_id(type);
+	uclass_id = conv_uclass_id(type);
 	if (uclass_id == UCLASS_INVALID) {
 		debug("%s: Unknown uclass for interface type'\n",
-		      blk_get_if_type_name(type));
+		      blk_get_uclass_name(type));
 		return NULL;
 	}
 
@@ -129,8 +128,8 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 	uclass_foreach_dev(dev, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
-		      type, devnum, dev->name, desc->if_type, desc->devnum);
+		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
+		      type, devnum, dev->name, desc->uclass_id, desc->devnum);
 		if (desc->devnum != devnum)
 			continue;
 
@@ -178,14 +177,14 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
 /**
  * get_desc() - Get the block device descriptor for the given device number
  *
- * @if_type:	Interface type
+ * @uclass_id:	Interface type
  * @devnum:	Device number (0 = first)
  * @descp:	Returns block device descriptor on success
  * Return: 0 on success, -ENODEV if there is no such device and no device
  * with a higher device number, -ENOENT if there is no such device but there
  * is one with a higher number, or other -ve on other error.
  */
-static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
+static int get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp)
 {
 	bool found_more = false;
 	struct udevice *dev;
@@ -199,9 +198,9 @@ static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
 	uclass_foreach_dev(dev, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
-		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
-		if (desc->if_type == if_type) {
+		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
+		      uclass_id, devnum, dev->name, desc->uclass_id, desc->devnum);
+		if (desc->uclass_id == uclass_id) {
 			if (desc->devnum == devnum) {
 				ret = device_probe(dev);
 				if (ret)
@@ -218,26 +217,26 @@ static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
 	return found_more ? -ENOENT : -ENODEV;
 }
 
-int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart)
 {
 	struct udevice *dev;
 	int ret;
 
-	ret = blk_get_device(if_type, devnum, &dev);
+	ret = blk_get_device(uclass_id, devnum, &dev);
 	if (ret)
 		return ret;
 
 	return blk_select_hwpart(dev, hwpart);
 }
 
-int blk_list_part(enum uclass_id if_type)
+int blk_list_part(enum uclass_id uclass_id)
 {
 	struct blk_desc *desc;
 	int devnum, ok;
 	int ret;
 
 	for (ok = 0, devnum = 0;; ++devnum) {
-		ret = get_desc(if_type, devnum, &desc);
+		ret = get_desc(uclass_id, devnum, &desc);
 		if (ret == -ENODEV)
 			break;
 		else if (ret)
@@ -255,12 +254,12 @@ int blk_list_part(enum uclass_id if_type)
 	return 0;
 }
 
-int blk_print_part_devnum(enum uclass_id if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id uclass_id, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
 
-	ret = get_desc(if_type, devnum, &desc);
+	ret = get_desc(uclass_id, devnum, &desc);
 	if (ret)
 		return ret;
 	if (desc->type == DEV_TYPE_UNKNOWN)
@@ -270,14 +269,14 @@ int blk_print_part_devnum(enum uclass_id if_type, int devnum)
 	return 0;
 }
 
-void blk_list_devices(enum uclass_id if_type)
+void blk_list_devices(enum uclass_id uclass_id)
 {
 	struct blk_desc *desc;
 	int ret;
 	int i;
 
 	for (i = 0;; ++i) {
-		ret = get_desc(if_type, i, &desc);
+		ret = get_desc(uclass_id, i, &desc);
 		if (ret == -ENODEV)
 			break;
 		else if (ret)
@@ -289,12 +288,12 @@ void blk_list_devices(enum uclass_id if_type)
 	}
 }
 
-int blk_print_device_num(enum uclass_id if_type, int devnum)
+int blk_print_device_num(enum uclass_id uclass_id, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
 
-	ret = get_desc(if_type, devnum, &desc);
+	ret = get_desc(uclass_id, devnum, &desc);
 	if (ret)
 		return ret;
 	printf("\nIDE device %d: ", devnum);
@@ -303,13 +302,13 @@ int blk_print_device_num(enum uclass_id if_type, int devnum)
 	return 0;
 }
 
-int blk_show_device(enum uclass_id if_type, int devnum)
+int blk_show_device(enum uclass_id uclass_id, int devnum)
 {
 	struct blk_desc *desc;
 	int ret;
 
 	printf("\nDevice %d: ", devnum);
-	ret = get_desc(if_type, devnum, &desc);
+	ret = get_desc(uclass_id, devnum, &desc);
 	if (ret == -ENODEV || ret == -ENOENT) {
 		printf("unknown device\n");
 		return -ENODEV;
@@ -324,14 +323,14 @@ int blk_show_device(enum uclass_id if_type, int devnum)
 	return 0;
 }
 
-ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer)
 {
 	struct blk_desc *desc;
 	ulong n;
 	int ret;
 
-	ret = get_desc(if_type, devnum, &desc);
+	ret = get_desc(uclass_id, devnum, &desc);
 	if (ret)
 		return ret;
 	n = blk_dread(desc, start, blkcnt, buffer);
@@ -341,13 +340,13 @@ ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 	return n;
 }
 
-ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer)
 {
 	struct blk_desc *desc;
 	int ret;
 
-	ret = get_desc(if_type, devnum, &desc);
+	ret = get_desc(uclass_id, devnum, &desc);
 	if (ret)
 		return ret;
 	return blk_dwrite(desc, start, blkcnt, buffer);
@@ -370,7 +369,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 	return blk_select_hwpart(desc->bdev, hwpart);
 }
 
-int blk_first_device(int if_type, struct udevice **devp)
+int blk_first_device(int uclass_id, struct udevice **devp)
 {
 	struct blk_desc *desc;
 	int ret;
@@ -382,7 +381,7 @@ int blk_first_device(int if_type, struct udevice **devp)
 		return -ENODEV;
 	do {
 		desc = dev_get_uclass_plat(*devp);
-		if (desc->if_type == if_type)
+		if (desc->uclass_id == uclass_id)
 			return 0;
 		ret = uclass_find_next_device(devp);
 		if (ret)
@@ -395,10 +394,10 @@ int blk_first_device(int if_type, struct udevice **devp)
 int blk_next_device(struct udevice **devp)
 {
 	struct blk_desc *desc;
-	int ret, if_type;
+	int ret, uclass_id;
 
 	desc = dev_get_uclass_plat(*devp);
-	if_type = desc->if_type;
+	uclass_id = desc->uclass_id;
 	do {
 		ret = uclass_find_next_device(devp);
 		if (ret)
@@ -406,12 +405,12 @@ int blk_next_device(struct udevice **devp)
 		if (!*devp)
 			return -ENODEV;
 		desc = dev_get_uclass_plat(*devp);
-		if (desc->if_type == if_type)
+		if (desc->uclass_id == uclass_id)
 			return 0;
 	} while (1);
 }
 
-int blk_find_device(int if_type, int devnum, struct udevice **devp)
+int blk_find_device(int uclass_id, int devnum, struct udevice **devp)
 {
 	struct uclass *uc;
 	struct udevice *dev;
@@ -423,9 +422,9 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp)
 	uclass_foreach_dev(dev, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
-		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
-		if (desc->if_type == if_type && desc->devnum == devnum) {
+		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
+		      uclass_id, devnum, dev->name, desc->uclass_id, desc->devnum);
+		if (desc->uclass_id == uclass_id && desc->devnum == devnum) {
 			*devp = dev;
 			return 0;
 		}
@@ -434,11 +433,11 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp)
 	return -ENODEV;
 }
 
-int blk_get_device(int if_type, int devnum, struct udevice **devp)
+int blk_get_device(int uclass_id, int devnum, struct udevice **devp)
 {
 	int ret;
 
-	ret = blk_find_device(if_type, devnum, devp);
+	ret = blk_find_device(uclass_id, devnum, devp);
 	if (ret)
 		return ret;
 
@@ -455,12 +454,12 @@ unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
 	if (!ops->read)
 		return -ENOSYS;
 
-	if (blkcache_read(block_dev->if_type, block_dev->devnum,
+	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
 			  start, blkcnt, block_dev->blksz, buffer))
 		return blkcnt;
 	blks_read = ops->read(dev, start, blkcnt, buffer);
 	if (blks_read == blkcnt)
-		blkcache_fill(block_dev->if_type, block_dev->devnum,
+		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
 			      start, blkcnt, block_dev->blksz, buffer);
 
 	return blks_read;
@@ -475,7 +474,7 @@ unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
 	if (!ops->write)
 		return -ENOSYS;
 
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 	return ops->write(dev, start, blkcnt, buffer);
 }
 
@@ -488,7 +487,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
 	if (!ops->erase)
 		return -ENOSYS;
 
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 	return ops->erase(dev, start, blkcnt);
 }
 
@@ -525,7 +524,7 @@ const char *blk_get_devtype(struct udevice *dev)
 	return uclass_get_name(device_get_uclass_id(parent));
 };
 
-int blk_find_max_devnum(enum uclass_id if_type)
+int blk_find_max_devnum(enum uclass_id uclass_id)
 {
 	struct udevice *dev;
 	int max_devnum = -ENODEV;
@@ -538,18 +537,18 @@ int blk_find_max_devnum(enum uclass_id if_type)
 	uclass_foreach_dev(dev, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		if (desc->if_type == if_type && desc->devnum > max_devnum)
+		if (desc->uclass_id == uclass_id && desc->devnum > max_devnum)
 			max_devnum = desc->devnum;
 	}
 
 	return max_devnum;
 }
 
-int blk_next_free_devnum(enum uclass_id if_type)
+int blk_next_free_devnum(enum uclass_id uclass_id)
 {
 	int ret;
 
-	ret = blk_find_max_devnum(if_type);
+	ret = blk_find_max_devnum(uclass_id);
 	if (ret == -ENODEV)
 		return 0;
 	if (ret < 0)
@@ -631,7 +630,7 @@ int blk_count_devices(enum blk_flag_t flag)
 	return count;
 }
 
-static int blk_claim_devnum(enum uclass_id if_type, int devnum)
+static int blk_claim_devnum(enum uclass_id uclass_id, int devnum)
 {
 	struct udevice *dev;
 	struct uclass *uc;
@@ -643,8 +642,8 @@ static int blk_claim_devnum(enum uclass_id if_type, int devnum)
 	uclass_foreach_dev(dev, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		if (desc->if_type == if_type && desc->devnum == devnum) {
-			int next = blk_next_free_devnum(if_type);
+		if (desc->uclass_id == uclass_id && desc->devnum == devnum) {
+			int next = blk_next_free_devnum(uclass_id);
 
 			if (next < 0)
 				return next;
@@ -657,7 +656,7 @@ static int blk_claim_devnum(enum uclass_id if_type, int devnum)
 }
 
 int blk_create_device(struct udevice *parent, const char *drv_name,
-		      const char *name, int if_type, int devnum, int blksz,
+		      const char *name, int uclass_id, int devnum, int blksz,
 		      lbaint_t lba, struct udevice **devp)
 {
 	struct blk_desc *desc;
@@ -665,9 +664,9 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 	int ret;
 
 	if (devnum == -1) {
-		devnum = blk_next_free_devnum(if_type);
+		devnum = blk_next_free_devnum(uclass_id);
 	} else {
-		ret = blk_claim_devnum(if_type, devnum);
+		ret = blk_claim_devnum(uclass_id, devnum);
 		if (ret < 0 && ret != -ENOENT)
 			return ret;
 	}
@@ -677,7 +676,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 	if (ret)
 		return ret;
 	desc = dev_get_uclass_plat(dev);
-	desc->if_type = if_type;
+	desc->uclass_id = uclass_id;
 	desc->blksz = blksz;
 	desc->log2blksz = LOG2(desc->blksz);
 	desc->lba = lba;
@@ -690,7 +689,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 }
 
 int blk_create_devicef(struct udevice *parent, const char *drv_name,
-		       const char *name, int if_type, int devnum, int blksz,
+		       const char *name, int uclass_id, int devnum, int blksz,
 		       lbaint_t lba, struct udevice **devp)
 {
 	char dev_name[30], *str;
@@ -701,7 +700,7 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name,
 	if (!str)
 		return -ENOMEM;
 
-	ret = blk_create_device(parent, drv_name, str, if_type, devnum,
+	ret = blk_create_device(parent, drv_name, str, uclass_id, devnum,
 				blksz, lba, devp);
 	if (ret) {
 		free(str);
@@ -725,7 +724,7 @@ int blk_probe_or_unbind(struct udevice *dev)
 	return ret;
 }
 
-int blk_unbind_all(int if_type)
+int blk_unbind_all(int uclass_id)
 {
 	struct uclass *uc;
 	struct udevice *dev, *next;
@@ -737,7 +736,7 @@ int blk_unbind_all(int if_type)
 	uclass_foreach_dev_safe(dev, next, uc) {
 		struct blk_desc *desc = dev_get_uclass_plat(dev);
 
-		if (desc->if_type == if_type) {
+		if (desc->uclass_id == uclass_id) {
 			ret = device_remove(dev, DM_REMOVE_NORMAL);
 			if (ret)
 				return ret;
diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
index 8c6f9cb208e..2ba5cc2d5a8 100644
--- a/drivers/block/blk_legacy.c
+++ b/drivers/block/blk_legacy.c
@@ -9,14 +9,14 @@
 #include <part.h>
 #include <linux/err.h>
 
-struct blk_driver *blk_driver_lookup_type(int if_type)
+struct blk_driver *blk_driver_lookup_type(int uclass_id)
 {
 	struct blk_driver *drv = ll_entry_start(struct blk_driver, blk_driver);
 	const int n_ents = ll_entry_count(struct blk_driver, blk_driver);
 	struct blk_driver *entry;
 
 	for (entry = drv; entry != drv + n_ents; entry++) {
-		if (if_type == entry->if_type)
+		if (uclass_id == entry->uclass_id)
 			return entry;
 	}
 
@@ -24,14 +24,14 @@ struct blk_driver *blk_driver_lookup_type(int if_type)
 	return NULL;
 }
 
-static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
+static struct blk_driver *blk_driver_lookup_typename(const char *uclass_idname)
 {
 	struct blk_driver *drv = ll_entry_start(struct blk_driver, blk_driver);
 	const int n_ents = ll_entry_count(struct blk_driver, blk_driver);
 	struct blk_driver *entry;
 
 	for (entry = drv; entry != drv + n_ents; entry++) {
-		if (!strcmp(if_typename, entry->if_typename))
+		if (!strcmp(uclass_idname, entry->uclass_idname))
 			return entry;
 	}
 
@@ -39,11 +39,11 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
 	return NULL;
 }
 
-const char *blk_get_if_type_name(enum uclass_id if_type)
+const char *blk_get_uclass_name(enum uclass_id uclass_id)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 
-	return drv ? drv->if_typename : NULL;
+	return drv ? drv->uclass_idname : NULL;
 }
 
 /**
@@ -70,14 +70,14 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
 	return drv->get_dev(devnum, descp);
 }
 
-int blk_list_part(enum uclass_id if_type)
+int blk_list_part(enum uclass_id uclass_id)
 {
 	struct blk_driver *drv;
 	struct blk_desc *desc;
 	int devnum, ok;
 	bool first = true;
 
-	drv = blk_driver_lookup_type(if_type);
+	drv = blk_driver_lookup_type(uclass_id);
 	if (!drv)
 		return -ENOSYS;
 	for (ok = 0, devnum = 0; devnum < drv->max_devs; ++devnum) {
@@ -97,9 +97,9 @@ int blk_list_part(enum uclass_id if_type)
 	return 0;
 }
 
-int blk_print_part_devnum(enum uclass_id if_type, int devnum)
+int blk_print_part_devnum(enum uclass_id uclass_id, int devnum)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int ret;
 
@@ -115,9 +115,9 @@ int blk_print_part_devnum(enum uclass_id if_type, int devnum)
 	return 0;
 }
 
-void blk_list_devices(enum uclass_id if_type)
+void blk_list_devices(enum uclass_id uclass_id)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int i;
 
@@ -133,9 +133,9 @@ void blk_list_devices(enum uclass_id if_type)
 	}
 }
 
-int blk_print_device_num(enum uclass_id if_type, int devnum)
+int blk_print_device_num(enum uclass_id uclass_id, int devnum)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int ret;
 
@@ -144,15 +144,15 @@ int blk_print_device_num(enum uclass_id if_type, int devnum)
 	ret = get_desc(drv, devnum, &desc);
 	if (ret)
 		return ret;
-	printf("\n%s device %d: ", drv->if_typename, devnum);
+	printf("\n%s device %d: ", drv->uclass_idname, devnum);
 	dev_print(desc);
 
 	return 0;
 }
 
-int blk_show_device(enum uclass_id if_type, int devnum)
+int blk_show_device(enum uclass_id uclass_id, int devnum)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int ret;
 
@@ -174,9 +174,9 @@ int blk_show_device(enum uclass_id if_type, int devnum)
 	return 0;
 }
 
-struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 
 	if (!drv)
@@ -190,7 +190,7 @@ struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
 
 int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(desc->if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(desc->uclass_id);
 
 	if (!drv)
 		return -ENOSYS;
@@ -200,9 +200,9 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 	return 0;
 }
 
-struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
+struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname, int devnum)
 {
-	struct blk_driver *drv = blk_driver_lookup_typename(if_typename);
+	struct blk_driver *drv = blk_driver_lookup_typename(uclass_idname);
 	struct blk_desc *desc;
 
 	if (!drv)
@@ -214,10 +214,10 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 	return desc;
 }
 
-ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	ulong n;
 	int ret;
@@ -234,10 +234,10 @@ ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 	return n;
 }
 
-ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int ret;
 
@@ -249,9 +249,9 @@ ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
 	return desc->block_write(desc, start, blkcnt, buffer);
 }
 
-int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
+int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart)
 {
-	struct blk_driver *drv = blk_driver_lookup_type(if_type);
+	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
 	struct blk_desc *desc;
 	int ret;
 
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 73da29ad552..ef5644d0b90 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -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 = UCLASS_IDE;
+	dev_desc->uclass_id = 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 = UCLASS_IDE;
+		ide_dev_desc[i].uclass_id = UCLASS_IDE;
 		ide_dev_desc[i].devnum = i;
 		ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
 		ide_dev_desc[i].blksz = 0;
@@ -1143,8 +1143,8 @@ UCLASS_DRIVER(ide) = {
 };
 #else
 U_BOOT_LEGACY_BLK(ide) = {
-	.if_typename	= "ide",
-	.if_type	= UCLASS_IDE,
+	.uclass_idname	= "ide",
+	.uclass_id	= UCLASS_IDE,
 	.max_devs	= CONFIG_SYS_IDE_MAXDEVICE,
 	.desc		= ide_dev_desc,
 };
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 2de12e0a93e..6e43404bcaa 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -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 = UCLASS_ROOT;
+	blk_dev->uclass_id = 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;
@@ -262,8 +262,8 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
 };
 #else
 U_BOOT_LEGACY_BLK(sandbox_host) = {
-	.if_typename	= "host",
-	.if_type	= UCLASS_ROOT,
+	.uclass_idname	= "host",
+	.uclass_id	= UCLASS_ROOT,
 	.max_devs	= SANDBOX_HOST_MAX_DEVICES,
 	.get_dev	= host_get_dev_err,
 };
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index b1bd4ae1bc8..759a6b728c8 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -472,7 +472,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
 
 	ret = mmc_switch_part(mmc, hwpart);
 	if (!ret)
-		blkcache_invalidate(desc->if_type, desc->devnum);
+		blkcache_invalidate(desc->uclass_id, desc->devnum);
 
 	return ret;
 }
diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
index 4e0891e5dfe..a101ee43fde 100644
--- a/drivers/mmc/mmc_legacy.c
+++ b/drivers/mmc/mmc_legacy.c
@@ -132,7 +132,7 @@ static struct mmc mmc_static = {
 	.dsr_imp		= 0,
 	.dsr			= 0xffffffff,
 	.block_dev = {
-		.if_type	= UCLASS_MMC,
+		.uclass_id	= 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 = UCLASS_MMC;
+	bdesc->uclass_id = UCLASS_MMC;
 	bdesc->removable = 1;
 	bdesc->devnum = mmc_get_next_devnum();
 	bdesc->block_read = mmc_bread;
@@ -253,8 +253,8 @@ static int mmc_get_dev(int dev, struct blk_desc **descp)
 }
 
 U_BOOT_LEGACY_BLK(mmc) = {
-	.if_typename	= "mmc",
-	.if_type	= UCLASS_MMC,
+	.uclass_idname	= "mmc",
+	.uclass_id	= UCLASS_MMC,
 	.max_devs	= -1,
 	.get_dev	= mmc_get_dev,
 	.select_hwpart	= mmc_select_hwpartp,
diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index cd4c2c29a65..f1682864611 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -144,7 +144,7 @@ static int enetc_init_sgmii(struct udevice *dev)
 	if (!enetc_has_imdio(dev))
 		return 0;
 
-	if (priv->if_type == PHY_INTERFACE_MODE_2500BASEX)
+	if (priv->uclass_id == PHY_INTERFACE_MODE_2500BASEX)
 		is2500 = true;
 
 	/*
@@ -219,7 +219,7 @@ static void enetc_setup_mac_iface(struct udevice *dev,
 	struct enetc_priv *priv = dev_get_priv(dev);
 	u32 if_mode;
 
-	switch (priv->if_type) {
+	switch (priv->uclass_id) {
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII_RXID:
@@ -276,14 +276,14 @@ static void enetc_start_pcs(struct udevice *dev)
 		return;
 	}
 
-	priv->if_type = dev_read_phy_mode(dev);
-	if (priv->if_type == PHY_INTERFACE_MODE_NA) {
+	priv->uclass_id = dev_read_phy_mode(dev);
+	if (priv->uclass_id == PHY_INTERFACE_MODE_NA) {
 		enetc_dbg(dev,
 			  "phy-mode property not found, defaulting to SGMII\n");
-		priv->if_type = PHY_INTERFACE_MODE_SGMII;
+		priv->uclass_id = PHY_INTERFACE_MODE_SGMII;
 	}
 
-	switch (priv->if_type) {
+	switch (priv->uclass_id) {
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_2500BASEX:
 		enetc_init_sgmii(dev);
diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h
index 69f2f4aaff1..f2acf367aa3 100644
--- a/drivers/net/fsl_enetc.h
+++ b/drivers/net/fsl_enetc.h
@@ -158,7 +158,7 @@ struct enetc_priv {
 	struct bd_ring tx_bdr;
 	struct bd_ring rx_bdr;
 
-	int if_type;
+	int uclass_id;
 	struct mii_dev imdio;
 	struct phy_device *phy;
 };
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 99be5aef877..3e769b0843f 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -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 = UCLASS_SCSI;
+	dev_desc->uclass_id = UCLASS_SCSI;
 	dev_desc->devnum = devnum;
 	dev_desc->part_type = PART_TYPE_UNKNOWN;
 
@@ -706,8 +706,8 @@ U_BOOT_DRIVER(scsi_blk) = {
 };
 #else
 U_BOOT_LEGACY_BLK(scsi) = {
-	.if_typename	= "scsi",
-	.if_type	= UCLASS_SCSI,
+	.uclass_idname	= "scsi",
+	.uclass_id	= UCLASS_SCSI,
 	.max_devs	= SCSI_MAX_DEVICE,
 	.desc		= scsi_dev_desc,
 };
diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
index 9710b79117c..30cfc56725c 100644
--- a/drivers/virtio/virtio_blk.c
+++ b/drivers/virtio/virtio_blk.c
@@ -75,7 +75,7 @@ static int virtio_blk_bind(struct udevice *dev)
 	struct blk_desc *desc = dev_get_uclass_plat(dev);
 	int devnum;
 
-	desc->if_type = UCLASS_VIRTIO;
+	desc->uclass_id = UCLASS_VIRTIO;
 	/*
 	 * Initialize the devnum to -ENODEV. This is to make sure that
 	 * blk_next_free_devnum() works as expected, since the default
diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c
index 1090e528d02..970182cd904 100644
--- a/drivers/xen/pvblock.c
+++ b/drivers/xen/pvblock.c
@@ -665,7 +665,7 @@ static int pvblock_blk_bind(struct udevice *udev)
 	struct blk_desc *desc = dev_get_uclass_plat(udev);
 	int devnum;
 
-	desc->if_type = UCLASS_PVBLOCK;
+	desc->uclass_id = UCLASS_PVBLOCK;
 	/*
 	 * Initialize the devnum to -ENODEV. This is to make sure that
 	 * blk_next_free_devnum() works as expected, since the default
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index c64e253abd4..a945904785f 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1145,7 +1145,7 @@ int file_fat_detectfs(void)
 	}
 
 	if (blk_enabled()) {
-		printf("Interface:  %s\n", blk_get_if_type_name(cur_dev->if_type));
+		printf("Interface:  %s\n", blk_get_uclass_name(cur_dev->uclass_id));
 		printf("  Device %d: ", cur_dev->devnum);
 		dev_print(cur_dev);
 	}
diff --git a/include/blk.h b/include/blk.h
index 279f9ea4a9d..cdc6f0fc7eb 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -54,7 +54,7 @@ struct blk_desc {
 	 * TODO: With driver model we should be able to use the parent
 	 * device's uclass instead.
 	 */
-	enum uclass_id	if_type;	/* type of the interface */
+	enum uclass_id	uclass_id;	/* type of the interface */
 	int		devnum;		/* device number */
 	unsigned char	part_type;	/* partition type */
 	unsigned char	target;		/* target SCSI ID */
@@ -114,7 +114,7 @@ int blkcache_init(void);
 /**
  * blkcache_read() - attempt to read a set of blocks from cache
  *
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
  * @param dev - device index of particular type
  * @param start - starting block number
  * @param blkcnt - number of blocks to read
@@ -131,7 +131,7 @@ int blkcache_read(int iftype, int dev,
  * blkcache_fill() - make data read from a block device available
  * to the block cache
  *
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
  * @param dev - device index of particular type
  * @param start - starting block number
  * @param blkcnt - number of blocks available
@@ -147,7 +147,7 @@ void blkcache_fill(int iftype, int dev,
  * blkcache_invalidate() - discard the cache for a set of blocks
  * because of a write or device (re)initialization.
  *
- * @param iftype - IF_TYPE_x for type of device
+ * @param iftype - uclass_id_x for type of device
  * @param dev - device index of particular type
  */
 void blkcache_invalidate(int iftype, int dev);
@@ -279,22 +279,22 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
  * This function does not activate the device. The device will be returned
  * whether or not it is activated.
  *
- * @if_type:	Interface type (enum uclass_id_t)
+ * @uclass_id:	Interface type (enum uclass_id_t)
  * @devnum:	Device number (specific to each interface type)
  * @devp:	the device, if found
  * Return: 0 if found, -ENODEV if no device found, or other -ve error value
  */
-int blk_find_device(int if_type, int devnum, struct udevice **devp);
+int blk_find_device(int uclass_id, int devnum, struct udevice **devp);
 
 /**
  * blk_get_device() - Find and probe a block device ready for use
  *
- * @if_type:	Interface type (enum uclass_id_t)
+ * @uclass_id:	Interface type (enum uclass_id_t)
  * @devnum:	Device number (specific to each interface type)
  * @devp:	the device, if found
  * Return: 0 if found, -ENODEV if no device found, or other -ve error value
  */
-int blk_get_device(int if_type, int devnum, struct udevice **devp);
+int blk_get_device(int uclass_id, int devnum, struct udevice **devp);
 
 /**
  * blk_first_device() - Find the first device for a given interface
@@ -305,7 +305,7 @@ int blk_get_device(int if_type, int devnum, struct udevice **devp);
  * @devp:	the device, if found
  * Return: 0 if found, -ENODEV if no device, or other -ve error value
  */
-int blk_first_device(int if_type, struct udevice **devp);
+int blk_first_device(int uclass_id, struct udevice **devp);
 
 /**
  * blk_next_device() - Find the next device for a given interface
@@ -327,7 +327,7 @@ int blk_next_device(struct udevice **devp);
  * @parent:	Parent of the new device
  * @drv_name:	Driver name to use for the block device
  * @name:	Name for the device
- * @if_type:	Interface type (enum uclass_id_t)
+ * @uclass_id:	Interface type (enum uclass_id_t)
  * @devnum:	Device number, specific to the interface type, or -1 to
  *		allocate the next available number
  * @blksz:	Block size of the device in bytes (typically 512)
@@ -335,7 +335,7 @@ int blk_next_device(struct udevice **devp);
  * @devp:	the new device (which has not been probed)
  */
 int blk_create_device(struct udevice *parent, const char *drv_name,
-		      const char *name, int if_type, int devnum, int blksz,
+		      const char *name, int uclass_id, int devnum, int blksz,
 		      lbaint_t lba, struct udevice **devp);
 
 /**
@@ -344,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
  * @parent:	Parent of the new device
  * @drv_name:	Driver name to use for the block device
  * @name:	Name for the device (parent name is prepended)
- * @if_type:	Interface type (enum uclass_id_t)
+ * @uclass_id:	Interface type (enum uclass_id_t)
  * @devnum:	Device number, specific to the interface type, or -1 to
  *		allocate the next available number
  * @blksz:	Block size of the device in bytes (typically 512)
@@ -352,7 +352,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
  * @devp:	the new device (which has not been probed)
  */
 int blk_create_devicef(struct udevice *parent, const char *drv_name,
-		       const char *name, int if_type, int devnum, int blksz,
+		       const char *name, int uclass_id, int devnum, int blksz,
 		       lbaint_t lba, struct udevice **devp);
 
 /**
@@ -372,33 +372,33 @@ int blk_probe_or_unbind(struct udevice *dev);
  *
  * The devices are removed and then unbound.
  *
- * @if_type:	Interface type to unbind
+ * @uclass_id:	Interface type to unbind
  * Return: 0 if OK, -ve on error
  */
-int blk_unbind_all(int if_type);
+int blk_unbind_all(int uclass_id);
 
 /**
  * blk_find_max_devnum() - find the maximum device number for an interface type
  *
- * Finds the last allocated device number for an interface type @if_type. The
+ * Finds the last allocated device number for an interface type @uclass_id. The
  * next number is safe to use for a newly allocated device.
  *
- * @if_type:	Interface type to scan
+ * @uclass_id:	Interface type to scan
  * Return: maximum device number found, or -ENODEV if none, or other -ve on
  * error
  */
-int blk_find_max_devnum(enum uclass_id if_type);
+int blk_find_max_devnum(enum uclass_id uclass_id);
 
 /**
  * blk_next_free_devnum() - get the next device number for an interface type
  *
  * Finds the next number that is safe to use for a newly allocated device for
- * an interface type @if_type.
+ * an interface type @uclass_id.
  *
- * @if_type:	Interface type to scan
+ * @uclass_id:	Interface type to scan
  * Return: next device number safe to use, or -ve on error
  */
-int blk_next_free_devnum(enum uclass_id if_type);
+int blk_next_free_devnum(enum uclass_id uclass_id);
 
 /**
  * blk_select_hwpart() - select a hardware partition
@@ -447,7 +447,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
 			      lbaint_t blkcnt, void *buffer)
 {
 	ulong blks_read;
-	if (blkcache_read(block_dev->if_type, block_dev->devnum,
+	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
 			  start, blkcnt, block_dev->blksz, buffer))
 		return blkcnt;
 
@@ -458,7 +458,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
 	 */
 	blks_read = block_dev->block_read(block_dev, start, blkcnt, buffer);
 	if (blks_read == blkcnt)
-		blkcache_fill(block_dev->if_type, block_dev->devnum,
+		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
 			      start, blkcnt, block_dev->blksz, buffer);
 
 	return blks_read;
@@ -467,14 +467,14 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
 static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
 			       lbaint_t blkcnt, const void *buffer)
 {
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 	return block_dev->block_write(block_dev, start, blkcnt, buffer);
 }
 
 static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
 			       lbaint_t blkcnt)
 {
-	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
 	return block_dev->block_erase(block_dev, start, blkcnt);
 }
 
@@ -485,15 +485,15 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
  * driver should be provided using U_BOOT_LEGACY_BLK() for each interface
  * type that is to be supported.
  *
- * @if_typename:	Interface type name
- * @if_type:		Interface type
+ * @uclass_idname:	Interface type name
+ * @uclass_id:		Interface type
  * @max_devs:		Maximum number of devices supported
  * @desc:		Pointer to list of devices for this interface type,
  *			or NULL to use @get_dev() instead
  */
 struct blk_driver {
-	const char *if_typename;
-	enum uclass_id if_type;
+	const char *uclass_idname;
+	enum uclass_id uclass_id;
 	int max_devs;
 	struct blk_desc *desc;
 	/**
@@ -540,7 +540,7 @@ struct blk_driver {
 #define U_BOOT_LEGACY_BLK(__name)					\
 	ll_entry_declare(struct blk_driver, __name, blk_driver)
 
-struct blk_driver *blk_driver_lookup_type(int if_type);
+struct blk_driver *blk_driver_lookup_type(int uclass_id);
 
 #endif /* !CONFIG_BLK */
 
@@ -550,23 +550,23 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
  * This looks through the available block devices of the given type, returning
  * the one with the given @devnum.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * Return: point to block device descriptor, or NULL if not found
  */
-struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
+struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum);
 
 /**
  * blk_get_devnum_by_type() - Get a block device by type name, and number
  *
- * This looks up the block device type based on @if_typename, then calls
+ * This looks up the block device type based on @uclass_idname, then calls
  * blk_get_devnum_by_type().
  *
- * @if_typename:	Block device type name
+ * @uclass_idname:	Block device type name
  * @devnum:		Device number
  * Return: point to block device descriptor, or NULL if not found
  */
-struct blk_desc *blk_get_devnum_by_typename(const char *if_typename,
+struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname,
 					    int devnum);
 
 /**
@@ -585,34 +585,34 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
 /**
  * blk_list_part() - list the partitions for block devices of a given type
  *
- * This looks up the partition type for each block device of type @if_type,
+ * This looks up the partition type for each block device of type @uclass_id,
  * then displays a list of partitions.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * Return: 0 if OK, -ENODEV if there is none of that type
  */
-int blk_list_part(enum uclass_id if_type);
+int blk_list_part(enum uclass_id uclass_id);
 
 /**
  * blk_list_devices() - list the block devices of a given type
  *
- * This lists each block device of the type @if_type, showing the capacity
+ * This lists each block device of the type @uclass_id, showing the capacity
  * as well as type-specific information.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  */
-void blk_list_devices(enum uclass_id if_type);
+void blk_list_devices(enum uclass_id uclass_id);
 
 /**
  * blk_show_device() - show information about a given block device
  *
  * This shows the block device capacity as well as type-specific information.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * Return: 0 if OK, -ENODEV for invalid device number
  */
-int blk_show_device(enum uclass_id if_type, int devnum);
+int blk_show_device(enum uclass_id uclass_id, int devnum);
 
 /**
  * blk_print_device_num() - show information about a given block device
@@ -620,45 +620,45 @@ int blk_show_device(enum uclass_id if_type, int devnum);
  * This is similar to blk_show_device() but returns an error if the block
  * device type is unknown.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
  * device is not connected
  */
-int blk_print_device_num(enum uclass_id if_type, int devnum);
+int blk_print_device_num(enum uclass_id uclass_id, int devnum);
 
 /**
  * blk_print_part_devnum() - print the partition information for a device
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
  * the interface type is not supported, other -ve on other error
  */
-int blk_print_part_devnum(enum uclass_id if_type, int devnum);
+int blk_print_part_devnum(enum uclass_id uclass_id, int devnum);
 
 /**
  * blk_read_devnum() - read blocks from a device
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * @blkcnt:	Number of blocks to read
  * @buffer:	Address to write data to
  * Return: number of blocks read, or -ve error number on error
  */
-ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		      lbaint_t blkcnt, void *buffer);
 
 /**
  * blk_write_devnum() - write blocks to a device
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * @blkcnt:	Number of blocks to write
  * @buffer:	Address to read data from
  * Return: number of blocks written, or -ve error number on error
  */
-ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
+ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
 		       lbaint_t blkcnt, const void *buffer);
 
 /**
@@ -667,31 +667,31 @@ ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
  * This is similar to blk_dselect_hwpart() but it looks up the interface and
  * device number.
  *
- * @if_type:	Block device type
+ * @uclass_id:	Block device type
  * @devnum:	Device number
  * @hwpart:	Partition number to select
  * Return: 0 if OK, -ve on error
  */
-int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
+int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart);
 
 /**
- * blk_get_if_type_name() - Get the name of an interface type
+ * blk_get_uclass_name() - Get the name of an interface type
  *
- * @if_type: Interface type to check
+ * @uclass_id: Interface type to check
  * Return: name of interface, or NULL if none
  */
-const char *blk_get_if_type_name(enum uclass_id if_type);
+const char *blk_get_uclass_name(enum uclass_id uclass_id);
 
 /**
  * blk_common_cmd() - handle common commands with block devices
  *
  * @args: Number of arguments to the command (argv[0] is the command itself)
  * @argv: Command arguments
- * @if_type: Interface type
+ * @uclass_id: Interface type
  * @cur_devnump: Current device number for this interface type
  * Return: 0 if OK, CMD_RET_ERROR on error
  */
-int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
+int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
 		   int *cur_devnump);
 
 enum blk_flag_t {
diff --git a/include/efi_api.h b/include/efi_api.h
index 83c01085fde..f9c9aa64b24 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -622,7 +622,7 @@ struct efi_device_path_sata {
 struct efi_device_path_mac_addr {
 	struct efi_device_path dp;
 	struct efi_mac_addr mac;
-	u8 if_type;
+	u8 uclass_id;
 } __packed;
 
 struct efi_device_path_usb_class {
@@ -1410,7 +1410,7 @@ struct efi_simple_network_mode {
 	struct efi_mac_address current_address;
 	struct efi_mac_address broadcast_address;
 	struct efi_mac_address permanent_address;
-	u8 if_type;
+	u8 uclass_id;
 	u8 mac_changeable;
 	u8 multitx_supported;
 	u8 media_present_supported;
diff --git a/include/efi_loader.h b/include/efi_loader.h
index ae58efb0036..aab128a6dda 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
 
 /* EFI system partition */
 extern struct efi_system_partition {
-	enum uclass_id if_type;
+	enum uclass_id uclass_id;
 	int devnum;
 	u8 part;
 } efi_system_partition;
@@ -545,7 +545,7 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
 				   struct efi_loaded_image *loaded_image_info);
 /* Create handles and protocols for the partitions of a block device */
 int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
-			       const char *if_typename, int diskid,
+			       const char *uclass_idname, int diskid,
 			       const char *pdevname);
 /* Called by bootefi to make GOP (graphical) interface available */
 efi_status_t efi_gop_register(void);
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index ebffb771228..9787033c3df 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -626,7 +626,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 		/* We only support IPv4 */
 		memcpy(&dp->mac, &pdata->enetaddr, ARP_HLEN);
 		/* Ethernet */
-		dp->if_type = 1;
+		dp->uclass_id = 1;
 		return &dp[1];
 	}
 #endif
diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
index 4d73954ef89..aef18483c3a 100644
--- a/lib/efi_loader/efi_device_path_to_text.c
+++ b/lib/efi_loader/efi_device_path_to_text.c
@@ -156,12 +156,12 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
 		struct efi_device_path_mac_addr *mdp =
 			(struct efi_device_path_mac_addr *)dp;
 
-		if (mdp->if_type <= 1)
+		if (mdp->uclass_id <= 1)
 			n = 6;
 		s += sprintf(s, "MAC(");
 		for (i = 0; i < n; ++i)
 			s += sprintf(s, "%02x", mdp->mac.addr[i]);
-		s += sprintf(s, ",%u)", mdp->if_type);
+		s += sprintf(s, ",%u)", mdp->uclass_id);
 
 		break;
 	}
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index ad543bc117e..83126f55ea1 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -379,7 +379,7 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
  *
  * @parent:		parent handle
  * @dp_parent:		parent device path
- * @if_typename:	interface name for block device
+ * @uclass_idname:	interface name for block device
  * @desc:		internal block device
  * @dev_index:		device index for block device
  * @part_info:		partition info
@@ -390,7 +390,7 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
 static efi_status_t efi_disk_add_dev(
 				efi_handle_t parent,
 				struct efi_device_path *dp_parent,
-				const char *if_typename,
+				const char *uclass_idname,
 				struct blk_desc *desc,
 				int dev_index,
 				struct disk_partition *part_info,
@@ -502,13 +502,13 @@ static efi_status_t efi_disk_add_dev(
 		  diskobj->media.last_block);
 
 	/* Store first EFI system partition */
-	if (part && !efi_system_partition.if_type) {
+	if (part && !efi_system_partition.uclass_id) {
 		if (part_info->bootable & PART_EFI_SYSTEM_PARTITION) {
-			efi_system_partition.if_type = desc->if_type;
+			efi_system_partition.uclass_id = desc->uclass_id;
 			efi_system_partition.devnum = desc->devnum;
 			efi_system_partition.part = part;
 			EFI_PRINT("EFI system partition: %s %x:%x\n",
-				  blk_get_if_type_name(desc->if_type),
+				  blk_get_uclass_name(desc->uclass_id),
 				  desc->devnum, part);
 		}
 	}
@@ -532,15 +532,15 @@ static int efi_disk_create_raw(struct udevice *dev)
 {
 	struct efi_disk_obj *disk;
 	struct blk_desc *desc;
-	const char *if_typename;
+	const char *uclass_idname;
 	int diskid;
 	efi_status_t ret;
 
 	desc = dev_get_uclass_plat(dev);
-	if_typename = blk_get_if_type_name(desc->if_type);
+	uclass_idname = blk_get_uclass_name(desc->uclass_id);
 	diskid = desc->devnum;
 
-	ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
+	ret = efi_disk_add_dev(NULL, NULL, uclass_idname, desc,
 			       diskid, NULL, 0, &disk);
 	if (ret != EFI_SUCCESS) {
 		if (ret == EFI_NOT_READY)
@@ -575,7 +575,7 @@ static int efi_disk_create_part(struct udevice *dev)
 {
 	efi_handle_t parent;
 	struct blk_desc *desc;
-	const char *if_typename;
+	const char *uclass_idname;
 	struct disk_part *part_data;
 	struct disk_partition *info;
 	unsigned int part;
@@ -589,7 +589,7 @@ static int efi_disk_create_part(struct udevice *dev)
 		return -1;
 
 	desc = dev_get_uclass_plat(dev_get_parent(dev));
-	if_typename = blk_get_if_type_name(desc->if_type);
+	uclass_idname = blk_get_uclass_name(desc->uclass_id);
 	diskid = desc->devnum;
 
 	part_data = dev_get_uclass_plat(dev);
@@ -601,7 +601,7 @@ static int efi_disk_create_part(struct udevice *dev)
 		return -1;
 	dp_parent = (struct efi_device_path *)handler->protocol_interface;
 
-	ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid,
+	ret = efi_disk_add_dev(parent, dp_parent, uclass_idname, desc, diskid,
 			       info, part, &disk);
 	if (ret != EFI_SUCCESS) {
 		log_err("Adding partition for %s failed\n", dev->name);
@@ -650,7 +650,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 != UCLASS_EFI_LOADER) {
+	if (desc->uclass_id != UCLASS_EFI_LOADER) {
 		ret = efi_disk_create_raw(dev);
 		if (ret)
 			return -1;
@@ -685,7 +685,7 @@ static int efi_disk_delete_raw(struct udevice *dev)
 		return -1;
 
 	desc = dev_get_uclass_plat(dev);
-	if (desc->if_type != UCLASS_EFI_LOADER) {
+	if (desc->uclass_id != UCLASS_EFI_LOADER) {
 		diskobj = container_of(handle, struct efi_disk_obj, header);
 		efi_free_pool(diskobj->dp);
 	}
diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
index 69276b275d9..0cdc1ff5381 100644
--- a/lib/efi_loader/efi_net.c
+++ b/lib/efi_loader/efi_net.c
@@ -924,7 +924,7 @@ efi_status_t efi_net_register(void)
 	netobj->net_mode.hwaddr_size = ARP_HLEN;
 	netobj->net_mode.media_header_size = ETHER_HDR_SIZE;
 	netobj->net_mode.max_packet_size = PKTSIZE;
-	netobj->net_mode.if_type = ARP_ETHER;
+	netobj->net_mode.uclass_id = ARP_ETHER;
 
 	netobj->pxe.revision = EFI_PXE_BASE_CODE_PROTOCOL_REVISION;
 	netobj->pxe.start = efi_pxe_base_code_start;
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 994e66392fb..3d58caa13da 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -38,13 +38,13 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
 	char part_str[PART_STR_LEN];
 	int r;
 
-	if (efi_system_partition.if_type == UCLASS_INVALID) {
+	if (efi_system_partition.uclass_id == UCLASS_INVALID) {
 		log_err("No EFI system partition\n");
 		return EFI_DEVICE_ERROR;
 	}
 	snprintf(part_str, PART_STR_LEN, "%x:%x",
 		 efi_system_partition.devnum, efi_system_partition.part);
-	r = fs_set_blk_dev(blk_get_if_type_name(efi_system_partition.if_type),
+	r = fs_set_blk_dev(blk_get_uclass_name(efi_system_partition.uclass_id),
 			   part_str, FS_TYPE_ANY);
 	if (r) {
 		log_err("Cannot read EFI system partition\n");
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 00/24] blk: Rationalise the block interface
  2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
                   ` (23 preceding siblings ...)
  2022-08-12  1:35 ` [PATCH v2 24/24] blk: Rename if_type to uclass_id Simon Glass
@ 2022-08-12 13:51 ` Johan Jonker
  2022-08-12 15:11   ` Simon Glass
  24 siblings, 1 reply; 42+ messages in thread
From: Johan Jonker @ 2022-08-12 13:51 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List
  Cc: Tom Rini, Heinrich Schuchardt, AKASHI Takahiro, Alexander Graf,
	Alexandru Gagniuc, Alexey Brodkin, Alper Nebi Yasak,
	Anastasiia Lukianenko, Andrew Davis, Andrew Scull,
	Ashok Reddy Soma, Aswath Govindraju, Bharat Gooty, Bin Meng,
	Chris Morgan, Denys Drozdov, Francesco Dolcini, Gary Bisson,
	Heiko Schocher, Huang Jianan, Ilias Apalodimas, Jaehoon Chung,
	Jens Wiklander, Joe Hershberger, Judy Wang, Loic Poulain,
	Lukasz Majewski, Marcel Ziswiler, Marek Behún, Marek Vasut,
	Mark Kettenis, Markus Niebel, Masahisa Kojima, Max Merchel,
	Michal Simek, Oleksandr Andrushchenko, Oleksandr Suvorov,
	Oleksii Bidnichenko, Ovidiu Panait, Pali Rohár,
	Patrice Chotard, Patrick Delaunay, Peng Fan, Philippe Reynes,
	Philippe Schenker, Ramon Fried, Rayagonda Kokatanur,
	Ricardo Salveti, Rick Chen, Sean Anderson, Stefan Roese,
	Tony Dinh, TsiChung Liew, Wolfgang Denk, Ye Li,
	Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32, Kever Yang, Philipp Tomsich

Hi Simon and others,

Some comments. Have a look if it's useful.
Include is an example of how currently a new Rockchip external RKNAND FTL block device must be included in U-boot.
Changes must be made all over the place. EFI has now become a somewhat "obligation" for block devices, then handling
should be made more easy I propose.

1:
The creation and removal of block devices is kind of dynamic with the blk_create_device function. 
Is it possible to make the necessary functions in efi_device_path.c and part.c more flexible as well by
a new "blk_create_efi_device()" and "blk_remove_efi_device()" function? So everything combined in one function.

2:
Make the class list more dynamic/expendable. Each time a new clas is needed the source code must be changed.
Include a function that returns a generated class number that takes in account the existing know classes.
ie,: "uclass_create" and "uclass_remove".

Example block device creation:

	ret = uclass_get_device(UCLASS_RK_IDB, 0, &dev);

// Be able to use a dynamic generated UCLASS for block devices.

	if (ret) {
		printf("no IDB device found\n");
		return CMD_RET_FAILURE;
	}
	ret = blk_get_device(IF_TYPE_RK_IDB, 0, &bdev);
	if (ret) {
		ret = blk_create_device(dev, "idb_blk", "blk",
					IF_TYPE_RK_IDB, 0, 512,
					LBA, &bdev);
		if (ret)
			return ret;

		ret = blk_probe_or_unbind(bdev);
		if (ret)
			return ret;
	}

Example block device removal:

	ret = blk_find_device(IF_TYPE_RK_IDB, 0, &bdev);

// Be able to find back a dynamic generated UCLASS.

	if (ret) {
		printf("no IDB blk device found\n");
		return 0;
	}

	device_remove(bdev, DM_REMOVE_NORMAL);
	device_unbind(bdev);

Make efi functions more flexible by replacing switch() functions by call back functions for:

dp_fill
dp_size
dev_print
print_part_header

Add them with "blk_create_efi_device()" in a structure.
If not defined fall back to standard functions.

====

Kind regards,

Johan Jonker

On 8/12/22 03:34, Simon Glass wrote:
> The block interface has two separate implementations, one using driver
> model and one not. The latter is really only needed for SPL, where
> size constraints allegedly don't allow use of driver model. Of course
> we still need space for filesystems and other code, so it isn't clear
> that driver model is anything more than the straw that breaks the
> camel's back.
> 
> The driver model version uses a uclass ID for the interface time, but
> converts back and forth between that and if_type, which is the legacy
> type.
> 
> The HAVE_BLOCK_DEVICE define is mostly a hangover from the old days.
> At present its main purpose is to enable the legacy block implementation
> in SPL.
> 
> Finally the use of 'select' to enable BLK does not work very well. It
> causes kconfig errors when another option depends on BLK and it is
> not recommended by the kconfig style guide.
> 
> This series aims to clean things up:
> - Enable BLK based on whether different media types are used, but still
>   allow boards to disable it
> - Rename HAVE_BLOCK_DEVICE to indicates its real purpose
> - Drop if_type and use the uclass instead
> - Drop some obsolete if_type values
> 
> An issue not resolved by this series is that the sandbox host interface
> does not actually have a device. At present it uses the root device, which
> was convenience for the driver model conversion but not really correct. It
> should be possible to clean this up, in a future series.
> 
> Another minor issue is the use of UCLASS_USB for a mass-storage device.
> This has been the case for a while and is not addresed by this series,
> other than to add a comment.
> 
> Note that this test relies on Tom Rini's series to drop various boards
> including warp and cm_t335
> 
> Finally, a patch is included to make binman put fake files in a
> subdirectory, since repeated runs of certain boards can cause unrelated
> failues (e.g. chromebook_coral) when fake files are left around.
> 
> Changes in v2:
> - Update commit message
> - Fix SPL_PARTITIONS too
> - Add SATA also
> - Refer to a suffix, not a prefix
> - Add new patch to handle UCLASS_EFI_MEDIA in dev_print()
> - Add new patch to drop ifname field from struct efi_disk_obj
> - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()
> 

From d0bb794b966a0134a6f321a414b48c28e8894180 Mon Sep 17 00:00:00 2001
From: Johan Jonker <jbx6244@gmail.com>
Date: Sun, 7 Aug 2022 15:25:55 +0200
Subject: prepare rknand


diff --git a/disk/part.c b/disk/part.c
index 79955c7fb0..3f8b97a6c6 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -150,6 +150,7 @@ void dev_print (struct blk_desc *dev_desc)
 	case IF_TYPE_USB:
 	case IF_TYPE_NVME:
 	case IF_TYPE_PVBLOCK:
+	case IF_TYPE_RKNAND:
 	case IF_TYPE_HOST:
 		printf ("Vendor: %s Rev: %s Prod: %s\n",
 			dev_desc->vendor,
@@ -293,6 +294,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
 	case IF_TYPE_PVBLOCK:
 		puts("PV BLOCK");
 		break;
+	case IF_TYPE_RKNAND:
+		puts("RKNAND");
+		break;
 	case IF_TYPE_VIRTIO:
 		puts("VirtIO");
 		break;
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 0b5f219d90..28b21836c4 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -33,6 +33,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[IF_TYPE_VIRTIO]	= "virtio",
 	[IF_TYPE_PVBLOCK]	= "pvblock",
 	[IF_TYPE_RK_IDB]	= "idb",
+	[IF_TYPE_RKNAND]	= "rknand",
 };
 
 static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
@@ -51,6 +52,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
 	[IF_TYPE_VIRTIO]	= UCLASS_VIRTIO,
 	[IF_TYPE_PVBLOCK]	= UCLASS_PVBLOCK,
 	[IF_TYPE_RK_IDB]	= UCLASS_RK_IDB,
+	[IF_TYPE_RKNAND]	= UCLASS_RKNAND,
 };
 
 static enum if_type if_typename_to_iftype(const char *if_typename)
diff --git a/include/blk.h b/include/blk.h
index a73cc577a0..56f2415e21 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -30,6 +30,7 @@ enum if_type {
 	IF_TYPE_USB,
 	IF_TYPE_DOC,
 	IF_TYPE_MMC,
+	IF_TYPE_RKNAND,
 	IF_TYPE_SD,
 	IF_TYPE_SATA,
 	IF_TYPE_HOST,
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 38a227f006..b102cdf46e 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -104,6 +104,7 @@ enum uclass_id {
 	UCLASS_REGULATOR,	/* Regulator device */
 	UCLASS_REMOTEPROC,	/* Remote Processor device */
 	UCLASS_RESET,		/* Reset controller device */
+	UCLASS_RKNAND,		/* Rockchip nand device with ftl */
 	UCLASS_RK_IDB,		/* Rockchip IDB device */
 	UCLASS_RNG,		/* Random Number Generator */
 	UCLASS_RTC,		/* Real time clock device */
diff --git a/include/efi_loader.h b/include/efi_loader.h
index 44d426035a..ddc7082ad6 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -145,6 +145,10 @@ static inline efi_status_t efi_launch_capsules(void)
 #define U_BOOT_IDB_DEV_GUID \
 	EFI_GUID(0xadc021df, 0x5f24, 0x464f, \
 		 0x9a, 0x88, 0xdb, 0xee, 0x3f, 0x1d, 0x14, 0x0f)
+/* GUID used as root for Rockchip RKNAND devices */
+#define U_BOOT_RKNAND_DEV_GUID \
+	EFI_GUID(0xe39f6cbb, 0x055a, 0x45a0, \
+		 0xb2, 0x75, 0x56, 0x0d, 0xa5, 0x22, 0x25, 0x99)
 
 /* Use internal device tree when starting UEFI application */
 #define EFI_FDT_USE_INTERNAL NULL
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index b7535373e7..9691f02b2e 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -31,6 +31,9 @@ const efi_guid_t efi_guid_virtio_dev = U_BOOT_VIRTIO_DEV_GUID;
 #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
 const efi_guid_t efi_guid_idb_dev = U_BOOT_IDB_DEV_GUID;
 #endif
+#if CONFIG_IS_ENABLED(RKNAND)
+const efi_guid_t efi_guid_rknand_dev = U_BOOT_IDB_DEV_GUID;
+#endif
 
 /* template END node: */
 static const struct efi_device_path END = {
@@ -578,6 +581,16 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
 			return dp_size(dev->parent)
 				+ sizeof(struct efi_device_path_vendor) + 1;
 #endif
+#if CONFIG_IS_ENABLED(RKNAND)
+		case UCLASS_RKNAND:
+			 /*
+			  * Rockchip IDB device will be represented
+			  * as vendor device with extra one byte for
+			  * device number
+			  */
+			return dp_size(dev->parent)
+				+ sizeof(struct efi_device_path_vendor) + 1;
+#endif
 #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
 		case UCLASS_RK_IDB:
 			 /*
@@ -680,6 +693,23 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 			return &dp->vendor_data[1];
 			}
 #endif
+#if CONFIG_IS_ENABLED(RKNAND)
+		case UCLASS_RKNAND: {
+			struct efi_device_path_vendor *dp;
+			struct blk_desc *desc = dev_get_uclass_plat(dev);
+
+			dp_fill(buf, dev->parent);
+			dp = buf;
+			++dp;
+			dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
+			dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
+			dp->dp.length = sizeof(*dp) + 1;
+			memcpy(&dp->guid, &efi_guid_rknand_dev,
+			       sizeof(efi_guid_t));
+			dp->vendor_data[0] = desc->devnum;
+			return &dp->vendor_data[1];
+			}
+#endif
 #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
 		case UCLASS_RK_IDB: {
 			struct efi_device_path_vendor *dp;

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 00/24] blk: Rationalise the block interface
  2022-08-12 13:51 ` [PATCH v2 00/24] blk: Rationalise the block interface Johan Jonker
@ 2022-08-12 15:11   ` Simon Glass
  2022-08-14  6:33     ` Johan Jonker
  0 siblings, 1 reply; 42+ messages in thread
From: Simon Glass @ 2022-08-12 15:11 UTC (permalink / raw)
  To: Johan Jonker
  Cc: U-Boot Mailing List, Tom Rini, Heinrich Schuchardt,
	AKASHI Takahiro, Alexander Graf, Alexandru Gagniuc,
	Alexey Brodkin, Alper Nebi Yasak, Anastasiia Lukianenko,
	Andrew Davis, Andrew Scull, Ashok Reddy Soma, Aswath Govindraju,
	Bharat Gooty, Bin Meng, Chris Morgan, Denys Drozdov,
	Francesco Dolcini, Gary Bisson, Heiko Schocher, Huang Jianan,
	Ilias Apalodimas, Jaehoon Chung, Jens Wiklander, Joe Hershberger,
	Judy Wang, Loic Poulain, Lukasz Majewski, Marcel Ziswiler,
	Marek Behún, Marek Vasut, Mark Kettenis, Markus Niebel,
	Masahisa Kojima, Max Merchel, Michal Simek,
	Oleksandr Andrushchenko, Oleksandr Suvorov, Oleksii Bidnichenko,
	Ovidiu Panait, Pali Rohár, Patrice Chotard,
	Patrick Delaunay, Peng Fan, Philippe Reynes, Philippe Schenker,
	Ramon Fried, Rayagonda Kokatanur, Ricardo Salveti, Rick Chen,
	Sean Anderson, Stefan Roese, Tony Dinh, TsiChung Liew,
	Wolfgang Denk, Ye Li, Ying-Chun Liu (PaulLiu),
	schspa, U-Boot STM32, Kever Yang, Philipp Tomsich

Hi Johan,

On Fri, 12 Aug 2022 at 07:51, Johan Jonker <jbx6244@gmail.com> wrote:
>
> Hi Simon and others,
>
> Some comments. Have a look if it's useful.
> Include is an example of how currently a new Rockchip external RKNAND FTL block device must be included in U-boot.
> Changes must be made all over the place. EFI has now become a somewhat "obligation" for block devices, then handling
> should be made more easy I propose.
>
> 1:
> The creation and removal of block devices is kind of dynamic with the blk_create_device function.
> Is it possible to make the necessary functions in efi_device_path.c and part.c more flexible as well by
> a new "blk_create_efi_device()" and "blk_remove_efi_device()" function? So everything combined in one function.

Do you mean to automatically create a device with the right uclass?
Yes I think that could be done, but I have not looked at it.

>
> 2:
> Make the class list more dynamic/expendable. Each time a new clas is needed the source code must be changed.
> Include a function that returns a generated class number that takes in account the existing know classes.
> ie,: "uclass_create" and "uclass_remove".
>
> Example block device creation:
>
>         ret = uclass_get_device(UCLASS_RK_IDB, 0, &dev);
>
> // Be able to use a dynamic generated UCLASS for block devices.
>
>         if (ret) {
>                 printf("no IDB device found\n");
>                 return CMD_RET_FAILURE;
>         }
>         ret = blk_get_device(IF_TYPE_RK_IDB, 0, &bdev);
>         if (ret) {
>                 ret = blk_create_device(dev, "idb_blk", "blk",
>                                         IF_TYPE_RK_IDB, 0, 512,
>                                         LBA, &bdev);
>                 if (ret)
>                         return ret;
>
>                 ret = blk_probe_or_unbind(bdev);
>                 if (ret)
>                         return ret;
>         }
>
> Example block device removal:
>
>         ret = blk_find_device(IF_TYPE_RK_IDB, 0, &bdev);

Note that the IF_TYPE goes away with this series and there is just the uclass.

>
> // Be able to find back a dynamic generated UCLASS.
>
>         if (ret) {
>                 printf("no IDB blk device found\n");
>                 return 0;
>         }
>
>         device_remove(bdev, DM_REMOVE_NORMAL);
>         device_unbind(bdev);
>
> Make efi functions more flexible by replacing switch() functions by call back functions for:
>
> dp_fill
> dp_size
> dev_print
> print_part_header
>
> Add them with "blk_create_efi_device()" in a structure.
> If not defined fall back to standard functions.

We are trying to integrate EFI better into U-Boot so that it uses the
normal devices. At present it has some parallel infrastructure.

Please take a look at your patch after applying this series, then let
me know what you think is needed.

Regards,
Simon



>
> ====
>
> Kind regards,
>
> Johan Jonker
>
> On 8/12/22 03:34, Simon Glass wrote:
> > The block interface has two separate implementations, one using driver
> > model and one not. The latter is really only needed for SPL, where
> > size constraints allegedly don't allow use of driver model. Of course
> > we still need space for filesystems and other code, so it isn't clear
> > that driver model is anything more than the straw that breaks the
> > camel's back.
> >
> > The driver model version uses a uclass ID for the interface time, but
> > converts back and forth between that and if_type, which is the legacy
> > type.
> >
> > The HAVE_BLOCK_DEVICE define is mostly a hangover from the old days.
> > At present its main purpose is to enable the legacy block implementation
> > in SPL.
> >
> > Finally the use of 'select' to enable BLK does not work very well. It
> > causes kconfig errors when another option depends on BLK and it is
> > not recommended by the kconfig style guide.
> >
> > This series aims to clean things up:
> > - Enable BLK based on whether different media types are used, but still
> >   allow boards to disable it
> > - Rename HAVE_BLOCK_DEVICE to indicates its real purpose
> > - Drop if_type and use the uclass instead
> > - Drop some obsolete if_type values
> >
> > An issue not resolved by this series is that the sandbox host interface
> > does not actually have a device. At present it uses the root device, which
> > was convenience for the driver model conversion but not really correct. It
> > should be possible to clean this up, in a future series.
> >
> > Another minor issue is the use of UCLASS_USB for a mass-storage device.
> > This has been the case for a while and is not addresed by this series,
> > other than to add a comment.
> >
> > Note that this test relies on Tom Rini's series to drop various boards
> > including warp and cm_t335
> >
> > Finally, a patch is included to make binman put fake files in a
> > subdirectory, since repeated runs of certain boards can cause unrelated
> > failues (e.g. chromebook_coral) when fake files are left around.
> >
> > Changes in v2:
> > - Update commit message
> > - Fix SPL_PARTITIONS too
> > - Add SATA also
> > - Refer to a suffix, not a prefix
> > - Add new patch to handle UCLASS_EFI_MEDIA in dev_print()
> > - Add new patch to drop ifname field from struct efi_disk_obj
> > - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()
> >
>
> From d0bb794b966a0134a6f321a414b48c28e8894180 Mon Sep 17 00:00:00 2001
> From: Johan Jonker <jbx6244@gmail.com>
> Date: Sun, 7 Aug 2022 15:25:55 +0200
> Subject: prepare rknand
>
>
> diff --git a/disk/part.c b/disk/part.c
> index 79955c7fb0..3f8b97a6c6 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -150,6 +150,7 @@ void dev_print (struct blk_desc *dev_desc)
>         case IF_TYPE_USB:
>         case IF_TYPE_NVME:
>         case IF_TYPE_PVBLOCK:
> +       case IF_TYPE_RKNAND:
>         case IF_TYPE_HOST:
>                 printf ("Vendor: %s Rev: %s Prod: %s\n",
>                         dev_desc->vendor,
> @@ -293,6 +294,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
>         case IF_TYPE_PVBLOCK:
>                 puts("PV BLOCK");
>                 break;
> +       case IF_TYPE_RKNAND:
> +               puts("RKNAND");
> +               break;
>         case IF_TYPE_VIRTIO:
>                 puts("VirtIO");
>                 break;
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index 0b5f219d90..28b21836c4 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -33,6 +33,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
>         [IF_TYPE_VIRTIO]        = "virtio",
>         [IF_TYPE_PVBLOCK]       = "pvblock",
>         [IF_TYPE_RK_IDB]        = "idb",
> +       [IF_TYPE_RKNAND]        = "rknand",
>  };
>
>  static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
> @@ -51,6 +52,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
>         [IF_TYPE_VIRTIO]        = UCLASS_VIRTIO,
>         [IF_TYPE_PVBLOCK]       = UCLASS_PVBLOCK,
>         [IF_TYPE_RK_IDB]        = UCLASS_RK_IDB,
> +       [IF_TYPE_RKNAND]        = UCLASS_RKNAND,
>  };
>
>  static enum if_type if_typename_to_iftype(const char *if_typename)
> diff --git a/include/blk.h b/include/blk.h
> index a73cc577a0..56f2415e21 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -30,6 +30,7 @@ enum if_type {
>         IF_TYPE_USB,
>         IF_TYPE_DOC,
>         IF_TYPE_MMC,
> +       IF_TYPE_RKNAND,
>         IF_TYPE_SD,
>         IF_TYPE_SATA,
>         IF_TYPE_HOST,
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index 38a227f006..b102cdf46e 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -104,6 +104,7 @@ enum uclass_id {
>         UCLASS_REGULATOR,       /* Regulator device */
>         UCLASS_REMOTEPROC,      /* Remote Processor device */
>         UCLASS_RESET,           /* Reset controller device */
> +       UCLASS_RKNAND,          /* Rockchip nand device with ftl */
>         UCLASS_RK_IDB,          /* Rockchip IDB device */
>         UCLASS_RNG,             /* Random Number Generator */
>         UCLASS_RTC,             /* Real time clock device */
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 44d426035a..ddc7082ad6 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -145,6 +145,10 @@ static inline efi_status_t efi_launch_capsules(void)
>  #define U_BOOT_IDB_DEV_GUID \
>         EFI_GUID(0xadc021df, 0x5f24, 0x464f, \
>                  0x9a, 0x88, 0xdb, 0xee, 0x3f, 0x1d, 0x14, 0x0f)
> +/* GUID used as root for Rockchip RKNAND devices */
> +#define U_BOOT_RKNAND_DEV_GUID \
> +       EFI_GUID(0xe39f6cbb, 0x055a, 0x45a0, \
> +                0xb2, 0x75, 0x56, 0x0d, 0xa5, 0x22, 0x25, 0x99)
>
>  /* Use internal device tree when starting UEFI application */
>  #define EFI_FDT_USE_INTERNAL NULL
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index b7535373e7..9691f02b2e 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -31,6 +31,9 @@ const efi_guid_t efi_guid_virtio_dev = U_BOOT_VIRTIO_DEV_GUID;
>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>  const efi_guid_t efi_guid_idb_dev = U_BOOT_IDB_DEV_GUID;
>  #endif
> +#if CONFIG_IS_ENABLED(RKNAND)
> +const efi_guid_t efi_guid_rknand_dev = U_BOOT_IDB_DEV_GUID;
> +#endif
>
>  /* template END node: */
>  static const struct efi_device_path END = {
> @@ -578,6 +581,16 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
>                         return dp_size(dev->parent)
>                                 + sizeof(struct efi_device_path_vendor) + 1;
>  #endif
> +#if CONFIG_IS_ENABLED(RKNAND)
> +               case UCLASS_RKNAND:
> +                        /*
> +                         * Rockchip IDB device will be represented
> +                         * as vendor device with extra one byte for
> +                         * device number
> +                         */
> +                       return dp_size(dev->parent)
> +                               + sizeof(struct efi_device_path_vendor) + 1;
> +#endif
>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>                 case UCLASS_RK_IDB:
>                          /*
> @@ -680,6 +693,23 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
>                         return &dp->vendor_data[1];
>                         }
>  #endif
> +#if CONFIG_IS_ENABLED(RKNAND)
> +               case UCLASS_RKNAND: {
> +                       struct efi_device_path_vendor *dp;
> +                       struct blk_desc *desc = dev_get_uclass_plat(dev);
> +
> +                       dp_fill(buf, dev->parent);
> +                       dp = buf;
> +                       ++dp;
> +                       dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
> +                       dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
> +                       dp->dp.length = sizeof(*dp) + 1;
> +                       memcpy(&dp->guid, &efi_guid_rknand_dev,
> +                              sizeof(efi_guid_t));
> +                       dp->vendor_data[0] = desc->devnum;
> +                       return &dp->vendor_data[1];
> +                       }
> +#endif
>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>                 case UCLASS_RK_IDB: {
>                         struct efi_device_path_vendor *dp;

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 00/24] blk: Rationalise the block interface
  2022-08-12 15:11   ` Simon Glass
@ 2022-08-14  6:33     ` Johan Jonker
  2022-08-15 17:37       ` Simon Glass
  0 siblings, 1 reply; 42+ messages in thread
From: Johan Jonker @ 2022-08-14  6:33 UTC (permalink / raw)
  To: Simon Glass, Heinrich Schuchardt, Tom Rini, AKASHI Takahiro,
	Masahisa Kojima, Sean Anderson, schspa, U-Boot-Denx



On 8/12/22 17:11, Simon Glass wrote:
> Hi Johan,
> 
> On Fri, 12 Aug 2022 at 07:51, Johan Jonker <jbx6244@gmail.com> wrote:
>>
>> Hi Simon and others,
>>
>> Some comments. Have a look if it's useful.
>> Include is an example of how currently a new Rockchip external RKNAND FTL block device must be included in U-boot.
>> Changes must be made all over the place. EFI has now become a somewhat "obligation" for block devices, then handling
>> should be made more easy I propose.
>>
>> 1:
>> The creation and removal of block devices is kind of dynamic with the blk_create_device function.
>> Is it possible to make the necessary functions in efi_device_path.c and part.c more flexible as well by
>> a new "blk_create_efi_device()" and "blk_remove_efi_device()" function? So everything combined in one function.
> 
> Do you mean to automatically create a device with the right uclass?
> Yes I think that could be done, but I have not looked at it.

Hi,

Some comments...
Reduced the number of public CC's.
I have included a patch with call back function as example, so efi_device_path.c and part.c don't have to be changed for every new block device.
Make EFI framework code without class specific things.
TODO define	{ UCLASS_XXXXX, "xxxxx" }, in class driver and not in a fixed array.
Look up for xxxxx ==> UCLASS_XXXXX needs a lot more work which is out of scope for my capacity now.

Kind regards,

Johan Jonker

===

This list name should be specified in the class driver.
Lookup functions need a rework then to get rid of this fixed array.


static struct {
	enum uclass_id id;
	const char *name;
} uclass_idname_str[] = {
	{ 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" },
	{ UCLASS_RKNAND, "rknand" },
};

===
Example for new call back functions:

void rknand_part_header(struct blk_desc *dev_desc)
{
	puts("RKNAND");
}

void rknand_dev_print(struct blk_desc *dev_desc)
{
	printf ("Vendor: %s Rev: %s Prod: %s\n",
		dev_desc->vendor,
		dev_desc->revision,
		dev_desc->product);
}

extern unsigned int dp_size(struct udevice *dev);
extern void *dp_fill(void *buf, struct udevice *dev);

/* GUID used as root for Rockchip RKNAND devices */
#define U_BOOT_RKNAND_DEV_GUID \
	EFI_GUID(0xe39f6cbb, 0x055a, 0x45a0, \
		 0xb2, 0x75, 0x56, 0x0d, 0xa5, 0x22, 0x25, 0x99)

const efi_guid_t efi_guid_rknand_dev = U_BOOT_RKNAND_DEV_GUID;

unsigned int rknand_dp_size(struct udevice *dev)
{
	return dp_size(dev->parent) + sizeof(struct efi_device_path_vendor) + 1;
}

void *rknand_dp_fill(void *buf, struct udevice *dev)
{
	struct efi_device_path_vendor *dp;
	struct blk_desc *desc = dev_get_uclass_plat(dev);

	dp_fill(buf, dev->parent);
	dp = buf;
	++dp;
	dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
	dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
	dp->dp.length = sizeof(*dp) + 1;
	memcpy(&dp->guid, &efi_guid_rknand_dev, sizeof(efi_guid_t));
	dp->vendor_data[0] = desc->devnum;
	return &dp->vendor_data[1];
}

static int rknand_blk_probe(struct udevice *udev)
{
	struct rknand_dev *ndev = dev_get_priv(udev->parent);
	struct blk_desc *desc = dev_get_uclass_plat(udev);

	debug("%s %d %p ndev = %p %p\n", __func__, __LINE__,
	      udev, ndev, udev->parent);
	ndev->dev = udev;
	desc->uclass_id = UCLASS_RKNAND;
	desc->lba = ndev->density;
	desc->log2blksz = 9;
	desc->blksz = 512;
	desc->bdev = udev;
	desc->devnum = 0;

//======

/* new call back functions */

	desc->dev_print = &rknand_dev_print;
	desc->part_header = &rknand_part_header;
	udev->dp_size = &rknand_dp_size;
	udev->dp_fill = &rknand_dp_fill;

//======
	sprintf(desc->vendor, "0x%.4x", 0x2207);
	memcpy(desc->product, "rknand", sizeof("rknand"));
	memcpy(desc->revision, "V1.00", sizeof("V1.00"));
	part_init(desc);
	return 0;
}
===
> 
>>
>> 2:
>> Make the class list more dynamic/expendable. Each time a new clas is needed the source code must be changed.
>> Include a function that returns a generated class number that takes in account the existing know classes.
>> ie,: "uclass_create" and "uclass_remove".
>>
>> Example block device creation:
>>
>>         ret = uclass_get_device(UCLASS_RK_IDB, 0, &dev);
>>
>> // Be able to use a dynamic generated UCLASS for block devices.
>>
>>         if (ret) {
>>                 printf("no IDB device found\n");
>>                 return CMD_RET_FAILURE;
>>         }
>>         ret = blk_get_device(IF_TYPE_RK_IDB, 0, &bdev);
>>         if (ret) {
>>                 ret = blk_create_device(dev, "idb_blk", "blk",
>>                                         IF_TYPE_RK_IDB, 0, 512,
>>                                         LBA, &bdev);
>>                 if (ret)
>>                         return ret;
>>
>>                 ret = blk_probe_or_unbind(bdev);
>>                 if (ret)
>>                         return ret;
>>         }
>>
>> Example block device removal:
>>
>>         ret = blk_find_device(IF_TYPE_RK_IDB, 0, &bdev);
> 
> Note that the IF_TYPE goes away with this series and there is just the uclass.
> 
>>
>> // Be able to find back a dynamic generated UCLASS.
>>
>>         if (ret) {
>>                 printf("no IDB blk device found\n");
>>                 return 0;
>>         }
>>
>>         device_remove(bdev, DM_REMOVE_NORMAL);
>>         device_unbind(bdev);
>>
>> Make efi functions more flexible by replacing switch() functions by call back functions for:
>>
>> dp_fill
>> dp_size
>> dev_print
>> print_part_header
>>
>> Add them with "blk_create_efi_device()" in a structure.
>> If not defined fall back to standard functions.
> 
> We are trying to integrate EFI better into U-Boot so that it uses the
> normal devices. At present it has some parallel infrastructure.
> 
> Please take a look at your patch after applying this series, then let
> me know what you think is needed.
> 
> Regards,
> Simon
> 
> 
> 
>>
>> ====
>>
>> Kind regards,
>>
>> Johan Jonker
>>
>> On 8/12/22 03:34, Simon Glass wrote:
>>> The block interface has two separate implementations, one using driver
>>> model and one not. The latter is really only needed for SPL, where
>>> size constraints allegedly don't allow use of driver model. Of course
>>> we still need space for filesystems and other code, so it isn't clear
>>> that driver model is anything more than the straw that breaks the
>>> camel's back.
>>>
>>> The driver model version uses a uclass ID for the interface time, but
>>> converts back and forth between that and if_type, which is the legacy
>>> type.
>>>
>>> The HAVE_BLOCK_DEVICE define is mostly a hangover from the old days.
>>> At present its main purpose is to enable the legacy block implementation
>>> in SPL.
>>>
>>> Finally the use of 'select' to enable BLK does not work very well. It
>>> causes kconfig errors when another option depends on BLK and it is
>>> not recommended by the kconfig style guide.
>>>
>>> This series aims to clean things up:
>>> - Enable BLK based on whether different media types are used, but still
>>>   allow boards to disable it
>>> - Rename HAVE_BLOCK_DEVICE to indicates its real purpose
>>> - Drop if_type and use the uclass instead
>>> - Drop some obsolete if_type values
>>>
>>> An issue not resolved by this series is that the sandbox host interface
>>> does not actually have a device. At present it uses the root device, which
>>> was convenience for the driver model conversion but not really correct. It
>>> should be possible to clean this up, in a future series.
>>>
>>> Another minor issue is the use of UCLASS_USB for a mass-storage device.
>>> This has been the case for a while and is not addresed by this series,
>>> other than to add a comment.
>>>
>>> Note that this test relies on Tom Rini's series to drop various boards
>>> including warp and cm_t335
>>>
>>> Finally, a patch is included to make binman put fake files in a
>>> subdirectory, since repeated runs of certain boards can cause unrelated
>>> failues (e.g. chromebook_coral) when fake files are left around.
>>>
>>> Changes in v2:
>>> - Update commit message
>>> - Fix SPL_PARTITIONS too
>>> - Add SATA also
>>> - Refer to a suffix, not a prefix
>>> - Add new patch to handle UCLASS_EFI_MEDIA in dev_print()
>>> - Add new patch to drop ifname field from struct efi_disk_obj
>>> - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()
>>>
>>
>> From d0bb794b966a0134a6f321a414b48c28e8894180 Mon Sep 17 00:00:00 2001
>> From: Johan Jonker <jbx6244@gmail.com>
>> Date: Sun, 7 Aug 2022 15:25:55 +0200
>> Subject: prepare rknand
>>
>>
>> diff --git a/disk/part.c b/disk/part.c
>> index 79955c7fb0..3f8b97a6c6 100644
>> --- a/disk/part.c
>> +++ b/disk/part.c
>> @@ -150,6 +150,7 @@ void dev_print (struct blk_desc *dev_desc)
>>         case IF_TYPE_USB:
>>         case IF_TYPE_NVME:
>>         case IF_TYPE_PVBLOCK:
>> +       case IF_TYPE_RKNAND:
>>         case IF_TYPE_HOST:
>>                 printf ("Vendor: %s Rev: %s Prod: %s\n",
>>                         dev_desc->vendor,
>> @@ -293,6 +294,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
>>         case IF_TYPE_PVBLOCK:
>>                 puts("PV BLOCK");
>>                 break;
>> +       case IF_TYPE_RKNAND:
>> +               puts("RKNAND");
>> +               break;
>>         case IF_TYPE_VIRTIO:
>>                 puts("VirtIO");
>>                 break;
>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>> index 0b5f219d90..28b21836c4 100644
>> --- a/drivers/block/blk-uclass.c
>> +++ b/drivers/block/blk-uclass.c
>> @@ -33,6 +33,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
>>         [IF_TYPE_VIRTIO]        = "virtio",
>>         [IF_TYPE_PVBLOCK]       = "pvblock",
>>         [IF_TYPE_RK_IDB]        = "idb",
>> +       [IF_TYPE_RKNAND]        = "rknand",
>>  };
>>
>>  static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
>> @@ -51,6 +52,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = {
>>         [IF_TYPE_VIRTIO]        = UCLASS_VIRTIO,
>>         [IF_TYPE_PVBLOCK]       = UCLASS_PVBLOCK,
>>         [IF_TYPE_RK_IDB]        = UCLASS_RK_IDB,
>> +       [IF_TYPE_RKNAND]        = UCLASS_RKNAND,
>>  };
>>
>>  static enum if_type if_typename_to_iftype(const char *if_typename)
>> diff --git a/include/blk.h b/include/blk.h
>> index a73cc577a0..56f2415e21 100644
>> --- a/include/blk.h
>> +++ b/include/blk.h
>> @@ -30,6 +30,7 @@ enum if_type {
>>         IF_TYPE_USB,
>>         IF_TYPE_DOC,
>>         IF_TYPE_MMC,
>> +       IF_TYPE_RKNAND,
>>         IF_TYPE_SD,
>>         IF_TYPE_SATA,
>>         IF_TYPE_HOST,
>> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
>> index 38a227f006..b102cdf46e 100644
>> --- a/include/dm/uclass-id.h
>> +++ b/include/dm/uclass-id.h
>> @@ -104,6 +104,7 @@ enum uclass_id {
>>         UCLASS_REGULATOR,       /* Regulator device */
>>         UCLASS_REMOTEPROC,      /* Remote Processor device */
>>         UCLASS_RESET,           /* Reset controller device */
>> +       UCLASS_RKNAND,          /* Rockchip nand device with ftl */
>>         UCLASS_RK_IDB,          /* Rockchip IDB device */
>>         UCLASS_RNG,             /* Random Number Generator */
>>         UCLASS_RTC,             /* Real time clock device */
>> diff --git a/include/efi_loader.h b/include/efi_loader.h
>> index 44d426035a..ddc7082ad6 100644
>> --- a/include/efi_loader.h
>> +++ b/include/efi_loader.h
>> @@ -145,6 +145,10 @@ static inline efi_status_t efi_launch_capsules(void)
>>  #define U_BOOT_IDB_DEV_GUID \
>>         EFI_GUID(0xadc021df, 0x5f24, 0x464f, \
>>                  0x9a, 0x88, 0xdb, 0xee, 0x3f, 0x1d, 0x14, 0x0f)
>> +/* GUID used as root for Rockchip RKNAND devices */
>> +#define U_BOOT_RKNAND_DEV_GUID \
>> +       EFI_GUID(0xe39f6cbb, 0x055a, 0x45a0, \
>> +                0xb2, 0x75, 0x56, 0x0d, 0xa5, 0x22, 0x25, 0x99)
>>
>>  /* Use internal device tree when starting UEFI application */
>>  #define EFI_FDT_USE_INTERNAL NULL
>> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
>> index b7535373e7..9691f02b2e 100644
>> --- a/lib/efi_loader/efi_device_path.c
>> +++ b/lib/efi_loader/efi_device_path.c
>> @@ -31,6 +31,9 @@ const efi_guid_t efi_guid_virtio_dev = U_BOOT_VIRTIO_DEV_GUID;
>>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>>  const efi_guid_t efi_guid_idb_dev = U_BOOT_IDB_DEV_GUID;
>>  #endif
>> +#if CONFIG_IS_ENABLED(RKNAND)
>> +const efi_guid_t efi_guid_rknand_dev = U_BOOT_IDB_DEV_GUID;
>> +#endif
>>
>>  /* template END node: */
>>  static const struct efi_device_path END = {
>> @@ -578,6 +581,16 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
>>                         return dp_size(dev->parent)
>>                                 + sizeof(struct efi_device_path_vendor) + 1;
>>  #endif
>> +#if CONFIG_IS_ENABLED(RKNAND)
>> +               case UCLASS_RKNAND:
>> +                        /*
>> +                         * Rockchip IDB device will be represented
>> +                         * as vendor device with extra one byte for
>> +                         * device number
>> +                         */
>> +                       return dp_size(dev->parent)
>> +                               + sizeof(struct efi_device_path_vendor) + 1;
>> +#endif
>>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>>                 case UCLASS_RK_IDB:
>>                          /*
>> @@ -680,6 +693,23 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
>>                         return &dp->vendor_data[1];
>>                         }
>>  #endif
>> +#if CONFIG_IS_ENABLED(RKNAND)
>> +               case UCLASS_RKNAND: {
>> +                       struct efi_device_path_vendor *dp;
>> +                       struct blk_desc *desc = dev_get_uclass_plat(dev);
>> +
>> +                       dp_fill(buf, dev->parent);
>> +                       dp = buf;
>> +                       ++dp;
>> +                       dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE;
>> +                       dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR;
>> +                       dp->dp.length = sizeof(*dp) + 1;
>> +                       memcpy(&dp->guid, &efi_guid_rknand_dev,
>> +                              sizeof(efi_guid_t));
>> +                       dp->vendor_data[0] = desc->devnum;
>> +                       return &dp->vendor_data[1];
>> +                       }
>> +#endif
>>  #if CONFIG_IS_ENABLED(ROCKCHIP_IDB)
>>                 case UCLASS_RK_IDB: {
>>                         struct efi_device_path_vendor *dp;


From 70ef594197302f3497dac1fa98f419be143257d1 Mon Sep 17 00:00:00 2001
From: Johan Jonker <jbx6244@gmail.com>
Date: Sat, 13 Aug 2022 20:51:51 +0200
Subject: [PATCH 1/2] disk: part: add call back functions for print_part_header
 and dev_print

In order to be able to add more block devices without changing
the part.c file add call back functions for print_part_header
and dev_print.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 disk/part.c   | 8 ++++++--
 include/blk.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index d73318c8..42e88fc7 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -120,7 +120,9 @@ void dev_print(struct blk_desc *dev_desc)
 		return;
 	}
 
-	switch (dev_desc->uclass_id) {
+	if (dev_desc->dev_print) {
+		dev_desc->dev_print(dev_desc);
+	} else switch (dev_desc->uclass_id) {
 	case UCLASS_SCSI:
 		printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
 			dev_desc->target,dev_desc->lun,
@@ -248,7 +250,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
 	CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
 	CONFIG_IS_ENABLED(EFI_PARTITION)
 	puts ("\nPartition Map for ");
-	switch (dev_desc->uclass_id) {
+	if (dev_desc->part_header) {
+		dev_desc->part_header(dev_desc);
+	} else switch (dev_desc->uclass_id) {
 	case UCLASS_IDE:
 		puts ("IDE");
 		break;
diff --git a/include/blk.h b/include/blk.h
index cdc6f0fc..f158f039 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -69,6 +69,8 @@ struct blk_desc {
 	lbaint_t	lba;		/* number of blocks */
 	unsigned long	blksz;		/* block size */
 	int		log2blksz;	/* for convenience: log2(blksz) */
+	void		(*part_header)(struct blk_desc *dev_desc); /* print_part_header in part.c */
+	void		(*dev_print)(struct blk_desc *dev_desc); /* rknand_dev_print in part.c */
 	char		vendor[BLK_VEN_SIZE + 1]; /* device vendor string */
 	char		product[BLK_PRD_SIZE + 1]; /* device product number */
 	char		revision[BLK_REV_SIZE + 1]; /* firmware revision */
-- 
2.20.1


From 8f05d7887955393e0b14cae43f061703694306a4 Mon Sep 17 00:00:00 2001
From: Johan Jonker <jbx6244@gmail.com>
Date: Sat, 13 Aug 2022 21:11:50 +0200
Subject: [PATCH 2/2] lib: efi_loader: efi_device_path: add dp_fill and dp_size
 call back functions

In order to be able to add more block devices without changing
the efi_device_path.c file add dp_fill and dp_size call back functions

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 include/dm/device.h              |  2 ++
 lib/efi_loader/efi_device_path.c | 12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/dm/device.h b/include/dm/device.h
index 12c6ba37..add219be 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -194,6 +194,8 @@ struct udevice {
 #if CONFIG_IS_ENABLED(DM_DMA)
 	ulong dma_offset;
 #endif
+	unsigned int (*dp_size)(struct udevice *dev);
+	void * (*dp_fill)(void *buf, struct udevice *dev);
 };
 
 static inline int dm_udevice_size(void)
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 9787033c..57ac31f1 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -515,7 +515,7 @@ bool efi_dp_is_multi_instance(const struct efi_device_path *dp)
 /* size of device-path not including END node for device and all parents
  * up to the root device.
  */
-__maybe_unused static unsigned int dp_size(struct udevice *dev)
+__maybe_unused unsigned int dp_size(struct udevice *dev)
 {
 	if (!dev || !dev->driver)
 		return sizeof(ROOT);
@@ -529,7 +529,9 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
 		return dp_size(dev->parent) +
 			sizeof(struct efi_device_path_mac_addr);
 	case UCLASS_BLK:
-		switch (dev->parent->uclass->uc_drv->id) {
+		if (dev->dp_size) {
+			return dev->dp_size(dev);
+		} else switch (dev->parent->uclass->uc_drv->id) {
 #ifdef CONFIG_IDE
 		case UCLASS_IDE:
 			return dp_size(dev->parent) +
@@ -600,7 +602,7 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
  * @dev		device
  * Return:	pointer to the end of the device path
  */
-__maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
+__maybe_unused void *dp_fill(void *buf, struct udevice *dev)
 {
 	if (!dev || !dev->driver)
 		return buf;
@@ -631,7 +633,9 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 	}
 #endif
 	case UCLASS_BLK:
-		switch (dev->parent->uclass->uc_drv->id) {
+		if (dev->dp_fill) {
+			return dev->dp_fill(buf, dev);
+		} else switch (dev->parent->uclass->uc_drv->id) {
 #ifdef CONFIG_SANDBOX
 		case UCLASS_ROOT: {
 			/* stop traversing parents at this point: */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 00/24] blk: Rationalise the block interface
  2022-08-14  6:33     ` Johan Jonker
@ 2022-08-15 17:37       ` Simon Glass
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-08-15 17:37 UTC (permalink / raw)
  To: Johan Jonker
  Cc: Heinrich Schuchardt, Tom Rini, AKASHI Takahiro, Masahisa Kojima,
	Sean Anderson, schspa, U-Boot-Denx

Hi Johan,

On Sun, 14 Aug 2022 at 00:34, Johan Jonker <jbx6244@gmail.com> wrote:
>
>
>
> On 8/12/22 17:11, Simon Glass wrote:
> > Hi Johan,
> >
> > On Fri, 12 Aug 2022 at 07:51, Johan Jonker <jbx6244@gmail.com> wrote:
> >>
> >> Hi Simon and others,
> >>
> >> Some comments. Have a look if it's useful.
> >> Include is an example of how currently a new Rockchip external RKNAND FTL block device must be included in U-boot.
> >> Changes must be made all over the place. EFI has now become a somewhat "obligation" for block devices, then handling
> >> should be made more easy I propose.
> >>
> >> 1:
> >> The creation and removal of block devices is kind of dynamic with the blk_create_device function.
> >> Is it possible to make the necessary functions in efi_device_path.c and part.c more flexible as well by
> >> a new "blk_create_efi_device()" and "blk_remove_efi_device()" function? So everything combined in one function.
> >
> > Do you mean to automatically create a device with the right uclass?
> > Yes I think that could be done, but I have not looked at it.
>
> Hi,
>
> Some comments...
> Reduced the number of public CC's.
> I have included a patch with call back function as example, so efi_device_path.c and part.c don't have to be changed for every new block device.
> Make EFI framework code without class specific things.
> TODO define     { UCLASS_XXXXX, "xxxxx" }, in class driver and not in a fixed array.
> Look up for xxxxx ==> UCLASS_XXXXX needs a lot more work which is out of scope for my capacity now.

I'm not keen on callbacks, but we could use events if necessary.

Would you please send your patches based on my series and to the
mailing list? You can mark them RFC if you are unsure, but I really
cannot see myself replying to patches that are sent as an attachment
and don't appear in patchwork :-)

Regards,
Simon

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 24/24] blk: Rename if_type to uclass_id
  2022-08-12  1:35 ` [PATCH v2 24/24] blk: Rename if_type to uclass_id Simon Glass
@ 2022-09-13 16:03   ` Tom Rini
  2022-09-14 17:09     ` Simon Glass
  2022-09-14  1:22   ` AKASHI Takahiro
  1 sibling, 1 reply; 42+ messages in thread
From: Tom Rini @ 2022-09-13 16:03 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Heinrich Schuchardt, AKASHI Takahiro,
	Anastasiia Lukianenko, Aswath Govindraju, Bin Meng,
	Ilias Apalodimas, Jaehoon Chung, Joe Hershberger,
	Lukasz Majewski, Marcel Ziswiler, Marek Vasut, Markus Niebel,
	Masahisa Kojima, Max Merchel, Oleksandr Andrushchenko,
	Oleksandr Suvorov, Oleksii Bidnichenko, Patrice Chotard,
	Patrick Delaunay, Peng Fan, Ramon Fried, Ricardo Salveti,
	Sean Anderson, Stefan Roese, Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32

[-- Attachment #1: Type: text/plain, Size: 622 bytes --]

On Thu, Aug 11, 2022 at 07:35:03PM -0600, Simon Glass wrote:

> Use the word 'uclass' instead of 'if_type' to complete the conversion.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v2:
> - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()

So, for this series, 1 through 22 apply cleanly (one easy fixup
required), and 23/24 appears to be applied already. But large chunks of
this patch do not apply to lib/efi_loader/efi_disk.c and it's unclear
what I should do here. Should I just apply 1-22 of this series? Or do
you expect to v3 this? Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj
  2022-08-12  1:35 ` [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj Simon Glass
@ 2022-09-13 16:17   ` Heinrich Schuchardt
  0 siblings, 0 replies; 42+ messages in thread
From: Heinrich Schuchardt @ 2022-09-13 16:17 UTC (permalink / raw)
  To: Simon Glass
  Cc: Tom Rini, AKASHI Takahiro, Alexander Graf, Ilias Apalodimas,
	U-Boot Mailing List

On 8/12/22 03:35, Simon Glass wrote:
> This is not used, so drop it.
>
> Suggested-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Add new patch to drop ifname field from struct efi_disk_obj
>
>   lib/efi_loader/efi_disk.c | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index 2e905f61840..ad543bc117e 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -40,7 +40,6 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
>   struct efi_disk_obj {
>   	struct efi_object header;
>   	struct efi_block_io ops;
> -	const char *ifname;

This patch is obsolete since commit ab31c8a15871 (" efi_loader: disk:
remove unused field").

Best regards

Heinrich

>   	int dev_index;
>   	struct efi_block_io_media media;
>   	struct efi_device_path *dp;
> @@ -476,7 +475,6 @@ static efi_status_t efi_disk_add_dev(
>   			return ret;
>   	}
>   	diskobj->ops = block_io_disk_template;
> -	diskobj->ifname = if_typename;
>   	diskobj->dev_index = dev_index;
>
>   	/* Fill in EFI IO Media info (for read/write callbacks) */


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 22/24] blk: Drop if_type
  2022-08-12  1:35 ` [PATCH v2 22/24] blk: Drop if_type Simon Glass
@ 2022-09-13 16:27   ` Heinrich Schuchardt
  2022-09-14  2:08     ` AKASHI Takahiro
  2022-09-14 17:10     ` Simon Glass
  0 siblings, 2 replies; 42+ messages in thread
From: Heinrich Schuchardt @ 2022-09-13 16:27 UTC (permalink / raw)
  To: Simon Glass
  Cc: Tom Rini, AKASHI Takahiro, Ilias Apalodimas, Masahisa Kojima,
	U-Boot Mailing List

On 8/12/22 03:35, Simon Glass wrote:
> Use the uclass ID instead.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>   cmd/blk_common.c           |  2 +-
>   drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
>   drivers/block/blk_legacy.c | 20 +++++++++----------
>   include/blk.h              | 41 ++++++++++++++++++--------------------
>   include/efi_loader.h       |  2 +-
>   5 files changed, 48 insertions(+), 51 deletions(-)
>
> diff --git a/cmd/blk_common.c b/cmd/blk_common.c
> index 4e442f2918b..369c5ae4bbe 100644
> --- a/cmd/blk_common.c
> +++ b/cmd/blk_common.c
> @@ -12,7 +12,7 @@
>   #include <blk.h>
>   #include <command.h>
>
> -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>   		   int *cur_devnump)
>   {
>   	const char *if_name = blk_get_if_type_name(if_type);
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index 436af764f91..a9a85aa37f3 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -34,7 +34,7 @@ static struct {
>   	{ UCLASS_PVBLOCK, "pvblock" },
>   };
>
> -static enum if_type if_typename_to_iftype(const char *if_typename)
> +static enum uclass_id if_typename_to_iftype(const char *if_typename)
>   {
>   	int i;
>
> @@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
>   	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 uclass_id if_type)
>   {
>   	/*
>   	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
> @@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
>   	return if_type;
>   }
>
> -const char *blk_get_if_type_name(enum if_type if_type)
> +const char *blk_get_if_type_name(enum uclass_id if_type)
>   {
>   	int i;
>
> @@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
>   	return "(none)";
>   }
>
> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_desc *desc;
>   	struct udevice *dev;
> @@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
>   struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>   {
>   	enum uclass_id uclass_id;
> -	enum if_type type;
> +	enum uclass_id type;
>   	struct udevice *dev;
>   	struct uclass *uc;
>   	int ret;
> @@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
>    * with a higher device number, -ENOENT if there is no such device but there
>    * is one with a higher number, or other -ve on other error.
>    */
> -static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
> +static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
>   {
>   	bool found_more = false;
>   	struct udevice *dev;
> @@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
>   	return found_more ? -ENOENT : -ENODEV;
>   }
>
> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
>   {
>   	struct udevice *dev;
>   	int ret;
> @@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
>   	return blk_select_hwpart(dev, hwpart);
>   }
>
> -int blk_list_part(enum if_type if_type)
> +int blk_list_part(enum uclass_id if_type)
>   {
>   	struct blk_desc *desc;
>   	int devnum, ok;
> @@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
>   	return 0;
>   }
>
> -int blk_print_part_devnum(enum if_type if_type, int devnum)
> +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_desc *desc;
>   	int ret;
> @@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -void blk_list_devices(enum if_type if_type)
> +void blk_list_devices(enum uclass_id if_type)
>   {
>   	struct blk_desc *desc;
>   	int ret;
> @@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
>   	}
>   }
>
> -int blk_print_device_num(enum if_type if_type, int devnum)
> +int blk_print_device_num(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_desc *desc;
>   	int ret;
> @@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -int blk_show_device(enum if_type if_type, int devnum)
> +int blk_show_device(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_desc *desc;
>   	int ret;
> @@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		      lbaint_t blkcnt, void *buffer)
>   {
>   	struct blk_desc *desc;
> @@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>   	return n;
>   }
>
> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		       lbaint_t blkcnt, const void *buffer)
>   {
>   	struct blk_desc *desc;
> @@ -525,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
>   	return uclass_get_name(device_get_uclass_id(parent));
>   };
>
> -int blk_find_max_devnum(enum if_type if_type)
> +int blk_find_max_devnum(enum uclass_id if_type)
>   {
>   	struct udevice *dev;
>   	int max_devnum = -ENODEV;
> @@ -545,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
>   	return max_devnum;
>   }
>
> -int blk_next_free_devnum(enum if_type if_type)
> +int blk_next_free_devnum(enum uclass_id if_type)
>   {
>   	int ret;
>
> @@ -631,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
>   	return count;
>   }
>
> -static int blk_claim_devnum(enum if_type if_type, int devnum)
> +static int blk_claim_devnum(enum uclass_id if_type, int devnum)
>   {
>   	struct udevice *dev;
>   	struct uclass *uc;
> diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
> index bd8a17df6a9..8c6f9cb208e 100644
> --- a/drivers/block/blk_legacy.c
> +++ b/drivers/block/blk_legacy.c
> @@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
>   	return NULL;
>   }
>
> -const char *blk_get_if_type_name(enum if_type if_type)
> +const char *blk_get_if_type_name(enum uclass_id if_type)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>
> @@ -70,7 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
>   	return drv->get_dev(devnum, descp);
>   }
>
> -int blk_list_part(enum if_type if_type)
> +int blk_list_part(enum uclass_id if_type)
>   {
>   	struct blk_driver *drv;
>   	struct blk_desc *desc;
> @@ -97,7 +97,7 @@ int blk_list_part(enum if_type if_type)
>   	return 0;
>   }
>
> -int blk_print_part_devnum(enum if_type if_type, int devnum)
> +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> @@ -115,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -void blk_list_devices(enum if_type if_type)
> +void blk_list_devices(enum uclass_id if_type)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> @@ -133,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
>   	}
>   }
>
> -int blk_print_device_num(enum if_type if_type, int devnum)
> +int blk_print_device_num(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> @@ -150,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -int blk_show_device(enum if_type if_type, int devnum)
> +int blk_show_device(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> @@ -174,7 +174,7 @@ int blk_show_device(enum if_type if_type, int devnum)
>   	return 0;
>   }
>
> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> @@ -214,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>   	return desc;
>   }
>
> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		      lbaint_t blkcnt, void *buffer)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> @@ -234,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>   	return n;
>   }
>
> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		       lbaint_t blkcnt, const void *buffer)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> @@ -249,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>   	return desc->block_write(desc, start, blkcnt, buffer);
>   }
>
> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
>   {
>   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>   	struct blk_desc *desc;
> diff --git a/include/blk.h b/include/blk.h
> index 548cd09d6bb..279f9ea4a9d 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -27,9 +27,6 @@ static inline bool blk_enabled(void)
>   	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
>   }
>
> -/* Interface types: */
> -#define if_type uclass_id
> -
>   #define BLK_VEN_SIZE		40
>   #define BLK_PRD_SIZE		20
>   #define BLK_REV_SIZE		8
> @@ -57,7 +54,7 @@ struct blk_desc {
>   	 * TODO: With driver model we should be able to use the parent
>   	 * device's uclass instead.
>   	 */
> -	enum if_type	if_type;	/* type of the interface */
> +	enum uclass_id	if_type;	/* type of the interface */
>   	int		devnum;		/* device number */
>   	unsigned char	part_type;	/* partition type */
>   	unsigned char	target;		/* target SCSI ID */
> @@ -282,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
>    * This function does not activate the device. The device will be returned
>    * whether or not it is activated.
>    *
> - * @if_type:	Interface type (enum if_type_t)
> + * @if_type:	Interface type (enum uclass_id_t)
>    * @devnum:	Device number (specific to each interface type)
>    * @devp:	the device, if found
>    * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> @@ -292,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
>   /**
>    * blk_get_device() - Find and probe a block device ready for use
>    *
> - * @if_type:	Interface type (enum if_type_t)
> + * @if_type:	Interface type (enum uclass_id_t)
>    * @devnum:	Device number (specific to each interface type)
>    * @devp:	the device, if found
>    * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> @@ -330,7 +327,7 @@ int blk_next_device(struct udevice **devp);
>    * @parent:	Parent of the new device
>    * @drv_name:	Driver name to use for the block device
>    * @name:	Name for the device
> - * @if_type:	Interface type (enum if_type_t)
> + * @if_type:	Interface type (enum uclass_id_t)
>    * @devnum:	Device number, specific to the interface type, or -1 to
>    *		allocate the next available number
>    * @blksz:	Block size of the device in bytes (typically 512)
> @@ -347,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>    * @parent:	Parent of the new device
>    * @drv_name:	Driver name to use for the block device
>    * @name:	Name for the device (parent name is prepended)
> - * @if_type:	Interface type (enum if_type_t)
> + * @if_type:	Interface type (enum uclass_id_t)
>    * @devnum:	Device number, specific to the interface type, or -1 to
>    *		allocate the next available number
>    * @blksz:	Block size of the device in bytes (typically 512)
> @@ -390,7 +387,7 @@ int blk_unbind_all(int if_type);
>    * Return: maximum device number found, or -ENODEV if none, or other -ve on
>    * error
>    */
> -int blk_find_max_devnum(enum if_type if_type);
> +int blk_find_max_devnum(enum uclass_id if_type);
>
>   /**
>    * blk_next_free_devnum() - get the next device number for an interface type
> @@ -401,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
>    * @if_type:	Interface type to scan
>    * Return: next device number safe to use, or -ve on error
>    */
> -int blk_next_free_devnum(enum if_type if_type);
> +int blk_next_free_devnum(enum uclass_id if_type);
>
>   /**
>    * blk_select_hwpart() - select a hardware partition
> @@ -496,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
>    */
>   struct blk_driver {
>   	const char *if_typename;
> -	enum if_type if_type;
> +	enum uclass_id if_type;
>   	int max_devs;
>   	struct blk_desc *desc;
>   	/**
> @@ -557,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
>    * @devnum:	Device number
>    * Return: point to block device descriptor, or NULL if not found
>    */
> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
>
>   /**
>    * blk_get_devnum_by_type() - Get a block device by type name, and number
> @@ -594,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
>    * @if_type:	Block device type
>    * Return: 0 if OK, -ENODEV if there is none of that type
>    */
> -int blk_list_part(enum if_type if_type);
> +int blk_list_part(enum uclass_id if_type);
>
>   /**
>    * blk_list_devices() - list the block devices of a given type
> @@ -604,7 +601,7 @@ int blk_list_part(enum if_type if_type);
>    *
>    * @if_type:	Block device type
>    */
> -void blk_list_devices(enum if_type if_type);
> +void blk_list_devices(enum uclass_id if_type);
>
>   /**
>    * blk_show_device() - show information about a given block device
> @@ -615,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
>    * @devnum:	Device number
>    * Return: 0 if OK, -ENODEV for invalid device number
>    */
> -int blk_show_device(enum if_type if_type, int devnum);
> +int blk_show_device(enum uclass_id if_type, int devnum);
>
>   /**
>    * blk_print_device_num() - show information about a given block device
> @@ -628,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
>    * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
>    * device is not connected
>    */
> -int blk_print_device_num(enum if_type if_type, int devnum);
> +int blk_print_device_num(enum uclass_id if_type, int devnum);
>
>   /**
>    * blk_print_part_devnum() - print the partition information for a device
> @@ -638,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
>    * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
>    * the interface type is not supported, other -ve on other error
>    */
> -int blk_print_part_devnum(enum if_type if_type, int devnum);
> +int blk_print_part_devnum(enum uclass_id if_type, int devnum);
>
>   /**
>    * blk_read_devnum() - read blocks from a device
> @@ -649,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
>    * @buffer:	Address to write data to
>    * Return: number of blocks read, or -ve error number on error
>    */
> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		      lbaint_t blkcnt, void *buffer);
>
>   /**
> @@ -661,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>    * @buffer:	Address to read data from
>    * Return: number of blocks written, or -ve error number on error
>    */
> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   		       lbaint_t blkcnt, const void *buffer);
>
>   /**
> @@ -675,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>    * @hwpart:	Partition number to select
>    * Return: 0 if OK, -ve on error
>    */
> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
>
>   /**
>    * blk_get_if_type_name() - Get the name of an interface type
> @@ -683,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>    * @if_type: Interface type to check
>    * Return: name of interface, or NULL if none
>    */
> -const char *blk_get_if_type_name(enum if_type if_type);
> +const char *blk_get_if_type_name(enum uclass_id if_type);
>
>   /**
>    * blk_common_cmd() - handle common commands with block devices
> @@ -694,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
>    * @cur_devnump: Current device number for this interface type
>    * Return: 0 if OK, CMD_RET_ERROR on error
>    */
> -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>   		   int *cur_devnump);
>
>   enum blk_flag_t {
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 3a63a1f75fd..ae58efb0036 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
>
>   /* EFI system partition */
>   extern struct efi_system_partition {
> -	enum if_type if_type;
> +	enum uclass_id if_type;
>   	int devnum;

Please, rename the field if_type to class_id in a later patch.

Uclass ID and device number may refer to a different device after
commands like usb init. It would be better if we could use the partition
GUID to identify a partition in the long term. But that is beyond the
scope of this series.

Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>


>   	u8 part;



>   } efi_system_partition;


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 24/24] blk: Rename if_type to uclass_id
  2022-08-12  1:35 ` [PATCH v2 24/24] blk: Rename if_type to uclass_id Simon Glass
  2022-09-13 16:03   ` Tom Rini
@ 2022-09-14  1:22   ` AKASHI Takahiro
  1 sibling, 0 replies; 42+ messages in thread
From: AKASHI Takahiro @ 2022-09-14  1:22 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Tom Rini, Heinrich Schuchardt,
	Anastasiia Lukianenko, Aswath Govindraju, Bin Meng,
	Ilias Apalodimas, Jaehoon Chung, Joe Hershberger,
	Lukasz Majewski, Marcel Ziswiler, Marek Vasut, Markus Niebel,
	Masahisa Kojima, Max Merchel, Oleksandr Andrushchenko,
	Oleksandr Suvorov, Oleksii Bidnichenko, Patrice Chotard,
	Patrick Delaunay, Peng Fan, Ramon Fried, Ricardo Salveti,
	Sean Anderson, Stefan Roese, Ying-Chun Liu (PaulLiu),
	schspa, uboot-stm32

Hi Simon,

On Thu, Aug 11, 2022 at 07:35:03PM -0600, Simon Glass wrote:
> Use the word 'uclass' instead of 'if_type' to complete the conversion.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v2:
> - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()
> 
>  board/st/common/stm32mp_dfu.c            |   2 +-
>  cmd/blk_common.c                         |  18 +--
>  cmd/lsblk.c                              |   2 +-
>  cmd/mmc.c                                |   2 +-
>  common/usb_storage.c                     |   6 +-
>  disk/disk-uclass.c                       |   8 +-
>  disk/part.c                              |  12 +-
>  doc/usage/partitions.rst                 |   2 +-
>  drivers/ata/sata.c                       |   2 +-
>  drivers/block/blk-uclass.c               | 145 +++++++++++------------
>  drivers/block/blk_legacy.c               |  58 ++++-----
>  drivers/block/ide.c                      |   8 +-
>  drivers/block/sandbox.c                  |   6 +-
>  drivers/mmc/mmc-uclass.c                 |   2 +-
>  drivers/mmc/mmc_legacy.c                 |   8 +-
>  drivers/net/fsl_enetc.c                  |  12 +-
>  drivers/net/fsl_enetc.h                  |   2 +-
>  drivers/scsi/scsi.c                      |   6 +-
>  drivers/virtio/virtio_blk.c              |   2 +-
>  drivers/xen/pvblock.c                    |   2 +-
>  fs/fat/fat.c                             |   2 +-
>  include/blk.h                            | 116 +++++++++---------
>  include/efi_api.h                        |   4 +-
>  include/efi_loader.h                     |   4 +-
>  lib/efi_loader/efi_device_path.c         |   2 +-
>  lib/efi_loader/efi_device_path_to_text.c |   4 +-
>  lib/efi_loader/efi_disk.c                |  26 ++--
>  lib/efi_loader/efi_net.c                 |   2 +-
>  lib/efi_loader/efi_var_file.c            |   4 +-
>  29 files changed, 234 insertions(+), 235 deletions(-)
> 
> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
> index fa48b2a35ee..0096f71dfc1 100644
> --- a/board/st/common/stm32mp_dfu.c
> +++ b/board/st/common/stm32mp_dfu.c
> @@ -37,7 +37,7 @@ static void board_get_alt_info_mmc(struct udevice *dev, char *buf)
>  	if (!desc)
>  		return;
>  
> -	name = blk_get_if_type_name(desc->if_type);
> +	name = blk_get_uclass_name(desc->uclass_id);
>  	devnum = desc->devnum;
>  	len = strlen(buf);
>  
> diff --git a/cmd/blk_common.c b/cmd/blk_common.c
> index 369c5ae4bbe..75a072caf51 100644
> --- a/cmd/blk_common.c
> +++ b/cmd/blk_common.c
> @@ -12,10 +12,10 @@
>  #include <blk.h>
>  #include <command.h>
>  
> -int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
>  		   int *cur_devnump)
>  {
> -	const char *if_name = blk_get_if_type_name(if_type);
> +	const char *if_name = blk_get_uclass_name(uclass_id);
>  
>  	switch (argc) {
>  	case 0:
> @@ -23,16 +23,16 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>  		return CMD_RET_USAGE;
>  	case 2:
>  		if (strncmp(argv[1], "inf", 3) == 0) {
> -			blk_list_devices(if_type);
> +			blk_list_devices(uclass_id);
>  			return 0;
>  		} else if (strncmp(argv[1], "dev", 3) == 0) {
> -			if (blk_print_device_num(if_type, *cur_devnump)) {
> +			if (blk_print_device_num(uclass_id, *cur_devnump)) {
>  				printf("\nno %s devices available\n", if_name);
>  				return CMD_RET_FAILURE;
>  			}
>  			return 0;
>  		} else if (strncmp(argv[1], "part", 4) == 0) {
> -			if (blk_list_part(if_type))
> +			if (blk_list_part(uclass_id))
>  				printf("\nno %s partition table available\n",
>  				       if_name);
>  			return 0;
> @@ -42,7 +42,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>  		if (strncmp(argv[1], "dev", 3) == 0) {
>  			int dev = (int)dectoul(argv[2], NULL);
>  
> -			if (!blk_show_device(if_type, dev)) {
> +			if (!blk_show_device(uclass_id, dev)) {
>  				*cur_devnump = dev;
>  				printf("... is now current device\n");
>  			} else {
> @@ -52,7 +52,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>  		} else if (strncmp(argv[1], "part", 4) == 0) {
>  			int dev = (int)dectoul(argv[2], NULL);
>  
> -			if (blk_print_part_devnum(if_type, dev)) {
> +			if (blk_print_part_devnum(uclass_id, dev)) {
>  				printf("\n%s device %d not available\n",
>  				       if_name, dev);
>  				return CMD_RET_FAILURE;
> @@ -71,7 +71,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>  			printf("\n%s read: device %d block # "LBAFU", count %lu ... ",
>  			       if_name, *cur_devnump, blk, cnt);
>  
> -			n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
> +			n = blk_read_devnum(uclass_id, *cur_devnump, blk, cnt,
>  					    (ulong *)addr);
>  
>  			printf("%ld blocks read: %s\n", n,
> @@ -86,7 +86,7 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>  			printf("\n%s write: device %d block # "LBAFU", count %lu ... ",
>  			       if_name, *cur_devnump, blk, cnt);
>  
> -			n = blk_write_devnum(if_type, *cur_devnump, blk, cnt,
> +			n = blk_write_devnum(uclass_id, *cur_devnump, blk, cnt,
>  					     (ulong *)addr);
>  
>  			printf("%ld blocks written: %s\n", n,
> diff --git a/cmd/lsblk.c b/cmd/lsblk.c
> index 6a1c8f5ef40..d214dafc3be 100644
> --- a/cmd/lsblk.c
> +++ b/cmd/lsblk.c
> @@ -36,7 +36,7 @@ static int do_lsblk(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
>  				continue;
>  			desc = dev_get_uclass_plat(udev);
>  			printf("%c %s %u", i ? ',' : ':',
> -			       blk_get_if_type_name(desc->if_type),
> +			       blk_get_uclass_name(desc->uclass_id),
>  			       desc->devnum);
>  			i++;
>  		}
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index 0f1f4e0a71d..6718e99ea7d 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -154,7 +154,7 @@ static struct mmc *__init_mmc_device(int dev, bool force_init,
>  
>  #ifdef CONFIG_BLOCK_CACHE
>  	struct blk_desc *bd = mmc_get_blk_desc(mmc);
> -	blkcache_invalidate(bd->if_type, bd->devnum);
> +	blkcache_invalidate(bd->uclass_id, bd->devnum);
>  #endif
>  
>  	return mmc;
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index 7d420160cd5..e59c819bac5 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -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 = UCLASS_USB;
> +		blkdev->uclass_id = UCLASS_USB;
>  		blkdev->devnum = usb_max_devs;
>  		blkdev->part_type = PART_TYPE_UNKNOWN;
>  		blkdev->target = 0xff;
> @@ -1577,8 +1577,8 @@ U_BOOT_DRIVER(usb_storage_blk) = {
>  };
>  #else
>  U_BOOT_LEGACY_BLK(usb) = {
> -	.if_typename	= "usb",
> -	.if_type	= UCLASS_USB,
> +	.uclass_idname	= "usb",
> +	.uclass_id	= UCLASS_USB,
>  	.max_devs	= USB_MAX_STOR_DEV,
>  	.desc		= usb_dev_desc,
>  };
> diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
> index 9351a5cfa68..551f8b1dca4 100644
> --- a/disk/disk-uclass.c
> +++ b/disk/disk-uclass.c
> @@ -191,12 +191,12 @@ unsigned long dev_read(struct udevice *dev, lbaint_t start,
>  		start_in_disk += part->gpt_part_info.start;
>  	}
>  
> -	if (blkcache_read(block_dev->if_type, block_dev->devnum,
> +	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
>  			  start_in_disk, blkcnt, block_dev->blksz, buffer))
>  		return blkcnt;
>  	blks_read = ops->read(dev, start, blkcnt, buffer);
>  	if (blks_read == blkcnt)
> -		blkcache_fill(block_dev->if_type, block_dev->devnum,
> +		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
>  			      start_in_disk, blkcnt, block_dev->blksz, buffer);
>  
>  	return blks_read;
> @@ -216,7 +216,7 @@ unsigned long dev_write(struct udevice *dev, lbaint_t start,
>  	if (!ops->write)
>  		return -ENOSYS;
>  
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  
>  	return ops->write(dev, start, blkcnt, buffer);
>  }
> @@ -235,7 +235,7 @@ unsigned long dev_erase(struct udevice *dev, lbaint_t start,
>  	if (!ops->erase)
>  		return -ENOSYS;
>  
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  
>  	return ops->erase(dev, start, blkcnt);
>  }
> diff --git a/disk/part.c b/disk/part.c
> index 5705c229d59..d73318c8ffe 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -120,7 +120,7 @@ void dev_print(struct blk_desc *dev_desc)
>  		return;
>  	}
>  
> -	switch (dev_desc->if_type) {
> +	switch (dev_desc->uclass_id) {
>  	case UCLASS_SCSI:
>  		printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
>  			dev_desc->target,dev_desc->lun,
> @@ -155,7 +155,7 @@ void dev_print(struct blk_desc *dev_desc)
>  		puts("device type unknown\n");
>  		return;
>  	default:
> -		printf("Unhandled device type: %i\n", dev_desc->if_type);
> +		printf("Unhandled device type: %i\n", dev_desc->uclass_id);
>  		return;
>  	}
>  	puts ("            Type: ");
> @@ -225,7 +225,7 @@ void part_init(struct blk_desc *dev_desc)
>  	const int n_ents = ll_entry_count(struct part_driver, part_driver);
>  	struct part_driver *entry;
>  
> -	blkcache_invalidate(dev_desc->if_type, dev_desc->devnum);
> +	blkcache_invalidate(dev_desc->uclass_id, dev_desc->devnum);
>  
>  	dev_desc->part_type = PART_TYPE_UNKNOWN;
>  	for (entry = drv; entry != drv + n_ents; entry++) {
> @@ -248,7 +248,7 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)
>  	CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
>  	CONFIG_IS_ENABLED(EFI_PARTITION)
>  	puts ("\nPartition Map for ");
> -	switch (dev_desc->if_type) {
> +	switch (dev_desc->uclass_id) {
>  	case UCLASS_IDE:
>  		puts ("IDE");
>  		break;
> @@ -408,7 +408,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 == UCLASS_MMC)
> +		if ((*dev_desc)->uclass_id == UCLASS_MMC)
>  			part_init(*dev_desc);
>  	}
>  
> @@ -762,7 +762,7 @@ void part_set_generic_name(const struct blk_desc *dev_desc,
>  {
>  	char *devtype;
>  
> -	switch (dev_desc->if_type) {
> +	switch (dev_desc->uclass_id) {
>  	case UCLASS_IDE:
>  	case UCLASS_AHCI:
>  		devtype = "hd";
> diff --git a/doc/usage/partitions.rst b/doc/usage/partitions.rst
> index 2c1a12b6bf5..628469bbec9 100644
> --- a/doc/usage/partitions.rst
> +++ b/doc/usage/partitions.rst
> @@ -20,7 +20,7 @@ generic syntax.
>  interface
>          The interface used to access the partition's device, like ``mmc`` or
>          ``scsi``. For a full list of supported interfaces, consult the
> -        ``if_typename_str`` array in ``drivers/block/blk-uclass.c``
> +        ``uclass_idname_str`` array in ``drivers/block/blk-uclass.c``
>  
>  devnum
>          The device number. This defaults to 0.
> diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
> index 604c721cfdc..ce3e9b5a400 100644
> --- a/drivers/ata/sata.c
> +++ b/drivers/ata/sata.c
> @@ -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 = UCLASS_AHCI;
> +		sata_dev_desc[i].uclass_id = 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;
> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> index a9a85aa37f3..f8157c8d6ae 100644
> --- a/drivers/block/blk-uclass.c
> +++ b/drivers/block/blk-uclass.c
> @@ -20,7 +20,7 @@
>  static struct {
>  	enum uclass_id id;
>  	const char *name;
> -} if_typename_str[] = {
> +} uclass_idname_str[] = {
>  	{ UCLASS_IDE, "ide" },
>  	{ UCLASS_SCSI, "scsi" },
>  	{ UCLASS_USB, "usb" },
> @@ -34,19 +34,19 @@ static struct {
>  	{ UCLASS_PVBLOCK, "pvblock" },
>  };
>  
> -static enum uclass_id if_typename_to_iftype(const char *if_typename)
> +static enum uclass_id uclass_idname_to_iftype(const char *uclass_idname)

If you don't mind changing an existing function's name,

>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
> -		if (!strcmp(if_typename, if_typename_str[i].name))
> -			return if_typename_str[i].id;
> +	for (i = 0; i < ARRAY_SIZE(uclass_idname_str); i++) {
> +		if (!strcmp(uclass_idname, uclass_idname_str[i].name))
> +			return uclass_idname_str[i].id;
>  	}
>  
>  	return UCLASS_INVALID;
>  }
>  
> -static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
> +static enum uclass_id conv_uclass_id(enum uclass_id uclass_id)
>  {
>  	/*
>  	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
> @@ -65,31 +65,30 @@ static enum uclass_id if_type_to_uclass_id(enum uclass_id if_type)
>  	 *    - rename UCLASS_USB name to "usb_ctlr"
>  	 *    - use UCLASS_MASS_STORAGE instead of UCLASS_USB in if_typename_str
>  	 */
> -	if (if_type == UCLASS_USB)
> +	if (uclass_id == UCLASS_USB)
>  		return UCLASS_MASS_STORAGE;
> -
> -	return if_type;
> +	return uclass_id;
>  }
>  
> -const char *blk_get_if_type_name(enum uclass_id if_type)
> +const char *blk_get_uclass_name(enum uclass_id uclass_id)
>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(if_typename_str); i++) {
> -		if (if_typename_str[i].id == if_type)
> -			return if_typename_str[i].name;
> +	for (i = 0; i < ARRAY_SIZE(uclass_idname_str); i++) {
> +		if (uclass_idname_str[i].id == uclass_id)
> +			return uclass_idname_str[i].name;
>  	}
>  
>  	return "(none)";
>  }
>  
> -struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum)

why not rename this function to blk_get_devnum_by_uclass_id()?
Now that we don't see any occurrence of word "type" in this function,
"by_type" might sound ambiguous.

>  {
>  	struct blk_desc *desc;
>  	struct udevice *dev;
>  	int ret;
>  
> -	ret = blk_get_device(if_type, devnum, &dev);
> +	ret = blk_get_device(uclass_id, devnum, &dev);
>  	if (ret)
>  		return NULL;
>  	desc = dev_get_uclass_plat(dev);
> @@ -102,7 +101,7 @@ struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>   * name in a local table. This gives us an interface type which we can match
>   * against the uclass of the block device's parent.
>   */
> -struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> +struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname, int devnum)
>  {
>  	enum uclass_id uclass_id;
>  	enum uclass_id type;
> @@ -110,16 +109,16 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>  	struct uclass *uc;
>  	int ret;
>  
> -	type = if_typename_to_iftype(if_typename);
> +	type = uclass_idname_to_iftype(uclass_idname);
>  	if (type == UCLASS_INVALID) {
>  		debug("%s: Unknown interface type '%s'\n", __func__,
> -		      if_typename);
> +		      uclass_idname);
>  		return NULL;
>  	}
> -	uclass_id = if_type_to_uclass_id(type);
> +	uclass_id = conv_uclass_id(type);
>  	if (uclass_id == UCLASS_INVALID) {
>  		debug("%s: Unknown uclass for interface type'\n",
> -		      blk_get_if_type_name(type));
> +		      blk_get_uclass_name(type));
>  		return NULL;
>  	}
>  
> @@ -129,8 +128,8 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>  	uclass_foreach_dev(dev, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
> -		      type, devnum, dev->name, desc->if_type, desc->devnum);
> +		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
> +		      type, devnum, dev->name, desc->uclass_id, desc->devnum);
>  		if (desc->devnum != devnum)
>  			continue;
>  
> @@ -178,14 +177,14 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
>  /**
>   * get_desc() - Get the block device descriptor for the given device number
>   *
> - * @if_type:	Interface type
> + * @uclass_id:	Interface type
>   * @devnum:	Device number (0 = first)
>   * @descp:	Returns block device descriptor on success
>   * Return: 0 on success, -ENODEV if there is no such device and no device
>   * with a higher device number, -ENOENT if there is no such device but there
>   * is one with a higher number, or other -ve on other error.
>   */
> -static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
> +static int get_desc(enum uclass_id uclass_id, int devnum, struct blk_desc **descp)
>  {
>  	bool found_more = false;
>  	struct udevice *dev;
> @@ -199,9 +198,9 @@ static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
>  	uclass_foreach_dev(dev, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
> -		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
> -		if (desc->if_type == if_type) {
> +		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
> +		      uclass_id, devnum, dev->name, desc->uclass_id, desc->devnum);
> +		if (desc->uclass_id == uclass_id) {
>  			if (desc->devnum == devnum) {
>  				ret = device_probe(dev);
>  				if (ret)
> @@ -218,26 +217,26 @@ static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
>  	return found_more ? -ENOENT : -ENODEV;
>  }
>  
> -int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> +int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart)
>  {
>  	struct udevice *dev;
>  	int ret;
>  
> -	ret = blk_get_device(if_type, devnum, &dev);
> +	ret = blk_get_device(uclass_id, devnum, &dev);
>  	if (ret)
>  		return ret;
>  
>  	return blk_select_hwpart(dev, hwpart);
>  }
>  
> -int blk_list_part(enum uclass_id if_type)
> +int blk_list_part(enum uclass_id uclass_id)
>  {
>  	struct blk_desc *desc;
>  	int devnum, ok;
>  	int ret;
>  
>  	for (ok = 0, devnum = 0;; ++devnum) {
> -		ret = get_desc(if_type, devnum, &desc);
> +		ret = get_desc(uclass_id, devnum, &desc);
>  		if (ret == -ENODEV)
>  			break;
>  		else if (ret)
> @@ -255,12 +254,12 @@ int blk_list_part(enum uclass_id if_type)
>  	return 0;
>  }
>  
> -int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> +int blk_print_part_devnum(enum uclass_id uclass_id, int devnum)
>  {
>  	struct blk_desc *desc;
>  	int ret;
>  
> -	ret = get_desc(if_type, devnum, &desc);
> +	ret = get_desc(uclass_id, devnum, &desc);
>  	if (ret)
>  		return ret;
>  	if (desc->type == DEV_TYPE_UNKNOWN)
> @@ -270,14 +269,14 @@ int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>  	return 0;
>  }
>  
> -void blk_list_devices(enum uclass_id if_type)
> +void blk_list_devices(enum uclass_id uclass_id)
>  {
>  	struct blk_desc *desc;
>  	int ret;
>  	int i;
>  
>  	for (i = 0;; ++i) {
> -		ret = get_desc(if_type, i, &desc);
> +		ret = get_desc(uclass_id, i, &desc);
>  		if (ret == -ENODEV)
>  			break;
>  		else if (ret)
> @@ -289,12 +288,12 @@ void blk_list_devices(enum uclass_id if_type)
>  	}
>  }
>  
> -int blk_print_device_num(enum uclass_id if_type, int devnum)
> +int blk_print_device_num(enum uclass_id uclass_id, int devnum)
>  {
>  	struct blk_desc *desc;
>  	int ret;
>  
> -	ret = get_desc(if_type, devnum, &desc);
> +	ret = get_desc(uclass_id, devnum, &desc);
>  	if (ret)
>  		return ret;
>  	printf("\nIDE device %d: ", devnum);
> @@ -303,13 +302,13 @@ int blk_print_device_num(enum uclass_id if_type, int devnum)
>  	return 0;
>  }
>  
> -int blk_show_device(enum uclass_id if_type, int devnum)
> +int blk_show_device(enum uclass_id uclass_id, int devnum)
>  {
>  	struct blk_desc *desc;
>  	int ret;
>  
>  	printf("\nDevice %d: ", devnum);
> -	ret = get_desc(if_type, devnum, &desc);
> +	ret = get_desc(uclass_id, devnum, &desc);
>  	if (ret == -ENODEV || ret == -ENOENT) {
>  		printf("unknown device\n");
>  		return -ENODEV;
> @@ -324,14 +323,14 @@ int blk_show_device(enum uclass_id if_type, int devnum)
>  	return 0;
>  }
>  
> -ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		      lbaint_t blkcnt, void *buffer)
>  {
>  	struct blk_desc *desc;
>  	ulong n;
>  	int ret;
>  
> -	ret = get_desc(if_type, devnum, &desc);
> +	ret = get_desc(uclass_id, devnum, &desc);
>  	if (ret)
>  		return ret;
>  	n = blk_dread(desc, start, blkcnt, buffer);
> @@ -341,13 +340,13 @@ ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>  	return n;
>  }
>  
> -ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		       lbaint_t blkcnt, const void *buffer)
>  {
>  	struct blk_desc *desc;
>  	int ret;
>  
> -	ret = get_desc(if_type, devnum, &desc);
> +	ret = get_desc(uclass_id, devnum, &desc);
>  	if (ret)
>  		return ret;
>  	return blk_dwrite(desc, start, blkcnt, buffer);
> @@ -370,7 +369,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
>  	return blk_select_hwpart(desc->bdev, hwpart);
>  }
>  
> -int blk_first_device(int if_type, struct udevice **devp)
> +int blk_first_device(int uclass_id, struct udevice **devp)
>  {
>  	struct blk_desc *desc;
>  	int ret;
> @@ -382,7 +381,7 @@ int blk_first_device(int if_type, struct udevice **devp)
>  		return -ENODEV;
>  	do {
>  		desc = dev_get_uclass_plat(*devp);
> -		if (desc->if_type == if_type)
> +		if (desc->uclass_id == uclass_id)
>  			return 0;
>  		ret = uclass_find_next_device(devp);
>  		if (ret)
> @@ -395,10 +394,10 @@ int blk_first_device(int if_type, struct udevice **devp)
>  int blk_next_device(struct udevice **devp)
>  {
>  	struct blk_desc *desc;
> -	int ret, if_type;
> +	int ret, uclass_id;
>  
>  	desc = dev_get_uclass_plat(*devp);
> -	if_type = desc->if_type;
> +	uclass_id = desc->uclass_id;
>  	do {
>  		ret = uclass_find_next_device(devp);
>  		if (ret)
> @@ -406,12 +405,12 @@ int blk_next_device(struct udevice **devp)
>  		if (!*devp)
>  			return -ENODEV;
>  		desc = dev_get_uclass_plat(*devp);
> -		if (desc->if_type == if_type)
> +		if (desc->uclass_id == uclass_id)
>  			return 0;
>  	} while (1);
>  }
>  
> -int blk_find_device(int if_type, int devnum, struct udevice **devp)
> +int blk_find_device(int uclass_id, int devnum, struct udevice **devp)
>  {
>  	struct uclass *uc;
>  	struct udevice *dev;
> @@ -423,9 +422,9 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp)
>  	uclass_foreach_dev(dev, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		debug("%s: if_type=%d, devnum=%d: %s, %d, %d\n", __func__,
> -		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
> -		if (desc->if_type == if_type && desc->devnum == devnum) {
> +		debug("%s: uclass_id=%d, devnum=%d: %s, %d, %d\n", __func__,
> +		      uclass_id, devnum, dev->name, desc->uclass_id, desc->devnum);
> +		if (desc->uclass_id == uclass_id && desc->devnum == devnum) {
>  			*devp = dev;
>  			return 0;
>  		}
> @@ -434,11 +433,11 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp)
>  	return -ENODEV;
>  }
>  
> -int blk_get_device(int if_type, int devnum, struct udevice **devp)
> +int blk_get_device(int uclass_id, int devnum, struct udevice **devp)
>  {
>  	int ret;
>  
> -	ret = blk_find_device(if_type, devnum, devp);
> +	ret = blk_find_device(uclass_id, devnum, devp);
>  	if (ret)
>  		return ret;
>  
> @@ -455,12 +454,12 @@ unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
>  	if (!ops->read)
>  		return -ENOSYS;
>  
> -	if (blkcache_read(block_dev->if_type, block_dev->devnum,
> +	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
>  			  start, blkcnt, block_dev->blksz, buffer))
>  		return blkcnt;
>  	blks_read = ops->read(dev, start, blkcnt, buffer);
>  	if (blks_read == blkcnt)
> -		blkcache_fill(block_dev->if_type, block_dev->devnum,
> +		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
>  			      start, blkcnt, block_dev->blksz, buffer);
>  
>  	return blks_read;
> @@ -475,7 +474,7 @@ unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
>  	if (!ops->write)
>  		return -ENOSYS;
>  
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  	return ops->write(dev, start, blkcnt, buffer);
>  }
>  
> @@ -488,7 +487,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
>  	if (!ops->erase)
>  		return -ENOSYS;
>  
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  	return ops->erase(dev, start, blkcnt);
>  }
>  
> @@ -525,7 +524,7 @@ const char *blk_get_devtype(struct udevice *dev)
>  	return uclass_get_name(device_get_uclass_id(parent));
>  };
>  
> -int blk_find_max_devnum(enum uclass_id if_type)
> +int blk_find_max_devnum(enum uclass_id uclass_id)
>  {
>  	struct udevice *dev;
>  	int max_devnum = -ENODEV;
> @@ -538,18 +537,18 @@ int blk_find_max_devnum(enum uclass_id if_type)
>  	uclass_foreach_dev(dev, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		if (desc->if_type == if_type && desc->devnum > max_devnum)
> +		if (desc->uclass_id == uclass_id && desc->devnum > max_devnum)
>  			max_devnum = desc->devnum;
>  	}
>  
>  	return max_devnum;
>  }
>  
> -int blk_next_free_devnum(enum uclass_id if_type)
> +int blk_next_free_devnum(enum uclass_id uclass_id)
>  {
>  	int ret;
>  
> -	ret = blk_find_max_devnum(if_type);
> +	ret = blk_find_max_devnum(uclass_id);
>  	if (ret == -ENODEV)
>  		return 0;
>  	if (ret < 0)
> @@ -631,7 +630,7 @@ int blk_count_devices(enum blk_flag_t flag)
>  	return count;
>  }
>  
> -static int blk_claim_devnum(enum uclass_id if_type, int devnum)
> +static int blk_claim_devnum(enum uclass_id uclass_id, int devnum)
>  {
>  	struct udevice *dev;
>  	struct uclass *uc;
> @@ -643,8 +642,8 @@ static int blk_claim_devnum(enum uclass_id if_type, int devnum)
>  	uclass_foreach_dev(dev, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		if (desc->if_type == if_type && desc->devnum == devnum) {
> -			int next = blk_next_free_devnum(if_type);
> +		if (desc->uclass_id == uclass_id && desc->devnum == devnum) {
> +			int next = blk_next_free_devnum(uclass_id);
>  
>  			if (next < 0)
>  				return next;
> @@ -657,7 +656,7 @@ static int blk_claim_devnum(enum uclass_id if_type, int devnum)
>  }
>  
>  int blk_create_device(struct udevice *parent, const char *drv_name,
> -		      const char *name, int if_type, int devnum, int blksz,
> +		      const char *name, int uclass_id, int devnum, int blksz,
>  		      lbaint_t lba, struct udevice **devp)
>  {
>  	struct blk_desc *desc;
> @@ -665,9 +664,9 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>  	int ret;
>  
>  	if (devnum == -1) {
> -		devnum = blk_next_free_devnum(if_type);
> +		devnum = blk_next_free_devnum(uclass_id);
>  	} else {
> -		ret = blk_claim_devnum(if_type, devnum);
> +		ret = blk_claim_devnum(uclass_id, devnum);
>  		if (ret < 0 && ret != -ENOENT)
>  			return ret;
>  	}
> @@ -677,7 +676,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>  	if (ret)
>  		return ret;
>  	desc = dev_get_uclass_plat(dev);
> -	desc->if_type = if_type;
> +	desc->uclass_id = uclass_id;
>  	desc->blksz = blksz;
>  	desc->log2blksz = LOG2(desc->blksz);
>  	desc->lba = lba;
> @@ -690,7 +689,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>  }
>  
>  int blk_create_devicef(struct udevice *parent, const char *drv_name,
> -		       const char *name, int if_type, int devnum, int blksz,
> +		       const char *name, int uclass_id, int devnum, int blksz,
>  		       lbaint_t lba, struct udevice **devp)
>  {
>  	char dev_name[30], *str;
> @@ -701,7 +700,7 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name,
>  	if (!str)
>  		return -ENOMEM;
>  
> -	ret = blk_create_device(parent, drv_name, str, if_type, devnum,
> +	ret = blk_create_device(parent, drv_name, str, uclass_id, devnum,
>  				blksz, lba, devp);
>  	if (ret) {
>  		free(str);
> @@ -725,7 +724,7 @@ int blk_probe_or_unbind(struct udevice *dev)
>  	return ret;
>  }
>  
> -int blk_unbind_all(int if_type)
> +int blk_unbind_all(int uclass_id)
>  {
>  	struct uclass *uc;
>  	struct udevice *dev, *next;
> @@ -737,7 +736,7 @@ int blk_unbind_all(int if_type)
>  	uclass_foreach_dev_safe(dev, next, uc) {
>  		struct blk_desc *desc = dev_get_uclass_plat(dev);
>  
> -		if (desc->if_type == if_type) {
> +		if (desc->uclass_id == uclass_id) {
>  			ret = device_remove(dev, DM_REMOVE_NORMAL);
>  			if (ret)
>  				return ret;
> diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
> index 8c6f9cb208e..2ba5cc2d5a8 100644
> --- a/drivers/block/blk_legacy.c
> +++ b/drivers/block/blk_legacy.c
> @@ -9,14 +9,14 @@
>  #include <part.h>
>  #include <linux/err.h>
>  
> -struct blk_driver *blk_driver_lookup_type(int if_type)
> +struct blk_driver *blk_driver_lookup_type(int uclass_id)
>  {
>  	struct blk_driver *drv = ll_entry_start(struct blk_driver, blk_driver);
>  	const int n_ents = ll_entry_count(struct blk_driver, blk_driver);
>  	struct blk_driver *entry;
>  
>  	for (entry = drv; entry != drv + n_ents; entry++) {
> -		if (if_type == entry->if_type)
> +		if (uclass_id == entry->uclass_id)
>  			return entry;
>  	}
>  
> @@ -24,14 +24,14 @@ struct blk_driver *blk_driver_lookup_type(int if_type)
>  	return NULL;
>  }
>  
> -static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
> +static struct blk_driver *blk_driver_lookup_typename(const char *uclass_idname)
>  {
>  	struct blk_driver *drv = ll_entry_start(struct blk_driver, blk_driver);
>  	const int n_ents = ll_entry_count(struct blk_driver, blk_driver);
>  	struct blk_driver *entry;
>  
>  	for (entry = drv; entry != drv + n_ents; entry++) {
> -		if (!strcmp(if_typename, entry->if_typename))
> +		if (!strcmp(uclass_idname, entry->uclass_idname))
>  			return entry;
>  	}
>  
> @@ -39,11 +39,11 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
>  	return NULL;
>  }
>  
> -const char *blk_get_if_type_name(enum uclass_id if_type)
> +const char *blk_get_uclass_name(enum uclass_id uclass_id)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  
> -	return drv ? drv->if_typename : NULL;
> +	return drv ? drv->uclass_idname : NULL;
>  }
>  
>  /**
> @@ -70,14 +70,14 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
>  	return drv->get_dev(devnum, descp);
>  }
>  
> -int blk_list_part(enum uclass_id if_type)
> +int blk_list_part(enum uclass_id uclass_id)
>  {
>  	struct blk_driver *drv;
>  	struct blk_desc *desc;
>  	int devnum, ok;
>  	bool first = true;
>  
> -	drv = blk_driver_lookup_type(if_type);
> +	drv = blk_driver_lookup_type(uclass_id);
>  	if (!drv)
>  		return -ENOSYS;
>  	for (ok = 0, devnum = 0; devnum < drv->max_devs; ++devnum) {
> @@ -97,9 +97,9 @@ int blk_list_part(enum uclass_id if_type)
>  	return 0;
>  }
>  
> -int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> +int blk_print_part_devnum(enum uclass_id uclass_id, int devnum)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int ret;
>  
> @@ -115,9 +115,9 @@ int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>  	return 0;
>  }
>  
> -void blk_list_devices(enum uclass_id if_type)
> +void blk_list_devices(enum uclass_id uclass_id)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int i;
>  
> @@ -133,9 +133,9 @@ void blk_list_devices(enum uclass_id if_type)
>  	}
>  }
>  
> -int blk_print_device_num(enum uclass_id if_type, int devnum)
> +int blk_print_device_num(enum uclass_id uclass_id, int devnum)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int ret;
>  
> @@ -144,15 +144,15 @@ int blk_print_device_num(enum uclass_id if_type, int devnum)
>  	ret = get_desc(drv, devnum, &desc);
>  	if (ret)
>  		return ret;
> -	printf("\n%s device %d: ", drv->if_typename, devnum);
> +	printf("\n%s device %d: ", drv->uclass_idname, devnum);
>  	dev_print(desc);
>  
>  	return 0;
>  }
>  
> -int blk_show_device(enum uclass_id if_type, int devnum)
> +int blk_show_device(enum uclass_id uclass_id, int devnum)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int ret;
>  
> @@ -174,9 +174,9 @@ int blk_show_device(enum uclass_id if_type, int devnum)
>  	return 0;
>  }
>  
> -struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  
>  	if (!drv)
> @@ -190,7 +190,7 @@ struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>  
>  int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(desc->if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(desc->uclass_id);
>  
>  	if (!drv)
>  		return -ENOSYS;
> @@ -200,9 +200,9 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
>  	return 0;
>  }
>  
> -struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> +struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname, int devnum)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_typename(if_typename);
> +	struct blk_driver *drv = blk_driver_lookup_typename(uclass_idname);
>  	struct blk_desc *desc;
>  
>  	if (!drv)
> @@ -214,10 +214,10 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>  	return desc;
>  }
>  
> -ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		      lbaint_t blkcnt, void *buffer)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	ulong n;
>  	int ret;
> @@ -234,10 +234,10 @@ ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>  	return n;
>  }
>  
> -ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		       lbaint_t blkcnt, const void *buffer)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int ret;
>  
> @@ -249,9 +249,9 @@ ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>  	return desc->block_write(desc, start, blkcnt, buffer);
>  }
>  
> -int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> +int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart)
>  {
> -	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> +	struct blk_driver *drv = blk_driver_lookup_type(uclass_id);
>  	struct blk_desc *desc;
>  	int ret;
>  
> diff --git a/drivers/block/ide.c b/drivers/block/ide.c
> index 73da29ad552..ef5644d0b90 100644
> --- a/drivers/block/ide.c
> +++ b/drivers/block/ide.c
> @@ -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 = UCLASS_IDE;
> +	dev_desc->uclass_id = 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 = UCLASS_IDE;
> +		ide_dev_desc[i].uclass_id = UCLASS_IDE;
>  		ide_dev_desc[i].devnum = i;
>  		ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
>  		ide_dev_desc[i].blksz = 0;
> @@ -1143,8 +1143,8 @@ UCLASS_DRIVER(ide) = {
>  };
>  #else
>  U_BOOT_LEGACY_BLK(ide) = {
> -	.if_typename	= "ide",
> -	.if_type	= UCLASS_IDE,
> +	.uclass_idname	= "ide",
> +	.uclass_id	= UCLASS_IDE,
>  	.max_devs	= CONFIG_SYS_IDE_MAXDEVICE,
>  	.desc		= ide_dev_desc,
>  };
> diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
> index 2de12e0a93e..6e43404bcaa 100644
> --- a/drivers/block/sandbox.c
> +++ b/drivers/block/sandbox.c
> @@ -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 = UCLASS_ROOT;
> +	blk_dev->uclass_id = 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;
> @@ -262,8 +262,8 @@ U_BOOT_DRIVER(sandbox_host_blk) = {
>  };
>  #else
>  U_BOOT_LEGACY_BLK(sandbox_host) = {
> -	.if_typename	= "host",
> -	.if_type	= UCLASS_ROOT,
> +	.uclass_idname	= "host",
> +	.uclass_id	= UCLASS_ROOT,
>  	.max_devs	= SANDBOX_HOST_MAX_DEVICES,
>  	.get_dev	= host_get_dev_err,
>  };
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index b1bd4ae1bc8..759a6b728c8 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -472,7 +472,7 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
>  
>  	ret = mmc_switch_part(mmc, hwpart);
>  	if (!ret)
> -		blkcache_invalidate(desc->if_type, desc->devnum);
> +		blkcache_invalidate(desc->uclass_id, desc->devnum);
>  
>  	return ret;
>  }
> diff --git a/drivers/mmc/mmc_legacy.c b/drivers/mmc/mmc_legacy.c
> index 4e0891e5dfe..a101ee43fde 100644
> --- a/drivers/mmc/mmc_legacy.c
> +++ b/drivers/mmc/mmc_legacy.c
> @@ -132,7 +132,7 @@ static struct mmc mmc_static = {
>  	.dsr_imp		= 0,
>  	.dsr			= 0xffffffff,
>  	.block_dev = {
> -		.if_type	= UCLASS_MMC,
> +		.uclass_id	= 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 = UCLASS_MMC;
> +	bdesc->uclass_id = UCLASS_MMC;
>  	bdesc->removable = 1;
>  	bdesc->devnum = mmc_get_next_devnum();
>  	bdesc->block_read = mmc_bread;
> @@ -253,8 +253,8 @@ static int mmc_get_dev(int dev, struct blk_desc **descp)
>  }
>  
>  U_BOOT_LEGACY_BLK(mmc) = {
> -	.if_typename	= "mmc",
> -	.if_type	= UCLASS_MMC,
> +	.uclass_idname	= "mmc",
> +	.uclass_id	= UCLASS_MMC,
>  	.max_devs	= -1,
>  	.get_dev	= mmc_get_dev,
>  	.select_hwpart	= mmc_select_hwpartp,
> diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
> index cd4c2c29a65..f1682864611 100644
> --- a/drivers/net/fsl_enetc.c
> +++ b/drivers/net/fsl_enetc.c
> @@ -144,7 +144,7 @@ static int enetc_init_sgmii(struct udevice *dev)
>  	if (!enetc_has_imdio(dev))
>  		return 0;
>  
> -	if (priv->if_type == PHY_INTERFACE_MODE_2500BASEX)
> +	if (priv->uclass_id == PHY_INTERFACE_MODE_2500BASEX)
>  		is2500 = true;
>  
>  	/*
> @@ -219,7 +219,7 @@ static void enetc_setup_mac_iface(struct udevice *dev,
>  	struct enetc_priv *priv = dev_get_priv(dev);
>  	u32 if_mode;
>  
> -	switch (priv->if_type) {
> +	switch (priv->uclass_id) {
>  	case PHY_INTERFACE_MODE_RGMII:
>  	case PHY_INTERFACE_MODE_RGMII_ID:
>  	case PHY_INTERFACE_MODE_RGMII_RXID:
> @@ -276,14 +276,14 @@ static void enetc_start_pcs(struct udevice *dev)
>  		return;
>  	}
>  
> -	priv->if_type = dev_read_phy_mode(dev);
> -	if (priv->if_type == PHY_INTERFACE_MODE_NA) {
> +	priv->uclass_id = dev_read_phy_mode(dev);
> +	if (priv->uclass_id == PHY_INTERFACE_MODE_NA) {
>  		enetc_dbg(dev,
>  			  "phy-mode property not found, defaulting to SGMII\n");
> -		priv->if_type = PHY_INTERFACE_MODE_SGMII;
> +		priv->uclass_id = PHY_INTERFACE_MODE_SGMII;
>  	}
>  
> -	switch (priv->if_type) {
> +	switch (priv->uclass_id) {
>  	case PHY_INTERFACE_MODE_SGMII:
>  	case PHY_INTERFACE_MODE_2500BASEX:
>  		enetc_init_sgmii(dev);
> diff --git a/drivers/net/fsl_enetc.h b/drivers/net/fsl_enetc.h
> index 69f2f4aaff1..f2acf367aa3 100644
> --- a/drivers/net/fsl_enetc.h
> +++ b/drivers/net/fsl_enetc.h
> @@ -158,7 +158,7 @@ struct enetc_priv {
>  	struct bd_ring tx_bdr;
>  	struct bd_ring rx_bdr;
>  
> -	int if_type;
> +	int uclass_id;
>  	struct mii_dev imdio;
>  	struct phy_device *phy;
>  };
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 99be5aef877..3e769b0843f 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -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 = UCLASS_SCSI;
> +	dev_desc->uclass_id = UCLASS_SCSI;
>  	dev_desc->devnum = devnum;
>  	dev_desc->part_type = PART_TYPE_UNKNOWN;
>  
> @@ -706,8 +706,8 @@ U_BOOT_DRIVER(scsi_blk) = {
>  };
>  #else
>  U_BOOT_LEGACY_BLK(scsi) = {
> -	.if_typename	= "scsi",
> -	.if_type	= UCLASS_SCSI,
> +	.uclass_idname	= "scsi",
> +	.uclass_id	= UCLASS_SCSI,
>  	.max_devs	= SCSI_MAX_DEVICE,
>  	.desc		= scsi_dev_desc,
>  };
> diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
> index 9710b79117c..30cfc56725c 100644
> --- a/drivers/virtio/virtio_blk.c
> +++ b/drivers/virtio/virtio_blk.c
> @@ -75,7 +75,7 @@ static int virtio_blk_bind(struct udevice *dev)
>  	struct blk_desc *desc = dev_get_uclass_plat(dev);
>  	int devnum;
>  
> -	desc->if_type = UCLASS_VIRTIO;
> +	desc->uclass_id = UCLASS_VIRTIO;
>  	/*
>  	 * Initialize the devnum to -ENODEV. This is to make sure that
>  	 * blk_next_free_devnum() works as expected, since the default
> diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c
> index 1090e528d02..970182cd904 100644
> --- a/drivers/xen/pvblock.c
> +++ b/drivers/xen/pvblock.c
> @@ -665,7 +665,7 @@ static int pvblock_blk_bind(struct udevice *udev)
>  	struct blk_desc *desc = dev_get_uclass_plat(udev);
>  	int devnum;
>  
> -	desc->if_type = UCLASS_PVBLOCK;
> +	desc->uclass_id = UCLASS_PVBLOCK;
>  	/*
>  	 * Initialize the devnum to -ENODEV. This is to make sure that
>  	 * blk_next_free_devnum() works as expected, since the default
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index c64e253abd4..a945904785f 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -1145,7 +1145,7 @@ int file_fat_detectfs(void)
>  	}
>  
>  	if (blk_enabled()) {
> -		printf("Interface:  %s\n", blk_get_if_type_name(cur_dev->if_type));
> +		printf("Interface:  %s\n", blk_get_uclass_name(cur_dev->uclass_id));
>  		printf("  Device %d: ", cur_dev->devnum);
>  		dev_print(cur_dev);
>  	}
> diff --git a/include/blk.h b/include/blk.h
> index 279f9ea4a9d..cdc6f0fc7eb 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -54,7 +54,7 @@ struct blk_desc {
>  	 * TODO: With driver model we should be able to use the parent
>  	 * device's uclass instead.
>  	 */
> -	enum uclass_id	if_type;	/* type of the interface */
> +	enum uclass_id	uclass_id;	/* type of the interface */
>  	int		devnum;		/* device number */
>  	unsigned char	part_type;	/* partition type */
>  	unsigned char	target;		/* target SCSI ID */
> @@ -114,7 +114,7 @@ int blkcache_init(void);
>  /**
>   * blkcache_read() - attempt to read a set of blocks from cache
>   *
> - * @param iftype - IF_TYPE_x for type of device
> + * @param iftype - uclass_id_x for type of device
>   * @param dev - device index of particular type
>   * @param start - starting block number
>   * @param blkcnt - number of blocks to read
> @@ -131,7 +131,7 @@ int blkcache_read(int iftype, int dev,
>   * blkcache_fill() - make data read from a block device available
>   * to the block cache
>   *
> - * @param iftype - IF_TYPE_x for type of device
> + * @param iftype - uclass_id_x for type of device
>   * @param dev - device index of particular type
>   * @param start - starting block number
>   * @param blkcnt - number of blocks available
> @@ -147,7 +147,7 @@ void blkcache_fill(int iftype, int dev,
>   * blkcache_invalidate() - discard the cache for a set of blocks
>   * because of a write or device (re)initialization.
>   *
> - * @param iftype - IF_TYPE_x for type of device
> + * @param iftype - uclass_id_x for type of device
>   * @param dev - device index of particular type
>   */
>  void blkcache_invalidate(int iftype, int dev);
> @@ -279,22 +279,22 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
>   * This function does not activate the device. The device will be returned
>   * whether or not it is activated.
>   *
> - * @if_type:	Interface type (enum uclass_id_t)
> + * @uclass_id:	Interface type (enum uclass_id_t)
>   * @devnum:	Device number (specific to each interface type)
>   * @devp:	the device, if found
>   * Return: 0 if found, -ENODEV if no device found, or other -ve error value
>   */
> -int blk_find_device(int if_type, int devnum, struct udevice **devp);
> +int blk_find_device(int uclass_id, int devnum, struct udevice **devp);
>  
>  /**
>   * blk_get_device() - Find and probe a block device ready for use
>   *
> - * @if_type:	Interface type (enum uclass_id_t)
> + * @uclass_id:	Interface type (enum uclass_id_t)
>   * @devnum:	Device number (specific to each interface type)
>   * @devp:	the device, if found
>   * Return: 0 if found, -ENODEV if no device found, or other -ve error value
>   */
> -int blk_get_device(int if_type, int devnum, struct udevice **devp);
> +int blk_get_device(int uclass_id, int devnum, struct udevice **devp);
>  
>  /**
>   * blk_first_device() - Find the first device for a given interface
> @@ -305,7 +305,7 @@ int blk_get_device(int if_type, int devnum, struct udevice **devp);
>   * @devp:	the device, if found
>   * Return: 0 if found, -ENODEV if no device, or other -ve error value
>   */
> -int blk_first_device(int if_type, struct udevice **devp);
> +int blk_first_device(int uclass_id, struct udevice **devp);
>  
>  /**
>   * blk_next_device() - Find the next device for a given interface
> @@ -327,7 +327,7 @@ int blk_next_device(struct udevice **devp);
>   * @parent:	Parent of the new device
>   * @drv_name:	Driver name to use for the block device
>   * @name:	Name for the device
> - * @if_type:	Interface type (enum uclass_id_t)
> + * @uclass_id:	Interface type (enum uclass_id_t)
>   * @devnum:	Device number, specific to the interface type, or -1 to
>   *		allocate the next available number
>   * @blksz:	Block size of the device in bytes (typically 512)
> @@ -335,7 +335,7 @@ int blk_next_device(struct udevice **devp);
>   * @devp:	the new device (which has not been probed)
>   */
>  int blk_create_device(struct udevice *parent, const char *drv_name,
> -		      const char *name, int if_type, int devnum, int blksz,
> +		      const char *name, int uclass_id, int devnum, int blksz,
>  		      lbaint_t lba, struct udevice **devp);
>  
>  /**
> @@ -344,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>   * @parent:	Parent of the new device
>   * @drv_name:	Driver name to use for the block device
>   * @name:	Name for the device (parent name is prepended)
> - * @if_type:	Interface type (enum uclass_id_t)
> + * @uclass_id:	Interface type (enum uclass_id_t)
>   * @devnum:	Device number, specific to the interface type, or -1 to
>   *		allocate the next available number
>   * @blksz:	Block size of the device in bytes (typically 512)
> @@ -352,7 +352,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>   * @devp:	the new device (which has not been probed)
>   */
>  int blk_create_devicef(struct udevice *parent, const char *drv_name,
> -		       const char *name, int if_type, int devnum, int blksz,
> +		       const char *name, int uclass_id, int devnum, int blksz,
>  		       lbaint_t lba, struct udevice **devp);
>  
>  /**
> @@ -372,33 +372,33 @@ int blk_probe_or_unbind(struct udevice *dev);
>   *
>   * The devices are removed and then unbound.
>   *
> - * @if_type:	Interface type to unbind
> + * @uclass_id:	Interface type to unbind
>   * Return: 0 if OK, -ve on error
>   */
> -int blk_unbind_all(int if_type);
> +int blk_unbind_all(int uclass_id);
>  
>  /**
>   * blk_find_max_devnum() - find the maximum device number for an interface type
>   *
> - * Finds the last allocated device number for an interface type @if_type. The
> + * Finds the last allocated device number for an interface type @uclass_id. The
>   * next number is safe to use for a newly allocated device.
>   *
> - * @if_type:	Interface type to scan
> + * @uclass_id:	Interface type to scan
>   * Return: maximum device number found, or -ENODEV if none, or other -ve on
>   * error
>   */
> -int blk_find_max_devnum(enum uclass_id if_type);
> +int blk_find_max_devnum(enum uclass_id uclass_id);
>  
>  /**
>   * blk_next_free_devnum() - get the next device number for an interface type
>   *
>   * Finds the next number that is safe to use for a newly allocated device for
> - * an interface type @if_type.
> + * an interface type @uclass_id.
>   *
> - * @if_type:	Interface type to scan
> + * @uclass_id:	Interface type to scan
>   * Return: next device number safe to use, or -ve on error
>   */
> -int blk_next_free_devnum(enum uclass_id if_type);
> +int blk_next_free_devnum(enum uclass_id uclass_id);
>  
>  /**
>   * blk_select_hwpart() - select a hardware partition
> @@ -447,7 +447,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
>  			      lbaint_t blkcnt, void *buffer)
>  {
>  	ulong blks_read;
> -	if (blkcache_read(block_dev->if_type, block_dev->devnum,
> +	if (blkcache_read(block_dev->uclass_id, block_dev->devnum,
>  			  start, blkcnt, block_dev->blksz, buffer))
>  		return blkcnt;
>  
> @@ -458,7 +458,7 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
>  	 */
>  	blks_read = block_dev->block_read(block_dev, start, blkcnt, buffer);
>  	if (blks_read == blkcnt)
> -		blkcache_fill(block_dev->if_type, block_dev->devnum,
> +		blkcache_fill(block_dev->uclass_id, block_dev->devnum,
>  			      start, blkcnt, block_dev->blksz, buffer);
>  
>  	return blks_read;
> @@ -467,14 +467,14 @@ static inline ulong blk_dread(struct blk_desc *block_dev, lbaint_t start,
>  static inline ulong blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
>  			       lbaint_t blkcnt, const void *buffer)
>  {
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  	return block_dev->block_write(block_dev, start, blkcnt, buffer);
>  }
>  
>  static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
>  			       lbaint_t blkcnt)
>  {
> -	blkcache_invalidate(block_dev->if_type, block_dev->devnum);
> +	blkcache_invalidate(block_dev->uclass_id, block_dev->devnum);
>  	return block_dev->block_erase(block_dev, start, blkcnt);
>  }
>  
> @@ -485,15 +485,15 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
>   * driver should be provided using U_BOOT_LEGACY_BLK() for each interface
>   * type that is to be supported.
>   *
> - * @if_typename:	Interface type name
> - * @if_type:		Interface type
> + * @uclass_idname:	Interface type name
> + * @uclass_id:		Interface type
>   * @max_devs:		Maximum number of devices supported
>   * @desc:		Pointer to list of devices for this interface type,
>   *			or NULL to use @get_dev() instead
>   */
>  struct blk_driver {
> -	const char *if_typename;
> -	enum uclass_id if_type;
> +	const char *uclass_idname;
> +	enum uclass_id uclass_id;
>  	int max_devs;
>  	struct blk_desc *desc;
>  	/**
> @@ -540,7 +540,7 @@ struct blk_driver {
>  #define U_BOOT_LEGACY_BLK(__name)					\
>  	ll_entry_declare(struct blk_driver, __name, blk_driver)
>  
> -struct blk_driver *blk_driver_lookup_type(int if_type);
> +struct blk_driver *blk_driver_lookup_type(int uclass_id);
>  
>  #endif /* !CONFIG_BLK */
>  
> @@ -550,23 +550,23 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
>   * This looks through the available block devices of the given type, returning
>   * the one with the given @devnum.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * Return: point to block device descriptor, or NULL if not found
>   */
> -struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id uclass_id, int devnum);
>  
>  /**
>   * blk_get_devnum_by_type() - Get a block device by type name, and number
>   *
> - * This looks up the block device type based on @if_typename, then calls
> + * This looks up the block device type based on @uclass_idname, then calls
>   * blk_get_devnum_by_type().
>   *
> - * @if_typename:	Block device type name
> + * @uclass_idname:	Block device type name
>   * @devnum:		Device number
>   * Return: point to block device descriptor, or NULL if not found
>   */
> -struct blk_desc *blk_get_devnum_by_typename(const char *if_typename,
> +struct blk_desc *blk_get_devnum_by_typename(const char *uclass_idname,
>  					    int devnum);
>  
>  /**
> @@ -585,34 +585,34 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
>  /**
>   * blk_list_part() - list the partitions for block devices of a given type
>   *
> - * This looks up the partition type for each block device of type @if_type,
> + * This looks up the partition type for each block device of type @uclass_id,
>   * then displays a list of partitions.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * Return: 0 if OK, -ENODEV if there is none of that type
>   */
> -int blk_list_part(enum uclass_id if_type);
> +int blk_list_part(enum uclass_id uclass_id);
>  
>  /**
>   * blk_list_devices() - list the block devices of a given type
>   *
> - * This lists each block device of the type @if_type, showing the capacity
> + * This lists each block device of the type @uclass_id, showing the capacity
>   * as well as type-specific information.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   */
> -void blk_list_devices(enum uclass_id if_type);
> +void blk_list_devices(enum uclass_id uclass_id);
>  
>  /**
>   * blk_show_device() - show information about a given block device
>   *
>   * This shows the block device capacity as well as type-specific information.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * Return: 0 if OK, -ENODEV for invalid device number
>   */
> -int blk_show_device(enum uclass_id if_type, int devnum);
> +int blk_show_device(enum uclass_id uclass_id, int devnum);
>  
>  /**
>   * blk_print_device_num() - show information about a given block device
> @@ -620,45 +620,45 @@ int blk_show_device(enum uclass_id if_type, int devnum);
>   * This is similar to blk_show_device() but returns an error if the block
>   * device type is unknown.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
>   * device is not connected
>   */
> -int blk_print_device_num(enum uclass_id if_type, int devnum);
> +int blk_print_device_num(enum uclass_id uclass_id, int devnum);
>  
>  /**
>   * blk_print_part_devnum() - print the partition information for a device
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
>   * the interface type is not supported, other -ve on other error
>   */
> -int blk_print_part_devnum(enum uclass_id if_type, int devnum);
> +int blk_print_part_devnum(enum uclass_id uclass_id, int devnum);
>  
>  /**
>   * blk_read_devnum() - read blocks from a device
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * @blkcnt:	Number of blocks to read
>   * @buffer:	Address to write data to
>   * Return: number of blocks read, or -ve error number on error
>   */
> -ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_read_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		      lbaint_t blkcnt, void *buffer);
>  
>  /**
>   * blk_write_devnum() - write blocks to a device
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * @blkcnt:	Number of blocks to write
>   * @buffer:	Address to read data from
>   * Return: number of blocks written, or -ve error number on error
>   */
> -ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> +ulong blk_write_devnum(enum uclass_id uclass_id, int devnum, lbaint_t start,
>  		       lbaint_t blkcnt, const void *buffer);
>  
>  /**
> @@ -667,31 +667,31 @@ ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>   * This is similar to blk_dselect_hwpart() but it looks up the interface and
>   * device number.
>   *
> - * @if_type:	Block device type
> + * @uclass_id:	Block device type
>   * @devnum:	Device number
>   * @hwpart:	Partition number to select
>   * Return: 0 if OK, -ve on error
>   */
> -int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
> +int blk_select_hwpart_devnum(enum uclass_id uclass_id, int devnum, int hwpart);
>  
>  /**
> - * blk_get_if_type_name() - Get the name of an interface type
> + * blk_get_uclass_name() - Get the name of an interface type
>   *
> - * @if_type: Interface type to check
> + * @uclass_id: Interface type to check
>   * Return: name of interface, or NULL if none
>   */
> -const char *blk_get_if_type_name(enum uclass_id if_type);
> +const char *blk_get_uclass_name(enum uclass_id uclass_id);
>  
>  /**
>   * blk_common_cmd() - handle common commands with block devices
>   *
>   * @args: Number of arguments to the command (argv[0] is the command itself)
>   * @argv: Command arguments
> - * @if_type: Interface type
> + * @uclass_id: Interface type
>   * @cur_devnump: Current device number for this interface type
>   * Return: 0 if OK, CMD_RET_ERROR on error
>   */
> -int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
>  		   int *cur_devnump);
>  
>  enum blk_flag_t {
> diff --git a/include/efi_api.h b/include/efi_api.h
> index 83c01085fde..f9c9aa64b24 100644
> --- a/include/efi_api.h
> +++ b/include/efi_api.h
> @@ -622,7 +622,7 @@ struct efi_device_path_sata {
>  struct efi_device_path_mac_addr {
>  	struct efi_device_path dp;
>  	struct efi_mac_addr mac;
> -	u8 if_type;
> +	u8 uclass_id;

The field is coincidentally named "if_type", but it has nothing to do
with U-Boot's driver model. It is defined in UEFI specification.
Please keep it unchanged.

>  } __packed;
>  
>  struct efi_device_path_usb_class {
> @@ -1410,7 +1410,7 @@ struct efi_simple_network_mode {
>  	struct efi_mac_address current_address;
>  	struct efi_mac_address broadcast_address;
>  	struct efi_mac_address permanent_address;
> -	u8 if_type;
> +	u8 uclass_id;

ditto

>  	u8 mac_changeable;
>  	u8 multitx_supported;
>  	u8 media_present_supported;
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index ae58efb0036..aab128a6dda 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
>  
>  /* EFI system partition */
>  extern struct efi_system_partition {
> -	enum uclass_id if_type;
> +	enum uclass_id uclass_id;
>  	int devnum;
>  	u8 part;
>  } efi_system_partition;
> @@ -545,7 +545,7 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
>  				   struct efi_loaded_image *loaded_image_info);
>  /* Create handles and protocols for the partitions of a block device */
>  int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
> -			       const char *if_typename, int diskid,
> +			       const char *uclass_idname, int diskid,
>  			       const char *pdevname);
>  /* Called by bootefi to make GOP (graphical) interface available */
>  efi_status_t efi_gop_register(void);
> diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
> index ebffb771228..9787033c3df 100644
> --- a/lib/efi_loader/efi_device_path.c
> +++ b/lib/efi_loader/efi_device_path.c
> @@ -626,7 +626,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
>  		/* We only support IPv4 */
>  		memcpy(&dp->mac, &pdata->enetaddr, ARP_HLEN);
>  		/* Ethernet */
> -		dp->if_type = 1;
> +		dp->uclass_id = 1;

ditto

>  		return &dp[1];
>  	}
>  #endif
> diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c
> index 4d73954ef89..aef18483c3a 100644
> --- a/lib/efi_loader/efi_device_path_to_text.c
> +++ b/lib/efi_loader/efi_device_path_to_text.c
> @@ -156,12 +156,12 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
>  		struct efi_device_path_mac_addr *mdp =
>  			(struct efi_device_path_mac_addr *)dp;
>  
> -		if (mdp->if_type <= 1)
> +		if (mdp->uclass_id <= 1)
>  			n = 6;
>  		s += sprintf(s, "MAC(");
>  		for (i = 0; i < n; ++i)
>  			s += sprintf(s, "%02x", mdp->mac.addr[i]);
> -		s += sprintf(s, ",%u)", mdp->if_type);
> +		s += sprintf(s, ",%u)", mdp->uclass_id);

ditto

>  
>  		break;
>  	}
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index ad543bc117e..83126f55ea1 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -379,7 +379,7 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
>   *
>   * @parent:		parent handle
>   * @dp_parent:		parent device path
> - * @if_typename:	interface name for block device
> + * @uclass_idname:	interface name for block device

I don't think that "interface name" is an appropriate word now.

>   * @desc:		internal block device
>   * @dev_index:		device index for block device
>   * @part_info:		partition info
> @@ -390,7 +390,7 @@ static int efi_fs_exists(struct blk_desc *desc, int part)
>  static efi_status_t efi_disk_add_dev(
>  				efi_handle_t parent,
>  				struct efi_device_path *dp_parent,
> -				const char *if_typename,
> +				const char *uclass_idname,
>  				struct blk_desc *desc,
>  				int dev_index,
>  				struct disk_partition *part_info,
> @@ -502,13 +502,13 @@ static efi_status_t efi_disk_add_dev(
>  		  diskobj->media.last_block);
>  
>  	/* Store first EFI system partition */
> -	if (part && !efi_system_partition.if_type) {
> +	if (part && !efi_system_partition.uclass_id) {
>  		if (part_info->bootable & PART_EFI_SYSTEM_PARTITION) {
> -			efi_system_partition.if_type = desc->if_type;
> +			efi_system_partition.uclass_id = desc->uclass_id;
>  			efi_system_partition.devnum = desc->devnum;
>  			efi_system_partition.part = part;
>  			EFI_PRINT("EFI system partition: %s %x:%x\n",
> -				  blk_get_if_type_name(desc->if_type),
> +				  blk_get_uclass_name(desc->uclass_id),
>  				  desc->devnum, part);
>  		}
>  	}
> @@ -532,15 +532,15 @@ static int efi_disk_create_raw(struct udevice *dev)
>  {
>  	struct efi_disk_obj *disk;
>  	struct blk_desc *desc;
> -	const char *if_typename;
> +	const char *uclass_idname;

The commit ab31c8a15871 made this variable gone.

>  	int diskid;
>  	efi_status_t ret;
>  
>  	desc = dev_get_uclass_plat(dev);
> -	if_typename = blk_get_if_type_name(desc->if_type);
> +	uclass_idname = blk_get_uclass_name(desc->uclass_id);

ditto

>  	diskid = desc->devnum;
>  
> -	ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
> +	ret = efi_disk_add_dev(NULL, NULL, uclass_idname, desc,

ditto

>  			       diskid, NULL, 0, &disk);
>  	if (ret != EFI_SUCCESS) {
>  		if (ret == EFI_NOT_READY)
> @@ -575,7 +575,7 @@ static int efi_disk_create_part(struct udevice *dev)
>  {
>  	efi_handle_t parent;
>  	struct blk_desc *desc;
> -	const char *if_typename;
> +	const char *uclass_idname;

ditto

>  	struct disk_part *part_data;
>  	struct disk_partition *info;
>  	unsigned int part;
> @@ -589,7 +589,7 @@ static int efi_disk_create_part(struct udevice *dev)
>  		return -1;
>  
>  	desc = dev_get_uclass_plat(dev_get_parent(dev));
> -	if_typename = blk_get_if_type_name(desc->if_type);
> +	uclass_idname = blk_get_uclass_name(desc->uclass_id);

ditto

>  	diskid = desc->devnum;
>  
>  	part_data = dev_get_uclass_plat(dev);
> @@ -601,7 +601,7 @@ static int efi_disk_create_part(struct udevice *dev)
>  		return -1;
>  	dp_parent = (struct efi_device_path *)handler->protocol_interface;
>  
> -	ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid,
> +	ret = efi_disk_add_dev(parent, dp_parent, uclass_idname, desc, diskid,
>  			       info, part, &disk);

ditto

>  	if (ret != EFI_SUCCESS) {
>  		log_err("Adding partition for %s failed\n", dev->name);
> @@ -650,7 +650,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 != UCLASS_EFI_LOADER) {
> +	if (desc->uclass_id != UCLASS_EFI_LOADER) {
>  		ret = efi_disk_create_raw(dev);
>  		if (ret)
>  			return -1;
> @@ -685,7 +685,7 @@ static int efi_disk_delete_raw(struct udevice *dev)
>  		return -1;
>  
>  	desc = dev_get_uclass_plat(dev);
> -	if (desc->if_type != UCLASS_EFI_LOADER) {
> +	if (desc->uclass_id != UCLASS_EFI_LOADER) {
>  		diskobj = container_of(handle, struct efi_disk_obj, header);
>  		efi_free_pool(diskobj->dp);
>  	}
> diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c
> index 69276b275d9..0cdc1ff5381 100644
> --- a/lib/efi_loader/efi_net.c
> +++ b/lib/efi_loader/efi_net.c
> @@ -924,7 +924,7 @@ efi_status_t efi_net_register(void)
>  	netobj->net_mode.hwaddr_size = ARP_HLEN;
>  	netobj->net_mode.media_header_size = ETHER_HDR_SIZE;
>  	netobj->net_mode.max_packet_size = PKTSIZE;
> -	netobj->net_mode.if_type = ARP_ETHER;
> +	netobj->net_mode.uclass_id = ARP_ETHER;

ditto

-Takahiro Akashi

>  
>  	netobj->pxe.revision = EFI_PXE_BASE_CODE_PROTOCOL_REVISION;
>  	netobj->pxe.start = efi_pxe_base_code_start;
> diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
> index 994e66392fb..3d58caa13da 100644
> --- a/lib/efi_loader/efi_var_file.c
> +++ b/lib/efi_loader/efi_var_file.c
> @@ -38,13 +38,13 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
>  	char part_str[PART_STR_LEN];
>  	int r;
>  
> -	if (efi_system_partition.if_type == UCLASS_INVALID) {
> +	if (efi_system_partition.uclass_id == UCLASS_INVALID) {
>  		log_err("No EFI system partition\n");
>  		return EFI_DEVICE_ERROR;
>  	}
>  	snprintf(part_str, PART_STR_LEN, "%x:%x",
>  		 efi_system_partition.devnum, efi_system_partition.part);
> -	r = fs_set_blk_dev(blk_get_if_type_name(efi_system_partition.if_type),
> +	r = fs_set_blk_dev(blk_get_uclass_name(efi_system_partition.uclass_id),
>  			   part_str, FS_TYPE_ANY);
>  	if (r) {
>  		log_err("Cannot read EFI system partition\n");
> -- 
> 2.37.1.595.g718a3a8f04-goog
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE
  2022-08-12  1:34 ` [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE Simon Glass
@ 2022-09-14  1:42   ` AKASHI Takahiro
  2022-09-14  7:34     ` Heinrich Schuchardt
  0 siblings, 1 reply; 42+ messages in thread
From: AKASHI Takahiro @ 2022-09-14  1:42 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Tom Rini, Heinrich Schuchardt,
	Alexander Graf, Alexandru Gagniuc, Alexey Brodkin,
	Alper Nebi Yasak, Anastasiia Lukianenko, Andrew Davis,
	Andrew Scull, Bin Meng, Heiko Schocher, Ilias Apalodimas,
	Jaehoon Chung, Mark Kettenis, Masahisa Kojima, Michal Simek,
	Oleksandr Andrushchenko, Pali Roh??r, Peng Fan, Philippe Reynes,
	Stefan Roese, Wolfgang Denk, Ye Li

On Thu, Aug 11, 2022 at 07:34:48PM -0600, Simon Glass wrote:
> This option is fact really related to SPL. For U-Boot proper we always use
> driver model for block devices, so CONFIG_BLK is enabled if block devices
> are in use.
> 
> It is only for SPL that we have two cases:
> 
> - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
> - SPL_BLK is not enabled, in which case (if we need block devices) we must
>   use blk_legacy.c
> 
> Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
> different enough from BLK and SPL_BLK that there should be no confusion.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> (no changes since v1)
> 
>  common/spl/Kconfig                             | 4 ++--
>  configs/axm_defconfig                          | 2 +-
>  configs/bcm968380gerg_ram_defconfig            | 2 +-
>  configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
>  configs/nsim_hs38_defconfig                    | 2 +-
>  configs/qemu-ppce500_defconfig                 | 2 +-
>  disk/Makefile                                  | 4 ++--
>  disk/disk-uclass.c                             | 3 +--
>  doc/develop/driver-model/migration.rst         | 2 +-
>  drivers/Makefile                               | 2 +-
>  drivers/ata/Kconfig                            | 2 +-
>  drivers/block/Kconfig                          | 8 ++++----
>  drivers/block/Makefile                         | 2 +-
>  drivers/mmc/Kconfig                            | 2 +-
>  drivers/nvme/Kconfig                           | 2 +-
>  drivers/scsi/Kconfig                           | 2 +-
>  drivers/xen/Kconfig                            | 2 +-
>  include/blk.h                                  | 2 +-
>  lib/efi_loader/Kconfig                         | 2 +-
>  19 files changed, 24 insertions(+), 25 deletions(-)
> 
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index ee98810e9e9..4c3e74ae5eb 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
>  config SPL_MMC
>  	bool "Support MMC"
>  	depends on MMC
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  Enable support for MMC (Multimedia Card) within SPL. This enables
>  	  the MMC protocol implementation and allows any enabled drivers to
> @@ -1318,7 +1318,7 @@ config SPL_THERMAL
>  
>  config SPL_USB_HOST
>  	bool "Support USB host drivers"
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  Enable access to USB (Universal Serial Bus) host devices so that
>  	  SPL can load U-Boot from a connected USB peripheral, such as a USB
> diff --git a/configs/axm_defconfig b/configs/axm_defconfig
> index a5f60bd8d0c..c42fb37d6c9 100644
> --- a/configs/axm_defconfig
> +++ b/configs/axm_defconfig
> @@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_SPL_DM=y
>  CONFIG_BLK=y
> -CONFIG_HAVE_BLOCK_DEVICE=y
> +CONFIG_SPL_LEGACY_BLOCK=y
>  CONFIG_CLK=y
>  CONFIG_CLK_AT91=y
>  CONFIG_AT91_GPIO=y
> diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
> index 0475535e991..246add6029c 100644
> --- a/configs/bcm968380gerg_ram_defconfig
> +++ b/configs/bcm968380gerg_ram_defconfig
> @@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
>  CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  # CONFIG_NET is not set
>  # CONFIG_DM_DEVICE_REMOVE is not set
> -CONFIG_HAVE_BLOCK_DEVICE=y
> +CONFIG_SPL_LEGACY_BLOCK=y
>  CONFIG_BCM6345_GPIO=y
>  CONFIG_LED=y
>  CONFIG_LED_BCM6328=y
> diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
> index b9ee281be9f..fdfab14d53e 100644
> --- a/configs/gardena-smart-gateway-mt7688_defconfig
> +++ b/configs/gardena-smart-gateway-mt7688_defconfig
> @@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
>  CONFIG_NET_RANDOM_ETHADDR=y
>  CONFIG_SPL_DM=y
>  # CONFIG_DM_DEVICE_REMOVE is not set
> -CONFIG_HAVE_BLOCK_DEVICE=y
> +CONFIG_SPL_LEGACY_BLOCK=y
>  CONFIG_BOOTCOUNT_LIMIT=y
>  CONFIG_LED=y
>  CONFIG_LED_BLINK=y
> diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
> index 3c3d1812a79..3f23fc4189f 100644
> --- a/configs/nsim_hs38_defconfig
> +++ b/configs/nsim_hs38_defconfig
> @@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>  CONFIG_USE_BOOTFILE=y
>  CONFIG_BOOTFILE="uImage"
>  CONFIG_BLK=y
> -CONFIG_HAVE_BLOCK_DEVICE=y
> +CONFIG_SPL_LEGACY_BLOCK=y
>  CONFIG_DM_ETH=y
>  CONFIG_DM_SERIAL=y
>  CONFIG_DEBUG_UART_SHIFT=2
> diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
> index 034f7e6935b..3241f5520eb 100644
> --- a/configs/qemu-ppce500_defconfig
> +++ b/configs/qemu-ppce500_defconfig
> @@ -40,7 +40,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
>  CONFIG_DM=y
>  CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
>  CONFIG_BLK=y
> -CONFIG_HAVE_BLOCK_DEVICE=y
> +CONFIG_SPL_LEGACY_BLOCK=y
>  CONFIG_LBA48=y
>  CONFIG_CHIP_SELECTS_PER_CTRL=0
>  CONFIG_MPC8XXX_GPIO=y
> diff --git a/disk/Makefile b/disk/Makefile
> index 458e21e3fb7..45588cf66e4 100644
> --- a/disk/Makefile
> +++ b/disk/Makefile
> @@ -10,8 +10,8 @@ ifdef CONFIG_$(SPL_TPL_)BLK
>  obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
>  endif
>  
> -# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
> -ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
> +# Must have BLK or SPL_LEGACY_BLOCK to support partitions
> +ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_SPL_LEGACY_BLOCK),)
>  obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
>  obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
>  obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
> diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
> index f3fb942a6b9..9351a5cfa68 100644
> --- a/disk/disk-uclass.c
> +++ b/disk/disk-uclass.c
> @@ -27,8 +27,7 @@ int part_create_block_devices(struct udevice *blk_dev)
>  	struct udevice *dev;
>  	int ret;
>  
> -	if (!CONFIG_IS_ENABLED(PARTITIONS) ||
> -	    !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
> +	if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
>  		return 0;
>  
>  	if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
> diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst
> index 5a604369258..742fea5515c 100644
> --- a/doc/develop/driver-model/migration.rst
> +++ b/doc/develop/driver-model/migration.rst
> @@ -57,7 +57,7 @@ In concert with maintainers migrating their block device usage to the
>  appropriate DM driver, CONFIG_BLK needs to be set as well.  The final deadline
>  here coincides with the final deadline for migration of the various block
>  subsystems.  At this point we will be able to audit and correct the logic in
> -Kconfig around using CONFIG_PARTITIONS and CONFIG_HAVE_BLOCK_DEVICE and make
> +Kconfig around using CONFIG_PARTITIONS and CONFIG_SPL_LEGACY_BLOCK and make
>  use of CONFIG_BLK / CONFIG_SPL_BLK as needed.
>  
>  CONFIG_DM_SPI / CONFIG_DM_SPI_FLASH
> diff --git a/drivers/Makefile b/drivers/Makefile
> index f2154e15d6a..9d9f69a3c9a 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -59,7 +59,7 @@ obj-$(CONFIG_SPL_WATCHDOG) += watchdog/
>  obj-$(CONFIG_SPL_USB_HOST) += usb/host/
>  obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
>  obj-$(CONFIG_SPL_SATA) += ata/ scsi/
> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
>  obj-$(CONFIG_SPL_BLK) += block/
>  obj-$(CONFIG_SPL_THERMAL) += thermal/
>  
> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> index 70e6bd321a6..c3f2ac058a3 100644
> --- a/drivers/ata/Kconfig
> +++ b/drivers/ata/Kconfig
> @@ -9,7 +9,7 @@ config AHCI
>  
>  config SATA
>  	bool "Support SATA controllers"
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  This enables support for SATA (Serial Advanced Technology
>  	  Attachment), a serial bus standard for connecting to hard drives and
> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> index df242df9c5f..5a0c434058a 100644
> --- a/drivers/block/Kconfig
> +++ b/drivers/block/Kconfig
> @@ -11,7 +11,7 @@ config BLK
>  	  be partitioned into several areas, called 'partitions' in U-Boot.
>  	  A filesystem can be placed in each partition.
>  
> -config HAVE_BLOCK_DEVICE
> +config SPL_LEGACY_BLOCK
>  	bool "Enable Legacy Block Device"
>  	help
>  	  Some devices require block support whether or not DM is enabled
> @@ -109,7 +109,7 @@ endif  # EFI_MEDIA
>  
>  config IDE
>  	bool "Support IDE controllers"
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  Enables support for IDE (Integrated Drive Electronics) hard drives.
>  	  This allows access to raw blocks and filesystems on an IDE drive
> @@ -222,7 +222,7 @@ endif  # IDE
>  
>  config LBA48
>  	bool "Enable LBA support for disks larger than 137GB"
> -	depends on HAVE_BLOCK_DEVICE
> +	depends on SPL_LEGACY_BLOCK
>  	help
>  	  Set this to enable support for disks larger than 137GB.
>  	  Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
> @@ -231,7 +231,7 @@ config LBA48
>  
>  config SYS_64BIT_LBA
>  	bool "Enable 64bit number of blocks on a block device"
> -	depends on HAVE_BLOCK_DEVICE
> +	depends on SPL_LEGACY_BLOCK
>  	help
>  	  Make the block subsystem use 64bit sector addresses, rather than the
>  	  default of 32bit.
> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
> index b221a7c6eea..f48d3e12140 100644
> --- a/drivers/block/Makefile
> +++ b/drivers/block/Makefile
> @@ -6,7 +6,7 @@
>  obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
>  
>  ifndef CONFIG_$(SPL_)BLK
> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_legacy.o
> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += blk_legacy.o
>  endif
>  
>  ifndef CONFIG_SPL_BUILD
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index c5e1a1b0981..d45ad1a541d 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -3,7 +3,7 @@ menu "MMC Host controller Support"
>  config MMC
>  	bool "MMC/SD/SDIO card support"
>  	default ARM || PPC || SANDBOX
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	select DM_MMC if DM
>  	help
>  	  This selects MultiMediaCard, Secure Digital and Secure
> diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
> index 2a103ab5ed7..7b6d54615f8 100644
> --- a/drivers/nvme/Kconfig
> +++ b/drivers/nvme/Kconfig
> @@ -4,7 +4,7 @@
>  
>  config NVME
>  	bool "NVM Express device support"
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  This option enables support for NVM Express devices.
>  	  It supports basic functions of NVMe (read/write).
> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> index 19872fb52d8..4d643816fcc 100644
> --- a/drivers/scsi/Kconfig
> +++ b/drivers/scsi/Kconfig
> @@ -1,6 +1,6 @@
>  config SCSI
>  	bool "Support SCSI controllers"
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  This enables support for SCSI (Small Computer System Interface),
>  	  a parallel interface widely used with storage peripherals such as
> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> index 6ad2a936682..20db2c53065 100644
> --- a/drivers/xen/Kconfig
> +++ b/drivers/xen/Kconfig
> @@ -2,7 +2,7 @@ config PVBLOCK
>  	bool "Xen para-virtualized block device"
>  	depends on DM
>  	select BLK
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK
>  	help
>  	  This driver implements the front-end of the Xen virtual
>  	  block device driver. It communicates with a back-end driver
> diff --git a/include/blk.h b/include/blk.h
> index 332481a90b8..5bdffe74015 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -23,7 +23,7 @@ struct udevice;
>  
>  static inline bool blk_enabled(void)
>  {
> -	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE);
> +	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
>  }
>  
>  /* Interface types: */
> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> index e3f2402d0e8..5feafc16820 100644
> --- a/lib/efi_loader/Kconfig
> +++ b/lib/efi_loader/Kconfig
> @@ -20,7 +20,7 @@ config EFI_LOADER
>  	select EVENT_DYNAMIC
>  	select LIB_UUID
>  	imply PARTITION_UUIDS
> -	select HAVE_BLOCK_DEVICE
> +	select SPL_LEGACY_BLOCK

I don't think we need this "select" as efi_disk implementation
now fully relies on U-Boot dm.
(Kconfig has "depends on BLK".)

-Takahiro Akashi


>  	select REGEX
>  	imply FAT
>  	imply FAT_WRITE
> -- 
> 2.37.1.595.g718a3a8f04-goog
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 22/24] blk: Drop if_type
  2022-09-13 16:27   ` Heinrich Schuchardt
@ 2022-09-14  2:08     ` AKASHI Takahiro
  2022-09-14  7:45       ` Heinrich Schuchardt
  2022-09-14 17:10     ` Simon Glass
  1 sibling, 1 reply; 42+ messages in thread
From: AKASHI Takahiro @ 2022-09-14  2:08 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Simon Glass, Tom Rini, Ilias Apalodimas, Masahisa Kojima,
	U-Boot Mailing List

On Tue, Sep 13, 2022 at 06:27:37PM +0200, Heinrich Schuchardt wrote:
> On 8/12/22 03:35, Simon Glass wrote:
> > Use the uclass ID instead.
> > 
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> > 
> > (no changes since v1)
> > 
> >   cmd/blk_common.c           |  2 +-
> >   drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
> >   drivers/block/blk_legacy.c | 20 +++++++++----------
> >   include/blk.h              | 41 ++++++++++++++++++--------------------
> >   include/efi_loader.h       |  2 +-
> >   5 files changed, 48 insertions(+), 51 deletions(-)
> > 
> > diff --git a/cmd/blk_common.c b/cmd/blk_common.c
> > index 4e442f2918b..369c5ae4bbe 100644
> > --- a/cmd/blk_common.c
> > +++ b/cmd/blk_common.c
> > @@ -12,7 +12,7 @@
> >   #include <blk.h>
> >   #include <command.h>
> > 
> > -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> > +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> >   		   int *cur_devnump)
> >   {
> >   	const char *if_name = blk_get_if_type_name(if_type);
> > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> > index 436af764f91..a9a85aa37f3 100644
> > --- a/drivers/block/blk-uclass.c
> > +++ b/drivers/block/blk-uclass.c
> > @@ -34,7 +34,7 @@ static struct {
> >   	{ UCLASS_PVBLOCK, "pvblock" },
> >   };
> > 
> > -static enum if_type if_typename_to_iftype(const char *if_typename)
> > +static enum uclass_id if_typename_to_iftype(const char *if_typename)
> >   {
> >   	int i;
> > 
> > @@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
> >   	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 uclass_id if_type)
> >   {
> >   	/*
> >   	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
> > @@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
> >   	return if_type;
> >   }
> > 
> > -const char *blk_get_if_type_name(enum if_type if_type)
> > +const char *blk_get_if_type_name(enum uclass_id if_type)
> >   {
> >   	int i;
> > 
> > @@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
> >   	return "(none)";
> >   }
> > 
> > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_desc *desc;
> >   	struct udevice *dev;
> > @@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> >   struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> >   {
> >   	enum uclass_id uclass_id;
> > -	enum if_type type;
> > +	enum uclass_id type;
> >   	struct udevice *dev;
> >   	struct uclass *uc;
> >   	int ret;
> > @@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
> >    * with a higher device number, -ENOENT if there is no such device but there
> >    * is one with a higher number, or other -ve on other error.
> >    */
> > -static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
> > +static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
> >   {
> >   	bool found_more = false;
> >   	struct udevice *dev;
> > @@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
> >   	return found_more ? -ENOENT : -ENODEV;
> >   }
> > 
> > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> >   {
> >   	struct udevice *dev;
> >   	int ret;
> > @@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> >   	return blk_select_hwpart(dev, hwpart);
> >   }
> > 
> > -int blk_list_part(enum if_type if_type)
> > +int blk_list_part(enum uclass_id if_type)
> >   {
> >   	struct blk_desc *desc;
> >   	int devnum, ok;
> > @@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
> >   	return 0;
> >   }
> > 
> > -int blk_print_part_devnum(enum if_type if_type, int devnum)
> > +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_desc *desc;
> >   	int ret;
> > @@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -void blk_list_devices(enum if_type if_type)
> > +void blk_list_devices(enum uclass_id if_type)
> >   {
> >   	struct blk_desc *desc;
> >   	int ret;
> > @@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
> >   	}
> >   }
> > 
> > -int blk_print_device_num(enum if_type if_type, int devnum)
> > +int blk_print_device_num(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_desc *desc;
> >   	int ret;
> > @@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -int blk_show_device(enum if_type if_type, int devnum)
> > +int blk_show_device(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_desc *desc;
> >   	int ret;
> > @@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		      lbaint_t blkcnt, void *buffer)
> >   {
> >   	struct blk_desc *desc;
> > @@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> >   	return n;
> >   }
> > 
> > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		       lbaint_t blkcnt, const void *buffer)
> >   {
> >   	struct blk_desc *desc;
> > @@ -525,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
> >   	return uclass_get_name(device_get_uclass_id(parent));
> >   };
> > 
> > -int blk_find_max_devnum(enum if_type if_type)
> > +int blk_find_max_devnum(enum uclass_id if_type)
> >   {
> >   	struct udevice *dev;
> >   	int max_devnum = -ENODEV;
> > @@ -545,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
> >   	return max_devnum;
> >   }
> > 
> > -int blk_next_free_devnum(enum if_type if_type)
> > +int blk_next_free_devnum(enum uclass_id if_type)
> >   {
> >   	int ret;
> > 
> > @@ -631,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
> >   	return count;
> >   }
> > 
> > -static int blk_claim_devnum(enum if_type if_type, int devnum)
> > +static int blk_claim_devnum(enum uclass_id if_type, int devnum)
> >   {
> >   	struct udevice *dev;
> >   	struct uclass *uc;
> > diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
> > index bd8a17df6a9..8c6f9cb208e 100644
> > --- a/drivers/block/blk_legacy.c
> > +++ b/drivers/block/blk_legacy.c
> > @@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
> >   	return NULL;
> >   }
> > 
> > -const char *blk_get_if_type_name(enum if_type if_type)
> > +const char *blk_get_if_type_name(enum uclass_id if_type)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > 
> > @@ -70,7 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
> >   	return drv->get_dev(devnum, descp);
> >   }
> > 
> > -int blk_list_part(enum if_type if_type)
> > +int blk_list_part(enum uclass_id if_type)
> >   {
> >   	struct blk_driver *drv;
> >   	struct blk_desc *desc;
> > @@ -97,7 +97,7 @@ int blk_list_part(enum if_type if_type)
> >   	return 0;
> >   }
> > 
> > -int blk_print_part_devnum(enum if_type if_type, int devnum)
> > +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > @@ -115,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -void blk_list_devices(enum if_type if_type)
> > +void blk_list_devices(enum uclass_id if_type)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > @@ -133,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
> >   	}
> >   }
> > 
> > -int blk_print_device_num(enum if_type if_type, int devnum)
> > +int blk_print_device_num(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > @@ -150,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -int blk_show_device(enum if_type if_type, int devnum)
> > +int blk_show_device(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > @@ -174,7 +174,7 @@ int blk_show_device(enum if_type if_type, int devnum)
> >   	return 0;
> >   }
> > 
> > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > @@ -214,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> >   	return desc;
> >   }
> > 
> > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		      lbaint_t blkcnt, void *buffer)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > @@ -234,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> >   	return n;
> >   }
> > 
> > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		       lbaint_t blkcnt, const void *buffer)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > @@ -249,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> >   	return desc->block_write(desc, start, blkcnt, buffer);
> >   }
> > 
> > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> >   {
> >   	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> >   	struct blk_desc *desc;
> > diff --git a/include/blk.h b/include/blk.h
> > index 548cd09d6bb..279f9ea4a9d 100644
> > --- a/include/blk.h
> > +++ b/include/blk.h
> > @@ -27,9 +27,6 @@ static inline bool blk_enabled(void)
> >   	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
> >   }
> > 
> > -/* Interface types: */
> > -#define if_type uclass_id
> > -
> >   #define BLK_VEN_SIZE		40
> >   #define BLK_PRD_SIZE		20
> >   #define BLK_REV_SIZE		8
> > @@ -57,7 +54,7 @@ struct blk_desc {
> >   	 * TODO: With driver model we should be able to use the parent
> >   	 * device's uclass instead.
> >   	 */
> > -	enum if_type	if_type;	/* type of the interface */
> > +	enum uclass_id	if_type;	/* type of the interface */
> >   	int		devnum;		/* device number */
> >   	unsigned char	part_type;	/* partition type */
> >   	unsigned char	target;		/* target SCSI ID */
> > @@ -282,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
> >    * This function does not activate the device. The device will be returned
> >    * whether or not it is activated.
> >    *
> > - * @if_type:	Interface type (enum if_type_t)
> > + * @if_type:	Interface type (enum uclass_id_t)
> >    * @devnum:	Device number (specific to each interface type)
> >    * @devp:	the device, if found
> >    * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> > @@ -292,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
> >   /**
> >    * blk_get_device() - Find and probe a block device ready for use
> >    *
> > - * @if_type:	Interface type (enum if_type_t)
> > + * @if_type:	Interface type (enum uclass_id_t)
> >    * @devnum:	Device number (specific to each interface type)
> >    * @devp:	the device, if found
> >    * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> > @@ -330,7 +327,7 @@ int blk_next_device(struct udevice **devp);
> >    * @parent:	Parent of the new device
> >    * @drv_name:	Driver name to use for the block device
> >    * @name:	Name for the device
> > - * @if_type:	Interface type (enum if_type_t)
> > + * @if_type:	Interface type (enum uclass_id_t)
> >    * @devnum:	Device number, specific to the interface type, or -1 to
> >    *		allocate the next available number
> >    * @blksz:	Block size of the device in bytes (typically 512)
> > @@ -347,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
> >    * @parent:	Parent of the new device
> >    * @drv_name:	Driver name to use for the block device
> >    * @name:	Name for the device (parent name is prepended)
> > - * @if_type:	Interface type (enum if_type_t)
> > + * @if_type:	Interface type (enum uclass_id_t)
> >    * @devnum:	Device number, specific to the interface type, or -1 to
> >    *		allocate the next available number
> >    * @blksz:	Block size of the device in bytes (typically 512)
> > @@ -390,7 +387,7 @@ int blk_unbind_all(int if_type);
> >    * Return: maximum device number found, or -ENODEV if none, or other -ve on
> >    * error
> >    */
> > -int blk_find_max_devnum(enum if_type if_type);
> > +int blk_find_max_devnum(enum uclass_id if_type);
> > 
> >   /**
> >    * blk_next_free_devnum() - get the next device number for an interface type
> > @@ -401,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
> >    * @if_type:	Interface type to scan
> >    * Return: next device number safe to use, or -ve on error
> >    */
> > -int blk_next_free_devnum(enum if_type if_type);
> > +int blk_next_free_devnum(enum uclass_id if_type);
> > 
> >   /**
> >    * blk_select_hwpart() - select a hardware partition
> > @@ -496,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
> >    */
> >   struct blk_driver {
> >   	const char *if_typename;
> > -	enum if_type if_type;
> > +	enum uclass_id if_type;
> >   	int max_devs;
> >   	struct blk_desc *desc;
> >   	/**
> > @@ -557,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
> >    * @devnum:	Device number
> >    * Return: point to block device descriptor, or NULL if not found
> >    */
> > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
> > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
> > 
> >   /**
> >    * blk_get_devnum_by_type() - Get a block device by type name, and number
> > @@ -594,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
> >    * @if_type:	Block device type
> >    * Return: 0 if OK, -ENODEV if there is none of that type
> >    */
> > -int blk_list_part(enum if_type if_type);
> > +int blk_list_part(enum uclass_id if_type);
> > 
> >   /**
> >    * blk_list_devices() - list the block devices of a given type
> > @@ -604,7 +601,7 @@ int blk_list_part(enum if_type if_type);
> >    *
> >    * @if_type:	Block device type
> >    */
> > -void blk_list_devices(enum if_type if_type);
> > +void blk_list_devices(enum uclass_id if_type);
> > 
> >   /**
> >    * blk_show_device() - show information about a given block device
> > @@ -615,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
> >    * @devnum:	Device number
> >    * Return: 0 if OK, -ENODEV for invalid device number
> >    */
> > -int blk_show_device(enum if_type if_type, int devnum);
> > +int blk_show_device(enum uclass_id if_type, int devnum);
> > 
> >   /**
> >    * blk_print_device_num() - show information about a given block device
> > @@ -628,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
> >    * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
> >    * device is not connected
> >    */
> > -int blk_print_device_num(enum if_type if_type, int devnum);
> > +int blk_print_device_num(enum uclass_id if_type, int devnum);
> > 
> >   /**
> >    * blk_print_part_devnum() - print the partition information for a device
> > @@ -638,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
> >    * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
> >    * the interface type is not supported, other -ve on other error
> >    */
> > -int blk_print_part_devnum(enum if_type if_type, int devnum);
> > +int blk_print_part_devnum(enum uclass_id if_type, int devnum);
> > 
> >   /**
> >    * blk_read_devnum() - read blocks from a device
> > @@ -649,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
> >    * @buffer:	Address to write data to
> >    * Return: number of blocks read, or -ve error number on error
> >    */
> > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		      lbaint_t blkcnt, void *buffer);
> > 
> >   /**
> > @@ -661,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> >    * @buffer:	Address to read data from
> >    * Return: number of blocks written, or -ve error number on error
> >    */
> > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> >   		       lbaint_t blkcnt, const void *buffer);
> > 
> >   /**
> > @@ -675,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> >    * @hwpart:	Partition number to select
> >    * Return: 0 if OK, -ve on error
> >    */
> > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
> > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
> > 
> >   /**
> >    * blk_get_if_type_name() - Get the name of an interface type
> > @@ -683,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
> >    * @if_type: Interface type to check
> >    * Return: name of interface, or NULL if none
> >    */
> > -const char *blk_get_if_type_name(enum if_type if_type);
> > +const char *blk_get_if_type_name(enum uclass_id if_type);
> > 
> >   /**
> >    * blk_common_cmd() - handle common commands with block devices
> > @@ -694,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
> >    * @cur_devnump: Current device number for this interface type
> >    * Return: 0 if OK, CMD_RET_ERROR on error
> >    */
> > -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> > +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> >   		   int *cur_devnump);
> > 
> >   enum blk_flag_t {
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 3a63a1f75fd..ae58efb0036 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
> > 
> >   /* EFI system partition */
> >   extern struct efi_system_partition {
> > -	enum if_type if_type;
> > +	enum uclass_id if_type;
> >   	int devnum;
> 
> Please, rename the field if_type to class_id in a later patch.
> 
> Uclass ID and device number may refer to a different device after
> commands like usb init. It would be better if we could use the partition
> GUID to identify a partition in the long term. But that is beyond the
> scope of this series.

Well, as far as UEFI is concerned, we should use a device path
(and/or a handle to it) to uniquely identify a given device.

Then the whole code in efi_var_file.c can be rewritten
by using SIMPLE_FILE_SYSTEM_PROTOCOL attached to it.

-Takahiro Akashi

> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> 
> >   	u8 part;
> 
> 
> 
> >   } efi_system_partition;
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE
  2022-09-14  1:42   ` AKASHI Takahiro
@ 2022-09-14  7:34     ` Heinrich Schuchardt
  2022-09-14 17:10       ` Simon Glass
  0 siblings, 1 reply; 42+ messages in thread
From: Heinrich Schuchardt @ 2022-09-14  7:34 UTC (permalink / raw)
  To: Simon Glass
  Cc: AKASHI Takahiro, U-Boot Mailing List, Tom Rini, Alexander Graf,
	Alexandru Gagniuc, Alexey Brodkin, Alper Nebi Yasak,
	Anastasiia Lukianenko, Andrew Davis, Andrew Scull, Bin Meng,
	Heiko Schocher, Ilias Apalodimas, Jaehoon Chung, Mark Kettenis,
	Masahisa Kojima, Michal Simek, Oleksandr Andrushchenko,
	Pali Roh??r, Peng Fan, Philippe Reynes, Stefan Roese,
	Wolfgang Denk, Ye Li

On 9/14/22 03:42, AKASHI Takahiro wrote:
> On Thu, Aug 11, 2022 at 07:34:48PM -0600, Simon Glass wrote:
>> This option is fact really related to SPL. For U-Boot proper we always use
>> driver model for block devices, so CONFIG_BLK is enabled if block devices
>> are in use.
>>
>> It is only for SPL that we have two cases:
>>
>> - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
>> - SPL_BLK is not enabled, in which case (if we need block devices) we must
>>    use blk_legacy.c
>>
>> Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
>> different enough from BLK and SPL_BLK that there should be no confusion.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> (no changes since v1)
>>
>>   common/spl/Kconfig                             | 4 ++--
>>   configs/axm_defconfig                          | 2 +-
>>   configs/bcm968380gerg_ram_defconfig            | 2 +-
>>   configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
>>   configs/nsim_hs38_defconfig                    | 2 +-
>>   configs/qemu-ppce500_defconfig                 | 2 +-
>>   disk/Makefile                                  | 4 ++--
>>   disk/disk-uclass.c                             | 3 +--
>>   doc/develop/driver-model/migration.rst         | 2 +-
>>   drivers/Makefile                               | 2 +-
>>   drivers/ata/Kconfig                            | 2 +-
>>   drivers/block/Kconfig                          | 8 ++++----
>>   drivers/block/Makefile                         | 2 +-
>>   drivers/mmc/Kconfig                            | 2 +-
>>   drivers/nvme/Kconfig                           | 2 +-
>>   drivers/scsi/Kconfig                           | 2 +-
>>   drivers/xen/Kconfig                            | 2 +-
>>   include/blk.h                                  | 2 +-
>>   lib/efi_loader/Kconfig                         | 2 +-
>>   19 files changed, 24 insertions(+), 25 deletions(-)
>>
>> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
>> index ee98810e9e9..4c3e74ae5eb 100644
>> --- a/common/spl/Kconfig
>> +++ b/common/spl/Kconfig
>> @@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
>>   config SPL_MMC
>>   	bool "Support MMC"
>>   	depends on MMC
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  Enable support for MMC (Multimedia Card) within SPL. This enables
>>   	  the MMC protocol implementation and allows any enabled drivers to
>> @@ -1318,7 +1318,7 @@ config SPL_THERMAL
>>
>>   config SPL_USB_HOST
>>   	bool "Support USB host drivers"
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  Enable access to USB (Universal Serial Bus) host devices so that
>>   	  SPL can load U-Boot from a connected USB peripheral, such as a USB
>> diff --git a/configs/axm_defconfig b/configs/axm_defconfig
>> index a5f60bd8d0c..c42fb37d6c9 100644
>> --- a/configs/axm_defconfig
>> +++ b/configs/axm_defconfig
>> @@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
>>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>   CONFIG_SPL_DM=y
>>   CONFIG_BLK=y
>> -CONFIG_HAVE_BLOCK_DEVICE=y
>> +CONFIG_SPL_LEGACY_BLOCK=y
>>   CONFIG_CLK=y
>>   CONFIG_CLK_AT91=y
>>   CONFIG_AT91_GPIO=y
>> diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
>> index 0475535e991..246add6029c 100644
>> --- a/configs/bcm968380gerg_ram_defconfig
>> +++ b/configs/bcm968380gerg_ram_defconfig
>> @@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
>>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>   # CONFIG_NET is not set
>>   # CONFIG_DM_DEVICE_REMOVE is not set
>> -CONFIG_HAVE_BLOCK_DEVICE=y
>> +CONFIG_SPL_LEGACY_BLOCK=y
>>   CONFIG_BCM6345_GPIO=y
>>   CONFIG_LED=y
>>   CONFIG_LED_BCM6328=y
>> diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
>> index b9ee281be9f..fdfab14d53e 100644
>> --- a/configs/gardena-smart-gateway-mt7688_defconfig
>> +++ b/configs/gardena-smart-gateway-mt7688_defconfig
>> @@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
>>   CONFIG_NET_RANDOM_ETHADDR=y
>>   CONFIG_SPL_DM=y
>>   # CONFIG_DM_DEVICE_REMOVE is not set
>> -CONFIG_HAVE_BLOCK_DEVICE=y
>> +CONFIG_SPL_LEGACY_BLOCK=y
>>   CONFIG_BOOTCOUNT_LIMIT=y
>>   CONFIG_LED=y
>>   CONFIG_LED_BLINK=y
>> diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
>> index 3c3d1812a79..3f23fc4189f 100644
>> --- a/configs/nsim_hs38_defconfig
>> +++ b/configs/nsim_hs38_defconfig
>> @@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
>>   CONFIG_USE_BOOTFILE=y
>>   CONFIG_BOOTFILE="uImage"
>>   CONFIG_BLK=y
>> -CONFIG_HAVE_BLOCK_DEVICE=y
>> +CONFIG_SPL_LEGACY_BLOCK=y
>>   CONFIG_DM_ETH=y
>>   CONFIG_DM_SERIAL=y
>>   CONFIG_DEBUG_UART_SHIFT=2
>> diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
>> index 034f7e6935b..3241f5520eb 100644
>> --- a/configs/qemu-ppce500_defconfig
>> +++ b/configs/qemu-ppce500_defconfig
>> @@ -40,7 +40,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
>>   CONFIG_DM=y
>>   CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
>>   CONFIG_BLK=y
>> -CONFIG_HAVE_BLOCK_DEVICE=y
>> +CONFIG_SPL_LEGACY_BLOCK=y
>>   CONFIG_LBA48=y
>>   CONFIG_CHIP_SELECTS_PER_CTRL=0
>>   CONFIG_MPC8XXX_GPIO=y
>> diff --git a/disk/Makefile b/disk/Makefile
>> index 458e21e3fb7..45588cf66e4 100644
>> --- a/disk/Makefile
>> +++ b/disk/Makefile
>> @@ -10,8 +10,8 @@ ifdef CONFIG_$(SPL_TPL_)BLK
>>   obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
>>   endif
>>
>> -# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
>> -ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
>> +# Must have BLK or SPL_LEGACY_BLOCK to support partitions
>> +ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_SPL_LEGACY_BLOCK),)
>>   obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
>>   obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
>>   obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
>> diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
>> index f3fb942a6b9..9351a5cfa68 100644
>> --- a/disk/disk-uclass.c
>> +++ b/disk/disk-uclass.c
>> @@ -27,8 +27,7 @@ int part_create_block_devices(struct udevice *blk_dev)
>>   	struct udevice *dev;
>>   	int ret;
>>
>> -	if (!CONFIG_IS_ENABLED(PARTITIONS) ||
>> -	    !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
>> +	if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
>>   		return 0;
>>
>>   	if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
>> diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst
>> index 5a604369258..742fea5515c 100644
>> --- a/doc/develop/driver-model/migration.rst
>> +++ b/doc/develop/driver-model/migration.rst
>> @@ -57,7 +57,7 @@ In concert with maintainers migrating their block device usage to the
>>   appropriate DM driver, CONFIG_BLK needs to be set as well.  The final deadline
>>   here coincides with the final deadline for migration of the various block
>>   subsystems.  At this point we will be able to audit and correct the logic in
>> -Kconfig around using CONFIG_PARTITIONS and CONFIG_HAVE_BLOCK_DEVICE and make
>> +Kconfig around using CONFIG_PARTITIONS and CONFIG_SPL_LEGACY_BLOCK and make
>>   use of CONFIG_BLK / CONFIG_SPL_BLK as needed.
>>
>>   CONFIG_DM_SPI / CONFIG_DM_SPI_FLASH
>> diff --git a/drivers/Makefile b/drivers/Makefile
>> index f2154e15d6a..9d9f69a3c9a 100644
>> --- a/drivers/Makefile
>> +++ b/drivers/Makefile
>> @@ -59,7 +59,7 @@ obj-$(CONFIG_SPL_WATCHDOG) += watchdog/
>>   obj-$(CONFIG_SPL_USB_HOST) += usb/host/
>>   obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
>>   obj-$(CONFIG_SPL_SATA) += ata/ scsi/
>> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
>> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
>>   obj-$(CONFIG_SPL_BLK) += block/
>>   obj-$(CONFIG_SPL_THERMAL) += thermal/
>>
>> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
>> index 70e6bd321a6..c3f2ac058a3 100644
>> --- a/drivers/ata/Kconfig
>> +++ b/drivers/ata/Kconfig
>> @@ -9,7 +9,7 @@ config AHCI
>>
>>   config SATA
>>   	bool "Support SATA controllers"
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  This enables support for SATA (Serial Advanced Technology
>>   	  Attachment), a serial bus standard for connecting to hard drives and
>> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
>> index df242df9c5f..5a0c434058a 100644
>> --- a/drivers/block/Kconfig
>> +++ b/drivers/block/Kconfig
>> @@ -11,7 +11,7 @@ config BLK
>>   	  be partitioned into several areas, called 'partitions' in U-Boot.
>>   	  A filesystem can be placed in each partition.
>>
>> -config HAVE_BLOCK_DEVICE
>> +config SPL_LEGACY_BLOCK
>>   	bool "Enable Legacy Block Device"
>>   	help
>>   	  Some devices require block support whether or not DM is enabled
>> @@ -109,7 +109,7 @@ endif  # EFI_MEDIA
>>
>>   config IDE
>>   	bool "Support IDE controllers"
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  Enables support for IDE (Integrated Drive Electronics) hard drives.
>>   	  This allows access to raw blocks and filesystems on an IDE drive
>> @@ -222,7 +222,7 @@ endif  # IDE
>>
>>   config LBA48
>>   	bool "Enable LBA support for disks larger than 137GB"
>> -	depends on HAVE_BLOCK_DEVICE
>> +	depends on SPL_LEGACY_BLOCK
>>   	help
>>   	  Set this to enable support for disks larger than 137GB.
>>   	  Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
>> @@ -231,7 +231,7 @@ config LBA48
>>
>>   config SYS_64BIT_LBA
>>   	bool "Enable 64bit number of blocks on a block device"
>> -	depends on HAVE_BLOCK_DEVICE
>> +	depends on SPL_LEGACY_BLOCK
>>   	help
>>   	  Make the block subsystem use 64bit sector addresses, rather than the
>>   	  default of 32bit.
>> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
>> index b221a7c6eea..f48d3e12140 100644
>> --- a/drivers/block/Makefile
>> +++ b/drivers/block/Makefile
>> @@ -6,7 +6,7 @@
>>   obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
>>
>>   ifndef CONFIG_$(SPL_)BLK
>> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_legacy.o
>> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += blk_legacy.o
>>   endif
>>
>>   ifndef CONFIG_SPL_BUILD
>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
>> index c5e1a1b0981..d45ad1a541d 100644
>> --- a/drivers/mmc/Kconfig
>> +++ b/drivers/mmc/Kconfig
>> @@ -3,7 +3,7 @@ menu "MMC Host controller Support"
>>   config MMC
>>   	bool "MMC/SD/SDIO card support"
>>   	default ARM || PPC || SANDBOX
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	select DM_MMC if DM
>>   	help
>>   	  This selects MultiMediaCard, Secure Digital and Secure
>> diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
>> index 2a103ab5ed7..7b6d54615f8 100644
>> --- a/drivers/nvme/Kconfig
>> +++ b/drivers/nvme/Kconfig
>> @@ -4,7 +4,7 @@
>>
>>   config NVME
>>   	bool "NVM Express device support"
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  This option enables support for NVM Express devices.
>>   	  It supports basic functions of NVMe (read/write).
>> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
>> index 19872fb52d8..4d643816fcc 100644
>> --- a/drivers/scsi/Kconfig
>> +++ b/drivers/scsi/Kconfig
>> @@ -1,6 +1,6 @@
>>   config SCSI
>>   	bool "Support SCSI controllers"
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  This enables support for SCSI (Small Computer System Interface),
>>   	  a parallel interface widely used with storage peripherals such as
>> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
>> index 6ad2a936682..20db2c53065 100644
>> --- a/drivers/xen/Kconfig
>> +++ b/drivers/xen/Kconfig
>> @@ -2,7 +2,7 @@ config PVBLOCK
>>   	bool "Xen para-virtualized block device"
>>   	depends on DM
>>   	select BLK
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>>   	help
>>   	  This driver implements the front-end of the Xen virtual
>>   	  block device driver. It communicates with a back-end driver
>> diff --git a/include/blk.h b/include/blk.h
>> index 332481a90b8..5bdffe74015 100644
>> --- a/include/blk.h
>> +++ b/include/blk.h
>> @@ -23,7 +23,7 @@ struct udevice;
>>
>>   static inline bool blk_enabled(void)
>>   {
>> -	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE);
>> +	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
>>   }
>>
>>   /* Interface types: */
>> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
>> index e3f2402d0e8..5feafc16820 100644
>> --- a/lib/efi_loader/Kconfig
>> +++ b/lib/efi_loader/Kconfig
>> @@ -20,7 +20,7 @@ config EFI_LOADER
>>   	select EVENT_DYNAMIC
>>   	select LIB_UUID
>>   	imply PARTITION_UUIDS
>> -	select HAVE_BLOCK_DEVICE
>> +	select SPL_LEGACY_BLOCK
>
> I don't think we need this "select" as efi_disk implementation
> now fully relies on U-Boot dm.
> (Kconfig has "depends on BLK".)
>
> -Takahiro Akashi

The UEFI sub-system does not exist in SPL. Hence there should be no SPL
configuration flag affected.

Best regards

Heinrich

>
>
>>   	select REGEX
>>   	imply FAT
>>   	imply FAT_WRITE
>> --
>> 2.37.1.595.g718a3a8f04-goog
>>


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 22/24] blk: Drop if_type
  2022-09-14  2:08     ` AKASHI Takahiro
@ 2022-09-14  7:45       ` Heinrich Schuchardt
  2022-09-14  8:20         ` AKASHI Takahiro
  0 siblings, 1 reply; 42+ messages in thread
From: Heinrich Schuchardt @ 2022-09-14  7:45 UTC (permalink / raw)
  To: AKASHI Takahiro
  Cc: Simon Glass, Tom Rini, Ilias Apalodimas, Masahisa Kojima,
	U-Boot Mailing List

On 9/14/22 04:08, AKASHI Takahiro wrote:
> On Tue, Sep 13, 2022 at 06:27:37PM +0200, Heinrich Schuchardt wrote:
>> On 8/12/22 03:35, Simon Glass wrote:
>>> Use the uclass ID instead.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>>
>>> (no changes since v1)
>>>
>>>    cmd/blk_common.c           |  2 +-
>>>    drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
>>>    drivers/block/blk_legacy.c | 20 +++++++++----------
>>>    include/blk.h              | 41 ++++++++++++++++++--------------------
>>>    include/efi_loader.h       |  2 +-
>>>    5 files changed, 48 insertions(+), 51 deletions(-)
>>>
>>> diff --git a/cmd/blk_common.c b/cmd/blk_common.c
>>> index 4e442f2918b..369c5ae4bbe 100644
>>> --- a/cmd/blk_common.c
>>> +++ b/cmd/blk_common.c
>>> @@ -12,7 +12,7 @@
>>>    #include <blk.h>
>>>    #include <command.h>
>>>
>>> -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
>>> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>>>    		   int *cur_devnump)
>>>    {
>>>    	const char *if_name = blk_get_if_type_name(if_type);
>>> diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
>>> index 436af764f91..a9a85aa37f3 100644
>>> --- a/drivers/block/blk-uclass.c
>>> +++ b/drivers/block/blk-uclass.c
>>> @@ -34,7 +34,7 @@ static struct {
>>>    	{ UCLASS_PVBLOCK, "pvblock" },
>>>    };
>>>
>>> -static enum if_type if_typename_to_iftype(const char *if_typename)
>>> +static enum uclass_id if_typename_to_iftype(const char *if_typename)
>>>    {
>>>    	int i;
>>>
>>> @@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
>>>    	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 uclass_id if_type)
>>>    {
>>>    	/*
>>>    	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
>>> @@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
>>>    	return if_type;
>>>    }
>>>
>>> -const char *blk_get_if_type_name(enum if_type if_type)
>>> +const char *blk_get_if_type_name(enum uclass_id if_type)
>>>    {
>>>    	int i;
>>>
>>> @@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
>>>    	return "(none)";
>>>    }
>>>
>>> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
>>> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	struct udevice *dev;
>>> @@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
>>>    struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>>>    {
>>>    	enum uclass_id uclass_id;
>>> -	enum if_type type;
>>> +	enum uclass_id type;
>>>    	struct udevice *dev;
>>>    	struct uclass *uc;
>>>    	int ret;
>>> @@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
>>>     * with a higher device number, -ENOENT if there is no such device but there
>>>     * is one with a higher number, or other -ve on other error.
>>>     */
>>> -static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
>>> +static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
>>>    {
>>>    	bool found_more = false;
>>>    	struct udevice *dev;
>>> @@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
>>>    	return found_more ? -ENOENT : -ENODEV;
>>>    }
>>>
>>> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
>>> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
>>>    {
>>>    	struct udevice *dev;
>>>    	int ret;
>>> @@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
>>>    	return blk_select_hwpart(dev, hwpart);
>>>    }
>>>
>>> -int blk_list_part(enum if_type if_type)
>>> +int blk_list_part(enum uclass_id if_type)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	int devnum, ok;
>>> @@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
>>>    	return 0;
>>>    }
>>>
>>> -int blk_print_part_devnum(enum if_type if_type, int devnum)
>>> +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	int ret;
>>> @@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -void blk_list_devices(enum if_type if_type)
>>> +void blk_list_devices(enum uclass_id if_type)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	int ret;
>>> @@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
>>>    	}
>>>    }
>>>
>>> -int blk_print_device_num(enum if_type if_type, int devnum)
>>> +int blk_print_device_num(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	int ret;
>>> @@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -int blk_show_device(enum if_type if_type, int devnum)
>>> +int blk_show_device(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_desc *desc;
>>>    	int ret;
>>> @@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		      lbaint_t blkcnt, void *buffer)
>>>    {
>>>    	struct blk_desc *desc;
>>> @@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>    	return n;
>>>    }
>>>
>>> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		       lbaint_t blkcnt, const void *buffer)
>>>    {
>>>    	struct blk_desc *desc;
>>> @@ -525,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
>>>    	return uclass_get_name(device_get_uclass_id(parent));
>>>    };
>>>
>>> -int blk_find_max_devnum(enum if_type if_type)
>>> +int blk_find_max_devnum(enum uclass_id if_type)
>>>    {
>>>    	struct udevice *dev;
>>>    	int max_devnum = -ENODEV;
>>> @@ -545,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
>>>    	return max_devnum;
>>>    }
>>>
>>> -int blk_next_free_devnum(enum if_type if_type)
>>> +int blk_next_free_devnum(enum uclass_id if_type)
>>>    {
>>>    	int ret;
>>>
>>> @@ -631,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
>>>    	return count;
>>>    }
>>>
>>> -static int blk_claim_devnum(enum if_type if_type, int devnum)
>>> +static int blk_claim_devnum(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct udevice *dev;
>>>    	struct uclass *uc;
>>> diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
>>> index bd8a17df6a9..8c6f9cb208e 100644
>>> --- a/drivers/block/blk_legacy.c
>>> +++ b/drivers/block/blk_legacy.c
>>> @@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
>>>    	return NULL;
>>>    }
>>>
>>> -const char *blk_get_if_type_name(enum if_type if_type)
>>> +const char *blk_get_if_type_name(enum uclass_id if_type)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>
>>> @@ -70,7 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
>>>    	return drv->get_dev(devnum, descp);
>>>    }
>>>
>>> -int blk_list_part(enum if_type if_type)
>>> +int blk_list_part(enum uclass_id if_type)
>>>    {
>>>    	struct blk_driver *drv;
>>>    	struct blk_desc *desc;
>>> @@ -97,7 +97,7 @@ int blk_list_part(enum if_type if_type)
>>>    	return 0;
>>>    }
>>>
>>> -int blk_print_part_devnum(enum if_type if_type, int devnum)
>>> +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> @@ -115,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -void blk_list_devices(enum if_type if_type)
>>> +void blk_list_devices(enum uclass_id if_type)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> @@ -133,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
>>>    	}
>>>    }
>>>
>>> -int blk_print_device_num(enum if_type if_type, int devnum)
>>> +int blk_print_device_num(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> @@ -150,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -int blk_show_device(enum if_type if_type, int devnum)
>>> +int blk_show_device(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> @@ -174,7 +174,7 @@ int blk_show_device(enum if_type if_type, int devnum)
>>>    	return 0;
>>>    }
>>>
>>> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
>>> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> @@ -214,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
>>>    	return desc;
>>>    }
>>>
>>> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		      lbaint_t blkcnt, void *buffer)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>> @@ -234,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>    	return n;
>>>    }
>>>
>>> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		       lbaint_t blkcnt, const void *buffer)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>> @@ -249,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>    	return desc->block_write(desc, start, blkcnt, buffer);
>>>    }
>>>
>>> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
>>> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
>>>    {
>>>    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
>>>    	struct blk_desc *desc;
>>> diff --git a/include/blk.h b/include/blk.h
>>> index 548cd09d6bb..279f9ea4a9d 100644
>>> --- a/include/blk.h
>>> +++ b/include/blk.h
>>> @@ -27,9 +27,6 @@ static inline bool blk_enabled(void)
>>>    	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
>>>    }
>>>
>>> -/* Interface types: */
>>> -#define if_type uclass_id
>>> -
>>>    #define BLK_VEN_SIZE		40
>>>    #define BLK_PRD_SIZE		20
>>>    #define BLK_REV_SIZE		8
>>> @@ -57,7 +54,7 @@ struct blk_desc {
>>>    	 * TODO: With driver model we should be able to use the parent
>>>    	 * device's uclass instead.
>>>    	 */
>>> -	enum if_type	if_type;	/* type of the interface */
>>> +	enum uclass_id	if_type;	/* type of the interface */
>>>    	int		devnum;		/* device number */
>>>    	unsigned char	part_type;	/* partition type */
>>>    	unsigned char	target;		/* target SCSI ID */
>>> @@ -282,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
>>>     * This function does not activate the device. The device will be returned
>>>     * whether or not it is activated.
>>>     *
>>> - * @if_type:	Interface type (enum if_type_t)
>>> + * @if_type:	Interface type (enum uclass_id_t)
>>>     * @devnum:	Device number (specific to each interface type)
>>>     * @devp:	the device, if found
>>>     * Return: 0 if found, -ENODEV if no device found, or other -ve error value
>>> @@ -292,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
>>>    /**
>>>     * blk_get_device() - Find and probe a block device ready for use
>>>     *
>>> - * @if_type:	Interface type (enum if_type_t)
>>> + * @if_type:	Interface type (enum uclass_id_t)
>>>     * @devnum:	Device number (specific to each interface type)
>>>     * @devp:	the device, if found
>>>     * Return: 0 if found, -ENODEV if no device found, or other -ve error value
>>> @@ -330,7 +327,7 @@ int blk_next_device(struct udevice **devp);
>>>     * @parent:	Parent of the new device
>>>     * @drv_name:	Driver name to use for the block device
>>>     * @name:	Name for the device
>>> - * @if_type:	Interface type (enum if_type_t)
>>> + * @if_type:	Interface type (enum uclass_id_t)
>>>     * @devnum:	Device number, specific to the interface type, or -1 to
>>>     *		allocate the next available number
>>>     * @blksz:	Block size of the device in bytes (typically 512)
>>> @@ -347,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
>>>     * @parent:	Parent of the new device
>>>     * @drv_name:	Driver name to use for the block device
>>>     * @name:	Name for the device (parent name is prepended)
>>> - * @if_type:	Interface type (enum if_type_t)
>>> + * @if_type:	Interface type (enum uclass_id_t)
>>>     * @devnum:	Device number, specific to the interface type, or -1 to
>>>     *		allocate the next available number
>>>     * @blksz:	Block size of the device in bytes (typically 512)
>>> @@ -390,7 +387,7 @@ int blk_unbind_all(int if_type);
>>>     * Return: maximum device number found, or -ENODEV if none, or other -ve on
>>>     * error
>>>     */
>>> -int blk_find_max_devnum(enum if_type if_type);
>>> +int blk_find_max_devnum(enum uclass_id if_type);
>>>
>>>    /**
>>>     * blk_next_free_devnum() - get the next device number for an interface type
>>> @@ -401,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
>>>     * @if_type:	Interface type to scan
>>>     * Return: next device number safe to use, or -ve on error
>>>     */
>>> -int blk_next_free_devnum(enum if_type if_type);
>>> +int blk_next_free_devnum(enum uclass_id if_type);
>>>
>>>    /**
>>>     * blk_select_hwpart() - select a hardware partition
>>> @@ -496,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
>>>     */
>>>    struct blk_driver {
>>>    	const char *if_typename;
>>> -	enum if_type if_type;
>>> +	enum uclass_id if_type;
>>>    	int max_devs;
>>>    	struct blk_desc *desc;
>>>    	/**
>>> @@ -557,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
>>>     * @devnum:	Device number
>>>     * Return: point to block device descriptor, or NULL if not found
>>>     */
>>> -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
>>> +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
>>>
>>>    /**
>>>     * blk_get_devnum_by_type() - Get a block device by type name, and number
>>> @@ -594,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
>>>     * @if_type:	Block device type
>>>     * Return: 0 if OK, -ENODEV if there is none of that type
>>>     */
>>> -int blk_list_part(enum if_type if_type);
>>> +int blk_list_part(enum uclass_id if_type);
>>>
>>>    /**
>>>     * blk_list_devices() - list the block devices of a given type
>>> @@ -604,7 +601,7 @@ int blk_list_part(enum if_type if_type);
>>>     *
>>>     * @if_type:	Block device type
>>>     */
>>> -void blk_list_devices(enum if_type if_type);
>>> +void blk_list_devices(enum uclass_id if_type);
>>>
>>>    /**
>>>     * blk_show_device() - show information about a given block device
>>> @@ -615,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
>>>     * @devnum:	Device number
>>>     * Return: 0 if OK, -ENODEV for invalid device number
>>>     */
>>> -int blk_show_device(enum if_type if_type, int devnum);
>>> +int blk_show_device(enum uclass_id if_type, int devnum);
>>>
>>>    /**
>>>     * blk_print_device_num() - show information about a given block device
>>> @@ -628,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
>>>     * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
>>>     * device is not connected
>>>     */
>>> -int blk_print_device_num(enum if_type if_type, int devnum);
>>> +int blk_print_device_num(enum uclass_id if_type, int devnum);
>>>
>>>    /**
>>>     * blk_print_part_devnum() - print the partition information for a device
>>> @@ -638,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
>>>     * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
>>>     * the interface type is not supported, other -ve on other error
>>>     */
>>> -int blk_print_part_devnum(enum if_type if_type, int devnum);
>>> +int blk_print_part_devnum(enum uclass_id if_type, int devnum);
>>>
>>>    /**
>>>     * blk_read_devnum() - read blocks from a device
>>> @@ -649,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
>>>     * @buffer:	Address to write data to
>>>     * Return: number of blocks read, or -ve error number on error
>>>     */
>>> -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		      lbaint_t blkcnt, void *buffer);
>>>
>>>    /**
>>> @@ -661,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>     * @buffer:	Address to read data from
>>>     * Return: number of blocks written, or -ve error number on error
>>>     */
>>> -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>> +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
>>>    		       lbaint_t blkcnt, const void *buffer);
>>>
>>>    /**
>>> @@ -675,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
>>>     * @hwpart:	Partition number to select
>>>     * Return: 0 if OK, -ve on error
>>>     */
>>> -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>>> +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
>>>
>>>    /**
>>>     * blk_get_if_type_name() - Get the name of an interface type
>>> @@ -683,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
>>>     * @if_type: Interface type to check
>>>     * Return: name of interface, or NULL if none
>>>     */
>>> -const char *blk_get_if_type_name(enum if_type if_type);
>>> +const char *blk_get_if_type_name(enum uclass_id if_type);
>>>
>>>    /**
>>>     * blk_common_cmd() - handle common commands with block devices
>>> @@ -694,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
>>>     * @cur_devnump: Current device number for this interface type
>>>     * Return: 0 if OK, CMD_RET_ERROR on error
>>>     */
>>> -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
>>> +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
>>>    		   int *cur_devnump);
>>>
>>>    enum blk_flag_t {
>>> diff --git a/include/efi_loader.h b/include/efi_loader.h
>>> index 3a63a1f75fd..ae58efb0036 100644
>>> --- a/include/efi_loader.h
>>> +++ b/include/efi_loader.h
>>> @@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
>>>
>>>    /* EFI system partition */
>>>    extern struct efi_system_partition {
>>> -	enum if_type if_type;
>>> +	enum uclass_id if_type;
>>>    	int devnum;
>>
>> Please, rename the field if_type to class_id in a later patch.
>>
>> Uclass ID and device number may refer to a different device after
>> commands like usb init. It would be better if we could use the partition
>> GUID to identify a partition in the long term. But that is beyond the
>> scope of this series.
>
> Well, as far as UEFI is concerned, we should use a device path
> (and/or a handle to it) to uniquely identify a given device.

The address pointed to by a handle or struct udevice * maybe reused
after deleting the handle or device. This is why I mentioned the
partition GUID.

A device path for a partition contains the partition GUID, see UEFI spec
2.10, 10.3.5.1 Hard Drive.

Regards

Heinrich

>
> Then the whole code in efi_var_file.c can be rewritten
> by using SIMPLE_FILE_SYSTEM_PROTOCOL attached to it.
>
> -Takahiro Akashi
>
>> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>
>>
>>>    	u8 part;
>>
>>
>>
>>>    } efi_system_partition;
>>


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 22/24] blk: Drop if_type
  2022-09-14  7:45       ` Heinrich Schuchardt
@ 2022-09-14  8:20         ` AKASHI Takahiro
  0 siblings, 0 replies; 42+ messages in thread
From: AKASHI Takahiro @ 2022-09-14  8:20 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Simon Glass, Tom Rini, Ilias Apalodimas, Masahisa Kojima,
	U-Boot Mailing List

On Wed, Sep 14, 2022 at 09:45:47AM +0200, Heinrich Schuchardt wrote:
> On 9/14/22 04:08, AKASHI Takahiro wrote:
> > On Tue, Sep 13, 2022 at 06:27:37PM +0200, Heinrich Schuchardt wrote:
> > > On 8/12/22 03:35, Simon Glass wrote:
> > > > Use the uclass ID instead.
> > > > 
> > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > ---
> > > > 
> > > > (no changes since v1)
> > > > 
> > > >    cmd/blk_common.c           |  2 +-
> > > >    drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
> > > >    drivers/block/blk_legacy.c | 20 +++++++++----------
> > > >    include/blk.h              | 41 ++++++++++++++++++--------------------
> > > >    include/efi_loader.h       |  2 +-
> > > >    5 files changed, 48 insertions(+), 51 deletions(-)
> > > > 
> > > > diff --git a/cmd/blk_common.c b/cmd/blk_common.c
> > > > index 4e442f2918b..369c5ae4bbe 100644
> > > > --- a/cmd/blk_common.c
> > > > +++ b/cmd/blk_common.c
> > > > @@ -12,7 +12,7 @@
> > > >    #include <blk.h>
> > > >    #include <command.h>
> > > > 
> > > > -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> > > > +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> > > >    		   int *cur_devnump)
> > > >    {
> > > >    	const char *if_name = blk_get_if_type_name(if_type);
> > > > diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
> > > > index 436af764f91..a9a85aa37f3 100644
> > > > --- a/drivers/block/blk-uclass.c
> > > > +++ b/drivers/block/blk-uclass.c
> > > > @@ -34,7 +34,7 @@ static struct {
> > > >    	{ UCLASS_PVBLOCK, "pvblock" },
> > > >    };
> > > > 
> > > > -static enum if_type if_typename_to_iftype(const char *if_typename)
> > > > +static enum uclass_id if_typename_to_iftype(const char *if_typename)
> > > >    {
> > > >    	int i;
> > > > 
> > > > @@ -46,7 +46,7 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
> > > >    	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 uclass_id if_type)
> > > >    {
> > > >    	/*
> > > >    	 * This strange adjustment is used because we use UCLASS_MASS_STORAGE
> > > > @@ -71,7 +71,7 @@ static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
> > > >    	return if_type;
> > > >    }
> > > > 
> > > > -const char *blk_get_if_type_name(enum if_type if_type)
> > > > +const char *blk_get_if_type_name(enum uclass_id if_type)
> > > >    {
> > > >    	int i;
> > > > 
> > > > @@ -83,7 +83,7 @@ const char *blk_get_if_type_name(enum if_type if_type)
> > > >    	return "(none)";
> > > >    }
> > > > 
> > > > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> > > > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	struct udevice *dev;
> > > > @@ -105,7 +105,7 @@ struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> > > >    struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> > > >    {
> > > >    	enum uclass_id uclass_id;
> > > > -	enum if_type type;
> > > > +	enum uclass_id type;
> > > >    	struct udevice *dev;
> > > >    	struct uclass *uc;
> > > >    	int ret;
> > > > @@ -185,7 +185,7 @@ struct blk_desc *blk_get_by_device(struct udevice *dev)
> > > >     * with a higher device number, -ENOENT if there is no such device but there
> > > >     * is one with a higher number, or other -ve on other error.
> > > >     */
> > > > -static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
> > > > +static int get_desc(enum uclass_id if_type, int devnum, struct blk_desc **descp)
> > > >    {
> > > >    	bool found_more = false;
> > > >    	struct udevice *dev;
> > > > @@ -218,7 +218,7 @@ static int get_desc(enum if_type if_type, int devnum, struct blk_desc **descp)
> > > >    	return found_more ? -ENOENT : -ENODEV;
> > > >    }
> > > > 
> > > > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> > > > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> > > >    {
> > > >    	struct udevice *dev;
> > > >    	int ret;
> > > > @@ -230,7 +230,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> > > >    	return blk_select_hwpart(dev, hwpart);
> > > >    }
> > > > 
> > > > -int blk_list_part(enum if_type if_type)
> > > > +int blk_list_part(enum uclass_id if_type)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	int devnum, ok;
> > > > @@ -255,7 +255,7 @@ int blk_list_part(enum if_type if_type)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -int blk_print_part_devnum(enum if_type if_type, int devnum)
> > > > +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	int ret;
> > > > @@ -270,7 +270,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -void blk_list_devices(enum if_type if_type)
> > > > +void blk_list_devices(enum uclass_id if_type)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	int ret;
> > > > @@ -289,7 +289,7 @@ void blk_list_devices(enum if_type if_type)
> > > >    	}
> > > >    }
> > > > 
> > > > -int blk_print_device_num(enum if_type if_type, int devnum)
> > > > +int blk_print_device_num(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	int ret;
> > > > @@ -303,7 +303,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -int blk_show_device(enum if_type if_type, int devnum)
> > > > +int blk_show_device(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > >    	int ret;
> > > > @@ -324,7 +324,7 @@ int blk_show_device(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		      lbaint_t blkcnt, void *buffer)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > > @@ -341,7 +341,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > >    	return n;
> > > >    }
> > > > 
> > > > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		       lbaint_t blkcnt, const void *buffer)
> > > >    {
> > > >    	struct blk_desc *desc;
> > > > @@ -525,7 +525,7 @@ const char *blk_get_devtype(struct udevice *dev)
> > > >    	return uclass_get_name(device_get_uclass_id(parent));
> > > >    };
> > > > 
> > > > -int blk_find_max_devnum(enum if_type if_type)
> > > > +int blk_find_max_devnum(enum uclass_id if_type)
> > > >    {
> > > >    	struct udevice *dev;
> > > >    	int max_devnum = -ENODEV;
> > > > @@ -545,7 +545,7 @@ int blk_find_max_devnum(enum if_type if_type)
> > > >    	return max_devnum;
> > > >    }
> > > > 
> > > > -int blk_next_free_devnum(enum if_type if_type)
> > > > +int blk_next_free_devnum(enum uclass_id if_type)
> > > >    {
> > > >    	int ret;
> > > > 
> > > > @@ -631,7 +631,7 @@ int blk_count_devices(enum blk_flag_t flag)
> > > >    	return count;
> > > >    }
> > > > 
> > > > -static int blk_claim_devnum(enum if_type if_type, int devnum)
> > > > +static int blk_claim_devnum(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct udevice *dev;
> > > >    	struct uclass *uc;
> > > > diff --git a/drivers/block/blk_legacy.c b/drivers/block/blk_legacy.c
> > > > index bd8a17df6a9..8c6f9cb208e 100644
> > > > --- a/drivers/block/blk_legacy.c
> > > > +++ b/drivers/block/blk_legacy.c
> > > > @@ -39,7 +39,7 @@ static struct blk_driver *blk_driver_lookup_typename(const char *if_typename)
> > > >    	return NULL;
> > > >    }
> > > > 
> > > > -const char *blk_get_if_type_name(enum if_type if_type)
> > > > +const char *blk_get_if_type_name(enum uclass_id if_type)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > > 
> > > > @@ -70,7 +70,7 @@ static int get_desc(struct blk_driver *drv, int devnum, struct blk_desc **descp)
> > > >    	return drv->get_dev(devnum, descp);
> > > >    }
> > > > 
> > > > -int blk_list_part(enum if_type if_type)
> > > > +int blk_list_part(enum uclass_id if_type)
> > > >    {
> > > >    	struct blk_driver *drv;
> > > >    	struct blk_desc *desc;
> > > > @@ -97,7 +97,7 @@ int blk_list_part(enum if_type if_type)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -int blk_print_part_devnum(enum if_type if_type, int devnum)
> > > > +int blk_print_part_devnum(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > @@ -115,7 +115,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -void blk_list_devices(enum if_type if_type)
> > > > +void blk_list_devices(enum uclass_id if_type)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > @@ -133,7 +133,7 @@ void blk_list_devices(enum if_type if_type)
> > > >    	}
> > > >    }
> > > > 
> > > > -int blk_print_device_num(enum if_type if_type, int devnum)
> > > > +int blk_print_device_num(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > @@ -150,7 +150,7 @@ int blk_print_device_num(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -int blk_show_device(enum if_type if_type, int devnum)
> > > > +int blk_show_device(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > @@ -174,7 +174,7 @@ int blk_show_device(enum if_type if_type, int devnum)
> > > >    	return 0;
> > > >    }
> > > > 
> > > > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum)
> > > > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > @@ -214,7 +214,7 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
> > > >    	return desc;
> > > >    }
> > > > 
> > > > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		      lbaint_t blkcnt, void *buffer)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > > @@ -234,7 +234,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > >    	return n;
> > > >    }
> > > > 
> > > > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		       lbaint_t blkcnt, const void *buffer)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > > @@ -249,7 +249,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > >    	return desc->block_write(desc, start, blkcnt, buffer);
> > > >    }
> > > > 
> > > > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
> > > > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart)
> > > >    {
> > > >    	struct blk_driver *drv = blk_driver_lookup_type(if_type);
> > > >    	struct blk_desc *desc;
> > > > diff --git a/include/blk.h b/include/blk.h
> > > > index 548cd09d6bb..279f9ea4a9d 100644
> > > > --- a/include/blk.h
> > > > +++ b/include/blk.h
> > > > @@ -27,9 +27,6 @@ static inline bool blk_enabled(void)
> > > >    	return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
> > > >    }
> > > > 
> > > > -/* Interface types: */
> > > > -#define if_type uclass_id
> > > > -
> > > >    #define BLK_VEN_SIZE		40
> > > >    #define BLK_PRD_SIZE		20
> > > >    #define BLK_REV_SIZE		8
> > > > @@ -57,7 +54,7 @@ struct blk_desc {
> > > >    	 * TODO: With driver model we should be able to use the parent
> > > >    	 * device's uclass instead.
> > > >    	 */
> > > > -	enum if_type	if_type;	/* type of the interface */
> > > > +	enum uclass_id	if_type;	/* type of the interface */
> > > >    	int		devnum;		/* device number */
> > > >    	unsigned char	part_type;	/* partition type */
> > > >    	unsigned char	target;		/* target SCSI ID */
> > > > @@ -282,7 +279,7 @@ unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
> > > >     * This function does not activate the device. The device will be returned
> > > >     * whether or not it is activated.
> > > >     *
> > > > - * @if_type:	Interface type (enum if_type_t)
> > > > + * @if_type:	Interface type (enum uclass_id_t)
> > > >     * @devnum:	Device number (specific to each interface type)
> > > >     * @devp:	the device, if found
> > > >     * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> > > > @@ -292,7 +289,7 @@ int blk_find_device(int if_type, int devnum, struct udevice **devp);
> > > >    /**
> > > >     * blk_get_device() - Find and probe a block device ready for use
> > > >     *
> > > > - * @if_type:	Interface type (enum if_type_t)
> > > > + * @if_type:	Interface type (enum uclass_id_t)
> > > >     * @devnum:	Device number (specific to each interface type)
> > > >     * @devp:	the device, if found
> > > >     * Return: 0 if found, -ENODEV if no device found, or other -ve error value
> > > > @@ -330,7 +327,7 @@ int blk_next_device(struct udevice **devp);
> > > >     * @parent:	Parent of the new device
> > > >     * @drv_name:	Driver name to use for the block device
> > > >     * @name:	Name for the device
> > > > - * @if_type:	Interface type (enum if_type_t)
> > > > + * @if_type:	Interface type (enum uclass_id_t)
> > > >     * @devnum:	Device number, specific to the interface type, or -1 to
> > > >     *		allocate the next available number
> > > >     * @blksz:	Block size of the device in bytes (typically 512)
> > > > @@ -347,7 +344,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
> > > >     * @parent:	Parent of the new device
> > > >     * @drv_name:	Driver name to use for the block device
> > > >     * @name:	Name for the device (parent name is prepended)
> > > > - * @if_type:	Interface type (enum if_type_t)
> > > > + * @if_type:	Interface type (enum uclass_id_t)
> > > >     * @devnum:	Device number, specific to the interface type, or -1 to
> > > >     *		allocate the next available number
> > > >     * @blksz:	Block size of the device in bytes (typically 512)
> > > > @@ -390,7 +387,7 @@ int blk_unbind_all(int if_type);
> > > >     * Return: maximum device number found, or -ENODEV if none, or other -ve on
> > > >     * error
> > > >     */
> > > > -int blk_find_max_devnum(enum if_type if_type);
> > > > +int blk_find_max_devnum(enum uclass_id if_type);
> > > > 
> > > >    /**
> > > >     * blk_next_free_devnum() - get the next device number for an interface type
> > > > @@ -401,7 +398,7 @@ int blk_find_max_devnum(enum if_type if_type);
> > > >     * @if_type:	Interface type to scan
> > > >     * Return: next device number safe to use, or -ve on error
> > > >     */
> > > > -int blk_next_free_devnum(enum if_type if_type);
> > > > +int blk_next_free_devnum(enum uclass_id if_type);
> > > > 
> > > >    /**
> > > >     * blk_select_hwpart() - select a hardware partition
> > > > @@ -496,7 +493,7 @@ static inline ulong blk_derase(struct blk_desc *block_dev, lbaint_t start,
> > > >     */
> > > >    struct blk_driver {
> > > >    	const char *if_typename;
> > > > -	enum if_type if_type;
> > > > +	enum uclass_id if_type;
> > > >    	int max_devs;
> > > >    	struct blk_desc *desc;
> > > >    	/**
> > > > @@ -557,7 +554,7 @@ struct blk_driver *blk_driver_lookup_type(int if_type);
> > > >     * @devnum:	Device number
> > > >     * Return: point to block device descriptor, or NULL if not found
> > > >     */
> > > > -struct blk_desc *blk_get_devnum_by_type(enum if_type if_type, int devnum);
> > > > +struct blk_desc *blk_get_devnum_by_type(enum uclass_id if_type, int devnum);
> > > > 
> > > >    /**
> > > >     * blk_get_devnum_by_type() - Get a block device by type name, and number
> > > > @@ -594,7 +591,7 @@ int blk_dselect_hwpart(struct blk_desc *desc, int hwpart);
> > > >     * @if_type:	Block device type
> > > >     * Return: 0 if OK, -ENODEV if there is none of that type
> > > >     */
> > > > -int blk_list_part(enum if_type if_type);
> > > > +int blk_list_part(enum uclass_id if_type);
> > > > 
> > > >    /**
> > > >     * blk_list_devices() - list the block devices of a given type
> > > > @@ -604,7 +601,7 @@ int blk_list_part(enum if_type if_type);
> > > >     *
> > > >     * @if_type:	Block device type
> > > >     */
> > > > -void blk_list_devices(enum if_type if_type);
> > > > +void blk_list_devices(enum uclass_id if_type);
> > > > 
> > > >    /**
> > > >     * blk_show_device() - show information about a given block device
> > > > @@ -615,7 +612,7 @@ void blk_list_devices(enum if_type if_type);
> > > >     * @devnum:	Device number
> > > >     * Return: 0 if OK, -ENODEV for invalid device number
> > > >     */
> > > > -int blk_show_device(enum if_type if_type, int devnum);
> > > > +int blk_show_device(enum uclass_id if_type, int devnum);
> > > > 
> > > >    /**
> > > >     * blk_print_device_num() - show information about a given block device
> > > > @@ -628,7 +625,7 @@ int blk_show_device(enum if_type if_type, int devnum);
> > > >     * Return: 0 if OK, -ENODEV for invalid device number, -ENOENT if the block
> > > >     * device is not connected
> > > >     */
> > > > -int blk_print_device_num(enum if_type if_type, int devnum);
> > > > +int blk_print_device_num(enum uclass_id if_type, int devnum);
> > > > 
> > > >    /**
> > > >     * blk_print_part_devnum() - print the partition information for a device
> > > > @@ -638,7 +635,7 @@ int blk_print_device_num(enum if_type if_type, int devnum);
> > > >     * Return: 0 if OK, -ENOENT if the block device is not connected, -ENOSYS if
> > > >     * the interface type is not supported, other -ve on other error
> > > >     */
> > > > -int blk_print_part_devnum(enum if_type if_type, int devnum);
> > > > +int blk_print_part_devnum(enum uclass_id if_type, int devnum);
> > > > 
> > > >    /**
> > > >     * blk_read_devnum() - read blocks from a device
> > > > @@ -649,7 +646,7 @@ int blk_print_part_devnum(enum if_type if_type, int devnum);
> > > >     * @buffer:	Address to write data to
> > > >     * Return: number of blocks read, or -ve error number on error
> > > >     */
> > > > -ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_read_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		      lbaint_t blkcnt, void *buffer);
> > > > 
> > > >    /**
> > > > @@ -661,7 +658,7 @@ ulong blk_read_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > >     * @buffer:	Address to read data from
> > > >     * Return: number of blocks written, or -ve error number on error
> > > >     */
> > > > -ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > > +ulong blk_write_devnum(enum uclass_id if_type, int devnum, lbaint_t start,
> > > >    		       lbaint_t blkcnt, const void *buffer);
> > > > 
> > > >    /**
> > > > @@ -675,7 +672,7 @@ ulong blk_write_devnum(enum if_type if_type, int devnum, lbaint_t start,
> > > >     * @hwpart:	Partition number to select
> > > >     * Return: 0 if OK, -ve on error
> > > >     */
> > > > -int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
> > > > +int blk_select_hwpart_devnum(enum uclass_id if_type, int devnum, int hwpart);
> > > > 
> > > >    /**
> > > >     * blk_get_if_type_name() - Get the name of an interface type
> > > > @@ -683,7 +680,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart);
> > > >     * @if_type: Interface type to check
> > > >     * Return: name of interface, or NULL if none
> > > >     */
> > > > -const char *blk_get_if_type_name(enum if_type if_type);
> > > > +const char *blk_get_if_type_name(enum uclass_id if_type);
> > > > 
> > > >    /**
> > > >     * blk_common_cmd() - handle common commands with block devices
> > > > @@ -694,7 +691,7 @@ const char *blk_get_if_type_name(enum if_type if_type);
> > > >     * @cur_devnump: Current device number for this interface type
> > > >     * Return: 0 if OK, CMD_RET_ERROR on error
> > > >     */
> > > > -int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
> > > > +int blk_common_cmd(int argc, char *const argv[], enum uclass_id if_type,
> > > >    		   int *cur_devnump);
> > > > 
> > > >    enum blk_flag_t {
> > > > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > > > index 3a63a1f75fd..ae58efb0036 100644
> > > > --- a/include/efi_loader.h
> > > > +++ b/include/efi_loader.h
> > > > @@ -156,7 +156,7 @@ extern bool efi_st_keep_devices;
> > > > 
> > > >    /* EFI system partition */
> > > >    extern struct efi_system_partition {
> > > > -	enum if_type if_type;
> > > > +	enum uclass_id if_type;
> > > >    	int devnum;
> > > 
> > > Please, rename the field if_type to class_id in a later patch.
> > > 
> > > Uclass ID and device number may refer to a different device after
> > > commands like usb init. It would be better if we could use the partition
> > > GUID to identify a partition in the long term. But that is beyond the
> > > scope of this series.
> > 
> > Well, as far as UEFI is concerned, we should use a device path
> > (and/or a handle to it) to uniquely identify a given device.
> 
> The address pointed to by a handle or struct udevice * maybe reused
> after deleting the handle or device. This is why I mentioned the
> partition GUID.

1) With a device path, you can find a corresponding handle dynamically
   by using efi_dp_find_obj().

2) With a handle, you can maintain (update) it by using
   EVT_DM_POST_PROBE/REMOVE hooks as "efi_system_partition" variable
   is in efi_disk_add_dev().

So both approaches are very much feasible, not depending directly
on the underlying U-Boot representation.

-Takahiro Akashi


> A device path for a partition contains the partition GUID, see UEFI spec
> 2.10, 10.3.5.1 Hard Drive.
> 
> Regards
> 
> Heinrich
> 
> > 
> > Then the whole code in efi_var_file.c can be rewritten
> > by using SIMPLE_FILE_SYSTEM_PROTOCOL attached to it.
> > 
> > -Takahiro Akashi
> > 
> > > Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > > 
> > > 
> > > >    	u8 part;
> > > 
> > > 
> > > 
> > > >    } efi_system_partition;
> > > 
> 

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 24/24] blk: Rename if_type to uclass_id
  2022-09-13 16:03   ` Tom Rini
@ 2022-09-14 17:09     ` Simon Glass
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-09-14 17:09 UTC (permalink / raw)
  To: Tom Rini
  Cc: U-Boot Mailing List, Heinrich Schuchardt, AKASHI Takahiro,
	Anastasiia Lukianenko, Aswath Govindraju, Bin Meng,
	Ilias Apalodimas, Jaehoon Chung, Joe Hershberger,
	Lukasz Majewski, Marcel Ziswiler, Marek Vasut, Markus Niebel,
	Masahisa Kojima, Max Merchel, Oleksandr Andrushchenko,
	Oleksandr Suvorov, Oleksii Bidnichenko, Patrice Chotard,
	Patrick Delaunay, Peng Fan, Ramon Fried, Ricardo Salveti,
	Sean Anderson, Stefan Roese, Ying-Chun Liu (PaulLiu),
	schspa, U-Boot STM32

Hi Tom,

On Tue, 13 Sept 2022 at 10:03, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Aug 11, 2022 at 07:35:03PM -0600, Simon Glass wrote:
>
> > Use the word 'uclass' instead of 'if_type' to complete the conversion.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > Changes in v2:
> > - Use conv_uclass_id() instead of the confusing uclass_id_to_uclass_id()
>
> So, for this series, 1 through 22 apply cleanly (one easy fixup
> required), and 23/24 appears to be applied already. But large chunks of
> this patch do not apply to lib/efi_loader/efi_disk.c and it's unclear
> what I should do here. Should I just apply 1-22 of this series? Or do
> you expect to v3 this? Thanks!

Yes please apply 1-22. For 24 I will then rebase on -next , address
the comments and resend.

Regards,
Simon

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE
  2022-09-14  7:34     ` Heinrich Schuchardt
@ 2022-09-14 17:10       ` Simon Glass
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-09-14 17:10 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: AKASHI Takahiro, U-Boot Mailing List, Tom Rini, Alexander Graf,
	Alexandru Gagniuc, Alexey Brodkin, Alper Nebi Yasak,
	Anastasiia Lukianenko, Andrew Davis, Andrew Scull, Bin Meng,
	Heiko Schocher, Ilias Apalodimas, Jaehoon Chung, Mark Kettenis,
	Masahisa Kojima, Michal Simek, Oleksandr Andrushchenko,
	Pali Roh??r, Peng Fan, Philippe Reynes, Stefan Roese,
	Wolfgang Denk, Ye Li

Hi Heinrich,

On Wed, 14 Sept 2022 at 01:40, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 9/14/22 03:42, AKASHI Takahiro wrote:
> > On Thu, Aug 11, 2022 at 07:34:48PM -0600, Simon Glass wrote:
> >> This option is fact really related to SPL. For U-Boot proper we always use
> >> driver model for block devices, so CONFIG_BLK is enabled if block devices
> >> are in use.
> >>
> >> It is only for SPL that we have two cases:
> >>
> >> - SPL_BLK is enabled, in which case we use driver model and blk-uclass.c
> >> - SPL_BLK is not enabled, in which case (if we need block devices) we must
> >>    use blk_legacy.c
> >>
> >> Rename the symbol to SPL_LEGACY_BLOCK to make this clear. This is
> >> different enough from BLK and SPL_BLK that there should be no confusion.
> >>
> >> Signed-off-by: Simon Glass <sjg@chromium.org>
> >> ---
> >>
> >> (no changes since v1)
> >>
> >>   common/spl/Kconfig                             | 4 ++--
> >>   configs/axm_defconfig                          | 2 +-
> >>   configs/bcm968380gerg_ram_defconfig            | 2 +-
> >>   configs/gardena-smart-gateway-mt7688_defconfig | 2 +-
> >>   configs/nsim_hs38_defconfig                    | 2 +-
> >>   configs/qemu-ppce500_defconfig                 | 2 +-
> >>   disk/Makefile                                  | 4 ++--
> >>   disk/disk-uclass.c                             | 3 +--
> >>   doc/develop/driver-model/migration.rst         | 2 +-
> >>   drivers/Makefile                               | 2 +-
> >>   drivers/ata/Kconfig                            | 2 +-
> >>   drivers/block/Kconfig                          | 8 ++++----
> >>   drivers/block/Makefile                         | 2 +-
> >>   drivers/mmc/Kconfig                            | 2 +-
> >>   drivers/nvme/Kconfig                           | 2 +-
> >>   drivers/scsi/Kconfig                           | 2 +-
> >>   drivers/xen/Kconfig                            | 2 +-
> >>   include/blk.h                                  | 2 +-
> >>   lib/efi_loader/Kconfig                         | 2 +-
> >>   19 files changed, 24 insertions(+), 25 deletions(-)
> >>
> >> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> >> index ee98810e9e9..4c3e74ae5eb 100644
> >> --- a/common/spl/Kconfig
> >> +++ b/common/spl/Kconfig
> >> @@ -792,7 +792,7 @@ config SPL_DM_MAILBOX
> >>   config SPL_MMC
> >>      bool "Support MMC"
> >>      depends on MMC
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        Enable support for MMC (Multimedia Card) within SPL. This enables
> >>        the MMC protocol implementation and allows any enabled drivers to
> >> @@ -1318,7 +1318,7 @@ config SPL_THERMAL
> >>
> >>   config SPL_USB_HOST
> >>      bool "Support USB host drivers"
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        Enable access to USB (Universal Serial Bus) host devices so that
> >>        SPL can load U-Boot from a connected USB peripheral, such as a USB
> >> diff --git a/configs/axm_defconfig b/configs/axm_defconfig
> >> index a5f60bd8d0c..c42fb37d6c9 100644
> >> --- a/configs/axm_defconfig
> >> +++ b/configs/axm_defconfig
> >> @@ -80,7 +80,7 @@ CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
> >>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >>   CONFIG_SPL_DM=y
> >>   CONFIG_BLK=y
> >> -CONFIG_HAVE_BLOCK_DEVICE=y
> >> +CONFIG_SPL_LEGACY_BLOCK=y
> >>   CONFIG_CLK=y
> >>   CONFIG_CLK_AT91=y
> >>   CONFIG_AT91_GPIO=y
> >> diff --git a/configs/bcm968380gerg_ram_defconfig b/configs/bcm968380gerg_ram_defconfig
> >> index 0475535e991..246add6029c 100644
> >> --- a/configs/bcm968380gerg_ram_defconfig
> >> +++ b/configs/bcm968380gerg_ram_defconfig
> >> @@ -42,7 +42,7 @@ CONFIG_CMD_NAND=y
> >>   CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >>   # CONFIG_NET is not set
> >>   # CONFIG_DM_DEVICE_REMOVE is not set
> >> -CONFIG_HAVE_BLOCK_DEVICE=y
> >> +CONFIG_SPL_LEGACY_BLOCK=y
> >>   CONFIG_BCM6345_GPIO=y
> >>   CONFIG_LED=y
> >>   CONFIG_LED_BCM6328=y
> >> diff --git a/configs/gardena-smart-gateway-mt7688_defconfig b/configs/gardena-smart-gateway-mt7688_defconfig
> >> index b9ee281be9f..fdfab14d53e 100644
> >> --- a/configs/gardena-smart-gateway-mt7688_defconfig
> >> +++ b/configs/gardena-smart-gateway-mt7688_defconfig
> >> @@ -78,7 +78,7 @@ CONFIG_VERSION_VARIABLE=y
> >>   CONFIG_NET_RANDOM_ETHADDR=y
> >>   CONFIG_SPL_DM=y
> >>   # CONFIG_DM_DEVICE_REMOVE is not set
> >> -CONFIG_HAVE_BLOCK_DEVICE=y
> >> +CONFIG_SPL_LEGACY_BLOCK=y
> >>   CONFIG_BOOTCOUNT_LIMIT=y
> >>   CONFIG_LED=y
> >>   CONFIG_LED_BLINK=y
> >> diff --git a/configs/nsim_hs38_defconfig b/configs/nsim_hs38_defconfig
> >> index 3c3d1812a79..3f23fc4189f 100644
> >> --- a/configs/nsim_hs38_defconfig
> >> +++ b/configs/nsim_hs38_defconfig
> >> @@ -30,7 +30,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> >>   CONFIG_USE_BOOTFILE=y
> >>   CONFIG_BOOTFILE="uImage"
> >>   CONFIG_BLK=y
> >> -CONFIG_HAVE_BLOCK_DEVICE=y
> >> +CONFIG_SPL_LEGACY_BLOCK=y
> >>   CONFIG_DM_ETH=y
> >>   CONFIG_DM_SERIAL=y
> >>   CONFIG_DEBUG_UART_SHIFT=2
> >> diff --git a/configs/qemu-ppce500_defconfig b/configs/qemu-ppce500_defconfig
> >> index 034f7e6935b..3241f5520eb 100644
> >> --- a/configs/qemu-ppce500_defconfig
> >> +++ b/configs/qemu-ppce500_defconfig
> >> @@ -40,7 +40,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
> >>   CONFIG_DM=y
> >>   CONFIG_SIMPLE_BUS_CORRECT_RANGE=y
> >>   CONFIG_BLK=y
> >> -CONFIG_HAVE_BLOCK_DEVICE=y
> >> +CONFIG_SPL_LEGACY_BLOCK=y
> >>   CONFIG_LBA48=y
> >>   CONFIG_CHIP_SELECTS_PER_CTRL=0
> >>   CONFIG_MPC8XXX_GPIO=y
> >> diff --git a/disk/Makefile b/disk/Makefile
> >> index 458e21e3fb7..45588cf66e4 100644
> >> --- a/disk/Makefile
> >> +++ b/disk/Makefile
> >> @@ -10,8 +10,8 @@ ifdef CONFIG_$(SPL_TPL_)BLK
> >>   obj-$(CONFIG_$(SPL_TPL_)PARTITIONS)  += disk-uclass.o
> >>   endif
> >>
> >> -# Must have BLK or HAVE_BLOCK_DEVICE to support partitions
> >> -ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_HAVE_BLOCK_DEVICE),)
> >> +# Must have BLK or SPL_LEGACY_BLOCK to support partitions
> >> +ifneq ($(CONFIG_$(SPL_TPL_)BLK),$(CONFIG_SPL_LEGACY_BLOCK),)
> >>   obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION)   += part_mac.o
> >>   obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION)   += part_dos.o
> >>   obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION)   += part_iso.o
> >> diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
> >> index f3fb942a6b9..9351a5cfa68 100644
> >> --- a/disk/disk-uclass.c
> >> +++ b/disk/disk-uclass.c
> >> @@ -27,8 +27,7 @@ int part_create_block_devices(struct udevice *blk_dev)
> >>      struct udevice *dev;
> >>      int ret;
> >>
> >> -    if (!CONFIG_IS_ENABLED(PARTITIONS) ||
> >> -        !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
> >> +    if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
> >>              return 0;
> >>
> >>      if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
> >> diff --git a/doc/develop/driver-model/migration.rst b/doc/develop/driver-model/migration.rst
> >> index 5a604369258..742fea5515c 100644
> >> --- a/doc/develop/driver-model/migration.rst
> >> +++ b/doc/develop/driver-model/migration.rst
> >> @@ -57,7 +57,7 @@ In concert with maintainers migrating their block device usage to the
> >>   appropriate DM driver, CONFIG_BLK needs to be set as well.  The final deadline
> >>   here coincides with the final deadline for migration of the various block
> >>   subsystems.  At this point we will be able to audit and correct the logic in
> >> -Kconfig around using CONFIG_PARTITIONS and CONFIG_HAVE_BLOCK_DEVICE and make
> >> +Kconfig around using CONFIG_PARTITIONS and CONFIG_SPL_LEGACY_BLOCK and make
> >>   use of CONFIG_BLK / CONFIG_SPL_BLK as needed.
> >>
> >>   CONFIG_DM_SPI / CONFIG_DM_SPI_FLASH
> >> diff --git a/drivers/Makefile b/drivers/Makefile
> >> index f2154e15d6a..9d9f69a3c9a 100644
> >> --- a/drivers/Makefile
> >> +++ b/drivers/Makefile
> >> @@ -59,7 +59,7 @@ obj-$(CONFIG_SPL_WATCHDOG) += watchdog/
> >>   obj-$(CONFIG_SPL_USB_HOST) += usb/host/
> >>   obj-$(CONFIG_OMAP_USB_PHY) += usb/phy/
> >>   obj-$(CONFIG_SPL_SATA) += ata/ scsi/
> >> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += block/
> >> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += block/
> >>   obj-$(CONFIG_SPL_BLK) += block/
> >>   obj-$(CONFIG_SPL_THERMAL) += thermal/
> >>
> >> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> >> index 70e6bd321a6..c3f2ac058a3 100644
> >> --- a/drivers/ata/Kconfig
> >> +++ b/drivers/ata/Kconfig
> >> @@ -9,7 +9,7 @@ config AHCI
> >>
> >>   config SATA
> >>      bool "Support SATA controllers"
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        This enables support for SATA (Serial Advanced Technology
> >>        Attachment), a serial bus standard for connecting to hard drives and
> >> diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
> >> index df242df9c5f..5a0c434058a 100644
> >> --- a/drivers/block/Kconfig
> >> +++ b/drivers/block/Kconfig
> >> @@ -11,7 +11,7 @@ config BLK
> >>        be partitioned into several areas, called 'partitions' in U-Boot.
> >>        A filesystem can be placed in each partition.
> >>
> >> -config HAVE_BLOCK_DEVICE
> >> +config SPL_LEGACY_BLOCK
> >>      bool "Enable Legacy Block Device"
> >>      help
> >>        Some devices require block support whether or not DM is enabled
> >> @@ -109,7 +109,7 @@ endif  # EFI_MEDIA
> >>
> >>   config IDE
> >>      bool "Support IDE controllers"
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        Enables support for IDE (Integrated Drive Electronics) hard drives.
> >>        This allows access to raw blocks and filesystems on an IDE drive
> >> @@ -222,7 +222,7 @@ endif  # IDE
> >>
> >>   config LBA48
> >>      bool "Enable LBA support for disks larger than 137GB"
> >> -    depends on HAVE_BLOCK_DEVICE
> >> +    depends on SPL_LEGACY_BLOCK
> >>      help
> >>        Set this to enable support for disks larger than 137GB.
> >>        Also look at CONFIG_SYS_64BIT_LBA.  Without both of these, LBA48
> >> @@ -231,7 +231,7 @@ config LBA48
> >>
> >>   config SYS_64BIT_LBA
> >>      bool "Enable 64bit number of blocks on a block device"
> >> -    depends on HAVE_BLOCK_DEVICE
> >> +    depends on SPL_LEGACY_BLOCK
> >>      help
> >>        Make the block subsystem use 64bit sector addresses, rather than the
> >>        default of 32bit.
> >> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
> >> index b221a7c6eea..f48d3e12140 100644
> >> --- a/drivers/block/Makefile
> >> +++ b/drivers/block/Makefile
> >> @@ -6,7 +6,7 @@
> >>   obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
> >>
> >>   ifndef CONFIG_$(SPL_)BLK
> >> -obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_legacy.o
> >> +obj-$(CONFIG_SPL_LEGACY_BLOCK) += blk_legacy.o
> >>   endif
> >>
> >>   ifndef CONFIG_SPL_BUILD
> >> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> >> index c5e1a1b0981..d45ad1a541d 100644
> >> --- a/drivers/mmc/Kconfig
> >> +++ b/drivers/mmc/Kconfig
> >> @@ -3,7 +3,7 @@ menu "MMC Host controller Support"
> >>   config MMC
> >>      bool "MMC/SD/SDIO card support"
> >>      default ARM || PPC || SANDBOX
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      select DM_MMC if DM
> >>      help
> >>        This selects MultiMediaCard, Secure Digital and Secure
> >> diff --git a/drivers/nvme/Kconfig b/drivers/nvme/Kconfig
> >> index 2a103ab5ed7..7b6d54615f8 100644
> >> --- a/drivers/nvme/Kconfig
> >> +++ b/drivers/nvme/Kconfig
> >> @@ -4,7 +4,7 @@
> >>
> >>   config NVME
> >>      bool "NVM Express device support"
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        This option enables support for NVM Express devices.
> >>        It supports basic functions of NVMe (read/write).
> >> diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
> >> index 19872fb52d8..4d643816fcc 100644
> >> --- a/drivers/scsi/Kconfig
> >> +++ b/drivers/scsi/Kconfig
> >> @@ -1,6 +1,6 @@
> >>   config SCSI
> >>      bool "Support SCSI controllers"
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        This enables support for SCSI (Small Computer System Interface),
> >>        a parallel interface widely used with storage peripherals such as
> >> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> >> index 6ad2a936682..20db2c53065 100644
> >> --- a/drivers/xen/Kconfig
> >> +++ b/drivers/xen/Kconfig
> >> @@ -2,7 +2,7 @@ config PVBLOCK
> >>      bool "Xen para-virtualized block device"
> >>      depends on DM
> >>      select BLK
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >>      help
> >>        This driver implements the front-end of the Xen virtual
> >>        block device driver. It communicates with a back-end driver
> >> diff --git a/include/blk.h b/include/blk.h
> >> index 332481a90b8..5bdffe74015 100644
> >> --- a/include/blk.h
> >> +++ b/include/blk.h
> >> @@ -23,7 +23,7 @@ struct udevice;
> >>
> >>   static inline bool blk_enabled(void)
> >>   {
> >> -    return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE);
> >> +    return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_SPL_LEGACY_BLOCK);
> >>   }
> >>
> >>   /* Interface types: */
> >> diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
> >> index e3f2402d0e8..5feafc16820 100644
> >> --- a/lib/efi_loader/Kconfig
> >> +++ b/lib/efi_loader/Kconfig
> >> @@ -20,7 +20,7 @@ config EFI_LOADER
> >>      select EVENT_DYNAMIC
> >>      select LIB_UUID
> >>      imply PARTITION_UUIDS
> >> -    select HAVE_BLOCK_DEVICE
> >> +    select SPL_LEGACY_BLOCK
> >
> > I don't think we need this "select" as efi_disk implementation
> > now fully relies on U-Boot dm.
> > (Kconfig has "depends on BLK".)
> >
> > -Takahiro Akashi
>
> The UEFI sub-system does not exist in SPL. Hence there should be no SPL
> configuration flag affected.

Yes, but note this patch is just about making sure things are exactly
as they are now, just with a rename. A later patches removes this from
here.

Regards,
Simon

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 22/24] blk: Drop if_type
  2022-09-13 16:27   ` Heinrich Schuchardt
  2022-09-14  2:08     ` AKASHI Takahiro
@ 2022-09-14 17:10     ` Simon Glass
  1 sibling, 0 replies; 42+ messages in thread
From: Simon Glass @ 2022-09-14 17:10 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, AKASHI Takahiro, Ilias Apalodimas, Masahisa Kojima,
	U-Boot Mailing List

Hi Heinrich,

On Tue, 13 Sept 2022 at 10:27, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 8/12/22 03:35, Simon Glass wrote:
> > Use the uclass ID instead.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >   cmd/blk_common.c           |  2 +-
> >   drivers/block/blk-uclass.c | 34 +++++++++++++++----------------
> >   drivers/block/blk_legacy.c | 20 +++++++++----------
> >   include/blk.h              | 41 ++++++++++++++++++--------------------
> >   include/efi_loader.h       |  2 +-
> >   5 files changed, 48 insertions(+), 51 deletions(-)
> >

[..]

> >   /* EFI system partition */
> >   extern struct efi_system_partition {
> > -     enum if_type if_type;
> > +     enum uclass_id if_type;
> >       int devnum;
>
> Please, rename the field if_type to class_id in a later patch.

Yes, this is done in a later patch:

        enum uclass_id uclass_id;

>
> Uclass ID and device number may refer to a different device after
> commands like usb init. It would be better if we could use the partition
> GUID to identify a partition in the long term. But that is beyond the
> scope of this series.
>
> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>

Thanks for the review.

Regards,
Simon

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS
  2022-08-12  1:34 ` [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS Simon Glass
@ 2022-09-16 19:37   ` Tom Rini
  0 siblings, 0 replies; 42+ messages in thread
From: Tom Rini @ 2022-09-16 19:37 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Heinrich Schuchardt, AKASHI Takahiro,
	Pali Rohár, Stefan Roese

[-- Attachment #1: Type: text/plain, Size: 279 bytes --]

On Thu, Aug 11, 2022 at 07:34:40PM -0600, Simon Glass wrote:

> Fix a few typos in this help text. Fix a typo in SPL_PARTITIONS while
> we are here.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

For patches 1 through 22, applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2022-09-16 19:37 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12  1:34 [PATCH v2 00/24] blk: Rationalise the block interface Simon Glass
2022-08-12  1:34 ` [PATCH v2 01/24] disk: Correct help for TPL_PARTITIONS Simon Glass
2022-09-16 19:37   ` Tom Rini
2022-08-12  1:34 ` [PATCH v2 02/24] blk: Enable CONFIG_BLK for all media Simon Glass
2022-08-12  1:34 ` [PATCH v2 03/24] ata: Fix an instance of SPL_SATA_SUPPORT Simon Glass
2022-08-12  1:34 ` [PATCH v2 04/24] sandbox: Avoid defining HAVE_BLOCK_DEVICE in Konfig Simon Glass
2022-08-12  1:34 ` [PATCH v2 05/24] disk: Use Makefile to omit partition drivers Simon Glass
2022-08-12  1:34 ` [PATCH v2 06/24] blk: Use a function for whether block devices are available Simon Glass
2022-08-12  1:34 ` [PATCH v2 07/24] cmd: Drop use of HAVE_BLOCK_DEVICE Simon Glass
2022-08-12  1:34 ` [PATCH v2 08/24] blk: Drop unnecessary #ifdef in in blk_legacy Simon Glass
2022-08-12  1:34 ` [PATCH v2 09/24] blk: Rename HAVE_BLOCK_DEVICE Simon Glass
2022-09-14  1:42   ` AKASHI Takahiro
2022-09-14  7:34     ` Heinrich Schuchardt
2022-09-14 17:10       ` Simon Glass
2022-08-12  1:34 ` [PATCH v2 10/24] blk: Select SPL_LEGACY_BLOCK automatically Simon Glass
2022-08-12  1:34 ` [PATCH v2 11/24] blk: Drop unnecessary CONFIG_SPL_LEGACY_BLOCK in defconfigs Simon Glass
2022-08-12  1:34 ` [PATCH v2 12/24] blk: Hide the BLK and SPL_LEGACY_BLOCK options Simon Glass
2022-08-12  1:34 ` [PATCH v2 13/24] blk: Drop IF_TYPE_DOC Simon Glass
2022-08-12  1:34 ` [PATCH v2 14/24] ide: Use a flag for an ATAPI device Simon Glass
2022-08-12  1:34 ` [PATCH v2 15/24] blk: Drop IF_TYPE_ATAPI Simon Glass
2022-08-12  1:34 ` [PATCH v2 16/24] blk: Drop IF_TYPE_SD Simon Glass
2022-08-12  1:34 ` [PATCH v2 17/24] blk: Rename var in blk_get_devnum_by_typename() Simon Glass
2022-08-12  1:34 ` [PATCH v2 18/24] blk: Rewrite if_type to name functions Simon Glass
2022-08-12  1:34 ` [PATCH v2 19/24] efi: Correct assumption about if_type Simon Glass
2022-08-12  1:34 ` [PATCH v2 20/24] blk: Switch over to using uclass IDs Simon Glass
2022-08-12  1:35 ` [PATCH v2 21/24] disk: Handle UCLASS_EFI_MEDIA in dev_print() Simon Glass
2022-08-12  1:35 ` [PATCH v2 22/24] blk: Drop if_type Simon Glass
2022-09-13 16:27   ` Heinrich Schuchardt
2022-09-14  2:08     ` AKASHI Takahiro
2022-09-14  7:45       ` Heinrich Schuchardt
2022-09-14  8:20         ` AKASHI Takahiro
2022-09-14 17:10     ` Simon Glass
2022-08-12  1:35 ` [PATCH v2 23/24] efi: Drop ifname field from struct efi_disk_obj Simon Glass
2022-09-13 16:17   ` Heinrich Schuchardt
2022-08-12  1:35 ` [PATCH v2 24/24] blk: Rename if_type to uclass_id Simon Glass
2022-09-13 16:03   ` Tom Rini
2022-09-14 17:09     ` Simon Glass
2022-09-14  1:22   ` AKASHI Takahiro
2022-08-12 13:51 ` [PATCH v2 00/24] blk: Rationalise the block interface Johan Jonker
2022-08-12 15:11   ` Simon Glass
2022-08-14  6:33     ` Johan Jonker
2022-08-15 17:37       ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.