mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
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>
This commit is contained in:
parent
8b44f074a7
commit
6bce70d0a9
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user