From f07b3c1da92db108662f99417a212fc1eddc44d1 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 24 Apr 2018 10:04:33 +0200 Subject: HID: generic: create one input report per application type It is not a good idea to try to fit all types of applications in the same input report. There are a lot of devices that are needing the quirk HID_MULTI_INPUT but this quirk doesn't match the actual HID description as it is based on the report ID. Given that most devices with MULTI_INPUT I can think of split nicely the devices inputs into application, it is a good thing to split the devices by default based on this assumption. Also make hid-multitouch following this rule, to not have to deal with too many input created. While we are at it, fix some checkpatch complaints about converting 'unsigned' to 'unsigned int'. Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- drivers/hid/hid-input.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/hid/hid-input.c') diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index fd1c4fe..7463ee2 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1610,6 +1610,20 @@ static struct hid_input *hidinput_match(struct hid_report *report) return NULL; } +static struct hid_input *hidinput_match_application(struct hid_report *report) +{ + struct hid_device *hid = report->device; + struct hid_input *hidinput; + + list_for_each_entry(hidinput, &hid->inputs, list) { + if (hidinput->report && + hidinput->report->application == report->application) + return hidinput; + } + + return NULL; +} + static inline void hidinput_configure_usages(struct hid_input *hidinput, struct hid_report *report) { @@ -1670,6 +1684,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) */ if (hid->quirks & HID_QUIRK_MULTI_INPUT) hidinput = hidinput_match(report); + else if (hid->maxapplication > 1 && + (hid->quirks & HID_QUIRK_INPUT_PER_APP)) + hidinput = hidinput_match_application(report); if (!hidinput) { hidinput = hidinput_allocate(hid); -- cgit v1.1