Re: [PATCH v1 2/2] iio: dac: ad5504: use adi,output-range-volts for scale calculation

From: Jonathan Cameron

Date: Sun Feb 15 2026 - 13:05:53 EST


On Thu, 12 Feb 2026 22:15:55 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> 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.
>