@@ -168,12 +168,12 @@ static int open_collection(struct hid_parser *parser, unsigned type)
parser->device->maxcollection;
collection = parser->device->collection +
- parser->device->maxcollection;
+ parser->device->maxcollection++;
collection->type = type;
collection->usage = usage;
collection->level = parser->collection_stack_ptr - 1;
- collection->parent = parser->active_collection;
- parser->active_collection = parser->device->maxcollection++;
+ collection->parent = (collection->level == 0) ? UINT_MAX :
+ parser->collection_stack[collection->level - 1];
if (type == HID_COLLECTION_APPLICATION)
parser->device->maxapplication++;
@@ -192,9 +192,6 @@ static int close_collection(struct hid_parser *parser)
return -EINVAL;
}
parser->collection_stack_ptr--;
- if (parser->active_collection != UINT_MAX)
- parser->active_collection =
- parser->device->collection[parser->active_collection].parent;
return 0;
}
@@ -820,7 +817,6 @@ static int hid_scan_report(struct hid_device *hid)
return -ENOMEM;
parser->device = hid;
- parser->active_collection = UINT_MAX;
hid->group = HID_GROUP_GENERIC;
/*
@@ -1177,7 +1173,6 @@ int hid_open_report(struct hid_device *device)
}
parser->device = device;
- parser->active_collection = UINT_MAX;
end = start + size;
@@ -658,7 +658,6 @@ struct hid_parser {
unsigned int *collection_stack;
unsigned int collection_stack_ptr;
unsigned int collection_stack_size;
- unsigned int active_collection;
struct hid_device *device;
unsigned int scan_flags;
};
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> --- This could be squashed into the previous patch. --- drivers/hid/hid-core.c | 11 +++-------- include/linux/hid.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-)