Re: [PATCH v5 4/7] iio: adc: ad4030: Use BIT macro to improve code readability
From: Andy Shevchenko
Date: Sat Oct 18 2025 - 13:35:28 EST
On Tue, Oct 14, 2025 at 07:21:58PM -0300, Marcelo Schmitt wrote:
> Use BIT macro to make the list of average modes more readable.
>
> Suggested-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
Okay, but...
...
> static const int ad4030_average_modes[] = {
> - 1, 2, 4, 8, 16, 32, 64, 128,
> - 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
> - 65536,
> + BIT(0), /* No averaging/oversampling */
> + BIT(1), BIT(2), BIT(3), BIT(4), /* 2 to 16 */
> + BIT(5), BIT(6), BIT(7), BIT(8), /* 32 to 256 */
> + BIT(9), BIT(10), BIT(11), BIT(12), /* 512 to 4096 */
> + BIT(13), BIT(14), BIT(15), BIT(16), /* 8192 to 65536 */
...the comments now a bit odd as it's unclear in which step the values are.
Taking this into account I would rather drop the comments for all bits but
0.
Or even drop all and make a top comment to explain the meaning of values
0, 1, and bit permutations, if any.
> };
--
With Best Regards,
Andy Shevchenko