]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
HID: hid-ite: clean up usage of 'driver_data'
authorPawel Zalewski (The Capable Hub) <pzalewski@thegoodpenguin.co.uk>
Mon, 18 May 2026 16:06:27 +0000 (17:06 +0100)
committerBenjamin Tissoires <bentiss@kernel.org>
Mon, 1 Jun 2026 16:28:41 +0000 (18:28 +0200)
The module is storing an integer inside the drvdata pointer, which is
confusing, lets fix this and set the whole of 'hid_device_id' struct
as the drvdata and then simply use its integer 'driver_data' field for
quirks, which shall make the code cleaner, type-safe, consistent and
more readable.

This makes the cast to (void *) during storage a bit safer (just to
suppress the const qualifier warning) and the cast to (unsigned long)
during retrieval is removed.

Signed-off-by: Pawel Zalewski (The Capable Hub) <pzalewski@thegoodpenguin.co.uk>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/hid-ite.c

index 8e42780a2663c228a367e5c5c255af8b0386f3ec..63908f24b5241ae7805fa922ca6c862d9987286b 100644 (file)
@@ -15,7 +15,9 @@
 
 static const __u8 *ite_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize)
 {
-       unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
+
+       const struct hid_device_id *id = hid_get_drvdata(hdev);
+       unsigned long quirks = id->driver_data;
 
        if (quirks & QUIRK_TOUCHPAD_ON_OFF_REPORT) {
                /* For Acer Aspire Switch 10 SW5-012 keyboard-dock */
@@ -44,7 +46,8 @@ static int ite_input_mapping(struct hid_device *hdev,
                int *max)
 {
 
-       unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
+       const struct hid_device_id *id = hid_get_drvdata(hdev);
+       unsigned long quirks = id->driver_data;
 
        if ((quirks & QUIRK_TOUCHPAD_ON_OFF_REPORT) &&
            (usage->hid & HID_USAGE_PAGE) == 0x00880000) {
@@ -94,7 +97,7 @@ static int ite_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
        int ret;
 
-       hid_set_drvdata(hdev, (void *)id->driver_data);
+       hid_set_drvdata(hdev, (void *)id);
 
        ret = hid_open_report(hdev);
        if (ret)