[U-Boot] [PATCH 11/23] dm: part: Drop the block_drvr table

Simon Glass sjg at chromium.org
Mon Apr 11 03:12:31 CEST 2016


This is not needed since we can use the functions provided by the legacy
block device support.

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

 disk/part.c               | 67 ++++++++++-------------------------------------
 lib/efi_loader/efi_disk.c | 19 +++++++++-----
 2 files changed, 26 insertions(+), 60 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index 5d6dc68..4b850fa 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -21,34 +21,6 @@
 #define PRINTF(fmt,args...)
 #endif
 
-const struct block_drvr block_drvr[] = {
-#if defined(CONFIG_CMD_IDE)
-	{ .name = "ide", },
-#endif
-#if defined(CONFIG_CMD_SATA)
-	{.name = "sata", },
-#endif
-#if defined(CONFIG_SCSI)
-	{ .name = "scsi", },
-#endif
-#if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
-	{ .name = "usb", },
-#endif
-#if defined(CONFIG_MMC)
-	{
-		.name = "mmc",
-		.select_hwpart = mmc_select_hwpart,
-	},
-#endif
-#if defined(CONFIG_SYSTEMACE)
-	{ .name = "ace", },
-#endif
-#if defined(CONFIG_SANDBOX)
-	{ .name = "host", },
-#endif
-	{ },
-};
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
@@ -70,34 +42,23 @@ static struct part_driver *part_driver_lookup_type(int part_type)
 
 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
-	const struct block_drvr *drvr = block_drvr;
-	char *name;
+	struct blk_desc *dev_desc;
+	int ret;
 
-	if (!ifname)
+	dev_desc = blk_get_devnum_by_typename(ifname, dev);
+	if (!dev_desc) {
+		debug("%s: No device for iface '%s', dev %d\n", __func__,
+		      ifname, dev);
 		return NULL;
-
-	name = drvr->name;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-	name += gd->reloc_off;
-#endif
-	while (drvr->name) {
-		name = drvr->name;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-		name += gd->reloc_off;
-#endif
-		if (strncmp(ifname, name, strlen(name)) == 0) {
-			struct blk_desc *dev_desc;
-
-			dev_desc = blk_get_devnum_by_typename(name, dev);
-			if (!dev_desc)
-				return NULL;
-			if (blk_dselect_hwpart(dev_desc, hwpart))
-				return NULL;
-			return dev_desc;
-		}
-		drvr++;
 	}
-	return NULL;
+	ret = blk_dselect_hwpart(dev_desc, hwpart);
+	if (ret) {
+		debug("%s: Failed to select h/w partition: err-%d\n", __func__,
+		      ret);
+		return NULL;
+	}
+
+	return dev_desc;
 }
 
 struct blk_desc *blk_get_dev(const char *ifname, int dev)
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index aaff947..8a8b685 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <blk.h>
 #include <efi_loader.h>
 #include <inttypes.h>
 #include <part.h>
@@ -147,13 +148,17 @@ static const struct efi_block_io block_io_disk_template = {
  */
 int efi_disk_register(void)
 {
-	const struct block_drvr *cur_drvr;
-	int i;
+	const struct blk_driver *cur_drvr;
+	int i, if_type;
 	int disks = 0;
 
 	/* Search for all available disk devices */
-	for (cur_drvr = block_drvr; cur_drvr->name; cur_drvr++) {
-		printf("Scanning disks on %s...\n", cur_drvr->name);
+	for (if_type = 0; if_type < IF_TYPE_COUNT; if_type++) {
+		cur_drvr = blk_driver_lookup_type(if_type);
+		if (!cur_drvr)
+			continue;
+
+		printf("Scanning disks on %s...\n", cur_drvr->if_typename);
 		for (i = 0; i < 4; i++) {
 			struct blk_desc *desc;
 			struct efi_disk_obj *diskobj;
@@ -161,7 +166,7 @@ int efi_disk_register(void)
 			int objlen = sizeof(*diskobj) + (sizeof(*dp) * 2);
 			char devname[16] = { 0 }; /* dp->str is u16[16] long */
 
-			desc = blk_get_dev(cur_drvr->name, i);
+			desc = blk_get_devnum_by_type(if_type, i);
 			if (!desc)
 				continue;
 			if (desc->type == DEV_TYPE_UNKNOWN)
@@ -176,7 +181,7 @@ int efi_disk_register(void)
 			diskobj->parent.protocols[1].open = efi_disk_open_dp;
 			diskobj->parent.handle = diskobj;
 			diskobj->ops = block_io_disk_template;
-			diskobj->ifname = cur_drvr->name;
+			diskobj->ifname = cur_drvr->if_typename;
 			diskobj->dev_index = i;
 
 			/* Fill in EFI IO Media info (for read/write callbacks) */
@@ -194,7 +199,7 @@ int efi_disk_register(void)
 			dp[0].dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH;
 			dp[0].dp.length = sizeof(*dp);
 			snprintf(devname, sizeof(devname), "%s%d",
-				 cur_drvr->name, i);
+				 cur_drvr->if_typename, i);
 			ascii2unicode(dp[0].str, devname);
 
 			dp[1].dp.type = DEVICE_PATH_TYPE_END;
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list