[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250519-timestamp-v1-7-fcb4f6c2721c@gmail.com>
Date: Mon, 19 May 2025 23:25:59 +0900
From: Gyeyoung Baek <gye976@...il.com>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>
Cc: Gyeyoung Baek <gye976@...il.com>,
linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH RFC 7/9] iio: trigger: Add new API iio_trigger_attach_timestamp()
This new API is used in `iio_poll_func_register()` to handle the case
where the trigger writes a timestamp directly into the consumer (i.e. early_timestamp == true).
Signed-off-by: Gyeyoung Baek <gye976@...il.com>
---
drivers/iio/industrialio-trigger.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index d6b0e1ec4153..f394933b9d0a 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -288,6 +288,15 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, int irq)
clear_bit(irq - trig->subirq_base, trig->pool);
}
+static int iio_trigger_attach_timestamp(struct iio_trigger *trig,
+ struct iio_poll_func *pf)
+{
+ /* RFC */
+ trig->consumer_pf[pf->irq - trig->subirq_base] = pf;
+
+ return 0;
+}
+
static int iio_poll_func_register(struct iio_poll_func *pf,
struct iio_trigger *trig)
{
@@ -302,6 +311,16 @@ static int iio_poll_func_register(struct iio_poll_func *pf,
if (!pf->timestamp_enabled)
goto out_request_irq;
+ /*
+ * The trigger supports grabbing timestamp.
+ * Just request raw irq handler.
+ */
+ if (trig->early_timestamp) {
+ ret = iio_trigger_attach_timestamp(trig, pf);
+ pf->timestamp_type = IIO_TIMESTAMP_TYPE_TRIGGER;
+ goto out_request_irq;
+ }
+
if (trig->trig_type & IIO_TRIG_TYPE_POLL_NESTED) {
bottomhalf = iio_pollfunc_bottom_half_wrapper;
pf->timestamp_type = IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF;
@@ -395,6 +414,9 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig,
module_put(iio_dev_opaque->driver_module);
pf->irq = 0;
+ /* RFC */
+ trig->consumer_pf[pf->irq - trig->subirq_base] = NULL;
+
return ret;
}
--
2.43.0
Powered by blists - more mailing lists