From: sashiko-bot@kernel.org
To: "Antoniu Miclaus" <antoniu.miclaus@analog.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] iio: adc: ad4080: add support for AD4883
Date: Mon, 20 Jul 2026 13:58:13 +0000 [thread overview]
Message-ID: <20260720135813.7EA771F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720133707.103366-3-antoniu.miclaus@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `ad4080_get_scale` function calculates the fractional part of the scale in micro units but returns `IIO_VAL_INT_PLUS_NANO`, causing the userspace scale value to be off by a factor of 1000.
--
--- Patch [2]: [PATCH 2/2] iio: adc: ad4080: add support for AD4883 ---
commit 1f80e540484a260f71b5515f8af8d43748391d9e
Author: Antoniu Miclaus <antoniu.miclaus@analog.com>
iio: adc: ad4080: add support for AD4883
This commit adds support for the AD4883, a dual-channel, 16-bit, 40 MSPS
SAR ADC. It shares the register map and SPI interface with the AD4080
family and provides two independent ADC channels.
> diff --git a/drivers/iio/adc/ad4080.c b/drivers/iio/adc/ad4080.c
> index c7ecf6971be45..543728c7e88c0 100644
> --- a/drivers/iio/adc/ad4080.c
> +++ b/drivers/iio/adc/ad4080.c
[ ... ]
> @@ -646,6 +652,16 @@ static const struct ad4080_chip_info ad4880_chip_info = {
> .lvds_cnv_clk_cnt_max = AD4080_LVDS_CNV_CLK_CNT_MAX,
> };
>
> +static const struct ad4080_chip_info ad4883_chip_info = {
> + .name = "ad4883",
> + .product_id = AD4883_CHIP_ID,
> + .scale_table = ad4080_scale_table,
[Severity: High]
This isn't a bug introduced by this patch, but looking at how the scale table
is used in ad4080_get_scale(), is there a mismatch in the units returned?
drivers/iio/adc/ad4080.c:ad4080_get_scale() {
...
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 fractional part is calculated using modulo 1000000 (micro units)
but returned as IIO_VAL_INT_PLUS_NANO, the IIO core will format it as a
nano-scale value. Does this cause the scale exposed to userspace to be off
by a factor of 1000?
Should this return IIO_VAL_INT_PLUS_MICRO instead, or calculate with
1000000000ULL to match the NANO return type?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720133707.103366-1-antoniu.miclaus@analog.com?part=2
prev parent reply other threads:[~2026-07-20 13:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 13:37 [PATCH 0/2] iio: adc: ad4080: add support for AD4883 Antoniu Miclaus
2026-07-20 13:37 ` [PATCH 1/2] dt-bindings: iio: adc: ad4080: add AD4883 support Antoniu Miclaus
2026-07-20 13:37 ` [PATCH 2/2] iio: adc: ad4080: add support for AD4883 Antoniu Miclaus
2026-07-20 13:58 ` sashiko-bot [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=20260720135813.7EA771F00A3A@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.