forked from drath/libratbag
Make libratbag-hidraw return negative errnos on error
Be consistent here. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -82,7 +82,7 @@ static int hidpp10_write_command(struct ratbag_device *device, __u8 *cmd, int si
|
||||
return 0;
|
||||
|
||||
if (res < 0)
|
||||
log_error(device->ratbag, "Error: %d\n", errno);
|
||||
log_error(device->ratbag, "Error: %d\n", -res);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ int hidpp10_request_command(struct ratbag_device *device, union hidpp10_message
|
||||
} while (ret > 0);
|
||||
|
||||
if (ret < 0) {
|
||||
log_error(ratbag, " USB error: %d\n", errno);
|
||||
log_error(ratbag, " USB error: %d\n", -ret);
|
||||
perror("write");
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ hidpp20_write_command(struct ratbag_device *device, uint8_t *cmd, int size)
|
||||
return 0;
|
||||
|
||||
if (res < 0)
|
||||
log_error(device->ratbag, "Error: %d\n", errno);
|
||||
log_error(device->ratbag, "Error: %d\n", -res);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ hidpp20_request_command(struct ratbag_device *device, union hidpp20_message *msg
|
||||
} while (ret > 0);
|
||||
|
||||
if (ret < 0) {
|
||||
log_error(ratbag, " USB error: %d\n", errno);
|
||||
log_error(ratbag, " USB error: %d\n", -ret);
|
||||
perror("write");
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ ratbag_hidraw_output_report(struct ratbag_device *ratbag, uint8_t *buf, size_t l
|
||||
rc = write(ratbag->hidraw_fd, buf, len);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
return -errno;
|
||||
|
||||
if (rc != (int)len)
|
||||
return -EIO;
|
||||
@@ -139,8 +139,11 @@ ratbag_hidraw_output_report(struct ratbag_device *ratbag, uint8_t *buf, size_t l
|
||||
int
|
||||
ratbag_hidraw_read_input_report(struct ratbag_device *ratbag, uint8_t *buf, size_t len)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (len < 1 || !buf || ratbag->hidraw_fd < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return read(ratbag->hidraw_fd, buf, len);
|
||||
rc = read(ratbag->hidraw_fd, buf, len);
|
||||
return rc >= 0 ? rc : -errno;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ int ratbag_open_hidraw(struct ratbag_device *ratbag);
|
||||
* @rtype: HID report type
|
||||
* @reqtype: HID_REQ_GET_REPORT or HID_REQ_SET_REPORT
|
||||
*
|
||||
* @return: count of data transfered, negative if error
|
||||
* @return count of data transfered, or a negative errno on error
|
||||
*
|
||||
* Same behavior as hid_hw_request, but with raw buffers instead.
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ int ratbag_hidraw_raw_request(struct ratbag_device *ratbag, unsigned char report
|
||||
* @buf: raw data to transfer
|
||||
* @len: length of buf
|
||||
*
|
||||
* @return: count of data transfered, negative if error
|
||||
* @return count of data transfered, or a negative errno on error
|
||||
*/
|
||||
int ratbag_hidraw_output_report(struct ratbag_device *ratbag, uint8_t *buf, size_t len);
|
||||
|
||||
@@ -72,7 +72,7 @@ int ratbag_hidraw_output_report(struct ratbag_device *ratbag, uint8_t *buf, size
|
||||
* @buf: resulting raw data
|
||||
* @len: length of buf
|
||||
*
|
||||
* @return: count of data transfered, negative if error
|
||||
* @return count of data transfered, or a negative errno on error
|
||||
*/
|
||||
int ratbag_hidraw_read_input_report(struct ratbag_device *ratbag, uint8_t *buf, size_t len);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user