aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/kfifo_buf.c
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@kernel.org>2012-08-27 13:40:04 -0400
committerJonathan Cameron <jic23@kernel.org>2012-08-27 13:58:36 -0400
commit08ce9b44b53c580987b6a63df4e2206e45e20b92 (patch)
tree62e59a11a0048b3f26af6c616f7ab931aed97734 /drivers/iio/kfifo_buf.c
parentc559afbfb08c7eac215ba417251225d3a8e01062 (diff)
iio:kfifo_buf improve error handling in read_first_n.
These two elements were originally in the patch iio:kfifo_buf Take advantage of the fixed record size used in IIO but Lars-Peter Clausen pointed out they should not have been so here they are. 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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 8a6d28ce21b2..6ec763f1202a 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -108,10 +108,12 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
108 int ret, copied; 108 int ret, copied;
109 struct iio_kfifo *kf = iio_to_kfifo(r); 109 struct iio_kfifo *kf = iio_to_kfifo(r);
110 110
111 if (n < r->bytes_per_datum) 111 if (n < r->bytes_per_datum || r->bytes_per_datum == 0)
112 return -EINVAL; 112 return -EINVAL;
113 113
114 ret = kfifo_to_user(&kf->kf, buf, n, &copied); 114 ret = kfifo_to_user(&kf->kf, buf, n, &copied);
115 if (ret < 0)
116 return ret;
115 117
116 return copied; 118 return copied;
117} 119}