summaryrefslogtreecommitdiffstats
path: root/drivers/iio/kfifo_buf.c
diff options
context:
space:
mode:
authorGabriele Mazzotta <gabriele.mzt@gmail.com>2015-05-02 14:31:16 +0200
committerJonathan Cameron <jic23@kernel.org>2015-05-08 00:36:58 +0200
commite5f1efb9ae71bbb79629d660dc19b51ce7b95439 (patch)
treefb9414341e79faad10f508d0d19b18eb1db62e1f /drivers/iio/kfifo_buf.c
parentiio: mcp320x: Fix occasional incorrect readings (diff)
downloadlinux-e5f1efb9ae71bbb79629d660dc19b51ce7b95439.tar.xz
linux-e5f1efb9ae71bbb79629d660dc19b51ce7b95439.zip
iio: kfifo: Set update_needed to false only if a buffer was allocated
Check whether the allocation of a new kfifo buffer failed or not before setting the update_needed flag to false. This will make iio_request_update_kfifo() try to allocate a new buffer the next time a buffer update is requested. Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/kfifo_buf.c')
-rw-r--r--drivers/iio/kfifo_buf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
index 847ca561afe0..55c267bbfd2f 100644
--- a/drivers/iio/kfifo_buf.c
+++ b/drivers/iio/kfifo_buf.c
@@ -38,7 +38,8 @@ 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);
- buf->update_needed = false;
+ if (ret >= 0)
+ buf->update_needed = false;
} else {
kfifo_reset_out(&buf->kf);
}