diff options
| -rw-r--r-- | drivers/hid/hid-logitech-hidpp.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 8d2d54b527b0..61f9e75c45d2 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
| @@ -151,6 +151,14 @@ static int __hidpp_send_report(struct hid_device *hdev, | |||
| 151 | return ret == fields_count ? 0 : -1; | 151 | return ret == fields_count ? 0 : -1; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | /** | ||
| 155 | * hidpp_send_message_sync() returns 0 in case of success, and something else | ||
| 156 | * in case of a failure. | ||
| 157 | * - If ' something else' is positive, that means that an error has been raised | ||
| 158 | * by the protocol itself. | ||
| 159 | * - If ' something else' is negative, that means that we had a classic error | ||
| 160 | * (-ENOMEM, -EPIPE, etc...) | ||
| 161 | */ | ||
| 154 | static int hidpp_send_message_sync(struct hidpp_device *hidpp, | 162 | static int hidpp_send_message_sync(struct hidpp_device *hidpp, |
| 155 | struct hidpp_report *message, | 163 | struct hidpp_report *message, |
| 156 | struct hidpp_report *response) | 164 | struct hidpp_report *response) |
| @@ -359,8 +367,13 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) | |||
| 359 | return 0; | 367 | return 0; |
| 360 | } | 368 | } |
| 361 | 369 | ||
| 370 | if (ret > 0) { | ||
| 371 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | ||
| 372 | __func__, ret); | ||
| 373 | return -EPROTO; | ||
| 374 | } | ||
| 362 | if (ret) | 375 | if (ret) |
| 363 | return -ret; | 376 | return ret; |
| 364 | 377 | ||
| 365 | hidpp->protocol_major = response.fap.params[0]; | 378 | hidpp->protocol_major = response.fap.params[0]; |
| 366 | hidpp->protocol_minor = response.fap.params[1]; | 379 | hidpp->protocol_minor = response.fap.params[1]; |
| @@ -398,8 +411,13 @@ static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, | |||
| 398 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, | 411 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, |
| 399 | CMD_GET_DEVICE_NAME_TYPE_GET_COUNT, NULL, 0, &response); | 412 | CMD_GET_DEVICE_NAME_TYPE_GET_COUNT, NULL, 0, &response); |
| 400 | 413 | ||
| 414 | if (ret > 0) { | ||
| 415 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | ||
| 416 | __func__, ret); | ||
| 417 | return -EPROTO; | ||
| 418 | } | ||
| 401 | if (ret) | 419 | if (ret) |
| 402 | return -ret; | 420 | return ret; |
| 403 | 421 | ||
| 404 | *nameLength = response.fap.params[0]; | 422 | *nameLength = response.fap.params[0]; |
| 405 | 423 | ||
| @@ -417,8 +435,13 @@ static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, | |||
| 417 | CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME, &char_index, 1, | 435 | CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME, &char_index, 1, |
| 418 | &response); | 436 | &response); |
| 419 | 437 | ||
| 438 | if (ret > 0) { | ||
| 439 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | ||
| 440 | __func__, ret); | ||
| 441 | return -EPROTO; | ||
| 442 | } | ||
| 420 | if (ret) | 443 | if (ret) |
| 421 | return -ret; | 444 | return ret; |
| 422 | 445 | ||
| 423 | if (response.report_id == REPORT_ID_HIDPP_LONG) | 446 | if (response.report_id == REPORT_ID_HIDPP_LONG) |
| 424 | count = HIDPP_REPORT_LONG_LENGTH - 4; | 447 | count = HIDPP_REPORT_LONG_LENGTH - 4; |
| @@ -524,8 +547,13 @@ static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, | |||
| 524 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, | 547 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, |
| 525 | CMD_TOUCHPAD_GET_RAW_INFO, NULL, 0, &response); | 548 | CMD_TOUCHPAD_GET_RAW_INFO, NULL, 0, &response); |
| 526 | 549 | ||
| 550 | if (ret > 0) { | ||
| 551 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | ||
| 552 | __func__, ret); | ||
| 553 | return -EPROTO; | ||
| 554 | } | ||
| 527 | if (ret) | 555 | if (ret) |
| 528 | return -ret; | 556 | return ret; |
| 529 | 557 | ||
| 530 | raw_info->x_size = get_unaligned_be16(¶ms[0]); | 558 | raw_info->x_size = get_unaligned_be16(¶ms[0]); |
| 531 | raw_info->y_size = get_unaligned_be16(¶ms[2]); | 559 | raw_info->y_size = get_unaligned_be16(¶ms[2]); |
