Commit fa56e0e4 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-2023060501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

Pull HID fix from Jiri Kosina:

 - Final, confirmed fix for regression causing some devices connected
   via Logitech HID++ Unifying receiver take too long to initialize
   (Benjamin Tissoires)

* tag 'for-linus-2023060501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  HID: hidpp: terminate retry loop on success
parents f8dba31b 7c28afd5
...@@ -286,7 +286,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, ...@@ -286,7 +286,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
struct hidpp_report *message, struct hidpp_report *message,
struct hidpp_report *response) struct hidpp_report *response)
{ {
int ret; int ret = -1;
int max_retries = 3; int max_retries = 3;
mutex_lock(&hidpp->send_mutex); mutex_lock(&hidpp->send_mutex);
...@@ -300,13 +300,13 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, ...@@ -300,13 +300,13 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
*/ */
*response = *message; *response = *message;
for (; max_retries != 0; max_retries--) { for (; max_retries != 0 && ret; max_retries--) {
ret = __hidpp_send_report(hidpp->hid_dev, message); ret = __hidpp_send_report(hidpp->hid_dev, message);
if (ret) { if (ret) {
dbg_hid("__hidpp_send_report returned err: %d\n", ret); dbg_hid("__hidpp_send_report returned err: %d\n", ret);
memset(response, 0, sizeof(struct hidpp_report)); memset(response, 0, sizeof(struct hidpp_report));
goto exit; break;
} }
if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, if (!wait_event_timeout(hidpp->wait, hidpp->answer_available,
...@@ -314,14 +314,14 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, ...@@ -314,14 +314,14 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
dbg_hid("%s:timeout waiting for response\n", __func__); dbg_hid("%s:timeout waiting for response\n", __func__);
memset(response, 0, sizeof(struct hidpp_report)); memset(response, 0, sizeof(struct hidpp_report));
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
goto exit; break;
} }
if (response->report_id == REPORT_ID_HIDPP_SHORT && if (response->report_id == REPORT_ID_HIDPP_SHORT &&
response->rap.sub_id == HIDPP_ERROR) { response->rap.sub_id == HIDPP_ERROR) {
ret = response->rap.params[1]; ret = response->rap.params[1];
dbg_hid("%s:got hidpp error %02X\n", __func__, ret); dbg_hid("%s:got hidpp error %02X\n", __func__, ret);
goto exit; break;
} }
if ((response->report_id == REPORT_ID_HIDPP_LONG || if ((response->report_id == REPORT_ID_HIDPP_LONG ||
...@@ -330,13 +330,12 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, ...@@ -330,13 +330,12 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
ret = response->fap.params[1]; ret = response->fap.params[1];
if (ret != HIDPP20_ERROR_BUSY) { if (ret != HIDPP20_ERROR_BUSY) {
dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret);
goto exit; break;
} }
dbg_hid("%s:got busy hidpp 2.0 error %02X, retrying\n", __func__, ret); dbg_hid("%s:got busy hidpp 2.0 error %02X, retrying\n", __func__, ret);
} }
} }
exit:
mutex_unlock(&hidpp->send_mutex); mutex_unlock(&hidpp->send_mutex);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment