Re: [PATCH] iio: imu: bmi270: fix zero timestamp in triggered buffer

From: Andy Shevchenko

Date: Wed Oct 28 2026 - 04:58:53 EST


On Wed, Oct 28, 2026 at 10:59:26AM +0800, Liu Yufei wrote:
> When the device's own data ready trigger is used, the trigger is
> polled with iio_trigger_poll_nested() from the threaded IRQ handler.
> In that path the pollfunc top half, iio_pollfunc_store_time(), is
> never run, so pf->timestamp is left at zero and every sample pushed
> to the buffer carries a zero timestamp.
>
> Take the timestamp in the trigger handler itself and drop the top
> half, so that a valid timestamp is provided for all triggers.

...

> + s64 timestamp = iio_get_time_ns(indio_dev);

Do we need this variable? Why not call it directly?

> iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
> - pf->timestamp);
> + timestamp);

iio_get_time_ns(indio_dev);

--
With Best Regards,
Andy Shevchenko