Re: [PATCH v5 6/6] iio: imu: inv_icm42607: Add accelerometer calibbias support
From: Andy Shevchenko
Date: Fri Oct 02 2026 - 09:22:18 EST
On Fri, Oct 02, 2026 at 01:54:30PM +0200, Kanak Shilledar wrote:
> Expose IIO_CHAN_INFO_CALIBBIAS on the accelerometer channels. The
> registers are stored in MREG1. The calibration bias is written to
> OFFSET_USER4 to OFFSET_USER8 registers in MREG1. Reject the out of
> limit calibbias values instead of clamping it.
>
> Note: The accelerometer functionality is tested with Invensense,
> ICM42370-P development board.
...
> + case IIO_MOD_X:
> + case IIO_MOD_Z:
> + offset = sign_extend32(((lo_val & 0xF0) << 4) | hi_val, 11);
> + break;
> + case IIO_MOD_Y:
> + offset = sign_extend32(((hi_val & 0x0F) << 8) | lo_val, 11);
> + break;
Why do we have hi/lo and not proper __le16 or __be16 type for that to begin
with?
...
> + val64 = (s64)offset * 5LL * 9806650LL;
> + /* For rounding, add + or - divisor (10000) divided by 2 */
> + if (val64 >= 0)
> + val64 += 10000LL / 2LL;
> + else
> + val64 -= 10000LL / 2LL;
> +
> + bias = div_s64(val64, 10000L);
We have DIV_S64_ROUND_CLOSEST().
...
Overall, the feeling is that this is cumbersome change and may be split to
smaller and more isolated logical updates.
--
With Best Regards,
Andy Shevchenko