summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2019-01-14 10:19:22 +0300
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2019-01-16 16:29:48 +0300
commit1950f462916edc9581168ca8d5882a8101e8bbcf (patch)
tree866de4ed3a30a68635f0d49b433c82ea175df50b /drivers/hid/hid-core.c
parent77ae0d8e401f083ca69c202502da4fc0e38cb1b7 (diff)
downloadlinux-1950f462916edc9581168ca8d5882a8101e8bbcf.tar.xz
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>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f9093dedf647..9993b692598f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -173,8 +173,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_idx = parser->active_collection_idx;
- parser->active_collection_idx = collection_index;
+ collection->parent_idx = (collection->level == 0) ? -1 :
+ parser->collection_stack[collection->level - 1];
if (type == HID_COLLECTION_APPLICATION)
parser->device->maxapplication++;
@@ -193,13 +193,6 @@ static int close_collection(struct hid_parser *parser)
return -EINVAL;
}
parser->collection_stack_ptr--;
- if (parser->active_collection_idx != -1) {
- struct hid_device *device = parser->device;
- struct hid_collection *c;
-
- c = &device->collection[parser->active_collection_idx];
- parser->active_collection_idx = c->parent_idx;
- }
return 0;
}
@@ -825,7 +818,6 @@ static int hid_scan_report(struct hid_device *hid)
return -ENOMEM;
parser->device = hid;
- parser->active_collection_idx = -1;
hid->group = HID_GROUP_GENERIC;
/*
@@ -1179,7 +1171,6 @@ int hid_open_report(struct hid_device *device)
}
parser->device = device;
- parser->active_collection_idx = -1;
end = start + size;