From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <lars@metafoo.de>,
<Michael.Hennerich@analog.com>, <dlechner@baylibre.com>,
<nuno.sa@analog.com>, <andy@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<jonath4nns@gmail.com>
Subject: Re: [PATCH v6 5/5] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family
Date: Fri, 16 Jan 2026 18:52:00 +0000 [thread overview]
Message-ID: <20260116185200.38be8bc7@jic23-huawei> (raw)
In-Reply-To: <fd9acf8fca67679a33441ea18d1d06b2aa2c5fad.1768350772.git.Jonathan.Santos@analog.com>
On Wed, 14 Jan 2026 06:27:29 -0300
Jonathan Santos <Jonathan.Santos@analog.com> wrote:
> Add support for ADAQ7767/68/69-1 series, which includes PGIA and
> Anti-aliasing filter (AAF) gains. Unlike the AD7768-1, they do not
> provide a VCM regulator interface.
>
> The PGA gain is configured in run-time through the scale attribute,
> if supported by the device. PGA is controlled by GPIOs provided in
> the device tree.
>
> The AAF gain is defined by hardware connections and should be specified
> in the device tree.
>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Hi Jonathan,
See inline. One small thing I am fine fixing up whilst applying
if nothing else comes up.
thanks,
Jonathan
> ---
> diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> index bd4b2e090c5b..980c079ab41a 100644
> --- a/drivers/iio/adc/ad7768-1.c
> +++ b/drivers/iio/adc/ad7768-1.c
> +static void ad7768_fill_scale_tbl(struct iio_dev *dev)
> +{
> + struct ad7768_state *st = iio_priv(dev);
> + const struct iio_scan_type *scan_type;
> + int val, val2, tmp0, tmp1, i;
> + struct u32_fract fract;
> + unsigned long n, d;
> + u64 tmp2;
> +
> + scan_type = iio_get_current_scan_type(dev, &dev->channels[0]);
> + if (scan_type->sign == 's')
> + val2 = scan_type->realbits - 1;
> + else
> + val2 = scan_type->realbits;
> +
> + for (i = 0; i < st->chip->num_pga_modes; i++) {
> + /* Convert gain to a fraction format */
> + fract.numerator = st->chip->pga_gains[i];
> + fract.denominator = MILLI;
> + if (st->chip->has_variable_aaf) {
> + fract.numerator *= ad7768_aaf_gains_bp[st->aaf_gain];
> + fract.denominator *= PERMYRIAD;
> + }
> +
> + rational_best_approximation(fract.numerator, fract.denominator,
> + INT_MAX, INT_MAX, &n, &d);
> +
> + val = mult_frac(st->vref_uv, d, n);
> + /* Would multiply by NANO here, but value is already in milli */
> + tmp2 = ((u64)val * MICRO) >> val2;
> + tmp0 = div_u64_rem(tmp2, NANO, &tmp1);
> + st->scale_tbl[i][0] = tmp0; /* Integer part */
> + st->scale_tbl[i][1] = abs(tmp1); /* Fractional part */
How does remainder from div_u64_rem() end up other than positive?
That divides a u64 by a u32 and takes a u32 * for that final parameter.
Changing the type of tmp1 to u32 should do the job. Given we do the divisor
is big enough, this can't be something subtle with the top bit set
(if it were it would need a comment!)
If nothing else comes up I can do that whilst applying
(I'll wait on Andy having a chance to sanity check the PERMYRIAD stuff anyway).
> + }
> +}
> +
next prev parent reply other threads:[~2026-01-16 18:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 9:26 [PATCH v6 0/5] Add support for ADAQ776x-1 ADC Family Jonathan Santos
2026-01-14 9:26 ` [PATCH v6 1/5] dt-bindings: iio: adc: ad7768-1: add new supported parts Jonathan Santos
2026-01-14 9:26 ` [PATCH v6 2/5] iio: adc: ad7768-1: introduce chip info for future multidevice support Jonathan Santos
2026-01-14 9:27 ` [PATCH v6 3/5] units: add conversion macros for percentage related units Jonathan Santos
2026-01-19 7:54 ` Andy Shevchenko
2026-01-19 7:57 ` Andy Shevchenko
2026-01-14 9:27 ` [PATCH v6 4/5] iio: adc: ad7768-1: refactor ad7768_write_raw() Jonathan Santos
2026-01-14 9:27 ` [PATCH v6 5/5] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family Jonathan Santos
2026-01-16 18:52 ` Jonathan Cameron [this message]
2026-01-19 8:06 ` Andy Shevchenko
2026-01-22 19:25 ` [PATCH v6 0/5] Add " 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=20260116185200.38be8bc7@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Santos@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jonath4nns@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--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