[PATCH] dm: core: fix uclass_get_by_name

Tim Harvey tharvey at gateworks.com
Wed Feb 16 20:07:46 CET 2022


On Wed, Feb 16, 2022 at 11:00 AM Simon Glass <sjg at chromium.org> wrote:
>
> Hi Tim,
>
> On Wed, 16 Feb 2022 at 08:57, Tim Harvey <tharvey at gateworks.com> wrote:
> >
> > 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(-)
> >
>
> 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.
>
> > 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
> >

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=*


More information about the U-Boot mailing list