]> git.baikalelectronics.ru Git - kernel.git/commit
HID: wacom: generic: Treat serial number and related fields as unsigned
authorJason Gerecke <killertofu@gmail.com>
Wed, 6 Nov 2019 19:59:46 +0000 (11:59 -0800)
committerJiri Kosina <jkosina@suse.cz>
Wed, 6 Nov 2019 20:37:29 +0000 (21:37 +0100)
commit7ada0f69c7b8cdc79ce9d692a0682e9e5e31ad13
tree4a09d3a6037b7085058506029ceb1ed7beb2aac9
parent76f4dc30c8a4a0302df77fe1dfcd37bf03b85bc5
HID: wacom: generic: Treat serial number and related fields as unsigned

The HID descriptors for most Wacom devices oddly declare the serial
number and other related fields as signed integers. When these numbers
are ingested by the HID subsystem, they are automatically sign-extended
into 32-bit integers. We treat the fields as unsigned elsewhere in the
kernel and userspace, however, so this sign-extension causes problems.
In particular, the sign-extended tool ID sent to userspace as ABS_MISC
does not properly match unsigned IDs used by xf86-input-wacom and libwacom.

We introduce a function 'wacom_s32tou' that can undo the automatic sign
extension performed by 'hid_snto32'. We call this function when processing
the serial number and related fields to ensure that we are dealing with
and reporting the unsigned form. We opt to use this method rather than
adding a descriptor fixup in 'wacom_hid_usage_quirk' since it should be
more robust in the face of future devices.

Ref: https://github.com/linuxwacom/input-wacom/issues/134
Fixes: 97b60fe1f3 ("HID: wacom: generic: Support tool ID and additional tool types")
CC: <stable@vger.kernel.org> # v4.10+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: Aaron Armstrong Skomra <aaron.skomra@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/wacom.h
drivers/hid/wacom_wac.c