[PATCH] dm: core: fix uclass_get_by_name

Tim Harvey tharvey at gateworks.com
Wed Feb 16 16:57:05 CET 2022


When calling uclass_get_by_name we want to do a full match on the uclass
name, not a partial match.

Signed-off-by: Tim Harvey <tharvey at gateworks.com>
---
 drivers/core/uclass.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 2578803b7a4d..82efefae5265 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -196,7 +196,16 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)
 
 enum uclass_id uclass_get_by_name(const char *name)
 {
-	return uclass_get_by_name_len(name, strlen(name));
+	int i;
+
+	for (i = 0; i < UCLASS_COUNT; i++) {
+		struct uclass_driver *uc_drv = lists_uclass_lookup(i);
+
+		if (uc_drv && !strcmp(uc_drv->name, name))
+			return i;
+	}
+
+	return UCLASS_INVALID;
 }
 
 int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
-- 
2.17.1



More information about the U-Boot mailing list