Commit 1950f462 authored by Philipp Zabel's avatar Philipp Zabel Committed by Benjamin Tissoires

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: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
parent 77ae0d8e
...@@ -173,8 +173,8 @@ static int open_collection(struct hid_parser *parser, unsigned type) ...@@ -173,8 +173,8 @@ static int open_collection(struct hid_parser *parser, unsigned type)
collection->type = type; collection->type = type;
collection->usage = usage; collection->usage = usage;
collection->level = parser->collection_stack_ptr - 1; collection->level = parser->collection_stack_ptr - 1;
collection->parent_idx = parser->active_collection_idx; collection->parent_idx = (collection->level == 0) ? -1 :
parser->active_collection_idx = collection_index; parser->collection_stack[collection->level - 1];
if (type == HID_COLLECTION_APPLICATION) if (type == HID_COLLECTION_APPLICATION)
parser->device->maxapplication++; parser->device->maxapplication++;
...@@ -193,13 +193,6 @@ static int close_collection(struct hid_parser *parser) ...@@ -193,13 +193,6 @@ static int close_collection(struct hid_parser *parser)
return -EINVAL; return -EINVAL;
} }
parser->collection_stack_ptr--; 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; return 0;
} }
...@@ -825,7 +818,6 @@ static int hid_scan_report(struct hid_device *hid) ...@@ -825,7 +818,6 @@ static int hid_scan_report(struct hid_device *hid)
return -ENOMEM; return -ENOMEM;
parser->device = hid; parser->device = hid;
parser->active_collection_idx = -1;
hid->group = HID_GROUP_GENERIC; hid->group = HID_GROUP_GENERIC;
/* /*
...@@ -1179,7 +1171,6 @@ int hid_open_report(struct hid_device *device) ...@@ -1179,7 +1171,6 @@ int hid_open_report(struct hid_device *device)
} }
parser->device = device; parser->device = device;
parser->active_collection_idx = -1;
end = start + size; end = start + size;
......
...@@ -658,7 +658,6 @@ struct hid_parser { ...@@ -658,7 +658,6 @@ struct hid_parser {
unsigned int *collection_stack; unsigned int *collection_stack;
unsigned int collection_stack_ptr; unsigned int collection_stack_ptr;
unsigned int collection_stack_size; unsigned int collection_stack_size;
int active_collection_idx; /* device->collection */
struct hid_device *device; struct hid_device *device;
unsigned int scan_flags; unsigned int scan_flags;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment