Re: [PATCH v1 08/14] extcon: Switch to use kasprintf_strarray()

From: Andy Shevchenko
Date: Wed Apr 05 2023 - 11:05:54 EST


On Wed, Apr 05, 2023 at 11:16:36AM +0300, Andy Shevchenko wrote:
> On Mon, Apr 03, 2023 at 11:58:41PM +0900, Chanwoo Choi wrote:
> > On 23. 3. 22. 23:39, Andy Shevchenko wrote:
> > > Since we have a generic helper, switch the module to use it.
> > > No functional change intended.

...

> > > + edev->cable_names = kasprintf_strarray(GFP_KERNEL, "cable", edev->max_supported);
> > > + if (!edev->cable_names) {
> > > + kfree(edev->cables);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > for (index = 0; index < edev->max_supported; index++) {
> > > cable = &edev->cables[index];
> > >
>
> > > + str = edev->cable_names[index];
> > > + strreplace(str, '-', '.');
> > >
> > > cable->edev = edev;
> > > cable->cable_index = index;
>
> ...
>
> > > /* /sys/class/extcon/.../cable.n/... */
> > > struct device_type extcon_dev_type;
> > > struct extcon_cable *cables;
> > > + char **cable_names;
> >
> > The extcon cable information should be included in struct extcon_cable
> > in order to gather information into one point like encapsulation.
> >
> > I don't prefer to add 'cable_names'.
>
> I don't get this. The idea is to allocate the cable names in one call,
> we have already API for that. The cable names are kept in the struct
> extcon_cable as before. So, functionally it doesn't change anything,
> it is a simple cleanup.

Okay, I see now your point. I can redo this a bit better I think.

--
With Best Regards,
Andy Shevchenko