Received: by 10.192.165.156 with SMTP id m28csp45797imm; Tue, 17 Apr 2018 06:20:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/JtlyVtXxyWqJXeca4Sz9QxY/3QKOTSmUdLs4LcJdpTt9gAO/+LntZTJ5DLWqVuWcTiBpT X-Received: by 2002:a17:902:6b4c:: with SMTP id g12-v6mr2056378plt.148.1523971234548; Tue, 17 Apr 2018 06:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523971234; cv=none; d=google.com; s=arc-20160816; b=sPQ3FC5cr60GiSJS9UkjyCbggqyvxYNFXA9C2+qv0KQpuA8HFZh0fuDre+Q9aJOL/B Cs5R6Ob2OJ4R8hh0vruy0zOTr3whrqHkvXvL7H3so+yrX7ufV7xtr29FtdIe4NbqYarT TYzX2wCXZA8VRw8jAGy7nn7KEEOW+C7WUrgcgAQ8iQxnN8pZCXl0pzsKtNAQD8GobC/p B49SvuOuVOLkpQjEjAg4qhRxCbd/oeNMDP2BiX1TL65tSOHbgHghZnxi/K/m6t7hDuUI d9gmVt0HNfK2yPy0EMAZZSnW6l0yuHkvJG9V3YCuE3wtLaVD55fWzTx2qjd8PORgn2Vh MtUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=HFDdg8SNPbaNXOZTTAq+EN7iSRzN1y7CDCZaR6UxrFs=; b=XEG+l0VDJI707bh5TdM+TJjKq/DOC8oAxDyPejI0XfLWSClfKtRIc7X7q3RqEveG8t BD9lsAnCqNLW6pMIV8V9ywOUS5omJJTiBM/Yn98KwP6VMzkIVCZtp8JXjDgEJA73MJtf oCudkYLU2CHv19GKoaASz8DpRFOC052hPKrtaVMHYezAqP0BynUzWvPoD0esvlPt56nx l0Q1zJ3pjDlOFRodpV3YPCzMXiLJXWoy0RBFVL9tc3P8rzEvXEKrY/RYxPfFS02+B9BR QyK2JnMbRLnD5NfVlvxziZh+gnjcpn81L3bgvfjXsy6/EMpZ5OeVp1nRdG7TMxHy/aXW F6RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si12717278pfk.357.2018.04.17.06.20.20; Tue, 17 Apr 2018 06:20:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbeDQNS6 (ORCPT + 99 others); Tue, 17 Apr 2018 09:18:58 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54770 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753070AbeDQNSn (ORCPT ); Tue, 17 Apr 2018 09:18:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F361A401DEA7; Tue, 17 Apr 2018 13:18:42 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB1DF1C70F; Tue, 17 Apr 2018 13:18:41 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina Cc: Dmitry Torokhov , Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 2/2] HID: input: append a suffix matching the application Date: Tue, 17 Apr 2018 15:18:33 +0200 Message-Id: <20180417131833.8551-3-benjamin.tissoires@redhat.com> In-Reply-To: <20180417131833.8551-1-benjamin.tissoires@redhat.com> References: <20180417131833.8551-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 17 Apr 2018 13:18:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 17 Apr 2018 13:18:43 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Given that we create one input node per application, we should name the input node accordingly to not lose userspace. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-input.c | 64 ++++++++++++++++++++++++++++++++++++++------ drivers/hid/hid-multitouch.c | 30 +++++++-------------- include/linux/hid.h | 1 + 3 files changed, 66 insertions(+), 29 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 0803d5adefa7..886d81df50d4 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1500,15 +1500,56 @@ static void report_features(struct hid_device *hid) } } -static struct hid_input *hidinput_allocate(struct hid_device *hid) +static struct hid_input *hidinput_allocate(struct hid_device *hid, + unsigned application) { struct hid_input *hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL); struct input_dev *input_dev = input_allocate_device(); - if (!hidinput || !input_dev) { - kfree(hidinput); - input_free_device(input_dev); - hid_err(hid, "Out of memory during hid input probe\n"); - return NULL; + const char *suffix = NULL; + + if (!hidinput || !input_dev) + goto fail; + + if ((hid->quirks & HID_QUIRK_INPUT_PER_APP) && + hid->maxapplication > 1) { + switch (application) { + case HID_GD_KEYBOARD: + suffix = "Keyboard"; + break; + case HID_GD_KEYPAD: + suffix = "Keypad"; + break; + case HID_GD_MOUSE: + suffix = "Mouse"; + break; + case HID_DG_STYLUS: + suffix = "Pen"; + break; + case HID_DG_TOUCHSCREEN: + suffix = "Touchscreen"; + break; + case HID_DG_TOUCHPAD: + suffix = "Touchpad"; + break; + case HID_GD_SYSTEM_CONTROL: + suffix = "System Control"; + break; + case HID_CP_CONSUMER_CONTROL: + suffix = "Consumer Control"; + break; + case HID_GD_WIRELESS_RADIO_CTLS: + suffix = "Wireless Radio Control"; + break; + default: + break; + } + } + + if (suffix) { + hidinput->name = kasprintf(GFP_KERNEL, "%s %s", + hid->name, suffix); + if (!hidinput->name) + goto fail; } input_set_drvdata(input_dev, hid); @@ -1518,7 +1559,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid) input_dev->setkeycode = hidinput_setkeycode; input_dev->getkeycode = hidinput_getkeycode; - input_dev->name = hid->name; + input_dev->name = hidinput->name ? hidinput->name : hid->name; input_dev->phys = hid->phys; input_dev->uniq = hid->uniq; input_dev->id.bustype = hid->bus; @@ -1530,6 +1571,12 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid) list_add_tail(&hidinput->list, &hid->inputs); return hidinput; + +fail: + kfree(hidinput); + input_free_device(input_dev); + hid_err(hid, "Out of memory during hid input probe\n"); + return NULL; } static bool hidinput_has_been_populated(struct hid_input *hidinput) @@ -1575,6 +1622,7 @@ static void hidinput_cleanup_hidinput(struct hid_device *hid, list_del(&hidinput->list); input_free_device(hidinput->input); + kfree(hidinput->name); for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) { if (k == HID_OUTPUT_REPORT && @@ -1686,7 +1734,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) hidinput = hidinput_match_application(report); if (!hidinput) { - hidinput = hidinput_allocate(hid); + hidinput = hidinput_allocate(hid, report->application); if (!hidinput) goto out_unwind; } diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 2a0caf2e24ce..cfbaedc55e02 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1294,33 +1294,21 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) } else { switch (field->application) { case HID_GD_KEYBOARD: - suffix = "Keyboard"; - break; case HID_GD_KEYPAD: - suffix = "Keypad"; - break; case HID_GD_MOUSE: - suffix = "Mouse"; - break; - case HID_DG_STYLUS: - suffix = "Pen"; - /* force BTN_STYLUS to allow tablet matching in udev */ - __set_bit(BTN_STYLUS, hi->input->keybit); - break; - case HID_DG_TOUCHSCREEN: - /* we do not set suffix = "Touchscreen" */ - break; case HID_DG_TOUCHPAD: - suffix = "Touchpad"; - break; case HID_GD_SYSTEM_CONTROL: - suffix = "System Control"; - break; case HID_CP_CONSUMER_CONTROL: - suffix = "Consumer Control"; - break; case HID_GD_WIRELESS_RADIO_CTLS: - suffix = "Wireless Radio Control"; + /* already handled by hid core */ + break; + case HID_DG_TOUCHSCREEN: + /* we do not set suffix = "Touchscreen" */ + hi->input->name = hdev->name; + break; + case HID_DG_STYLUS: + /* force BTN_STYLUS to allow tablet matching in udev */ + __set_bit(BTN_STYLUS, hi->input->keybit); break; case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: suffix = "Custom Media Keys"; diff --git a/include/linux/hid.h b/include/linux/hid.h index 8d52cefedfe5..1d1387773a7c 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -511,6 +511,7 @@ struct hid_input { struct list_head list; struct hid_report *report; struct input_dev *input; + const char *name; bool registered; }; -- 2.14.3