Re: [PATCH v4 11/17] iio: adc: ad7768-1: add regulator to control VCM output

From: Jonathan Cameron
Date: Sat Mar 08 2025 - 08:08:54 EST


On Fri, 7 Mar 2025 11:32:54 -0300
Marcelo Schmitt <marcelo.schmitt1@xxxxxxxxx> wrote:

> Looks ok. One minor commnet inline.
>
> On 03/06, Jonathan Santos wrote:
> > The VCM output voltage can be used as a common-mode voltage within the
> > amplifier preconditioning circuits external to the AD7768-1.
> >
> > This change allows the user to configure VCM output using the regulator
> > framework.
> >
> > Signed-off-by: Jonathan Santos <Jonathan.Santos@xxxxxxxxxx>
>
> Acked-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>


...

> > diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
> > index e88e9431bb7a..2a6317f5b582 100644
> > --- a/drivers/iio/adc/ad7768-1.c
> > +++ b/drivers/iio/adc/ad7768-1.c
> > @@ -12,8 +12,10 @@
> > #include <linux/gpio/consumer.h>
> > #include <linux/kernel.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
> > #include <linux/regmap.h>
> > #include <linux/regulator/consumer.h>
> > +#include <linux/regulator/driver.h>
> > #include <linux/sysfs.h>
> > #include <linux/spi/spi.h>
> >
> > @@ -80,9 +82,15 @@
> > #define AD7768_CONV_MODE_MSK GENMASK(2, 0)
> > #define AD7768_CONV_MODE(x) FIELD_PREP(AD7768_CONV_MODE_MSK, x)
> >
> > +/* AD7768_REG_ANALOG2 */
> > +#define AD7768_REG_ANALOG2_VCM_MSK GENMASK(2, 0)
> > +#define AD7768_REG_ANALOG2_VCM(x) FIELD_PREP(AD7768_REG_ANALOG2_VCM_MSK, x)
>
> Should we enforce macro argument evaluation here?
> #define AD7768_REG_ANALOG2_VCM(x) FIELD_PREP(AD7768_REG_ANALOG2_VCM_MSK, (x))
>
Yes. Seems there is another case above as well that needs fixing up.

> > +
> > #define AD7768_RD_FLAG_MSK(x) (BIT(6) | ((x) & 0x3F))
> > #define AD7768_WR_FLAG_MSK(x) ((x) & 0x3F)
> >