Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c53431eb authored by Peter Hutterer's avatar Peter Hutterer Committed by Benjamin Tissoires
Browse files

HID: core: store the collections as a basic tree



For each collection parsed, store a pointer to the parent collection
(if any). This makes it a lot easier to look up which collection(s)
any given item is part of

Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
Verified-by: default avatarHarry Cutts <hcutts@chromium.org>
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
parent 52ea8996
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ static int open_collection(struct hid_parser *parser, unsigned type)
	collection->type = type;
	collection->usage = usage;
	collection->level = parser->collection_stack_ptr - 1;
	collection->parent = parser->active_collection;
	parser->active_collection = collection;

	if (type == HID_COLLECTION_APPLICATION)
		parser->device->maxapplication++;
@@ -190,6 +192,8 @@ static int close_collection(struct hid_parser *parser)
		return -EINVAL;
	}
	parser->collection_stack_ptr--;
	if (parser->active_collection)
		parser->active_collection = parser->active_collection->parent;
	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -427,6 +427,7 @@ struct hid_local {
 */

struct hid_collection {
	struct hid_collection *parent;
	unsigned type;
	unsigned usage;
	unsigned level;
@@ -650,6 +651,7 @@ struct hid_parser {
	unsigned int         *collection_stack;
	unsigned int          collection_stack_ptr;
	unsigned int          collection_stack_size;
	struct hid_collection *active_collection;
	struct hid_device    *device;
	unsigned int          scan_flags;
};