aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@kernel.org>2012-06-30 08:52:00 -0400
committerJonathan Cameron <jic23@kernel.org>2012-08-27 13:58:30 -0400
commitc559afbfb08c7eac215ba417251225d3a8e01062 (patch)
treefedb159ef6c40d89c2fe9769dfddac67be6667f3 /drivers/iio
parent8e8287526844441008df286536a21722277bb487 (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')
-rw-r--r--drivers/iio/kfifo_buf.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 6bf9d05f484..8a6d28ce21b 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,
22 return -EINVAL; 22 return -EINVAL;
23 23
24 __iio_update_buffer(&buf->buffer, bytes_per_datum, length); 24 __iio_update_buffer(&buf->buffer, bytes_per_datum, length);
25 return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL); 25 return __kfifo_alloc((struct __kfifo *)&buf->kf, length,
26 bytes_per_datum, GFP_KERNEL);
26} 27}
27 28
28static int iio_request_update_kfifo(struct iio_buffer *r) 29static int iio_request_update_kfifo(struct iio_buffer *r)
@@ -94,9 +95,10 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
94{ 95{
95 int ret; 96 int ret;
96 struct iio_kfifo *kf = iio_to_kfifo(r); 97 struct iio_kfifo *kf = iio_to_kfifo(r);
97 ret = kfifo_in(&kf->kf, data, r->bytes_per_datum); 98 ret = kfifo_in(&kf->kf, data, 1);
98 if (ret != r->bytes_per_datum) 99 if (ret != 1)
99 return -EBUSY; 100 return -EBUSY;
101
100 return 0; 102 return 0;
101} 103}
102 104
@@ -109,7 +111,6 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
109 if (n < r->bytes_per_datum) 111 if (n < r->bytes_per_datum)
110 return -EINVAL; 112 return -EINVAL;
111 113
112 n = rounddown(n, r->bytes_per_datum);
113 ret = kfifo_to_user(&kf->kf, buf, n, &copied); 114 ret = kfifo_to_user(&kf->kf, buf, n, &copied);
114 115
115 return copied; 116 return copied;