From: David Lechner Date: Sun, 17 May 2026 17:00:59 +0000 (-0500) Subject: docs: iio: triggered-buffers: use new helpers in example X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6bce70d0a9bc907cedb12f498ebc4cd5f7ac7cee;p=thirdparty%2Flinux.git 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 --- diff --git a/Documentation/driver-api/iio/triggered-buffers.rst b/Documentation/driver-api/iio/triggered-buffers.rst index 23b82357eba64..23762b06fdc65 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;