Skip to content

Commit 1950f46

Browse files
pH5bentiss
authored andcommitted
HID: core: simplify active collection tracking
Manually tracking an active collection to set collection parents is not necessary, we just have to look one step back into the collection stack to find the correct parent. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 77ae0d8 commit 1950f46

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

drivers/hid/hid-core.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ static int open_collection(struct hid_parser *parser, unsigned type)
173173
collection->type = type;
174174
collection->usage = usage;
175175
collection->level = parser->collection_stack_ptr - 1;
176-
collection->parent_idx = parser->active_collection_idx;
177-
parser->active_collection_idx = collection_index;
176+
collection->parent_idx = (collection->level == 0) ? -1 :
177+
parser->collection_stack[collection->level - 1];
178178

179179
if (type == HID_COLLECTION_APPLICATION)
180180
parser->device->maxapplication++;
@@ -193,13 +193,6 @@ static int close_collection(struct hid_parser *parser)
193193
return -EINVAL;
194194
}
195195
parser->collection_stack_ptr--;
196-
if (parser->active_collection_idx != -1) {
197-
struct hid_device *device = parser->device;
198-
struct hid_collection *c;
199-
200-
c = &device->collection[parser->active_collection_idx];
201-
parser->active_collection_idx = c->parent_idx;
202-
}
203196
return 0;
204197
}
205198

@@ -825,7 +818,6 @@ static int hid_scan_report(struct hid_device *hid)
825818
return -ENOMEM;
826819

827820
parser->device = hid;
828-
parser->active_collection_idx = -1;
829821
hid->group = HID_GROUP_GENERIC;
830822

831823
/*
@@ -1179,7 +1171,6 @@ int hid_open_report(struct hid_device *device)
11791171
}
11801172

11811173
parser->device = device;
1182-
parser->active_collection_idx = -1;
11831174

11841175
end = start + size;
11851176

include/linux/hid.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ struct hid_parser {
658658
unsigned int *collection_stack;
659659
unsigned int collection_stack_ptr;
660660
unsigned int collection_stack_size;
661-
int active_collection_idx; /* device->collection */
662661
struct hid_device *device;
663662
unsigned int scan_flags;
664663
};

0 commit comments

Comments
 (0)