diff mbox series

[U-Boot] drivers: core: use strcmp when find device by name

Message ID 20190428095656.32495-1-peng.fan@nxp.com
State Superseded
Delegated to: Simon Glass
Headers show
Series [U-Boot] drivers: core: use strcmp when find device by name | expand

Commit Message

Peng Fan April 28, 2019, 9:43 a.m. UTC
`if (!strncmp(dev->name, name, strlen(name)))` might find out
the wrong device, it might find out `dram_pll_ref_sel`, when name is
`dram_pll`. So use strcmp to avoid such issue.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/core/uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass May 7, 2019, 3:52 a.m. UTC | #1
On Sun, 28 Apr 2019 at 03:43, Peng Fan <peng.fan@nxp.com> wrote:
>
> `if (!strncmp(dev->name, name, strlen(name)))` might find out
> the wrong device, it might find out `dram_pll_ref_sel`, when name is
> `dram_pll`. So use strcmp to avoid such issue.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/core/uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

This seems to match the function description in the header file, too.
Peng Fan May 15, 2019, 11:57 a.m. UTC | #2
Hi Simon,

> Subject: Re: [PATCH] drivers: core: use strcmp when find device by name
> 
> On Sun, 28 Apr 2019 at 03:43, Peng Fan <peng.fan@nxp.com> wrote:
> >
> > `if (!strncmp(dev->name, name, strlen(name)))` might find out the
> > wrong device, it might find out `dram_pll_ref_sel`, when name is
> > `dram_pll`. So use strcmp to avoid such issue.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/core/uclass.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> This seems to match the function description in the header file, too.

Will you pick up this patch? Not see this patch in your tree.

Thanks,
Peng.
Simon Glass May 20, 2019, 12:16 p.m. UTC | #3
Hi Peng,

On Wed, 15 May 2019 at 05:57, Peng Fan <peng.fan@nxp.com> wrote:
>
> Hi Simon,
>
> > Subject: Re: [PATCH] drivers: core: use strcmp when find device by name
> >
> > On Sun, 28 Apr 2019 at 03:43, Peng Fan <peng.fan@nxp.com> wrote:
> > >
> > > `if (!strncmp(dev->name, name, strlen(name)))` might find out the
> > > wrong device, it might find out `dram_pll_ref_sel`, when name is
> > > `dram_pll`. So use strcmp to avoid such issue.
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > >  drivers/core/uclass.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> > This seems to match the function description in the header file, too.
>
> Will you pick up this patch? Not see this patch in your tree.

I found that this causes a test failure - can you try 'make qcheck'
and see if you can figure out what is going on?

Regards,
Simon
Peng Fan May 22, 2019, 7:10 a.m. UTC | #4
Hi Simon,

> Subject: Re: [PATCH] drivers: core: use strcmp when find device by name
> 
> Hi Peng,
> 
> On Wed, 15 May 2019 at 05:57, Peng Fan <peng.fan@nxp.com> wrote:
> >
> > Hi Simon,
> >
> > > Subject: Re: [PATCH] drivers: core: use strcmp when find device by
> > > name
> > >
> > > On Sun, 28 Apr 2019 at 03:43, Peng Fan <peng.fan@nxp.com> wrote:
> > > >
> > > > `if (!strncmp(dev->name, name, strlen(name)))` might find out the
> > > > wrong device, it might find out `dram_pll_ref_sel`, when name is
> > > > `dram_pll`. So use strcmp to avoid such issue.
> > > >
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > > ---
> > > >  drivers/core/uclass.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > Reviewed-by: Simon Glass <sjg@chromium.org>
> > >
> > > This seems to match the function description in the header file, too.
> >
> > Will you pick up this patch? Not see this patch in your tree.
> 
> I found that this causes a test failure - can you try 'make qcheck'
> and see if you can figure out what is going on?

With this patch applied. Test/dm/adc.c and usb.c needs some change to
use real device name. I just posted out new patchset including this one.

Pease review.

Thanks,
Peng

> 
> Regards,
> Simon
diff mbox series

Patch

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index fc3157de39..e2f35393a9 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -260,7 +260,7 @@  int uclass_find_device_by_name(enum uclass_id id, const char *name,
 		return ret;
 
 	uclass_foreach_dev(dev, uc) {
-		if (!strncmp(dev->name, name, strlen(name))) {
+		if (!strcmp(dev->name, name)) {
 			*devp = dev;
 			return 0;
 		}