Re: [PATCH v1 2/2] iio: dac: ad5504: use adi,output-range-volts for scale calculation
From: Andy Shevchenko
Date: Mon Feb 16 2026 - 02:22:19 EST
On Sun, Feb 15, 2026 at 06:05:38PM +0000, Jonathan Cameron wrote:
> 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:
...
> > > + 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.
With comment on DT in mind I think this multiplication will gone
(as IIUC the DT units is microvolts or so).
> > > + else
> > > + st->vref_mv = 30000;
> >
> > 30 * MILLI;
> >
> > Needs units.h.
--
With Best Regards,
Andy Shevchenko