]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: constify params and return value of fetch_item()
authorThomas Weißschuh <linux@weissschuh.net>
Sat, 3 Aug 2024 12:34:20 +0000 (14:34 +0200)
committerBenjamin Tissoires <bentiss@kernel.org>
Tue, 27 Aug 2024 14:18:51 +0000 (16:18 +0200)
fetch_item() does not modify the descriptor it operates on.
As a prerequisite for the constification of hid_driver::dev_rdesc,
mark the parameters and return value of fetch_item() as const.

Also adapt the variable types in the callers to match this
constification.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20240803-hid-const-fixup-v2-4-f53d7a7b29d8@weissschuh.net
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/hid-core.c
include/linux/hid.h

index 0d2cbe491708fb0c679551aaba05a3f1d5cd9fe9..3110695883217419034cb5d8c07fb7819afbb310 100644 (file)
@@ -723,7 +723,7 @@ static void hid_device_release(struct device *dev)
  * items, though they are not used yet.
  */
 
-static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item)
+static const u8 *fetch_item(const __u8 *start, const __u8 *end, struct hid_item *item)
 {
        u8 b;
 
@@ -880,8 +880,8 @@ static int hid_scan_report(struct hid_device *hid)
 {
        struct hid_parser *parser;
        struct hid_item item;
-       __u8 *start = hid->dev_rdesc;
-       __u8 *end = start + hid->dev_rsize;
+       const __u8 *start = hid->dev_rdesc;
+       const __u8 *end = start + hid->dev_rsize;
        static int (*dispatch_type[])(struct hid_parser *parser,
                                      struct hid_item *item) = {
                hid_scan_main,
@@ -1204,10 +1204,10 @@ int hid_open_report(struct hid_device *device)
        struct hid_parser *parser;
        struct hid_item item;
        unsigned int size;
-       __u8 *start;
+       const __u8 *start;
        __u8 *buf;
-       __u8 *end;
-       __u8 *next;
+       const __u8 *end;
+       const __u8 *next;
        int ret;
        int i;
        static int (*dispatch_type[])(struct hid_parser *parser,
index dda34d8cad1919c82998d28789d82082d3db69ae..502bbc6f078c8d0f8b175ec0c84d555b863ace62 100644 (file)
@@ -46,7 +46,7 @@ struct hid_item {
            __s16  s16;
            __u32  u32;
            __s32  s32;
-           __u8  *longdata;
+           const __u8  *longdata;
        } data;
 };