From 6bce70d0a9bc907cedb12f498ebc4cd5f7ac7cee Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 17 May 2026 12:00:59 -0500 Subject: [PATCH] docs: iio: triggered-buffers: use new helpers in example 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 Reviewed-by: Stepan Ionichev Signed-off-by: Jonathan Cameron --- Documentation/driver-api/iio/triggered-buffers.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/iio/triggered-buffers.rst b/Documentation/driver-api/iio/triggered-buffers.rst index 23b82357eba6..23762b06fdc6 100644 --- a/Documentation/driver-api/iio/triggered-buffers.rst +++ b/Documentation/driver-api/iio/triggered-buffers.rst @@ -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;