From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Taha Ed-Dafili" <0rayn.dev@gmail.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-mentees@lists.linuxfoundation.org, me@brighamcampbell.com,
skhan@linuxfoundation.org
Subject: Re: [PATCH v1 2/2] iio: dac: ad5504: use adi,output-range-volts for scale calculation
Date: Sun, 15 Feb 2026 18:05:38 +0000 [thread overview]
Message-ID: <20260215180538.36f536aa@jic23-huawei> (raw)
In-Reply-To: <aY40-0v9tbXC4tPY@smile.fi.intel.com>
On Thu, 12 Feb 2026 22:15:55 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Thu, Feb 12, 2026 at 07:19:55PM +0100, Taha Ed-Dafili wrote:
> > The driver previously used VCC to calculate the scale, but the datasheet
> > states the output range is fixed by the R_SEL pin (0-30V or 0-60V).
> >
> > Update probe to read `adi,output-range-volts` for the scale. Default
> > to the 60V range if the property is missing, while keeping the VCC
> > regulator enable for power.
>
> ...
>
> > #include <linux/regulator/consumer.h>
> > #include <linux/module.h>
> > #include <linux/bitops.h>
> > +#include <linux/property.h>
>
> Add it before 'linux/s*.h' includes to make less ordering issues.
> Ideally one additional patch to sort the headers and one to replace
> "proxy" headers (following IWYU principle).
>
> ...
>
> > + ret = device_property_read_u32(&spi->dev, "adi,output-range-volts", &val);
>
> You can pack this into 80 limit with help of
>
> struct device *dev = &spi->dev;
>
> being defined in the top of the function.
>
> > + if (ret)
> > + val = 60;
>
> Also this seems an optional, so
>
> val = 60;
> device_property_read_u32(dev, "adi,output-range-volts", &val);
>
> would be enough.
>
> ...
>
> > + if (val == 60)
> > + st->vref_mv = 60000;
>
> 60 * MILLI;
val * MILLI
given it only takes the values 30 and 60 I think. If you want to protect
against other values, then check it explicitly rather than everything than
isn't 60 being assumed to be 30.
Thanks,
J
>
> > + else
> > + st->vref_mv = 30000;
>
> 30 * MILLI;
>
> Needs units.h.
>
next prev parent reply other threads:[~2026-02-15 18:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 18:19 [PATCH v1 0/2] iio: dac: ad5504: fix voltage scaling and add missing bindings Taha Ed-Dafili
2026-02-12 18:19 ` [PATCH v1 1/2] dt-bindings: iio: dac: ad5504: add output-range and missing gpios Taha Ed-Dafili
2026-02-13 8:11 ` Krzysztof Kozlowski
2026-02-13 17:05 ` Taha Ed-Dafili
2026-02-13 17:07 ` Krzysztof Kozlowski
2026-02-12 18:19 ` [PATCH v1 2/2] iio: dac: ad5504: use adi,output-range-volts for scale calculation Taha Ed-Dafili
2026-02-12 20:15 ` Andy Shevchenko
2026-02-13 17:05 ` Taha Ed-Dafili
2026-02-15 18:03 ` Jonathan Cameron
2026-02-15 18:05 ` Jonathan Cameron [this message]
2026-02-16 7:21 ` Andy Shevchenko
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=20260215180538.36f536aa@jic23-huawei \
--to=jic23@kernel.org \
--cc=0rayn.dev@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mentees@lists.linuxfoundation.org \
--cc=me@brighamcampbell.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.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