diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2014-12-06 01:00:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-06-14 11:09:24 -0400 |
commit | 97b603a4e96565c3a3b09b9a4131d4107b0c6581 (patch) | |
tree | 9a5998d695b4671500826e2c21f9d1780fa5d965 | |
parent | 723db167246ae60999699916a1563887e3adb535 (diff) |
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 <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/staging/iio/Documentation/generic_buffer.c | 9 |
1 files changed, 6 insertions, 3 deletions
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) | |||
305 | read_size = read(fp, | 305 | read_size = read(fp, |
306 | data, | 306 | data, |
307 | toread*scan_size); | 307 | toread*scan_size); |
308 | if (read_size == -EAGAIN) { | 308 | if (read_size < 0) { |
309 | printf("nothing available\n"); | 309 | if (errno == -EAGAIN) { |
310 | continue; | 310 | printf("nothing available\n"); |
311 | continue; | ||
312 | } else | ||
313 | break; | ||
311 | } | 314 | } |
312 | for (i = 0; i < read_size/scan_size; i++) | 315 | for (i = 0; i < read_size/scan_size; i++) |
313 | process_scan(data + scan_size*i, | 316 | process_scan(data + scan_size*i, |