Linux Input Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: wacom: generic: Avoid reporting a serial of '0' to userspace
@ 2024-02-01  4:40 Tobita, Tatsunosuke
  2024-02-13 10:40 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Tobita, Tatsunosuke @ 2024-02-01  4:40 UTC (permalink / raw
  To: linux-input, Benjamin Tissoires, Jiri Kosina
  Cc: Ping Cheng, Jason Gerecke, Aaron Armstrong Skomra, Joshua Dickens,
	Tatsunosuke Tobita, Jason Gerecke, stable

From: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>

The xf86-input-wacom driver does not treat '0' as a valid serial
number and will drop any input report which contains an
MSC_SERIAL = 0 event. The kernel driver already takes care to
avoid sending any MSC_SERIAL event if the value of serial[0] == 0
(which is the case for devices that don't actually report a
serial number), but this is not quite sufficient.
Only the lower 32 bits of the serial get reported to userspace,
so if this portion of the serial is zero then there can still
be problems.

This commit allows the driver to report either the lower 32 bits
if they are non-zero or the upper 32 bits otherwise.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
Fixes: f85c9dc678a5 ("HID: wacom: generic: Support tool ID and additional tool types")
CC: stable@vger.kernel.org # v4.10
---
 drivers/hid/wacom_wac.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index da8a01fedd39..fbe10fbc5769 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2575,7 +2575,14 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
 				wacom_wac->hid_data.tipswitch);
 		input_report_key(input, wacom_wac->tool[0], sense);
 		if (wacom_wac->serial[0]) {
-			input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
+			/*
+			 * xf86-input-wacom does not accept a serial number
+			 * of '0'. Report the low 32 bits if possible, but
+			 * if they are zero, report the upper ones instead.
+			 */
+			__u32 serial_lo = wacom_wac->serial[0] & 0xFFFFFFFFu;
+			__u32 serial_hi = wacom_wac->serial[0] >> 32;
+			input_event(input, EV_MSC, MSC_SERIAL, (int)(serial_lo ? serial_lo : serial_hi));
 			input_report_abs(input, ABS_MISC, sense ? id : 0);
 		}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] HID: wacom: generic: Avoid reporting a serial of '0' to userspace
  2024-02-01  4:40 [PATCH 1/2] HID: wacom: generic: Avoid reporting a serial of '0' to userspace Tobita, Tatsunosuke
@ 2024-02-13 10:40 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2024-02-13 10:40 UTC (permalink / raw
  To: Tobita, Tatsunosuke
  Cc: linux-input, Benjamin Tissoires, Ping Cheng, Jason Gerecke,
	Aaron Armstrong Skomra, Joshua Dickens, Tatsunosuke Tobita,
	Jason Gerecke, stable

On Thu, 1 Feb 2024, Tobita, Tatsunosuke wrote:

> From: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
> 
> The xf86-input-wacom driver does not treat '0' as a valid serial
> number and will drop any input report which contains an
> MSC_SERIAL = 0 event. The kernel driver already takes care to
> avoid sending any MSC_SERIAL event if the value of serial[0] == 0
> (which is the case for devices that don't actually report a
> serial number), but this is not quite sufficient.
> Only the lower 32 bits of the serial get reported to userspace,
> so if this portion of the serial is zero then there can still
> be problems.
> 
> This commit allows the driver to report either the lower 32 bits
> if they are non-zero or the upper 32 bits otherwise.
> 
> Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
> Signed-off-by: Tatsunosuke Tobita <tatsunosuke.tobita@wacom.com>
> Fixes: f85c9dc678a5 ("HID: wacom: generic: Support tool ID and additional tool types")
> CC: stable@vger.kernel.org # v4.10

Applied to hid.git#for-6.8/upstream-fixes.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-13 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01  4:40 [PATCH 1/2] HID: wacom: generic: Avoid reporting a serial of '0' to userspace Tobita, Tatsunosuke
2024-02-13 10:40 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).