diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-09-18 16:02:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-09-21 07:36:30 -0400 |
commit | a87c82e454f184a9473f8cdfd4d304205f585f65 (patch) | |
tree | 5f158830b28d740e6782dac2683fd46cde7b23fb /drivers/iio/industrialio-buffer.c | |
parent | d66e0452bf6b0d98cd1a478918c92f2baffcb413 (diff) |
iio: Stop sampling when the device is removed
Make sure to stop sampling when the device is removed, otherwise it will
continue to sample forever.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r-- | drivers/iio/industrialio-buffer.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 5862c88ed5ad..2710f7245c3b 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
@@ -460,6 +460,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask, | |||
460 | return bytes; | 460 | return bytes; |
461 | } | 461 | } |
462 | 462 | ||
463 | void iio_disable_all_buffers(struct iio_dev *indio_dev) | ||
464 | { | ||
465 | struct iio_buffer *buffer, *_buffer; | ||
466 | |||
467 | if (list_empty(&indio_dev->buffer_list)) | ||
468 | return; | ||
469 | |||
470 | if (indio_dev->setup_ops->predisable) | ||
471 | indio_dev->setup_ops->predisable(indio_dev); | ||
472 | |||
473 | list_for_each_entry_safe(buffer, _buffer, | ||
474 | &indio_dev->buffer_list, buffer_list) | ||
475 | list_del_init(&buffer->buffer_list); | ||
476 | |||
477 | indio_dev->currentmode = INDIO_DIRECT_MODE; | ||
478 | if (indio_dev->setup_ops->postdisable) | ||
479 | indio_dev->setup_ops->postdisable(indio_dev); | ||
480 | } | ||
481 | |||
463 | int iio_update_buffers(struct iio_dev *indio_dev, | 482 | int iio_update_buffers(struct iio_dev *indio_dev, |
464 | struct iio_buffer *insert_buffer, | 483 | struct iio_buffer *insert_buffer, |
465 | struct iio_buffer *remove_buffer) | 484 | struct iio_buffer *remove_buffer) |