diff options
author | Adam Kropelin <akropel1@rochester.rr.com> | 2005-07-11 02:09:32 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-07-11 02:09:32 -0400 |
commit | bc5d04822bd9f34ea93a681f05f5e5683935d574 (patch) | |
tree | f0ebc97e220fbf9c7f104ade10bc93443aca40ef /drivers/usb | |
parent | 153ab429cad3b585ddf1a5521cfaadb57402cd31 (diff) |
Input: HID - only report events coming from interrupts to hiddev
Currently hid-core follows the same code path for input reports
regardless of whether they are a result of interrupt transfers or
control transfers. That leads to interrupt events erroneously being
reported to hiddev for regular control transfers.
Prior to 2.6.12 the problem was mitigated by the fact that
reporting to hiddev is supressed if the field value has not changed,
which is often the case. Said filtering was removed in 2.6.12-rc1 which
means any input reports fetched via control transfers result in hiddev
interrupt events. This behavior can quickly lead to a feedback loop
where a userspace app, in response to interrupt events, issues control
transfers which in turn create more interrupt events.
This patch prevents input reports that arrive via control transfers from
being reported to hiddev as interrupt events.
Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/input/hid-core.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index 271f5bdb8bb3..30b1b2dae731 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -789,12 +789,12 @@ static __inline__ int search(__s32 *array, __s32 value, unsigned n) | |||
789 | return -1; | 789 | return -1; |
790 | } | 790 | } |
791 | 791 | ||
792 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, struct pt_regs *regs) | 792 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value, int interrupt, struct pt_regs *regs) |
793 | { | 793 | { |
794 | hid_dump_input(usage, value); | 794 | hid_dump_input(usage, value); |
795 | if (hid->claimed & HID_CLAIMED_INPUT) | 795 | if (hid->claimed & HID_CLAIMED_INPUT) |
796 | hidinput_hid_event(hid, field, usage, value, regs); | 796 | hidinput_hid_event(hid, field, usage, value, regs); |
797 | if (hid->claimed & HID_CLAIMED_HIDDEV) | 797 | if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt) |
798 | hiddev_hid_event(hid, field, usage, value, regs); | 798 | hiddev_hid_event(hid, field, usage, value, regs); |
799 | } | 799 | } |
800 | 800 | ||
@@ -804,7 +804,7 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s | |||
804 | * reporting to the layer). | 804 | * reporting to the layer). |
805 | */ | 805 | */ |
806 | 806 | ||
807 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, struct pt_regs *regs) | 807 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt, struct pt_regs *regs) |
808 | { | 808 | { |
809 | unsigned n; | 809 | unsigned n; |
810 | unsigned count = field->report_count; | 810 | unsigned count = field->report_count; |
@@ -831,19 +831,19 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, __u | |||
831 | for (n = 0; n < count; n++) { | 831 | for (n = 0; n < count; n++) { |
832 | 832 | ||
833 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { | 833 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { |
834 | hid_process_event(hid, field, &field->usage[n], value[n], regs); | 834 | hid_process_event(hid, field, &field->usage[n], value[n], interrupt, regs); |
835 | continue; | 835 | continue; |
836 | } | 836 | } |
837 | 837 | ||
838 | if (field->value[n] >= min && field->value[n] <= max | 838 | if (field->value[n] >= min && field->value[n] <= max |
839 | && field->usage[field->value[n] - min].hid | 839 | && field->usage[field->value[n] - min].hid |
840 | && search(value, field->value[n], count)) | 840 | && search(value, field->value[n], count)) |
841 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, regs); | 841 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt, regs); |
842 | 842 | ||
843 | if (value[n] >= min && value[n] <= max | 843 | if (value[n] >= min && value[n] <= max |
844 | && field->usage[value[n] - min].hid | 844 | && field->usage[value[n] - min].hid |
845 | && search(field->value, value[n], count)) | 845 | && search(field->value, value[n], count)) |
846 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, regs); | 846 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt, regs); |
847 | } | 847 | } |
848 | 848 | ||
849 | memcpy(field->value, value, count * sizeof(__s32)); | 849 | memcpy(field->value, value, count * sizeof(__s32)); |
@@ -851,7 +851,7 @@ exit: | |||
851 | kfree(value); | 851 | kfree(value); |
852 | } | 852 | } |
853 | 853 | ||
854 | static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs) | 854 | static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_regs *regs) |
855 | { | 855 | { |
856 | struct hid_device *hid = urb->context; | 856 | struct hid_device *hid = urb->context; |
857 | struct hid_report_enum *report_enum = hid->report_enum + type; | 857 | struct hid_report_enum *report_enum = hid->report_enum + type; |
@@ -899,7 +899,7 @@ static int hid_input_report(int type, struct urb *urb, struct pt_regs *regs) | |||
899 | hiddev_report_event(hid, report); | 899 | hiddev_report_event(hid, report); |
900 | 900 | ||
901 | for (n = 0; n < report->maxfield; n++) | 901 | for (n = 0; n < report->maxfield; n++) |
902 | hid_input_field(hid, report->field[n], data, regs); | 902 | hid_input_field(hid, report->field[n], data, interrupt, regs); |
903 | 903 | ||
904 | if (hid->claimed & HID_CLAIMED_INPUT) | 904 | if (hid->claimed & HID_CLAIMED_INPUT) |
905 | hidinput_report_event(hid, report); | 905 | hidinput_report_event(hid, report); |
@@ -918,7 +918,7 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs) | |||
918 | 918 | ||
919 | switch (urb->status) { | 919 | switch (urb->status) { |
920 | case 0: /* success */ | 920 | case 0: /* success */ |
921 | hid_input_report(HID_INPUT_REPORT, urb, regs); | 921 | hid_input_report(HID_INPUT_REPORT, urb, 1, regs); |
922 | break; | 922 | break; |
923 | case -ECONNRESET: /* unlink */ | 923 | case -ECONNRESET: /* unlink */ |
924 | case -ENOENT: | 924 | case -ENOENT: |
@@ -1142,7 +1142,7 @@ static void hid_ctrl(struct urb *urb, struct pt_regs *regs) | |||
1142 | switch (urb->status) { | 1142 | switch (urb->status) { |
1143 | case 0: /* success */ | 1143 | case 0: /* success */ |
1144 | if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) | 1144 | if (hid->ctrl[hid->ctrltail].dir == USB_DIR_IN) |
1145 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, regs); | 1145 | hid_input_report(hid->ctrl[hid->ctrltail].report->type, urb, 0, regs); |
1146 | case -ESHUTDOWN: /* unplug */ | 1146 | case -ESHUTDOWN: /* unplug */ |
1147 | case -EILSEQ: /* unplug timectrl on uhci */ | 1147 | case -EILSEQ: /* unplug timectrl on uhci */ |
1148 | unplug = 1; | 1148 | unplug = 1; |