Re: [PATCH v2] iio: magnetometer: bmc150: use FIELD_PREP and FIELD_GET helpers
From: Andy Shevchenko
Date: Tue Jun 09 2026 - 10:48:36 EST
On Tue, Jun 09, 2026 at 01:21:45AM +0000, Hungyu Lin wrote:
> Replace open-coded bitfield operations with FIELD_PREP() and
> FIELD_GET() helpers where appropriate.
>
> Also simplify bmc150_magn_set_odr() by returning directly from
> the matching table entry.
...
> ret = regmap_read(data->regmap, BMC150_MAGN_REG_OPMODE_ODR, ®_val);
> if (ret < 0)
> return ret;
> - odr_val = (reg_val & BMC150_MAGN_MASK_ODR) >> BMC150_MAGN_SHIFT_ODR;
> +
Stray addition. This calculation is coupled with the above regmap, so I see
a value of having no blank line there (as in the original code).
> + odr_val = FIELD_GET(BMC150_MAGN_MASK_ODR, reg_val);
>
> for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++)
...
The rest looks good to me, I dunno if Jonathan wants a new version (probably
he does as IIO closed for this cycle anyway).
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
--
With Best Regards,
Andy Shevchenko