Re: [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support

Andy Shevchenko <[email protected]>
Newsgroups org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-spi
Organization Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo
Message-ID <[email protected]>
On Thu, Aug 27, 2026 at 10:30:19AM +0200, Joshua Crofts wrote:
> On Thu, 27 Aug 2026 09:34:48 +0200
> Janani Sunil <[email protected]> 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



_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.