From patchwork Wed Nov 14 15:59:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1742341 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 AFEB03FC64 for ; Wed, 14 Nov 2012 16:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422917Ab2KNQCt (ORCPT ); Wed, 14 Nov 2012 11:02:49 -0500 Received: from mail-wg0-f44.google.com ([74.125.82.44]:38389 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422773Ab2KNP7q (ORCPT ); Wed, 14 Nov 2012 10:59:46 -0500 Received: by mail-wg0-f44.google.com with SMTP id dr13so307340wgb.1 for ; Wed, 14 Nov 2012 07:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=xm/Hg0B9fey9sgyH+Z+RuheJ4kV5lgsxcol3OxflO/o=; b=HFkHiVJkK7k2ezOzX+n5qfYKtcaYjFUeFetVuRQ4bHYbDLayUxX1xTplOW2YsJtzV/ x+jU7c3OUBMROvLi+iDL7d58kDDVsfYcppAO3KdR1ktOz4WOq2JQwsviOGaoG8m1Sh/R RJ1s1es1EI5UlubHUiK2VIi51Uv/0oaAHF6jbtXN/ERkqVEMVg8v3lhgZzuJ+fKKiUfI Cw3LcdSzqV0AxMi2JWvZP6xrWcEjU4amd7VN0DJt1T7wIYULwfrfzMr7oUzftTbCbBeQ oB3ZwFjpSot/wlgLXIMNnCMSW2XTbPlR9QtS3Li5MrzgE17DwuK5gVF8viH44GUOSc9B n2Lg== Received: by 10.180.80.131 with SMTP id r3mr26800374wix.0.1352908785120; Wed, 14 Nov 2012 07:59:45 -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 r10sm3050116wiz.0.2012.11.14.07.59.43 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 07:59:44 -0800 (PST) From: Benjamin Tissoires To: "benjamin.tissoires" , Dmitry Torokhov , Henrik Rydberg , Jiri Kosina , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/14] HID: hid-input: add usage_index in struct hid_usage. Date: Wed, 14 Nov 2012 16:59:16 +0100 Message-Id: <1352908766-4492-5-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1352908766-4492-1-git-send-email-benjamin.tissoires@gmail.com> References: <1352908766-4492-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Currently, there is no way to know the index of the current field in the .input_mapping and .event callbacks when this field is inside an array of HID fields. This patch adds this index to the struct hid_usage so that this information is available to input_mapping and event callbacks. Signed-off-by: Benjamin Tissoires Acked-by: Jiri Kosina --- drivers/hid/hid-core.c | 4 ++++ include/linux/hid.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9da3007..8f82c4c 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report); static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) { struct hid_field *field; + int i; if (report->maxfield == HID_MAX_FIELDS) { hid_err(report->device, "too many fields in report\n"); @@ -110,6 +111,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned field->value = (s32 *)(field->usage + usages); field->report = report; + for (i = 0; i < usages; i++) + field->usage[i].usage_index = i; + return field; } diff --git a/include/linux/hid.h b/include/linux/hid.h index a110a3e..ce14c32 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -379,6 +379,7 @@ struct hid_collection { struct hid_usage { unsigned hid; /* hid usage code */ unsigned collection_index; /* index into collection array */ + unsigned usage_index; /* index into usage array */ /* hidinput data */ __u16 code; /* input driver code */ __u8 type; /* input driver type */