From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> usb_control_msg() used to return the number bytes transferred wheras the replacement (control_message()) just returns 0 vs. error. This means the EALREADY handling is now broken. So let's just remove the EALREADY handling entirely. Cc: Marcel Holtmann <marcel@xxxxxxxxxxxx> Fixes: e3cc40084ce4 ("tools: Remove libusb dependency from hid2hci") --- tools/hid2hci.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/hid2hci.c b/tools/hid2hci.c index 1e0f7aa2ab8b..206a5af032ae 100644 --- a/tools/hid2hci.c +++ b/tools/hid2hci.c @@ -111,10 +111,7 @@ static int usb_switch_csr(int fd, enum mode mode) err = control_message(fd, USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, mode, 0, NULL, 0, 10000); - if (err == 0) { - err = -1; - errno = EALREADY; - } else if (errno == ETIMEDOUT) + if (err < 0 && errno == ETIMEDOUT) err = 0; return err; @@ -255,13 +252,8 @@ static int usb_switch_dell(int fd, enum mode mode) USB_REQ_SET_CONFIGURATION, 0x7f | (0x03 << 8), 0, report, sizeof(report), 5000); - if (err == 0) { - err = -1; - errno = EALREADY; - } else { - if (errno == ETIMEDOUT) - err = 0; - } + if (err < 0 && errno == ETIMEDOUT) + err = 0; return err; } -- 2.21.0