Skip to content

Commit 6bce70d

Browse files
dlechjic23
authored andcommitted
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 <dlechner@baylibre.com> Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 8b44f07 commit 6bce70d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Documentation/driver-api/iio/triggered-buffers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ A typical triggered buffer setup looks like this::
2929

3030
irqreturn_t sensor_trigger_handler(int irq, void *p)
3131
{
32-
u16 buf[8];
32+
IIO_DECLARE_BUFFER_WITH_TS(u16, buf, 3) = { };
3333
int i = 0;
3434

3535
/* read data for each active channel */
36-
for_each_set_bit(bit, active_scan_mask, masklength)
37-
buf[i++] = sensor_get_data(bit)
36+
iio_for_each_active_channel(indio_dev, bit)
37+
buf[i++] = sensor_get_data(bit);
3838

39-
iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp);
39+
iio_push_to_buffers_with_ts(indio_dev, buf, sizeof(buf), timestamp);
4040

4141
iio_trigger_notify_done(trigger);
4242
return IRQ_HANDLED;

0 commit comments

Comments
 (0)