From: Chi-Wen Weng <cwweng.linux@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>,
Victor Chernyakin <chernyakin.victor.j@outlook.com>
Cc: 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: Thu, 12 Nov 2026 09:26:00 +0800 [thread overview]
Message-ID: <c52e7b57-9d40-456c-a2f6-545c0bca9b46@gmail.com> (raw)
In-Reply-To: <avR2DaxSJJwpnWP9@ashevche-desk.local>
Andy Shevchenko 於 2026/11/11 下午 10:05 寫道:
> 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().
>
Thanks Victor and Andy for the discussion.
I'll keep size_add() for consistency and future-proofing, as Andy suggested.
Thanks,
Chi-Wen
next prev parent reply other threads:[~2026-11-12 1:26 UTC|newest]
Thread overview: 14+ 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
2026-11-12 1:26 ` Chi-Wen Weng [this message]
2026-11-11 17:10 ` Victor Chernyakin
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=c52e7b57-9d40-456c-a2f6-545c0bca9b46@gmail.com \
--to=cwweng.linux@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=chernyakin.victor.j@outlook.com \
--cc=conor+dt@kernel.org \
--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®