Re: [PATCH v2 1/2] iio: imu: inv_icm42600: add WoM support

From: Andy Shevchenko
Date: Thu Apr 17 2025 - 12:10:50 EST


On Thu, Apr 17, 2025 at 5:25 PM Jean-Baptiste Maneyrol
<Jean-Baptiste.Maneyrol@xxxxxxx> wrote:
> > On Tue, Apr 15, 2025 at 5:47 PM Jean-Baptiste Maneyrol via B4 Relay
> > <devnull+jean-baptiste.maneyrol.tdk.com@xxxxxxxxxx> wrote:

...

> > > + /* 1000/256mg per LSB converted in m/s² in micro (1000000) */
> >
> > That 1000000 is redundant, just properly spell the units.
>
> I will use um/s²

FWIW, you may even use a Greek MU letter, kernel is UTF-8 compatible :-)
μm/s²

...

> > > + /* limit value to 8 bits and prevent 0 */
> > > + return min(255, max(1, value));
> >
> > Reinvention of the clamp() ?
>
> It was a copy-paste of an older driver, at the time clamp was not here.
> I will replace by clamp, it is much more readable.

For the curious, read this https://lwn.net/Articles/983965/.
The min(max()) may have really unexpected side effects :-)

...

> > > + if (sleep_ms)
> >
> > Do you need this check?
>
> We need this check in the case sleep_ms is 0. It will happen if accel is
> already on. msleep(0) was usually doing a sleep before. I don't know if it
> is still the case.

I'm wondering if it's documented anywhere, do we need to update /
improve a documentation?

> > > + msleep(sleep_ms);

--
With Best Regards,
Andy Shevchenko