dm: core: fix uclass_get_by_name
PATCH 1/1 dm: core: fix uclass_get_by_name
When calling uclass_get_by_name we want to do a full match on the uclass name, not a partial match.
--- drivers/core/uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/core/uclass.c +10 -1
@@ -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)
Signature · 1 line
2.17.1
Hi Tim,
Quoted 9 lines · Tim Harvey
When calling
uclass_get_by_namewe want to do a full match on the uclass name, not a partial match.Signed-off-by Tim Harvey <[email protected]>--- drivers/core/uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
There was already a patch for this from someone and I believe I left some comments on it. Please take a look. We should add a test also, that catches the bad behaviour.
Quoted 23 lines
drivers/core/uclass.c +10
-2@@ -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) --
Quoted 2 lines
2.17.1
Regards,
SImon
Quoted 39 lines · Simon Glass
Hi Tim,
Quoted 9 lines · Tim Harvey
When calling
uclass_get_by_namewe want to do a full match on the uclass name, not a partial match.Signed-off-by Tim Harvey <[email protected]>--- drivers/core/uclass.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)There was already a patch for this from someone and I believe I left some comments on it. Please take a look. We should add a test also, that catches the bad behaviour.
Quoted 21 lines
drivers/core/uclass.c +10
-1@@ -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 ; }
Quoted 4 lines
Quoted 4 lines
drivers/core/uclass.c +0
-1int dev_get_uclass_index (struct udevice *dev,struct uclass **ucp) --2.17.1
Simon,
Ok - I see that patch in a series from Patrick Delaunay [1]. This patch is important to fix the 'dm bind' command.
Patrick - any follow-up on that series?
Best regards,
Tim
Tim
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=281477&state=*