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

From: Andy Shevchenko

Date: Thu Feb 12 2026 - 15:16:10 EST


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;

> + else
> + st->vref_mv = 30000;

30 * MILLI;

Needs units.h.

--
With Best Regards,
Andy Shevchenko