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

From: Andy Shevchenko
Date: Sun Jun 08 2025 - 16:03:37 EST


On Sat, Jun 07, 2025 at 04:50:04PM +0100, Jonathan Cameron wrote:
> 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:

...

> > > + 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.

Standard pattern is

regval = (regval & ~mask) | (val & mask);

this will be robust against any changes in the val.

--
With Best Regards,
Andy Shevchenko