From: sashiko-bot@kernel.org
To: "Antoniu Miclaus" <antoniu.miclaus@analog.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] iio: adc: ad4080: add support for AD4884
Date: Fri, 22 May 2026 12:20:17 +0000 [thread overview]
Message-ID: <20260522122017.CE3391F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260522115337.18188-3-antoniu.miclaus@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incorrect IIO scale calculation results in a factor of 1000 error for exposed voltage scales.
--
commit ec9f31937338c4b8462c0623182623b90d6e39ad
Author: Antoniu Miclaus <antoniu.miclaus@analog.com>
iio: adc: ad4080: add support for AD4884
Add support for the AD4884, a dual-channel, 16-bit, 40 MSPS SAR ADC.
> diff --git a/drivers/iio/adc/ad4080.c b/drivers/iio/adc/ad4080.c
> index 265d85ac171a9..764d49eca9e0e 100644
> --- a/drivers/iio/adc/ad4080.c
> +++ b/drivers/iio/adc/ad4080.c
[ ... ]
> @@ -541,6 +542,11 @@ static const struct iio_chan_spec ad4880_channels[] = {
> AD4880_CHANNEL_DEFINE(20, 32, 1),
> };
>
> +static const struct iio_chan_spec ad4884_channels[] = {
> + AD4880_CHANNEL_DEFINE(16, 16, 0),
> + AD4880_CHANNEL_DEFINE(16, 16, 1),
> +};
> +
[Severity: High]
This isn't a bug introduced by this patch, but I noticed that when the channel
exposes the scale attribute, the calculation in ad4080_get_scale() seems
mathematically incorrect:
drivers/iio/adc/ad4080.c:ad4080_get_scale() {
unsigned int tmp;
tmp = (st->info->scale_table[0][0] * 1000000ULL) >>
st->info->channels[0].scan_type.realbits;
*val = tmp / 1000000;
*val2 = tmp % 1000000;
return IIO_VAL_INT_PLUS_NANO;
}
Since the fraction is calculated by multiplying by 1,000,000 and then using
modulo 1,000,000, val2 holds micro units.
However, IIO_VAL_INT_PLUS_NANO tells the IIO core to format val2 as nano
units (billionths).
Does this mismatch cause the sysfs scale attribute to expose a value that is
exactly 1000 times smaller than intended for these channels?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260522115337.18188-1-antoniu.miclaus@analog.com?part=2
next prev parent reply other threads:[~2026-05-22 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 11:53 [PATCH 0/2] iio: adc: ad4080: add support for AD4884 Antoniu Miclaus
2026-05-22 11:53 ` [PATCH 1/2] dt-bindings: iio: adc: ad4080: add AD4884 support Antoniu Miclaus
2026-05-22 12:32 ` Jonathan Cameron
2026-05-22 16:10 ` Conor Dooley
2026-05-22 11:53 ` [PATCH 2/2] iio: adc: ad4080: add support for AD4884 Antoniu Miclaus
2026-05-22 12:20 ` sashiko-bot [this message]
2026-05-22 12:33 ` Jonathan Cameron
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=20260522122017.CE3391F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.