Re: [PATCH 07/12] iio: pressure: rohm-bm1390: Fix AVE_NUM initialization
Jonathan Cameron <[email protected]>
| Newsgroups | gmane.linux.kernel.iio,gmane.linux.kernel |
|---|---|
| Message-ID | <20260817021252.5ef32a57@jic23-huawei> |
On Mon, 10 Aug 2026 10:53:07 +0300 Matti Vaittinen <[email protected]> wrote: > From: Matti Vaittinen <[email protected]> > > 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 <[email protected]> > 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; >