diff options
author | Josselin Costanzi <josselin.costanzi@mobile-devices.fr> | 2015-03-22 20:33:38 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-03-29 16:17:09 +0100 |
commit | 37d3455672732b29a477732a94abfe95e199f0ce (patch) | |
tree | a2e4920bbecaec6f3773cbc5a7228d17283b7d21 /drivers/iio/kfifo_buf.c | |
parent | 9444a300c2be3ce6266462e3171ceb6636cc62e8 (diff) | |
download | linux-37d3455672732b29a477732a94abfe95e199f0ce.tar.bz2 |
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 'drivers/iio/kfifo_buf.c')
-rw-r--r-- | drivers/iio/kfifo_buf.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c index b2beea01c49b..847ca561afe0 100644 --- a/drivers/iio/kfifo_buf.c +++ b/drivers/iio/kfifo_buf.c @@ -83,9 +83,6 @@ static int iio_store_to_kfifo(struct iio_buffer *r, ret = kfifo_in(&kf->kf, data, 1); if (ret != 1) return -EBUSY; - - wake_up_interruptible_poll(&r->pollq, POLLIN | POLLRDNORM); - return 0; } @@ -109,16 +106,16 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, return copied; } -static bool iio_kfifo_buf_data_available(struct iio_buffer *r) +static size_t iio_kfifo_buf_data_available(struct iio_buffer *r) { struct iio_kfifo *kf = iio_to_kfifo(r); - bool empty; + size_t samples; mutex_lock(&kf->user_lock); - empty = kfifo_is_empty(&kf->kf); + samples = kfifo_len(&kf->kf); mutex_unlock(&kf->user_lock); - return !empty; + return samples; } static void iio_kfifo_buffer_release(struct iio_buffer *buffer) |