aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio/buffer.h
diff options
context:
space:
mode:
authorJosselin Costanzi <josselin.costanzi@mobile-devices.fr>2015-03-22 20:33:38 +0200
committerJonathan Cameron <jic23@kernel.org>2015-03-29 16:17:09 +0100
commit37d3455672732b29a477732a94abfe95e199f0ce (patch)
treea2e4920bbecaec6f3773cbc5a7228d17283b7d21 /include/linux/iio/buffer.h
parentIIO: Add support for L3GD20H gyroscope (diff)
downloadlinux-dev-37d3455672732b29a477732a94abfe95e199f0ce.tar.xz
linux-dev-37d3455672732b29a477732a94abfe95e199f0ce.zip
iio: add watermark logic to iio read and poll
Currently the IIO buffer blocking read only wait until at least one data element is available. This patch makes the reader sleep until enough data is collected before returning to userspace. This should limit the read() calls count when trying to get data in batches. Co-author: Yannick Bedhomme <yannick.bedhomme@mobile-devices.fr> Signed-off-by: Josselin Costanzi <josselin.costanzi@mobile-devices.fr> [rebased and remove buffer timeout] Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include/linux/iio/buffer.h')
-rw-r--r--include/linux/iio/buffer.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index b65850a41127..eb8622b78ec9 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -21,8 +21,8 @@ struct iio_buffer;
* struct iio_buffer_access_funcs - access functions for buffers.
* @store_to: actually store stuff to the buffer
* @read_first_n: try to get a specified number of bytes (must exist)
- * @data_available: indicates whether data for reading from the buffer is
- * available.
+ * @data_available: indicates how much data is available for reading from
+ * the buffer.
* @request_update: if a parameter change has been marked, update underlying
* storage.
* @set_bytes_per_datum:set number of bytes per datum
@@ -43,7 +43,7 @@ struct iio_buffer_access_funcs {
int (*read_first_n)(struct iio_buffer *buffer,
size_t n,
char __user *buf);
- bool (*data_available)(struct iio_buffer *buffer);
+ size_t (*data_available)(struct iio_buffer *buffer);
int (*request_update)(struct iio_buffer *buffer);
@@ -72,6 +72,7 @@ struct iio_buffer_access_funcs {
* @demux_bounce: [INTERN] buffer for doing gather from incoming scan.
* @buffer_list: [INTERN] entry in the devices list of current buffers.
* @ref: [INTERN] reference count of the buffer.
+ * @watermark: [INTERN] number of datums to wait for poll/read.
*/
struct iio_buffer {
int length;
@@ -90,6 +91,7 @@ struct iio_buffer {
void *demux_bounce;
struct list_head buffer_list;
struct kref ref;
+ unsigned int watermark;
};
/**