Revert "HID: core: move Usage Page concatenation to Main item [1/1]"
authorChristian Hoffmann <chrmhoffmann@gmail.com>
Tue, 31 Jan 2023 22:06:15 +0000 (23:06 +0100)
committerChristian Hoffmann <chrmhoffmann@gmail.com>
Sun, 12 Feb 2023 08:05:33 +0000 (09:05 +0100)
This reverts commit e611bb331f9099d54274d5bd5cf68f233e254198.

drivers/hid/hid-core.c
include/linux/hid.h

index eca445a98b5aa94690f28c47c346fc273f5ee1ca..ceb4df96e0d55c9d6f1c9205692e5d793c608818 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/hidraw.h>
 
 #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);
 
index 9748c6714bc7f7f8d870a0144f49e82e2a1baa45..04bdf5477ec5126b39a7cac8324aa848aa54acd3 100644 (file)
@@ -380,7 +380,6 @@ struct hid_local {
        unsigned usage_minimum;
        unsigned delimiter_depth;
        unsigned delimiter_branch;
-       bool usage_page_last;
 };
 
 /*