Re: [PATCH v2 1/3] iio: imu: bmi270: add channel for step counter

From: Jonathan Cameron
Date: Sat Jun 07 2025 - 11:50:24 EST


On Fri, 6 Jun 2025 12:14:44 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> On Thu, Jun 05, 2025 at 07:05:01PM -0300, Gustavo Silva wrote:
> > Add a channel for enabling/disabling the step counter, reading the
> > number of steps and resetting the counter.
>
> ...
>
> > +static int bmi270_update_feature_reg(struct bmi270_data *data,
> > + enum bmi270_feature_reg_id id,
> > + u16 mask, u16 val)
> > +{
> > + u16 regval = 0;
>
> Redundant assignment.
>
> > + int ret;
> > +
> > + ret = bmi270_read_feature_reg(data, id, &regval);
> > + if (ret)
> > + return ret;
>
> > + set_mask_bits(&regval, mask, val);
>
> You can't do this on the 16-bit values on some architectures.
> Maybe it's easy to implement cmpxchg() for 16-bit values there,
> though.

It doesn't need to be atomic, so stick to traditional

regval &= ~mask;
regval |= bits;

And avoid the fun of architectural corner cases entirely.
>
> > + return bmi270_write_feature_reg(data, id, regval);
> > +}
>