From: Nuno Sá Date: Thu, 16 Feb 2023 10:14:50 +0000 (+0100) Subject: iio: buffer: correctly return bytes written in output buffers X-Git-Tag: v6.3-rc6~5^2^2~8 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b5184a26a28fac1d708b0bfeeb958a9260c2924c;p=linux-2.6-block.git iio: buffer: correctly return bytes written in output buffers If for some reason 'rb->access->write()' does not write the full requested data and the O_NONBLOCK is set, we would return 'n' to userspace which is not really truth. Hence, let's return the number of bytes we effectively wrote. Fixes: 9eeee3b0bf190 ("iio: Add output buffer support") Signed-off-by: Nuno Sá Reviewed-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20230216101452.591805-2-nuno.sa@analog.com Cc: Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 80c78bd6bbef..6340d8e1430b 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -220,7 +220,7 @@ static ssize_t iio_buffer_write(struct file *filp, const char __user *buf, } while (ret == 0); remove_wait_queue(&rb->pollq, &wait); - return ret < 0 ? ret : n; + return ret < 0 ? ret : written; } /**