From 22b6e87f37d9ccc862ce8ced6558cdabd86275d7 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 19 Jun 2021 18:18:51 +0900 Subject: [PATCH] ibmpc: Revert 2a0471fd on ibmpc_host_send() Restoring old recv_data can overwrite response data when the response is multi-byte. This can happen when device responds with multiple bytes quickly, for example Logitech MX518(PS/2) sends FA 00 in short period to F2 command while most of devices doesn't send second byte that fast. recv_data is cleared when calling ibmpc_host_send() you will have to retain the data yourself before calling it. Or you have to make sure that recv_data is empty as possible before calling the function. Alternatively, ibmpc_host_send() can be changed to check if recv_data is empty before seding command. --- tmk_core/protocol/ibmpc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c index 880380f1..c275b5e3 100644 --- a/tmk_core/protocol/ibmpc.c +++ b/tmk_core/protocol/ibmpc.c @@ -153,19 +153,12 @@ RETRY: WAIT(data_hi, 300, 7); WAIT(clock_hi, 300, 8); - uint16_t d = recv_data; - // clear buffer to get response correctly ibmpc_host_isr_clear(); idle(); IBMPC_INT_ON(); - int16_t r = ibmpc_host_recv_response(); - if (d != 0xFFFF) dprintf("r:%04X ", d); - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { - recv_data = d; - } - return r; + return ibmpc_host_recv_response(); ERROR: // Retry for Z-150 AT start bit error if (ibmpc_error == 1 && retry++ < 10) {