mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: jean-baptiste.maneyrol@tdk.com
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: invensense: improve period measurement by using a longer delay
Date: Fri, 17 Jul 2026 21:09:54 +0300	[thread overview]
Message-ID: <alpv8rAJk65aW7h4@ashevche-desk.local> (raw)
In-Reply-To: <20260717-iio-common-inv-sensors-timestamp-rework-v1-2-d1afee2805cd@tdk.com>

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



  reply	other threads:[~2026-07-17 18:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 12:39 [PATCH 0/2] iio: common: improve InvenSense sample timestamping Jean-Baptiste Maneyrol via B4 Relay
2026-07-17 12:39 ` [PATCH 1/2] iio: invensense: better timestamp alignment when using watermark Jean-Baptiste Maneyrol via B4 Relay
2026-07-17 18:06   ` Andy Shevchenko
2026-07-18  1:14   ` Jonathan Cameron
2026-07-17 12:39 ` [PATCH 2/2] iio: invensense: improve period measurement by using a longer delay Jean-Baptiste Maneyrol via B4 Relay
2026-07-17 18:09   ` Andy Shevchenko [this message]
2026-07-18  1:25   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpv8rAJk65aW7h4@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jean-baptiste.maneyrol@tdk.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox