From: Christian Hoffmann Date: Tue, 31 Jan 2023 22:06:15 +0000 (+0100) Subject: Revert "HID: core: move Usage Page concatenation to Main item [1/1]" X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cb140920ea5bfde82befc167fafc25ab9bfa75f5;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git Revert "HID: core: move Usage Page concatenation to Main item [1/1]" This reverts commit e611bb331f9099d54274d5bd5cf68f233e254198. --- diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index eca445a98b5a..ceb4df96e0d5 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -37,7 +37,6 @@ #include #include "hid-ids.h" -#define GET_COMPLETE_USAGE(page, id) (((page) << 16) + ((id) & 0xffff)) /* * Version Information @@ -207,14 +206,7 @@ static int hid_add_usage(struct hid_parser *parser, unsigned usage, u8 size) hid_err(parser->device, "usage index exceeded\n"); return -1; } - if (size <= 2) { - parser->local.usage_page_last = false; - parser->local.usage[parser->local.usage_index] = - GET_COMPLETE_USAGE(parser->global.usage_page, usage); - } else { - parser->local.usage[parser->local.usage_index] = usage; - } - + parser->local.usage[parser->local.usage_index] = usage; parser->local.usage_size[parser->local.usage_index] = size; parser->local.collection_index[parser->local.usage_index] = parser->collection_stack_ptr ? @@ -354,7 +346,6 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: parser->global.usage_page = item_udata(item); - parser->local.usage_page_last = true; return 0; case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: @@ -532,20 +523,13 @@ static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) * usage value." */ -static void hid_concatenate_last_usage_page(struct hid_parser *parser) +static void hid_concatenate_usage_page(struct hid_parser *parser) { int i; - unsigned int usage; - unsigned int usage_page = parser->global.usage_page; - if (!parser->local.usage_page_last) - return; for (i = 0; i < parser->local.usage_index; i++) - if (parser->local.usage_size[i] <= 2) { - usage = parser->local.usage[i]; - parser->local.usage[i] = - GET_COMPLETE_USAGE(usage_page, usage); - } + if (parser->local.usage_size[i] <= 2) + parser->local.usage[i] += parser->global.usage_page << 16; } /* @@ -557,7 +541,7 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) __u32 data; int ret; - hid_concatenate_last_usage_page(parser); + hid_concatenate_usage_page(parser); data = item_udata(item); @@ -772,7 +756,7 @@ static int hid_scan_main(struct hid_parser *parser, struct hid_item *item) __u32 data; int i; - hid_concatenate_last_usage_page(parser); + hid_concatenate_usage_page(parser); data = item_udata(item); diff --git a/include/linux/hid.h b/include/linux/hid.h index 9748c6714bc7..04bdf5477ec5 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -380,7 +380,6 @@ struct hid_local { unsigned usage_minimum; unsigned delimiter_depth; unsigned delimiter_branch; - bool usage_page_last; }; /*