From: Peter Meerwald Date: Sat, 6 Dec 2014 06:00:00 +0000 (+0000) Subject: staging:iio: Fix error handling in generic_buffer example X-Git-Tag: v3.17-rc1~123^2~1942^2~7 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=97b603a4e96565c3a3b09b9a4131d4107b0c6581;p=karo-tx-linux.git staging:iio: Fix error handling in generic_buffer example read() does not return -EAGAIN read() returns -1 and the errno value needs to be checked for -EAGAIN Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c index 40d0ecac047f..044ea196aa6f 100644 --- a/drivers/staging/iio/Documentation/generic_buffer.c +++ b/drivers/staging/iio/Documentation/generic_buffer.c @@ -305,9 +305,12 @@ int main(int argc, char **argv) read_size = read(fp, data, toread*scan_size); - if (read_size == -EAGAIN) { - printf("nothing available\n"); - continue; + if (read_size < 0) { + if (errno == -EAGAIN) { + printf("nothing available\n"); + continue; + } else + break; } for (i = 0; i < read_size/scan_size; i++) process_scan(data + scan_size*i,