Linux IIO development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Jean-Baptiste Maneyrol <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-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] iio: inv_sensors: better timestamp alignment when using watermark
Date: Mon, 20 Jul 2026 22:31:39 +0300	[thread overview]
Message-ID: <al53m6cQ641ZPvYp@ashevche-desk.local> (raw)
In-Reply-To: <BE1P281MB14263FC8209148C6147866A2CEC32@BE1P281MB1426.DEUP281.PROD.OUTLOOK.COM>

On Mon, Jul 20, 2026 at 03:07:05PM +0000, Jean-Baptiste Maneyrol wrote:
> >________________________________________
> >From: Andy Shevchenko <andriy.shevchenko@intel.com>
> >Sent: Monday, July 20, 2026 13:33
> >On Mon, Jul 20, 2026 at 12:38:33PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote:

...

> >>  void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
> >
> >>       if (sample_nb == 0)
> >>               return;
> >>
> >> +     /* no previous data, compute theoretical value from interrupt */
> >> +     if (ts->timestamp == 0) {
> >> +             /* elapsed time: sensor period * sensor samples number */
> >> +             interval = (s64)ts->period * (s64)sample_nb;
> >
> >The both variables are unsigned. Why do we cast them to the signed type?
> >
> Hello Andy,
> 
> the idea here is to have a (timestamp - interval) doing the difference on
> variables of the same type, s64. I tried to avoid difference between signed
> and unsigned values that can be problematic.
> 
> Interval is s64 for this reason, and that's why I cast the 2 u32 values to
> s64 (which should not be a problem).
> 
> Is that OK like this or do you prefer I change to u64 (with implicit
> conversion to s64 when assigning to interval)?

It was just a question. If you think it's better as is, I'm fine.

> >> +             ts->timestamp = timestamp - interval;
> >> +     }

...

> >> -     /* no previous data, compute theoretical value from interrupt */
> >> -     if (ts->timestamp == 0) {
> >> -             /* elapsed time: sensor period * sensor samples number */
> >> -             interval = (s64)ts->period * (s64)sample_nb;
> >
> >Yeah, I see this is the original code, but consider revisiting.
> >
> >> -             ts->timestamp = it->up - interval;
> >> -             return;
> >> -     }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-07-20 19:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 10:38 [PATCH v2 0/3] iio: common: improve InvenSense sample timestamping Jean-Baptiste Maneyrol via B4 Relay
2026-07-20 10:38 ` [PATCH v2 1/3] iio: inv_sensors: convert to kernel types Jean-Baptiste Maneyrol via B4 Relay
2026-07-20 11:29   ` Andy Shevchenko
2026-07-24  0:01     ` Jonathan Cameron
2026-07-20 10:38 ` [PATCH v2 2/3] iio: inv_sensors: better timestamp alignment when using watermark Jean-Baptiste Maneyrol via B4 Relay
2026-07-20 11:33   ` Andy Shevchenko
2026-07-20 15:07     ` Jean-Baptiste Maneyrol
2026-07-20 19:31       ` Andy Shevchenko [this message]
2026-07-20 10:38 ` [PATCH v2 3/3] iio: inv_sensors: improve period measurement by using a longer delay Jean-Baptiste Maneyrol via B4 Relay

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=al53m6cQ641ZPvYp@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Jean-Baptiste.Maneyrol@tdk.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.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