From 68a1f2cc8676f22a6fd49f344f99e326eb7f5117 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Thu, 7 Feb 2008 16:48:46 +0100 Subject: [PATCH] HID: fix processing of event quirks The old code (before move) stopped further processing of the event after it has been already processed by the quirk handler. The new code didn't propagate the return value properly, and therefore the processing always proceeded, which was wrong. This patch fixes it. Pointed out in kernel.org bugzilla #9842 Signed-off-by: Jiri Kosina --- drivers/hid/hid-input-quirks.c | 17 +++++++++-------- drivers/hid/hid-input.c | 3 ++- include/linux/hid.h | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c index a870ba58faa3..dceadd0c1419 100644 --- a/drivers/hid/hid-input-quirks.c +++ b/drivers/hid/hid-input-quirks.c @@ -352,7 +352,7 @@ int hidinput_mapping_quirks(struct hid_usage *usage, return 0; } -void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) +int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct input_dev *input; @@ -362,34 +362,34 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON; else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON; - return; + return 1; } if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && (usage->type == EV_REL) && (usage->code == REL_WHEEL)) { hid->delayed_value = value; - return; + return 1; } if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && (usage->hid == 0x000100b8)) { input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value); - return; + return 1; } if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) { input_event(input, usage->type, usage->code, -value); - return; + return 1; } if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) { input_event(input, usage->type, REL_HWHEEL, value); - return; + return 1; } if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value)) - return; + return 1; /* Handling MS keyboards special buttons */ if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS && @@ -416,8 +416,9 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && usage->type == EV_REL && usage->code == REL_HWHEEL) { input_event(input, usage->type, REL_WHEEL, -value); - return; + return 1; } + return 0; } diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 5325d98b4328..43342785110c 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -854,7 +854,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct return; /* handle input events for quirky devices */ - hidinput_event_quirks(hid, field, usage, value); + if (hidinput_event_quirks(hid, field, usage, value)) + return; if (usage->hat_min < usage->hat_max || usage->hat_dir) { int hat_dir = usage->hat_dir; diff --git a/include/linux/hid.h b/include/linux/hid.h index 3902690647b0..74ff57596eb1 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -528,7 +528,7 @@ int hid_set_field(struct hid_field *, unsigned, __s32); int hid_input_report(struct hid_device *, int type, u8 *, int, int); int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *); -void hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); +int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32); void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt); void hid_output_report(struct hid_report *report, __u8 *data); -- 2.34.1