Re: [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support
From: Andy Shevchenko
Date: Thu Aug 27 2026 - 05:21:14 EST
On Thu, Aug 27, 2026 at 10:30:19AM +0200, Joshua Crofts wrote:
> On Thu, 27 Aug 2026 09:34:48 +0200
> Janani Sunil <janani.sunil@xxxxxxxxxx> wrote:
...
> > +#include <linux/array_size.h>
> > +#include <linux/bits.h>
> > +#include <linux/delay.h>
> > +#include <linux/dev_printk.h>
> > +#include <linux/err.h>
> > +#include <linux/errno.h>
> > +#include <linux/iio/iio.h>
>
> IIO specific headers should go after the generic <linux/*> headers,
> it's just convention.
>
> > +#include <linux/module.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/reset.h>
> > +#include <linux/spi/spi.h>
> > +#include <linux/types.h>
> > +#include <linux/units.h>
When it's a single header we don't strict this too much.
...
> > +static int ad5529r_write_raw(struct iio_dev *indio_dev,
> > + struct iio_chan_spec const *chan,
> > + int val, int val2, long mask)
> > +{
> > + struct ad5529r_state *st = iio_priv(indio_dev);
> > + unsigned int reg_addr;
> > +
> > + switch (mask) {
> > + case IIO_CHAN_INFO_RAW:
> > + if (val < 0 || val > GENMASK(st->model_data->resolution - 1, 0))
>
> There is a function for this - in_range(), in linux/minmax.h.
This is a trade-off and sometimes open-coded variants are okay.
I'm fine with either.
> > + return -EINVAL;
> > +
> > + reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
> > +
> > + return regmap_write(st->regmap_16bit, reg_addr, val);
> > + default:
> > + return -EINVAL;
> > + }
> > +}
--
With Best Regards,
Andy Shevchenko