[PATCH v4 2/2] iio: adc: Add Nuvoton MA35D1 EADC driver
Andy Shevchenko
andriy.shevchenko at intel.com
Wed Nov 11 06:05:01 PST 2026
On Tue, Nov 10, 2026 at 08:08:03PM -0600, Victor Chernyakin wrote:
...
> > + if (!num_channels)
> > + return dev_err_probe(dev, -ENOENT, "no ADC channels configured\n");
> > +
> > + if (num_channels > MA35D1_EADC_MAX_EXT_CHANNELS)
> > + return dev_err_probe(dev, -ENOSPC, "too many ADC channels\n");
> > +
> > + channels = devm_kcalloc(dev, size_add(num_channels, 1),
> > + sizeof(*channels), GFP_KERNEL);
>
> Couldn't size_add() just be regular +?
> (Question to Andy who originally suggested it)
> We've just checked that num_channels is small and won't overflow.
While that's true, the other aspect(s) of this is in play. Namely we want to
have the same pattern over the kernel that makes code robust (tomorrow some
cases can be modified unnoticed with opening such an issue again) along with
the potential of finding those patterns and update in case of mass-updates
of low-level API, and I have heard for the matter of fact that devm_*alloc*()
are in the plans to move to something like k*alloc_obj*() or k*alloc_flex().
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list