aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-04-24 23:30:59 -0600
committerTom Rini <trini@konsulko.com>2022-04-25 10:00:03 -0400
commit6aa4fe39122a85ce1ef559139518fa5042406186 (patch)
treeeaf85bd156690a2fd2ab9a77e92ce31c53f2b35a /drivers
parent8565efd509236dc7d4e766de39edae2cefb10057 (diff)
downloadu-boot-6aa4fe39122a85ce1ef559139518fa5042406186.zip
u-boot-6aa4fe39122a85ce1ef559139518fa5042406186.tar.gz
u-boot-6aa4fe39122a85ce1ef559139518fa5042406186.tar.bz2
dm: core: Rename and fix uclass_get_by_name_len()
It seems that namelen is more common in U-Boot. Rename this function to fit in better. Also fix a bug where it breaks the operation of uclass_get_by_name() and add a test. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reported-by: Tim Harvey <tharvey@gateworks.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/uclass.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 2578803..4b9b54f 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -180,14 +180,15 @@ void uclass_set_priv(struct uclass *uc, void *priv)
uc->priv_ = priv;
}
-enum uclass_id uclass_get_by_name_len(const char *name, int len)
+enum uclass_id uclass_get_by_namelen(const char *name, int len)
{
int i;
for (i = 0; i < UCLASS_COUNT; i++) {
struct uclass_driver *uc_drv = lists_uclass_lookup(i);
- if (uc_drv && !strncmp(uc_drv->name, name, len))
+ if (uc_drv && !strncmp(uc_drv->name, name, len) &&
+ strlen(uc_drv->name) == len)
return i;
}
@@ -196,7 +197,7 @@ 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));
+ return uclass_get_by_namelen(name, strlen(name));
}
int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)