Re: [PATCH v2 07/17] drivers: Introduce dev_set_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 11, 2018 at 1:56 AM Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> wrote:
>
> On Tue, Oct 09, 2018 at 07:57:27PM -0700, Andrey Smirnov wrote:
> > On Tue, Oct 9, 2018 at 10:38 AM Andrey Smirnov <andrew.smirnov@xxxxxxxxx> wrote:
> > > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > > index c43a4bde2..c25498bf4 100644
> > > --- a/drivers/base/driver.c
> > > +++ b/drivers/base/driver.c
> > > @@ -468,16 +468,57 @@ EXPORT_SYMBOL(dummy_probe);
> > >
> > >  const char *dev_id(const struct device_d *dev)
> > >  {
> > > -       static char buf[MAX_DRIVER_NAME + 16];
> > > +       static char *buf;
> > > +       int err;
> > > +
> > > +       if (buf)
> > > +               free(buf);
> >
> > Ugh, I just realized that original implementation of this function
> > didn't work right for constructs like
> >
> > https://git.pengutronix.de/cgit/barebox/tree/drivers/mci/mci-core.c#n1826
> >
> > because the result of calling dev_name() for one of the arguments
> > would get clobbered by the call to dev_name() inside of dev_info().
> > Switching to heap allocated memory only makes things worse.
> >
> > Sascha, one solution for this that I can see is to just return
> > dev->name for the case of dev->id == DEVICE_ID_SINGLE and add a
> > "_name" field to struct device_d that can be lazily filled with device
> > name + ID string for dev->id != DEVICE_ID_SINGLE and returned as
> > result.
>
> Not sure if "name" and "_name" are good names, but generally I think we
> can do it that way.

OK, I'll call them "name" and "unique_name" correspondingly them and
let you fix it up when applying if you have something better in mind.

> Could you split this patch up into two and in the first one just add a
> dev_set_name function which sprintf() into the string array and converts
> the users and only in the second patch do the conversion to an allocated
> dev->name?
>

Sure, sounds good. Will do in v3.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux