[PATCH] iio: chemical: scd4x: expose timestamp channel

Fiona Klute posted 1 patch 1 month, 3 weeks ago
drivers/iio/chemical/scd4x.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] iio: chemical: scd4x: expose timestamp channel
Posted by Fiona Klute 1 month, 3 weeks ago
Timestamps were already written to the buffer in
scd4x_trigger_handler(), this patch makes them available as a channel.

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
---
 drivers/iio/chemical/scd4x.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
index 0fd839176e264..23a326fb62a7e 100644
--- a/drivers/iio/chemical/scd4x.c
+++ b/drivers/iio/chemical/scd4x.c
@@ -59,6 +59,8 @@ enum scd4x_channel_idx {
 	SCD4X_CO2,
 	SCD4X_TEMP,
 	SCD4X_HR,
+	/* kernel timestamp, at the end of buffer */
+	SCD4X_TS,
 };
 
 struct scd4x_state {
@@ -615,6 +617,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
 			.endianness = IIO_CPU,
 		},
 	},
+	IIO_CHAN_SOFT_TIMESTAMP(SCD4X_TS),
 };
 
 static int scd4x_suspend(struct device *dev)
-- 
2.51.0

Re: [PATCH] iio: chemical: scd4x: expose timestamp channel
Posted by Jonathan Cameron 1 month, 2 weeks ago
On Thu, 18 Dec 2025 16:12:05 +0100
Fiona Klute <fiona.klute@gmx.de> wrote:

> Timestamps were already written to the buffer in
> scd4x_trigger_handler(), this patch makes them available as a channel.
> 
> Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
Applied to the togreg branch of iio.git. Initially pushed out as testing
to let 0-day have a brief look at it.

Thanks,

Jonathan

> ---
>  drivers/iio/chemical/scd4x.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c
> index 0fd839176e264..23a326fb62a7e 100644
> --- a/drivers/iio/chemical/scd4x.c
> +++ b/drivers/iio/chemical/scd4x.c
> @@ -59,6 +59,8 @@ enum scd4x_channel_idx {
>  	SCD4X_CO2,
>  	SCD4X_TEMP,
>  	SCD4X_HR,
> +	/* kernel timestamp, at the end of buffer */
> +	SCD4X_TS,
>  };
>  
>  struct scd4x_state {
> @@ -615,6 +617,7 @@ static const struct iio_chan_spec scd4x_channels[] = {
>  			.endianness = IIO_CPU,
>  		},
>  	},
> +	IIO_CHAN_SOFT_TIMESTAMP(SCD4X_TS),
>  };
>  
>  static int scd4x_suspend(struct device *dev)
Re: [PATCH] iio: chemical: scd4x: expose timestamp channel
Posted by Fiona Klute 1 month, 2 weeks ago
Am 21.12.25 um 19:05 schrieb Jonathan Cameron:
> On Thu, 18 Dec 2025 16:12:05 +0100
> Fiona Klute <fiona.klute@gmx.de> wrote:
> 
>> Timestamps were already written to the buffer in
>> scd4x_trigger_handler(), this patch makes them available as a channel.
>>
>> Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
> Applied to the togreg branch of iio.git. Initially pushed out as testing
> to let 0-day have a brief look at it.
Thank you! Could you also pick my channel endianness fix for the scd4x 
driver [1]? The patches apply independently, but timestamps aren't going 
to be very useful as long as the data that goes with them is incorrect. 
Or does that need to go via a different tree as a bugfix?

Best regards,
Fiona


[1] 
https://lore.kernel.org/linux-iio/20251213163226.1678707-1-fiona.klute@gmx.de/T/