diff options
author | Jonathan Cameron <jic23@kernel.org> | 2012-06-30 13:52:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-08-27 18:58:37 +0100 |
commit | 7c388ec1d4bc55b72802afbddb26ab87bc762438 (patch) | |
tree | f938cead3ba869643d80849ef912c71b1497ee83 /drivers/iio | |
parent | 08ce9b44b53c580987b6a63df4e2206e45e20b92 (diff) | |
download | talos-op-linux-7c388ec1d4bc55b72802afbddb26ab87bc762438.tar.gz talos-op-linux-7c388ec1d4bc55b72802afbddb26ab87bc762438.zip |
iio: kfifo - add poll support.
This buffer implementation was missing poll support.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/kfifo_buf.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c index 6ec763f1202a..63da42498a9a 100644 --- a/drivers/iio/kfifo_buf.c +++ b/drivers/iio/kfifo_buf.c @@ -6,6 +6,7 @@ #include <linux/kfifo.h> #include <linux/mutex.h> #include <linux/iio/kfifo_buf.h> +#include <linux/sched.h> struct iio_kfifo { struct iio_buffer buffer; @@ -36,6 +37,7 @@ static int iio_request_update_kfifo(struct iio_buffer *r) kfifo_free(&buf->kf); ret = __iio_allocate_kfifo(buf, buf->buffer.bytes_per_datum, buf->buffer.length); + r->stufftoread = false; error_ret: return ret; } @@ -82,6 +84,9 @@ static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd) static int iio_set_length_kfifo(struct iio_buffer *r, int length) { + /* Avoid an invalid state */ + if (length < 2) + length = 2; if (r->length != length) { r->length = length; iio_mark_update_needed_kfifo(r); @@ -98,6 +103,8 @@ static int iio_store_to_kfifo(struct iio_buffer *r, ret = kfifo_in(&kf->kf, data, 1); if (ret != 1) return -EBUSY; + r->stufftoread = true; + wake_up_interruptible(&r->pollq); return 0; } @@ -115,6 +122,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, if (ret < 0) return ret; + if (kfifo_is_empty(&kf->kf)) + r->stufftoread = false; + /* verify it is still empty to avoid race */ + if (!kfifo_is_empty(&kf->kf)) + r->stufftoread = true; + return copied; } @@ -139,7 +152,7 @@ struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev) iio_buffer_init(&kf->buffer); kf->buffer.attrs = &iio_kfifo_attribute_group; kf->buffer.access = &kfifo_access_funcs; - + kf->buffer.length = 2; return &kf->buffer; } EXPORT_SYMBOL(iio_kfifo_allocate); |