From patchwork Wed Apr 15 23:52:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 6223431 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B1D09F2EC for ; Wed, 15 Apr 2015 23:53:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29B1F20306 for ; Wed, 15 Apr 2015 23:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B13320328 for ; Wed, 15 Apr 2015 23:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932841AbbDOXxH (ORCPT ); Wed, 15 Apr 2015 19:53:07 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:33455 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755719AbbDOXxG (ORCPT ); Wed, 15 Apr 2015 19:53:06 -0400 Received: by pdbnk13 with SMTP id nk13so69996750pdb.0 for ; Wed, 15 Apr 2015 16:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NBS2cu5QWMovqyeXmNb0lUAGaXAmYwg64TTAMxLOtE4=; b=HEUoB9HL1sHz98z1tHKMS4jt0vr78qXiZS6lrb2QIB21UakEOxyIqz0kmFYSNnbh7k p9Y2wh5UMo1LjmUugWbA3FTnNoGal/iwKqEUWjZEjr9A0VgpuB9tgFWHkESM6z5N+ePH QipUQnF5dfN7xDSSbU41LfCnrXAQpVZbRUosZZDovh264Q330iuu1tUiXHUGiWgUUaL7 BhBxmk/G2oMaAbODkOdzElzAGqc3peUfEuzlqxJ8bcG9vFO4I3OOvUeRTGrAfUXUrhK/ +WViIgRjkud+6NcZfDCE18N4C9IO9yWee2mu5KXdtmb70U+kwYhJHZ28hbbic4KIlhxd WGDw== X-Received: by 10.66.186.142 with SMTP id fk14mr51175912pac.74.1429141985563; Wed, 15 Apr 2015 16:53:05 -0700 (PDT) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id da3sm5221607pdb.8.2015.04.15.16.53.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Apr 2015 16:53:05 -0700 (PDT) From: Ping Cheng X-Google-Original-From: Ping Cheng To: jkosina@suse.cz Cc: linux-input@vger.kernel.org, Ping Cheng Subject: [PATCH 1/4] HID: wacom: retrieve name from HID descriptor for generic devices Date: Wed, 15 Apr 2015 16:52:59 -0700 Message-Id: <1429141979-16793-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HID generic devices share the same default name, "Wacom HID". This causes userland programs to show same device names for different devices, which would confuse end users with same device names for different devices too. This patch uses name retrieved from HID descriptor, if a meaningful name is reported. Otherwise, affix its product ID to "Wacom HID". Signed-off-by: Ping Cheng --- drivers/hid/wacom_sys.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 1b00d8d..4c5d924 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1392,6 +1392,39 @@ static size_t wacom_compute_pktlen(struct hid_device *hdev) return size; } +static void wacom_update_name(struct wacom *wacom) +{ + struct wacom_wac *wacom_wac = &wacom->wacom_wac; + struct wacom_features *features = &wacom_wac->features; + + /* Generic devices name unspecified */ + if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", features->name)) { + if (strstr(wacom->hdev->name, "Wacom") || + strstr(wacom->hdev->name, "wacom") || + strstr(wacom->hdev->name, "WACOM")) { + /* name is in HID descriptor, use it */ + strlcpy(wacom_wac->name, wacom->hdev->name, + sizeof(wacom_wac->name)); + } else { + /* no meaningful name retrieved. use product ID */ + snprintf(wacom_wac->name, sizeof(wacom_wac->name), + "%s %x", features->name, wacom_wac->pid); + } + } else { + strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); + } + snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), + "%s Pad", wacom_wac->name); + + /* Append the device type to the name */ + if (features->device_type != BTN_TOOL_FINGER) + strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); + else if (features->touch_max) + strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); + else + strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); +} + static int wacom_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -1517,17 +1550,7 @@ static int wacom_probe(struct hid_device *hdev, } wacom_calculate_res(features); - strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); - snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), - "%s Pad", features->name); - - /* Append the device type to the name */ - if (features->device_type != BTN_TOOL_FINGER) - strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX); - else if (features->touch_max) - strlcat(wacom_wac->name, " Finger", WACOM_NAME_MAX); - else - strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX); + wacom_update_name(wacom); error = wacom_add_shared_data(hdev); if (error)