Re: [PATCH 07/12] iio: pressure: rohm-bm1390: Fix AVE_NUM initialization
From: Jonathan Cameron
Date: Sun Aug 16 2026 - 21:13:05 EST
On Mon, 10 Aug 2026 10:53:07 +0300
Matti Vaittinen <matti.vaittinen@xxxxxxxxx> wrote:
> From: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
>
> The BM1390 tries to initialize the AVE_NUM to 110b at the start-up. The
> field location is not taken into account, and value is written unsifted.
> This causes the AVE_NUM to be initialized to zero.
>
> Use FIELD_PREP() to shift the intended AVE_NUM value to correct field.
>
> Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
> Fixes: 81ca5979b6ed ("iio: pressure: Support ROHM BU1390")
> ---
> drivers/iio/pressure/rohm-bm1390.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/pressure/rohm-bm1390.c b/drivers/iio/pressure/rohm-bm1390.c
> index d00d7ed54cb1..29454570f257 100644
> --- a/drivers/iio/pressure/rohm-bm1390.c
> +++ b/drivers/iio/pressure/rohm-bm1390.c
> @@ -479,6 +479,7 @@ static const struct iio_info bm1390_info = {
>
> static int bm1390_chip_init(struct bm1390_data *data)
> {
> + u8 regval;
> int ret;
>
> ret = regmap_write_bits(data->regmap, BM1390_REG_POWER,
> @@ -512,8 +513,9 @@ static int bm1390_chip_init(struct bm1390_data *data)
> * Default to use IIR filter in "middle" mode. Also the AVE_NUM must
> * be fixed when IIR is in use.
> */
> + regval = FIELD_PREP(BM1390_MASK_AVE_NUM, BM1390_IIR_AVE_NUM);
> ret = regmap_update_bits(data->regmap, BM1390_REG_MODE_CTRL,
> - BM1390_MASK_AVE_NUM, BM1390_IIR_AVE_NUM);
> + BM1390_MASK_AVE_NUM,
FIELD_PREP(BM1390_MASK_AVE_NUM, BM1390_IIR_AVE_NUM));
If respining I would drop the local variable and just go a bit long on the line.
I like the mask to be clearly visible in both parameters and a local variable
prevents that. Fine if the line is really long, but it's only about 83 chars here.
Jonathan
> if (ret)
> return ret;
>