hidraw: return -ETIMEDOUT when a timeout occured

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This commit is contained in:
Benjamin Tissoires
2015-09-07 12:31:04 -04:00
parent a8e592e1bc
commit 7a679c9f97

View File

@@ -143,9 +143,13 @@ ratbag_hidraw_read_input_report(struct ratbag_device *device, uint8_t *buf, size
fds.fd = device->hidraw_fd;
fds.events = POLLIN;
if (poll(&fds, 1, 1000) == -1)
rc = poll(&fds, 1, 1000);
if (rc == -1)
return -errno;
if (rc == 0)
return -ETIMEDOUT;
rc = read(device->hidraw_fd, buf, len);
return rc >= 0 ? rc : -errno;
}