From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Victor Chernyakin <chernyakin.victor.j@outlook.com>
Cc: cwweng.linux@gmail.com, andy@kernel.org, conor+dt@kernel.org,
cwweng@nuvoton.com, devicetree@vger.kernel.org,
dlechner@baylibre.com, jic23@kernel.org, krzk+dt@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, nuno.sa@analog.com,
robh@kernel.org
Subject: Re: [PATCH v4 2/2] iio: adc: Add Nuvoton MA35D1 EADC driver
Date: Wed, 11 Nov 2026 16:05:01 +0200 [thread overview]
Message-ID: <avR2DaxSJJwpnWP9@ashevche-desk.local> (raw)
In-Reply-To: <SN1PR12MB2528F7F6F04801AB698A5A60A5712@SN1PR12MB2528.namprd12.prod.outlook.com>
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
prev parent reply other threads:[~2026-11-11 14:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 9:11 [PATCH v4 0/2] iio: adc: Add Nuvoton MA35D1 EADC support Chi-Wen Weng
2026-11-04 9:11 ` [PATCH v4 1/2] dt-bindings: iio: adc: Add Nuvoton MA35D1 EADC Chi-Wen Weng
2026-11-07 21:10 ` Jonathan Cameron
2026-11-10 19:08 ` Rob Herring
2026-11-11 2:15 ` Chi-Wen Weng
2026-11-11 14:09 ` Rob Herring
2026-11-04 9:11 ` [PATCH v4 2/2] iio: adc: Add Nuvoton MA35D1 EADC driver Chi-Wen Weng
2026-11-04 11:50 ` Andy Shevchenko
2026-11-05 11:05 ` Chi-Wen Weng
2026-11-07 21:31 ` Jonathan Cameron
2026-11-11 2:08 ` Victor Chernyakin
2026-11-11 14:05 ` Andy Shevchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avR2DaxSJJwpnWP9@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=chernyakin.victor.j@outlook.com \
--cc=conor+dt@kernel.org \
--cc=cwweng.linux@gmail.com \
--cc=cwweng@nuvoton.com \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®