HID: wacom: Ensure bootloader PID is usable in hidraw mode
authorJason Gerecke <killertofu@gmail.com>
Thu, 1 Dec 2022 23:11:41 +0000 (15:11 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 08:26:34 +0000 (09:26 +0100)
commit 1db1f392591aff13fd643f0ec7c1d5e27391d700 upstream.

Some Wacom devices have a special "bootloader" mode that is used for
firmware flashing. When operating in this mode, the device cannot be
used for input, and the HID descriptor is not able to be processed by
the driver. The driver generates an "Unknown device_type" warning and
then returns an error code from wacom_probe(). This is a problem because
userspace still needs to be able to interact with the device via hidraw
to perform the firmware flash.

This commit adds a non-generic device definition for 056a:0094 which
is used when devices are in "bootloader" mode. It marks the devices
with a special BOOTLOADER type that is recognized by wacom_probe() and
wacom_raw_event(). When we see this type we ensure a hidraw device is
created and otherwise keep our hands off so that userspace is in full
control.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.c
drivers/hid/wacom_wac.h

index 1486272a33a55c66024eb90d07802f1e32925cb1..3d521f289984a1b861a6707c261a1b1c2a0c8787 100644 (file)
@@ -61,6 +61,9 @@ static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
 
+       if (wacom->wacom_wac.features.type == BOOTLOADER)
+               return 0;
+
        if (size > WACOM_PKGLEN_MAX)
                return 1;
 
@@ -2616,6 +2619,11 @@ static int wacom_probe(struct hid_device *hdev,
                goto fail;
        }
 
+       if (features->type == BOOTLOADER) {
+               hid_warn(hdev, "Using device in hidraw-only mode");
+               return hid_hw_start(hdev, HID_CONNECT_HIDRAW);
+       }
+
        error = wacom_parse_and_register(wacom, false);
        if (error)
                goto fail;
index 496f69aed837600be731e8763e66083002857b9a..417e1083556bbccb303fdab62f00ab8c7aba486c 100644 (file)
@@ -4477,6 +4477,9 @@ static const struct wacom_features wacom_features_0x361 =
 static const struct wacom_features wacom_features_HID_ANY_ID =
        { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
 
+static const struct wacom_features wacom_features_0x94 =
+       { "Wacom Bootloader", .type = BOOTLOADER };
+
 #define USB_DEVICE_WACOM(prod)                                         \
        HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
        .driver_data = (kernel_ulong_t)&wacom_features_##prod
@@ -4550,6 +4553,7 @@ const struct hid_device_id wacom_ids[] = {
        { USB_DEVICE_WACOM(0x84) },
        { USB_DEVICE_WACOM(0x90) },
        { USB_DEVICE_WACOM(0x93) },
+       { USB_DEVICE_WACOM(0x94) },
        { USB_DEVICE_WACOM(0x97) },
        { USB_DEVICE_WACOM(0x9A) },
        { USB_DEVICE_WACOM(0x9F) },
index a61d3543b8e6d20b782b9214c5007b83bc018d2a..a5c61096fa457d38e7730be46c1a4d2de478ba9d 100644 (file)
@@ -237,6 +237,7 @@ enum {
        MTTPC,
        MTTPC_B,
        HID_GENERIC,
+       BOOTLOADER,
        MAX_TYPE
 };