Re: [PATCH v5 18/18] iio: magnetometer: ak8975: make use of the macros from bits.h

From: Jonathan Cameron

Date: Wed May 06 2026 - 13:14:22 EST


On Tue, 05 May 2026 13:46:14 +0200
Joshua Crofts via B4 Relay <devnull+joshua.crofts1.gmail.com@xxxxxxxxxx> wrote:

> From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>
> Make use of BIT() and GENMASK() where it makes sense.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Co-developed-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
> Signed-off-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>

One small thing in here. Feel free to just leave that for a separate patch
and for now leave it as 0x7

> @@ -840,7 +833,7 @@ static const struct iio_chan_spec ak8975_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(3),
> };
>
> -static const unsigned long ak8975_scan_masks[] = { 0x7, 0 };
> +static const unsigned long ak8975_scan_masks[] = { GENMASK(2, 0), 0 };
Hmm. This is a fun one... It's actually 3 separate bits so please represent it
as BIT(0) | BIT(1) | BIT(2)

or maybe add an enum for the channel scan indexes?
BIT(SCAN_X) | BIT(SCAN_Y) | BIT(SCAN_Z)
(and there will be an unused here SCAN_TIMESTAMP


>
> static const struct iio_info ak8975_info = {
> .read_raw = &ak8975_read_raw,
>