From c37f45f1252836f9e866b3f2328ac32940c32ffa Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 13 Oct 2015 12:16:59 +1000 Subject: [PATCH] hidpp10: ignore the response length when comparing expected vs real response The request length doesn't tell us what the expected response length is, e.g. 0x63 (current resolution) is set with a long request but replies with a short ack. Signed-off-by: Peter Hutterer --- src/hidpp10.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index 2ec908d4..5ecd51f4 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -126,22 +126,9 @@ hidpp10_request_command(struct hidpp10_device *dev, union hidpp10_message *msg) /* create the expected header */ expected_header = *msg; - switch (msg->msg.sub_id) { - case SET_REGISTER_REQ: - expected_header.msg.report_id = REPORT_ID_SHORT; - break; - case GET_REGISTER_REQ: - expected_header.msg.report_id = REPORT_ID_SHORT; - break; - case SET_LONG_REGISTER_REQ: - expected_header.msg.report_id = REPORT_ID_LONG; - break; - case GET_LONG_REGISTER_REQ: - expected_header.msg.report_id = REPORT_ID_LONG; - break; - } - log_buf_raw(ratbag, " expected_header: ", expected_header.data, 4); + /* response message length doesn't depend on request length */ + log_buf_raw(ratbag, " expected_header: ?? ", &expected_header.data[1], 3); log_buf_raw(ratbag, " expected_error_dev: ", expected_error_dev.data, SHORT_MESSAGE_LENGTH); /* Send the message to the Device */ @@ -170,7 +157,7 @@ hidpp10_request_command(struct hidpp10_device *dev, union hidpp10_message *msg) read_buffer.msg.device_idx = msg->msg.device_idx; /* actual answer */ - if (!memcmp(read_buffer.data, expected_header.data, 4)) + if (!memcmp(&read_buffer.data[1], &expected_header.data[1], 3)) break; /* error */