*/
static int hid_scan_report(struct hid_device *hid)
{
--- ---- unsigned int page = 0, delim = 0;
+++ ++++ struct hid_parser *parser;
+++ ++++ struct hid_item item;
__u8 *start = hid->dev_rdesc;
__u8 *end = start + hid->dev_rsize;
--- ---- unsigned int u, u_min = 0, u_max = 0;
--- ---- struct hid_item item;
+++ ++++ static int (*dispatch_type[])(struct hid_parser *parser,
+++ ++++ struct hid_item *item) = {
+++ ++++ hid_scan_main,
+++ ++++ hid_parser_global,
+++ ++++ hid_parser_local,
+++ ++++ hid_parser_reserved
+++ ++++ };
+++ +++
+++ ++++ parser = vzalloc(sizeof(struct hid_parser));
+++ ++++ if (!parser)
+++ ++++ return -ENOMEM;
+
+++ ++++ parser->device = hid;
hid->group = HID_GROUP_GENERIC;
--- ---- while ((start = fetch_item(start, end, &item)) != NULL) {
--- ---- if (item.format != HID_ITEM_FORMAT_SHORT)
--- ---- return -EINVAL;
--- ---- if (item.type == HID_ITEM_TYPE_GLOBAL) {
--- ---- if (item.tag == HID_GLOBAL_ITEM_TAG_USAGE_PAGE)
--- ---- page = item_udata(&item) << 16;
--- ---- } else if (item.type == HID_ITEM_TYPE_LOCAL) {
--- ---- if (delim > 1)
--- ---- break;
--- ---- u = item_udata(&item);
--- ---- if (item.size <= 2)
--- ---- u += page;
--- ---- switch (item.tag) {
--- ---- case HID_LOCAL_ITEM_TAG_DELIMITER:
--- ---- delim += !!u;
--- ---- break;
--- ---- case HID_LOCAL_ITEM_TAG_USAGE:
--- ---- hid_scan_usage(hid, u);
--- ---- break;
--- ---- case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
--- ---- u_min = u;
--- ---- break;
--- ---- case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
--- ---- u_max = u;
--- ---- for (u = u_min; u <= u_max; u++)
--- ---- hid_scan_usage(hid, u);
--- ---- break;
--- ---- }
--- ---- } else if (page == HID_UP_SENSOR &&
--- ---- item.type == HID_ITEM_TYPE_MAIN &&
--- ---- item.tag == HID_MAIN_ITEM_TAG_BEGIN_COLLECTION &&
--- ---- (item_udata(&item) & 0xff) == HID_COLLECTION_PHYSICAL)
--- ---- hid->group = HID_GROUP_SENSOR_HUB;
--- ---- }
+++ ++++ /*
+++ ++++ * The parsing is simpler than the one in hid_open_report() as we should
+++ ++++ * be robust against hid errors. Those errors will be raised by
+++ ++++ * hid_open_report() anyway.
+++ ++++ */
+++ ++++ while ((start = fetch_item(start, end, &item)) != NULL)
+++ ++++ dispatch_type[item.type](parser, &item);
+++ ++++
+++ ++++ /*
+++ ++++ * Handle special flags set during scanning.
+++ ++++ */
+++ ++++ if ((parser->scan_flags & HID_SCAN_FLAG_MT_WIN_8) &&
+++ ++++ (hid->group == HID_GROUP_MULTITOUCH))
+++ ++++ hid->group = HID_GROUP_MULTITOUCH_WIN_8;
+++ ++++
+++ ++++ vfree(parser);
return 0;
}