Re: [PATCH 2/2] iio: invensense: improve period measurement by using a longer delay

From: Jean-Baptiste Maneyrol

Date: Mon Jul 20 2026 - 06:41:08 EST


>
>________________________________________
>From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
>Sent: Friday, July 17, 2026 20:09
>To: Jean-Baptiste Maneyrol
>Cc: Jonathan Cameron; David Lechner; Nuno Sá; Andy Shevchenko; linux-iio@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
>Subject: Re: [PATCH 2/2] iio: invensense: improve period measurement by using a longer delay
>
>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. 
>ZjQcmQRYFpfptBannerStart
>This Message Is From an External Sender
>This message came from outside your organization.
>
>ZjQcmQRYFpfptBannerEnd
>
>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.

Hello Andy,

no problem, I will do like that.

>
>--
>With Best Regards,
>Andy Shevchenko
>

Thanks,
JB