]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
docs: iio: triggered-buffers: use new helpers in example
authorDavid Lechner <dlechner@baylibre.com>
Sun, 17 May 2026 17:00:59 +0000 (12:00 -0500)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 10:01:46 +0000 (11:01 +0100)
Update the "typical" triggered buffer example to use various new helpers
that have been added in the last year or so. This reflects current
expectations of how similar code should be written.

Also zero-initialize the buffer so we don't leak stack data. And fix a
missing semicolon while we're at it.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Documentation/driver-api/iio/triggered-buffers.rst

index 23b82357eba64a0b98425a5a1e7328f8c5514912..23762b06fdc65a2b530ff2fe5fa5889936ad5cd6 100644 (file)
@@ -29,14 +29,14 @@ A typical triggered buffer setup looks like this::
 
     irqreturn_t sensor_trigger_handler(int irq, void *p)
     {
-        u16 buf[8];
+        IIO_DECLARE_BUFFER_WITH_TS(u16, buf, 3) = { };
         int i = 0;
 
         /* read data for each active channel */
-        for_each_set_bit(bit, active_scan_mask, masklength)
-            buf[i++] = sensor_get_data(bit)
+        iio_for_each_active_channel(indio_dev, bit)
+            buf[i++] = sensor_get_data(bit);
 
-        iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp);
+        iio_push_to_buffers_with_ts(indio_dev, buf, sizeof(buf), timestamp);
 
         iio_trigger_notify_done(trigger);
         return IRQ_HANDLED;