Re: [PATCH 2/2] iio: invensense: improve period measurement by using a longer delay
From: Andy Shevchenko
Date: Fri Jul 17 2026 - 14:12:53 EST
On Fri, Jul 17, 2026 at 02:39:41PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote:
> Period measurement can be difficult when using high sampling
> frequency where the jitter criteria is hard to meet because of the
> system jitter.
>
> This new version is using the delta time between 2 distant interrupts
> to measure an interval of at least 20ms. 20ms is a good compromise
> between the mitigation of system jitter and the delay to update
> period. This way we decorrelate the period measurement from the
> interrupt timestamps syncing using only the 2 last interrupts.
...
> void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
> size_t sample_nb, int64_t timestamp)
> {
> + const int64_t delta_threshold =
> + INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA,
> + ts->chip.jitter);
This is less readable than the split version.
const s64 delta_threshold;
Also, what const gives us here?
> struct inv_sensors_timestamp_interval *it;
> int64_t delta, interval;
> uint32_t period;
> - bool valid = false;
> + bool valid;
delta_threshold =
INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA, ts->chip.jitter);
(yes, I would go for a bit longer line).
> if (sample_nb == 0)
> return;
And why to assign it if we have to return, for example here?
Move the assignment closer to its first user.
--
With Best Regards,
Andy Shevchenko