From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Santos <jonath4nns@gmail.com>
Cc: 20250825154450.75eedc9b@jic23-huawei.smtp.subspace.kernel.org,
Jonathan Santos <Jonathan.Santos@analog.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, Michael.Hennerich@analog.com,
lars@metafoo.de, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, marcelo.schmitt1@gmail.com
Subject: Re: [PATCH v2 4/4] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family
Date: Sun, 31 Aug 2025 13:30:38 +0100 [thread overview]
Message-ID: <20250831133038.026d56e2@jic23-huawei> (raw)
In-Reply-To: <aK50KITsXoPTkRbA@JSANTO12-L01.ad.analog.com>
On Tue, 26 Aug 2025 23:57:44 -0300
Jonathan Santos <jonath4nns@gmail.com> wrote:
> On 08/25, Jonathan Cameron wrote:
> > On Sun, 24 Aug 2025 01:10:13 -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 enabled and controlled by the GPIO
> > > controller (GPIOs 0, 1 and 2) provided by the device with the SPI
> > > interface.
> > >
> > > The AAF gain is defined by hardware connections and should be specified
> > > in device tree.
> > >
> > > Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
> > Hi Jonathan
> >
> > Various minor comments inline.
> >
> > Thanks,
> >
> > Jonathan
> >
> ...
> > > /* Register VCM output regulator */
> > > - ret = ad7768_register_regulators(&spi->dev, st, indio_dev);
> > > - if (ret)
> > > - return ret;
> > > + if (st->chip->has_vcm_regulator) {
> > > + ret = ad7768_register_regulators(&spi->dev, st, indio_dev);
> > > + if (ret)
> > > + return ret;
> > > + }
> > > +
> > > + st->aaf_gain = AD7768_AAF_IN1;
> > > + ret = device_property_read_u32(&spi->dev, "adi,gain-milli", &val);
> > > + if (ret && st->chip->has_variable_aaf)
> > > + dev_warn(&spi->dev, "AAF gain not specified, using default\n");
> > > +
> > > + if (!ret && !st->chip->has_variable_aaf)
> > > + dev_warn(&spi->dev, "AAF gain not supported for %s\n", st->chip->name);
> >
> > I'm confused. If you hit this warn, you then go ahead and set it anyway. How does that
> > work?
> >
>
> I would be setting a variable that will not be used, so no functional impact.
> I could add another condition to avoid assigning it, or do you believe it
> is better to return error like before?
Just don't set it to avoid confusion. Alternative would be a comment that says that
it won't be used, which is probably more complex than the code.
>
> > > +
> > > + if (!ret) {
> > use a local bool for ret here with a suitable name. Carrying on using ret is
> > fragile against later code changes where someone doesn't realise it is still in use.
> >
>
> Maybe it is better to handle this in a helper function and apply the
> suggestion.
If that works, sounds good!
J
>
> > > + /* If provided, validate and set the gain */
> > > + switch (val) {
> > > + case 1000:
> > > + st->aaf_gain = AD7768_AAF_IN1;
> > > + break;
> > > + case 364:
> > > + st->aaf_gain = AD7768_AAF_IN2;
> > > + break;
> > > + case 143:
> > > + st->aaf_gain = AD7768_AAF_IN3;
> > > + break;
> > > + default:
> > > + return dev_err_probe(&spi->dev, -EINVAL,
> > > + "Invalid firmware provided AAF gain\n");
> > > + }
> > > + }
>
> Regards,
> Jonathan S.
>
prev parent reply other threads:[~2025-08-31 12:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-24 4:10 [PATCH v2 4/4] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family Jonathan Santos
2025-08-24 19:43 ` Andy Shevchenko
2025-08-29 19:11 ` Jonathan Santos
2025-08-30 4:54 ` Andy Shevchenko
2025-08-25 14:44 ` Jonathan Cameron
2025-08-27 2:57 ` Jonathan Santos
2025-08-31 12:30 ` Jonathan Cameron [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=20250831133038.026d56e2@jic23-huawei \
--to=jic23@kernel.org \
--cc=20250825154450.75eedc9b@jic23-huawei.smtp.subspace.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=marcelo.schmitt1@gmail.com \
--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