Skip to content

Commit

Permalink
serial: Report other errors (besides timeout) on serial write
Browse files Browse the repository at this point in the history
(ret < len) means either a timeout (not all bytes were written, ret >= 0
but < than len) or something else failed (ret < 0).

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Mar 4, 2021
1 parent 89e337b commit bcb3864
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ static ssize_t serial_write_data(struct iio_context_pdata *pdata,

IIO_DEBUG("Write returned %li: %s\n", (long) ret, data);

if (ret < len) {
if (ret < 0) {
IIO_ERROR("sp_blocking_write returned %i\n", (int) ret);
return ret;
} else if (ret < len) {
IIO_ERROR("sp_blocking_write has timedout\n");
return -ETIMEDOUT;
}
Expand Down

0 comments on commit bcb3864

Please sign in to comment.