Re: [PATCH 2/7] iio: light: opt3001: use macros from bits.h header
From: Jonathan Cameron
Date: Mon May 11 2026 - 09:26:22 EST
On Mon, 11 May 2026 13:07:29 +0200
Joshua Crofts <joshua.crofts1@xxxxxxxxx> wrote:
> On Mon, 11 May 2026 at 13:01, Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxx> wrote:
> >
> > On Mon, May 11, 2026 at 12:04:07PM +0200, Joshua Crofts via B4 Relay wrote:
> >
> > > Use GENMASK() and BIT() macros from bits.h header where it makes
> > > sense. While at it, remove unused macro.
> >
> > ...
> >
> > > #define OPT3001_CONFIGURATION_M_SHUTDOWN (0 << 9)
> > > -#define OPT3001_CONFIGURATION_M_SINGLE (1 << 9)
> > > +#define OPT3001_CONFIGURATION_M_SINGLE BIT(9)
> > > #define OPT3001_CONFIGURATION_M_CONTINUOUS (2 << 9) /* also 3 << 9 */
> >
> > No to this and similar changes. It's clear that this is a shifted plain value,
> > it's not a bitfield. If in doubt, always consult with datasheet, if there is
> > no such publicly available, ask driver author/maintainers of the subsystem.
>
> Yeah, I knew this was a bit of a gamble, will fix in the next iteration.
Bigger change but you could move to defining all these field values
without the shift and using FIELD_PREP() / FIELD_GET() with the mask (that is
one line above these).
That is how we'd do it in a modern driver.
J
>