aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-buffer.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-10-14 12:49:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-10-16 14:09:27 -0400
commit8e050996c85f2df135e54053ce74f47577382366 (patch)
tree7fe92436a50927fa8441f609b4b14b811c82c6d7 /drivers/iio/industrialio-buffer.c
parentcb6fbfa1387f47e5ef4ab2fac5ed71f3c1175f75 (diff)
iio: Update buffer's bytes per datum after updating the scan mask
Currently a IIO device driver needs to make sure to update the buffer's bytes per datum after the scan mask has changed. This is usually done in the preenable callback by invoking iio_sw_buffer_preenable(). This is something that needs to be done and is done for virtually all devices which support buffers (we currently have only one exception). Also this a bit of a layering violation since we have to call the buffer setup ops from the device setup ops. This requires the device driver to know about the internal requirements of the buffer (e.g. whether we need to call the set_bytes_per_datum) callback. And especially with in-kernel buffer consumers, which allows to attach arbitrary buffers to a device, this is something that the driver can't know. Moving this to the core allows us to drop the individual calls to iio_sw_buffer_preenable() from drivers. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Denis Ciocca <denis.ciocca@st.com> Cc: Marek Vasut <marex@denx.de> Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com> Cc: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/industrialio-buffer.c')
-rw-r--r--drivers/iio/industrialio-buffer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 796376ac2475..186f501e6415 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -492,6 +492,20 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
492 indio_dev->setup_ops->postdisable(indio_dev); 492 indio_dev->setup_ops->postdisable(indio_dev);
493} 493}
494 494
495static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev,
496 struct iio_buffer *buffer)
497{
498 unsigned int bytes;
499
500 if (!buffer->access->set_bytes_per_datum)
501 return;
502
503 bytes = iio_compute_scan_bytes(indio_dev, buffer->scan_mask,
504 buffer->scan_timestamp);
505
506 buffer->access->set_bytes_per_datum(buffer, bytes);
507}
508
495static int __iio_update_buffers(struct iio_dev *indio_dev, 509static int __iio_update_buffers(struct iio_dev *indio_dev,
496 struct iio_buffer *insert_buffer, 510 struct iio_buffer *insert_buffer,
497 struct iio_buffer *remove_buffer) 511 struct iio_buffer *remove_buffer)
@@ -589,7 +603,8 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
589 iio_compute_scan_bytes(indio_dev, 603 iio_compute_scan_bytes(indio_dev,
590 indio_dev->active_scan_mask, 604 indio_dev->active_scan_mask,
591 indio_dev->scan_timestamp); 605 indio_dev->scan_timestamp);
592 list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) 606 list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
607 iio_buffer_update_bytes_per_datum(indio_dev, buffer);
593 if (buffer->access->request_update) { 608 if (buffer->access->request_update) {
594 ret = buffer->access->request_update(buffer); 609 ret = buffer->access->request_update(buffer);
595 if (ret) { 610 if (ret) {
@@ -598,6 +613,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
598 goto error_run_postdisable; 613 goto error_run_postdisable;
599 } 614 }
600 } 615 }
616 }
601 if (indio_dev->info->update_scan_mode) { 617 if (indio_dev->info->update_scan_mode) {
602 ret = indio_dev->info 618 ret = indio_dev->info
603 ->update_scan_mode(indio_dev, 619 ->update_scan_mode(indio_dev,