All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] blk: simplify blk_get_devnum_by_typename()
@ 2021-10-23 14:06 Heinrich Schuchardt
  2021-10-24 19:54 ` Simon Glass
  0 siblings, 1 reply; 14+ messages in thread
From: Heinrich Schuchardt @ 2021-10-23 14:06 UTC (permalink / raw)
  To: Simon Glass
  Cc: Patrick Delaunay, Ilias Apalodimas, u-boot, Heinrich Schuchardt

The block descriptor contains the if_type. There is no need to first look
up the uclass for the if_type and then to check the parent device's uclass
to know if the device has the correct if_type.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 drivers/block/blk-uclass.c | 35 +----------------------------------
 1 file changed, 1 insertion(+), 34 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 83682dcc18..b32067f957 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -33,22 +33,6 @@ static const char *if_typename_str[IF_TYPE_COUNT] = {
 	[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_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,
-	[IF_TYPE_HOST]		= UCLASS_ROOT,
-	[IF_TYPE_NVME]		= UCLASS_NVME,
-	[IF_TYPE_EFI]		= UCLASS_EFI,
-	[IF_TYPE_VIRTIO]	= UCLASS_VIRTIO,
-	[IF_TYPE_PVBLOCK]	= UCLASS_PVBLOCK,
-};
-
 static enum if_type if_typename_to_iftype(const char *if_typename)
 {
 	int i;
@@ -62,11 +46,6 @@ static enum if_type if_typename_to_iftype(const char *if_typename)
 	return IF_TYPE_UNKNOWN;
 }
 
-static enum uclass_id if_type_to_uclass_id(enum if_type if_type)
-{
-	return if_type_uclass_id[if_type];
-}
-
 const char *blk_get_if_type_name(enum if_type if_type)
 {
 	return if_typename_str[if_type];
@@ -93,7 +72,6 @@ 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;
 	struct udevice *dev;
 	struct uclass *uc;
@@ -105,12 +83,6 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 		      if_typename);
 		return NULL;
 	}
-	uclass_id = if_type_to_uclass_id(if_type);
-	if (uclass_id == UCLASS_INVALID) {
-		debug("%s: Unknown uclass for interface type'\n",
-		      if_typename_str[if_type]);
-		return NULL;
-	}
 
 	ret = uclass_get(UCLASS_BLK, &uc);
 	if (ret)
@@ -122,13 +94,8 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
 		      if_type, devnum, dev->name, desc->if_type, desc->devnum);
 		if (desc->devnum != devnum)
 			continue;
-
-		/* Find out the parent device uclass */
-		if (device_get_uclass_id(dev->parent) != uclass_id) {
-			debug("%s: parent uclass %d, this dev %d\n", __func__,
-			      device_get_uclass_id(dev->parent), uclass_id);
+		if (desc->if_type != if_type)
 			continue;
-		}
 
 		if (device_probe(dev))
 			return NULL;
-- 
2.32.0


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

end of thread, other threads:[~2021-11-13  9:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-23 14:06 [PATCH 1/1] blk: simplify blk_get_devnum_by_typename() Heinrich Schuchardt
2021-10-24 19:54 ` Simon Glass
2021-10-25  7:54   ` Heinrich Schuchardt
2021-10-25  8:00     ` Heinrich Schuchardt
2021-10-25 15:18       ` Simon Glass
2021-10-25 15:44         ` Heinrich Schuchardt
2021-10-25 17:29           ` Simon Glass
2021-10-25 18:41             ` Heinrich Schuchardt
2021-10-25 19:03               ` Simon Glass
2021-10-25 19:37                 ` Heinrich Schuchardt
2021-10-25 19:45                   ` Heinrich Schuchardt
2021-10-25 19:46                   ` Simon Glass
2021-11-13  9:05                     ` Heinrich Schuchardt
2021-10-25 15:46         ` Tom Rini

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.