Re: [PATCH 1/2] iio: light: ltr390: Add sysfs attribute to report data freshness

From: David Lechner
Date: Mon Jul 21 2025 - 16:25:52 EST


On 7/21/25 2:54 PM, Akshay Jindal wrote:
> Some IIO sensors provide a status bit indicating whether the current data
> register holds freshly measured data or stale data previously read.
>
> Expose this status via a new read-only sysfs attribute, 'data_fresh',
> which returns:
> - 1 if the data is freshly sampled
> - 0 if the data is stale
>
> This attribute allows userspace to observe data freshness directly, which
> can be useful for debugging or application-level filtering.

For debugging, using debugfs would make more sense.

For application level filtering, why does it matter if we have
read the same value before or not? The sampling_frequency is
available, so the application should be able to deduce when
fresh data should be available based on time.

I could see maybe polling this in the kernel in order to implement
a buffered capture mode, but not sure passing this on to userspace
is the best way to go about it.