]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
HID: wacom: Do not warn about dropped packets for first packet
authorJason Gerecke <jason.gerecke@wacom.com>
Mon, 9 Sep 2024 20:32:08 +0000 (13:32 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:29:12 +0000 (16:29 +0200)
[ Upstream commit 84aecf2d251a3359bc78b7c8e58f54b9fc966e89 ]

The driver currently assumes that the first sequence number it will see
is going to be 0. This is not a realiable assumption and can break if,
for example, the tablet has already been running for some time prior to
the kernel driver connecting to the device. This commit initializes the
expected sequence number to -1 and will only print the "Dropped" warning
the it has been updated to a non-negative value.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Joshua Dickens <joshua.dickens@wacom.com>
Fixes: 6d09085b38e5 ("HID: wacom: Adding Support for new usages")
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/wacom_wac.c
drivers/hid/wacom_wac.h

index c3c576641a38e126a6694789bf316c18f6109980..18b5cd0234d213e9f352eb9163cb3ddff8368d9d 100644 (file)
@@ -2368,6 +2368,9 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
                wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS3, 0);
                features->quirks &= ~WACOM_QUIRK_PEN_BUTTON3;
                break;
+       case WACOM_HID_WD_SEQUENCENUMBER:
+               wacom_wac->hid_data.sequence_number = -1;
+               break;
        }
 }
 
@@ -2492,7 +2495,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
                wacom_wac->hid_data.barrelswitch3 = value;
                return;
        case WACOM_HID_WD_SEQUENCENUMBER:
-               if (wacom_wac->hid_data.sequence_number != value) {
+               if (wacom_wac->hid_data.sequence_number != value &&
+                   wacom_wac->hid_data.sequence_number >= 0) {
                        int sequence_size = field->logical_maximum - field->logical_minimum + 1;
                        int drop_count = (value - wacom_wac->hid_data.sequence_number) % sequence_size;
                        hid_warn(hdev, "Dropped %d packets", drop_count);
index 57e185f18d53da281b9d7bec4748b4aafdf8c750..61073fe81ead229d69f29918a2b247ee322241e5 100644 (file)
@@ -324,7 +324,7 @@ struct hid_data {
        int bat_connected;
        int ps_connected;
        bool pad_input_event_flag;
-       unsigned short sequence_number;
+       int sequence_number;
        ktime_t time_delayed;
 };