summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-09-16 15:35:47 -0400
committerTom Rini <[email protected]>2022-09-16 15:35:47 -0400
commite17213b781ca86b40d2432aac1c6481308cff396 (patch)
treecce42cf3f4efee4ef239560c0a3c8eeb0ec47110 /disk
parent6ec7207ab3c4dad098967fef5df75e25240fd852 (diff)
parentec8bdc914c8328993cee62e01b4107b802cf45cc (diff)
Merge branch '2022-09-16-rationalize-the-block-interface' into next
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.
Diffstat (limited to 'disk')
-rw-r--r--disk/Kconfig8
-rw-r--r--disk/Makefile4
-rw-r--r--disk/disk-uclass.c3
-rw-r--r--disk/part.c151
-rw-r--r--disk/part_amiga.c4
-rw-r--r--disk/part_dos.c4
-rw-r--r--disk/part_efi.c3
-rw-r--r--disk/part_iso.c3
-rw-r--r--disk/part_mac.c3
9 files changed, 71 insertions, 112 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"
diff --git a/disk/Makefile b/disk/Makefile
index ec148832b33..45588cf66e4 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 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
obj-$(CONFIG_$(SPL_TPL_)AMIGA_PARTITION) += part_amiga.o
obj-$(CONFIG_$(SPL_TPL_)EFI_PARTITION) += part_efi.o
+endif
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/disk/part.c b/disk/part.c
index 79955c7fb00..5705c229d59 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
/* ------------------------------------------------------------------------- */
/*
@@ -120,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 */
@@ -130,39 +121,37 @@ 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_ATAPI:
- 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_SD:
- 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_DOC:
- puts("device type DOC\n");
- return;
- case IF_TYPE_UNKNOWN:
+ case UCLASS_EFI_MEDIA:
+ printf("EFI media Block Device %d\n", dev_desc->devnum);
+ break;
+ case UCLASS_INVALID:
puts("device type unknown\n");
return;
default:
@@ -228,9 +217,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)
{
@@ -263,40 +249,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_ATAPI:
- puts ("ATAPI");
- break;
- case IF_TYPE_USB:
+ case UCLASS_USB:
puts ("USB");
break;
- case IF_TYPE_DOC:
- puts ("DOC");
- 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:
@@ -325,38 +305,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 +402,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 == UCLASS_MMC)
+ part_init(*dev_desc);
+ }
cleanup:
free(dup_str);
@@ -785,22 +763,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 IF_TYPE_ATAPI:
+ 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_DOC:
- devtype = "docd";
- break;
- case IF_TYPE_MMC:
- case IF_TYPE_SD:
+ case UCLASS_MMC:
devtype = "mmcsd";
break;
default:
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