Re: [PATCH v3 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0
From: Andy Shevchenko
Date: Tue Mar 31 2026 - 07:06:19 EST
On Tue, Mar 31, 2026 at 01:53:29PM +0300, Dan Carpenter wrote:
> On Tue, Mar 31, 2026 at 12:17:07AM +0600, Md. Mahmudul Hasan Mabud wrote:
...
> > /*
> > * AD7816 config masks
> > */
> > -#define AD7816_FULL 0x1
> > -#define AD7816_PD 0x2
> > +#define AD7816_FULL 0
> > +#define AD7816_PD 1
>
> I don't love this. AD7816_PD used to be related to the spec but now
> it's just a random number which tricks you into thinking it has
> meaning but it doesn't.
>
> if (chip->mode == AD7816_PD) { /* operating mode 2 */
We can leave that and add a new member to the string array
[_DEFAULT] = "default";
and associate it with the default choice which seems to be _FULL as per
kzalloc() in the IIO core.
--
With Best Regards,
Andy Shevchenko