[PATCH V12 7/9] iio: imu: inv_icm42607: Add Accelerometer for icm42607
Andy Shevchenko
andriy.shevchenko at intel.com
Tue Jun 16 00:07:55 PDT 2026
On Mon, Jun 15, 2026 at 11:40:31AM -0500, Chris Morgan wrote:
> On Mon, Jun 15, 2026 at 06:07:15PM +0300, Andy Shevchenko wrote:
> > On Mon, Jun 15, 2026 at 09:51:40AM -0500, Chris Morgan wrote:
> > > On Mon, Jun 15, 2026 at 02:21:05PM +0300, Andy Shevchenko wrote:
> > > > On Thu, Jun 11, 2026 at 03:26:04PM -0500, Chris Morgan wrote:
...
> > > > > + for (i = 5; i < ARRAY_SIZE(inv_icm42607_accel_odr); ++i) {
> > > >
> > > > Why pre-increment? Same for all other cases.
> > >
> > > The register starts at 5 and all values below 5 are invalid. Starting
> > > this increment at 5 ensures we don't expose invalid values to
> > > userspace.
> >
> > It doesn't explain pre-increment. Post-increment should work as is.
>
> The array this references starts at 5, because those correspond to the
> values written to the odr register. That said, I do see a bug because
> the odr register is from highest to smallest and this array is
> backwards in the accel and gyro code. I'll fix that.
Good we even managed to find a bug, but what I initially pointed out is simply
as ++i versus i++. When I see ++i, it rises a flag: "this code is special", but
looking closer, I see nothing special about it.
> > > > > + if (i == odr)
> > > > > + break;
> > > > > + }
--
With Best Regards,
Andy Shevchenko
More information about the Linux-rockchip
mailing list