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:30 +0100 |
commit | c559afbfb08c7eac215ba417251225d3a8e01062 (patch) | |
tree | fedb159ef6c40d89c2fe9769dfddac67be6667f3 /drivers/iio/kfifo_buf.c | |
parent | 8e8287526844441008df286536a21722277bb487 (diff) |
iio:kfifo_buf Take advantage of the fixed record size used in IIO
By bypassing the standard macros for setting up the kfifo we can
take advantage of the fixed record size implementation without
having to have a type to pass in (from which the size of an element
is normally established).
In IIO we have variable 'scans' as our records in which any element
can be present or not. They do not however vary when we are
actually filling or reading from the buffer. Thus we have a fixed
record size whenever we are actually running. As setup and tear
down are not in the fast path we can take the overhead of reinitializing
the kfifo every time.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Diffstat (limited to 'drivers/iio/kfifo_buf.c')
-rw-r--r-- | drivers/iio/kfifo_buf.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c index 6bf9d05f4841..8a6d28ce21b2 100644 --- a/drivers/iio/kfifo_buf.c +++ b/drivers/iio/kfifo_buf.c @@ -22,7 +22,8 @@ static inline int __iio_allocate_kfifo(struct iio_kfifo *buf, return -EINVAL; __iio_update_buffer(&buf->buffer, bytes_per_datum, length); - return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL); + return __kfifo_alloc((struct __kfifo *)&buf->kf, length, + bytes_per_datum, GFP_KERNEL); } static int iio_request_update_kfifo(struct iio_buffer *r) @@ -94,9 +95,10 @@ static int iio_store_to_kfifo(struct iio_buffer *r, { int ret; struct iio_kfifo *kf = iio_to_kfifo(r); - ret = kfifo_in(&kf->kf, data, r->bytes_per_datum); - if (ret != r->bytes_per_datum) + ret = kfifo_in(&kf->kf, data, 1); + if (ret != 1) return -EBUSY; + return 0; } @@ -109,7 +111,6 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r, if (n < r->bytes_per_datum) return -EINVAL; - n = rounddown(n, r->bytes_per_datum); ret = kfifo_to_user(&kf->kf, buf, n, &copied); return copied; |