From patchwork Fri Feb 8 14:51:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 2116261 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 58F823FCA4 for ; Fri, 8 Feb 2013 14:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760150Ab3BHOvy (ORCPT ); Fri, 8 Feb 2013 09:51:54 -0500 Received: from mail-wg0-f52.google.com ([74.125.82.52]:39456 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760148Ab3BHOvw (ORCPT ); Fri, 8 Feb 2013 09:51:52 -0500 Received: by mail-wg0-f52.google.com with SMTP id 12so3043632wgh.7 for ; Fri, 08 Feb 2013 06:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer; bh=0PTeQ68T8UBOsaOXHaL8OFBUDtwDSR3rrHw5G/OlufI=; b=UUb7sLOIIW/YCZWN7+fMN+8VZ0zCd+TroMog7I988NhykgErSrG3pBYaGd0zSZMm4s 7r2IlBpV0GDHWSk0IsjsKsZgqkcIDfoQl+uJ7A87TEDIImZsXxZUj4bbl2BKSDB+KMFJ ISj3A7hy7NHVOOeHL1pDl3IHTQBQNb+mSlwQQEP6i9abT109nebxo4QVoJaXFbGFPdMB wacng9acbzZx/+xOV0lyBarxtWV7OvrcAogo9yWTuF0l82hMJPzl+B4RPvFX7hEh2D0V K8qPnvU+0E/ixKqWi9ZXZN07HUxUegP5nILNeg9ED/jRs2aNm+VVzAd0HI6WPRnhRzSN 8rAQ== X-Received: by 10.194.119.5 with SMTP id kq5mr10248334wjb.48.1360335102915; Fri, 08 Feb 2013 06:51:42 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id m6sm15937463wic.2.2013.02.08.06.51.41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 08 Feb 2013 06:51:42 -0800 (PST) From: Benjamin Tissoires To: Benjamin Tissoires , Rafi Rubin , Henrik Rydberg , Jiri Kosina , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: ntrig: use input_configured() callback to set the name Date: Fri, 8 Feb 2013 15:51:30 +0100 Message-Id: <1360335090-24024-1-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The use of input_configured() allows the ntrig driver to actually change the name of the input and its bitmask before it is added to the input subsystem. Thus, the logs are coherents and udev catch the real bitmask when the device is added. Signed-off-by: Benjamin Tissoires Signed-off-by: Rafi Rubin --- drivers/hid/hid-ntrig.c | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 2ffc0e3..7757e82 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c @@ -858,12 +858,43 @@ not_claimed_input: return 1; } +static void ntrig_input_configured(struct hid_device *hid, + struct hid_input *hidinput) + +{ + struct input_dev *input = hidinput->input; + + if (hidinput->report->maxfield < 1) + return; + + switch (hidinput->report->field[0]->application) { + case HID_DG_PEN: + input->name = "N-Trig Pen"; + break; + case HID_DG_TOUCHSCREEN: + /* These keys are redundant for fingers, clear them + * to prevent incorrect identification */ + __clear_bit(BTN_TOOL_PEN, input->keybit); + __clear_bit(BTN_TOOL_FINGER, input->keybit); + __clear_bit(BTN_0, input->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input->keybit); + /* + * The physical touchscreen (single touch) + * input has a value for physical, whereas + * the multitouch only has logical input + * fields. + */ + input->name = (hidinput->report->field[0]->physical) ? + "N-Trig Touchscreen" : + "N-Trig MultiTouch"; + break; + } +} + static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) { int ret; struct ntrig_data *nd; - struct hid_input *hidinput; - struct input_dev *input; struct hid_report *report; if (id->driver_data) @@ -901,38 +932,6 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_free; } - - list_for_each_entry(hidinput, &hdev->inputs, list) { - if (hidinput->report->maxfield < 1) - continue; - - input = hidinput->input; - switch (hidinput->report->field[0]->application) { - case HID_DG_PEN: - input->name = "N-Trig Pen"; - break; - case HID_DG_TOUCHSCREEN: - /* These keys are redundant for fingers, clear them - * to prevent incorrect identification */ - __clear_bit(BTN_TOOL_PEN, input->keybit); - __clear_bit(BTN_TOOL_FINGER, input->keybit); - __clear_bit(BTN_0, input->keybit); - __set_bit(BTN_TOOL_DOUBLETAP, input->keybit); - /* - * The physical touchscreen (single touch) - * input has a value for physical, whereas - * the multitouch only has logical input - * fields. - */ - input->name = - (hidinput->report->field[0] - ->physical) ? - "N-Trig Touchscreen" : - "N-Trig MultiTouch"; - break; - } - } - /* This is needed for devices with more recent firmware versions */ report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; if (report) { @@ -1023,6 +1022,7 @@ static struct hid_driver ntrig_driver = { .remove = ntrig_remove, .input_mapping = ntrig_input_mapping, .input_mapped = ntrig_input_mapped, + .input_configured = ntrig_input_configured, .usage_table = ntrig_grabbed_usages, .event = ntrig_event, };