Re: [PATCH v6 11/11] iio: adc: ti-ads1015: Replace custom shift macros with FIELD_PREP/GET

From: Andy Shevchenko

Date: Mon Nov 09 2026 - 14:46:40 EST


On Mon, Nov 09, 2026 at 10:28:05PM +0530, Archit Anant wrote:
> The driver currently uses custom _SHIFT macros and manual bitwise
> operations to read and write to the configuration register.
>
> Modernize the bitwise logic by replacing all manual shifts with the
> standard FIELD_PREP() and FIELD_GET() macros from <linux/bitfield.h>.
> This improves readability and prevents potential bitwise errors.
>
> Remove the now-unused _SHIFT macros from the top of the file.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>

...

> + mask = ADS1015_CFG_MUX_MASK | ADS1015_CFG_PGA_MASK |
> + ADS1015_CFG_DR_MASK;

Indentation is broken here.

> + cfg = FIELD_PREP(ADS1015_CFG_MUX_MASK, chan) |
> + FIELD_PREP(ADS1015_CFG_PGA_MASK, pga) |
> + FIELD_PREP(ADS1015_CFG_DR_MASK, dr);

--
With Best Regards,
Andy Shevchenko