Re: [PATCH v4 1/8] iio: adc: ad7606: add 'bits' parameter to channels macros
From: Alexandru Ardelean
Date: Fri Sep 06 2024 - 01:11:06 EST
On Fri, Sep 6, 2024 at 12:25 AM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
>
> On 9/5/24 3:23 AM, Alexandru Ardelean wrote:
> > There are some newer additions to the AD7606 family, which support 18 bit
> > precision.
> > Up until now, all chips were 16 bit.
> >
> > This change adds a 'bits' parameter to the AD760X_CHANNEL macro and renames
> > 'ad7606_channels' -> 'ad7606_channels_16bit' for the current devices.
> >
> > The AD7606_SW_CHANNEL() macro is also introduced, as a short-hand for IIO
> > channels in SW mode.
> >
> > Signed-off-by: Alexandru Ardelean <aardelean@xxxxxxxxxxxx>
> > ---
>
> ...
>
> > diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> > index 0c6a88cc4695..771121350f98 100644
> > --- a/drivers/iio/adc/ad7606.h
> > +++ b/drivers/iio/adc/ad7606.h
> > @@ -8,7 +8,7 @@
> > #ifndef IIO_ADC_AD7606_H_
> > #define IIO_ADC_AD7606_H_
> >
> > -#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all) { \
> > +#define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all, bits) { \
> > .type = IIO_VOLTAGE, \
> > .indexed = 1, \
> > .channel = num, \
> > @@ -19,24 +19,26 @@
> > .scan_index = num, \
> > .scan_type = { \
> > .sign = 's', \
> > - .realbits = 16, \
> > - .storagebits = 16, \
> > + .realbits = (bits), \
> > + .storagebits = (bits), \
>
> Technically OK in this patch since bits is still always 16 but we
> can avoid changing the same line again later to:
>
> (bits) > 16 ? 32 : 16
>
> if we just do that in this patch.
sure
will update
>
>
> > .endianness = IIO_CPU, \
> > }, \
> > }