Skip to content

Commit f262d1f

Browse files
bentissJiri Kosina
authored andcommitted
HID: add usage_index in struct hid_usage.
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 <benjamin.tissoires@gmail.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 7746383 commit f262d1f

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/hid/hid-core.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
9292
static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
9393
{
9494
struct hid_field *field;
95+
int i;
9596

9697
if (report->maxfield == HID_MAX_FIELDS) {
9798
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
110111
field->value = (s32 *)(field->usage + usages);
111112
field->report = report;
112113

114+
for (i = 0; i < usages; i++)
115+
field->usage[i].usage_index = i;
116+
113117
return field;
114118
}
115119

‎include/linux/hid.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ struct hid_collection {
342342
struct hid_usage {
343343
unsigned hid; /* hid usage code */
344344
unsigned collection_index; /* index into collection array */
345+
unsigned usage_index; /* index into usage array */
345346
/* hidinput data */
346347
__u16 code; /* input driver code */
347348
__u8 type; /* input driver type */

0 commit comments

Comments
 (0)