diff options
Diffstat (limited to 'drivers/hid/hid-logitech-dj.c')
-rw-r--r-- | drivers/hid/hid-logitech-dj.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c index 486dbde2ba2d..9bf8637747a5 100644 --- a/drivers/hid/hid-logitech-dj.c +++ b/drivers/hid/hid-logitech-dj.c | |||
@@ -238,13 +238,6 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev, | |||
238 | return; | 238 | return; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) || | ||
242 | (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) { | ||
243 | dev_err(&djrcv_hdev->dev, "%s: invalid device index:%d\n", | ||
244 | __func__, dj_report->device_index); | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | if (djrcv_dev->paired_dj_devices[dj_report->device_index]) { | 241 | if (djrcv_dev->paired_dj_devices[dj_report->device_index]) { |
249 | /* The device is already known. No need to reallocate it. */ | 242 | /* The device is already known. No need to reallocate it. */ |
250 | dbg_hid("%s: device is already known\n", __func__); | 243 | dbg_hid("%s: device is already known\n", __func__); |
@@ -557,7 +550,7 @@ static int logi_dj_ll_raw_request(struct hid_device *hid, | |||
557 | if (!out_buf) | 550 | if (!out_buf) |
558 | return -ENOMEM; | 551 | return -ENOMEM; |
559 | 552 | ||
560 | if (count < DJREPORT_SHORT_LENGTH - 2) | 553 | if (count > DJREPORT_SHORT_LENGTH - 2) |
561 | count = DJREPORT_SHORT_LENGTH - 2; | 554 | count = DJREPORT_SHORT_LENGTH - 2; |
562 | 555 | ||
563 | out_buf[0] = REPORT_ID_DJ_SHORT; | 556 | out_buf[0] = REPORT_ID_DJ_SHORT; |
@@ -663,7 +656,6 @@ static int logi_dj_raw_event(struct hid_device *hdev, | |||
663 | struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev); | 656 | struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev); |
664 | struct dj_report *dj_report = (struct dj_report *) data; | 657 | struct dj_report *dj_report = (struct dj_report *) data; |
665 | unsigned long flags; | 658 | unsigned long flags; |
666 | bool report_processed = false; | ||
667 | 659 | ||
668 | dbg_hid("%s, size:%d\n", __func__, size); | 660 | dbg_hid("%s, size:%d\n", __func__, size); |
669 | 661 | ||
@@ -691,27 +683,41 @@ static int logi_dj_raw_event(struct hid_device *hdev, | |||
691 | * anything else with it. | 683 | * anything else with it. |
692 | */ | 684 | */ |
693 | 685 | ||
686 | /* case 1) */ | ||
687 | if (data[0] != REPORT_ID_DJ_SHORT) | ||
688 | return false; | ||
689 | |||
690 | if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) || | ||
691 | (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) { | ||
692 | /* | ||
693 | * Device index is wrong, bail out. | ||
694 | * This driver can ignore safely the receiver notifications, | ||
695 | * so ignore those reports too. | ||
696 | */ | ||
697 | if (dj_report->device_index != DJ_RECEIVER_INDEX) | ||
698 | dev_err(&hdev->dev, "%s: invalid device index:%d\n", | ||
699 | __func__, dj_report->device_index); | ||
700 | return false; | ||
701 | } | ||
702 | |||
694 | spin_lock_irqsave(&djrcv_dev->lock, flags); | 703 | spin_lock_irqsave(&djrcv_dev->lock, flags); |
695 | if (dj_report->report_id == REPORT_ID_DJ_SHORT) { | 704 | switch (dj_report->report_type) { |
696 | switch (dj_report->report_type) { | 705 | case REPORT_TYPE_NOTIF_DEVICE_PAIRED: |
697 | case REPORT_TYPE_NOTIF_DEVICE_PAIRED: | 706 | case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED: |
698 | case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED: | 707 | logi_dj_recv_queue_notification(djrcv_dev, dj_report); |
699 | logi_dj_recv_queue_notification(djrcv_dev, dj_report); | 708 | break; |
700 | break; | 709 | case REPORT_TYPE_NOTIF_CONNECTION_STATUS: |
701 | case REPORT_TYPE_NOTIF_CONNECTION_STATUS: | 710 | if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] == |
702 | if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] == | 711 | STATUS_LINKLOSS) { |
703 | STATUS_LINKLOSS) { | 712 | logi_dj_recv_forward_null_report(djrcv_dev, dj_report); |
704 | logi_dj_recv_forward_null_report(djrcv_dev, dj_report); | ||
705 | } | ||
706 | break; | ||
707 | default: | ||
708 | logi_dj_recv_forward_report(djrcv_dev, dj_report); | ||
709 | } | 713 | } |
710 | report_processed = true; | 714 | break; |
715 | default: | ||
716 | logi_dj_recv_forward_report(djrcv_dev, dj_report); | ||
711 | } | 717 | } |
712 | spin_unlock_irqrestore(&djrcv_dev->lock, flags); | 718 | spin_unlock_irqrestore(&djrcv_dev->lock, flags); |
713 | 719 | ||
714 | return report_processed; | 720 | return true; |
715 | } | 721 | } |
716 | 722 | ||
717 | static int logi_dj_probe(struct hid_device *hdev, | 723 | static int logi_dj_probe(struct hid_device *hdev, |