debug: put the raw debug logs in hidraw, not in per-driver handlers

Might not be the best solution for hidpp10, because it just removes the
duplicates, but this way all of the other drivers can benefit from the
raw debug parameter.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires
2015-09-18 10:56:58 -04:00
parent 98c38ba77c
commit 0f1b11a874
3 changed files with 11 additions and 9 deletions

View File

@@ -141,7 +141,6 @@ hidpp10_request_command(struct hidpp10_device *dev, union hidpp10_message *msg)
break;
}
log_buf_raw(ratbag, "sending: ", msg->data, command_size);
log_buf_raw(ratbag, " expected_header: ", expected_header.data, 4);
log_buf_raw(ratbag, " expected_error_dev: ", expected_error_dev.data, SHORT_MESSAGE_LENGTH);
@@ -170,9 +169,6 @@ hidpp10_request_command(struct hidpp10_device *dev, union hidpp10_message *msg)
*/
read_buffer.msg.device_idx = msg->msg.device_idx;
log_buf_raw(ratbag, " *** received: ", read_buffer.data, ret > 0 ? ret : 0);
/* actual answer */
if (!memcmp(read_buffer.data, expected_header.data, 4))
break;

View File

@@ -103,8 +103,6 @@ hidpp20_request_command_allow_error(struct ratbag_device *device, union hidpp20_
msg_len = msg->msg.report_id == REPORT_ID_SHORT ? SHORT_MESSAGE_LENGTH : LONG_MESSAGE_LENGTH;
log_buf_raw(ratbag, "sending: ", msg->data, msg_len);
/* Send the message to the Device */
ret = hidpp20_write_command(device, msg->data, msg_len);
if (ret)
@@ -123,8 +121,6 @@ hidpp20_request_command_allow_error(struct ratbag_device *device, union hidpp20_
ret = ratbag_hidraw_read_input_report(device, read_buffer.data, LONG_MESSAGE_LENGTH);
}
log_buf_raw(ratbag, " *** received: ", read_buffer.data, ret > 0 ? ret : 0);
if (read_buffer.msg.report_id != REPORT_ID_SHORT &&
read_buffer.msg.report_id != REPORT_ID_LONG)
continue;

View File

@@ -170,7 +170,7 @@ int
ratbag_hidraw_raw_request(struct ratbag_device *device, unsigned char reportnum,
uint8_t *buf, size_t len, unsigned char rtype, int reqtype)
{
char tmp_buf[HID_MAX_BUFFER_SIZE];
uint8_t tmp_buf[HID_MAX_BUFFER_SIZE];
int rc;
if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf || device->hidraw.fd < 0)
@@ -188,10 +188,14 @@ ratbag_hidraw_raw_request(struct ratbag_device *device, unsigned char reportnum,
if (rc < 0)
return -errno;
log_buf_raw(device->ratbag, "feature get: ", tmp_buf, (unsigned)rc);
memcpy(buf, tmp_buf, rc);
return rc;
case HID_REQ_SET_REPORT:
buf[0] = reportnum;
log_buf_raw(device->ratbag, "feature set: ", buf, len);
rc = ioctl(device->hidraw.fd, HIDIOCSFEATURE(len), buf);
if (rc < 0)
return -errno;
@@ -210,6 +214,8 @@ ratbag_hidraw_output_report(struct ratbag_device *device, uint8_t *buf, size_t l
if (len < 1 || len > HID_MAX_BUFFER_SIZE || !buf || device->hidraw.fd < 0)
return -EINVAL;
log_buf_raw(device->ratbag, "output report: ", buf, len);
rc = write(device->hidraw.fd, buf, len);
if (rc < 0)
@@ -241,5 +247,9 @@ ratbag_hidraw_read_input_report(struct ratbag_device *device, uint8_t *buf, size
return -ETIMEDOUT;
rc = read(device->hidraw.fd, buf, len);
if (rc > 0)
log_buf_raw(device->ratbag, "input report: ", buf, rc);
return rc >= 0 ? rc : -errno;
}