Messages in this thread | | | Date | Wed, 18 Jan 2023 15:22:42 +0200 | From | Andy Shevchenko <> | Subject | Re: [PATCH v2 1/1] iio: adc: qcom-spmi-adc5: Fix the channel name |
| |
On Wed, Jan 18, 2023 at 01:35:28PM +0100, Marijn Suijten wrote: > On 2023-01-18 12:06:23, Andy Shevchenko wrote: > > The node name can contain an address part which is unused > > by the driver. Moreover, this string is propagated into > > the userspace label, sysfs filenames *and breaking ABI*. > > > > Cut the address part out before assigning the channel name. > > > > Fixes: 4f47a236a23d ("iio: adc: qcom-spmi-adc5: convert to device properties") > > Reported-by: Marijn Suijten <marijn.suijten@somainline.org> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>
Thank you!
My answers below.
...
> > + name = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", fwnode); > > Is this better/cleaner than copying the string from fwnode_get_name?
Coying to where? And what would be the lifetime of that string?
With devm_kasprintf(): - we don't care how long the string is - we don't care about corner cases of lifetime as it's the same as device itself (i.o.w. the same as the IIO device container)
...
> > + name[strchrnul(name, '@') - name] = '\0'; > > This is the same as *strchrnul(name, '@') = '\0'; if I'm not mistaken.
Yes, But it's harder to read and understand. I believe the compiler has enough power to optimize this to the same assembly code.
-- With Best Regards, Andy Shevchenko
| |