linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/17] iio: Update buffer's bytes per datum after updating the scan mask
@ 2013-10-14 16:49 Lars-Peter Clausen
  2013-10-14 16:49 ` [PATCH 02/17] iio:st_accel: Drop redundant call to iio_sw_buffer_preenable() Lars-Peter Clausen
                   ` (17 more replies)
  0 siblings, 18 replies; 35+ messages in thread
From: Lars-Peter Clausen @ 2013-10-14 16:49 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Denis Ciocca, Marek Vasut,
	Zubair Lutfullah, Jacek Anaszewski

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>
---
 drivers/iio/industrialio-buffer.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 796376a..186f501 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)
 		indio_dev->setup_ops->postdisable(indio_dev);
 }
 
+static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev,
+	struct iio_buffer *buffer)
+{
+	unsigned int bytes;
+
+	if (!buffer->access->set_bytes_per_datum)
+		return;
+
+	bytes = iio_compute_scan_bytes(indio_dev, buffer->scan_mask,
+		buffer->scan_timestamp);
+
+	buffer->access->set_bytes_per_datum(buffer, bytes);
+}
+
 static int __iio_update_buffers(struct iio_dev *indio_dev,
 		       struct iio_buffer *insert_buffer,
 		       struct iio_buffer *remove_buffer)
@@ -589,7 +603,8 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
 		iio_compute_scan_bytes(indio_dev,
 				       indio_dev->active_scan_mask,
 				       indio_dev->scan_timestamp);
-	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list)
+	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
+		iio_buffer_update_bytes_per_datum(indio_dev, buffer);
 		if (buffer->access->request_update) {
 			ret = buffer->access->request_update(buffer);
 			if (ret) {
@@ -598,6 +613,7 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
 				goto error_run_postdisable;
 			}
 		}
+	}
 	if (indio_dev->info->update_scan_mode) {
 		ret = indio_dev->info
 			->update_scan_mode(indio_dev,
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2013-10-16 17:17 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14 16:49 [PATCH 01/17] iio: Update buffer's bytes per datum after updating the scan mask Lars-Peter Clausen
2013-10-14 16:49 ` [PATCH 02/17] iio:st_accel: Drop redundant call to iio_sw_buffer_preenable() Lars-Peter Clausen
2013-10-16 18:11   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 03/17] iio:ad7266: Remove redundant call to iio_sw_preenable() Lars-Peter Clausen
2013-10-16 18:12   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 04/17] iio:ad7887: Remove redundant call to iio_sw_buffer_preenable() Lars-Peter Clausen
2013-10-16 18:12   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 05/17] iio:ad_sigma_delta: " Lars-Peter Clausen
2013-10-16 18:12   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 06/17] iio:ti_am335x: " Lars-Peter Clausen
2013-10-16 18:13   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 07/17] iio:st_gyro: " Lars-Peter Clausen
2013-10-16 18:13   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 08/17] iio:triggered-buffer: " Lars-Peter Clausen
2013-10-16 18:13   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 09/17] iio:st_magn: " Lars-Peter Clausen
2013-10-16 18:14   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 10/17] iio:st_pressure: " Lars-Peter Clausen
2013-10-16 18:14   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 11/17] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-10-16 18:14   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 12/17] staging:iio:lis3l02dq: " Lars-Peter Clausen
2013-10-16 18:15   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 13/17] staging:iio:mxs-lradc: " Lars-Peter Clausen
2013-10-16 18:15   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 14/17] staging:iio:simple-dummy: " Lars-Peter Clausen
2013-10-16 18:16   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 15/17] staging:iio:ad5933: " Lars-Peter Clausen
2013-10-16 18:16   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 16/17] staging:iio:ade7758: " Lars-Peter Clausen
2013-10-16 18:16   ` Jonathan Cameron
2013-10-14 16:49 ` [PATCH 17/17] iio: Remove unused iio_sw_buffer_preenable() Lars-Peter Clausen
2013-10-16 18:17   ` Jonathan Cameron
2013-10-14 22:00 ` [PATCH 01/17] iio: Update buffer's bytes per datum after updating the scan mask Jonathan Cameron
2013-10-16 18:09 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).