Blame SOURCES/0003-Split-EV_MSC-handling-out-of-the-EV_SYN-handling.patch

4955bb
From 7523a530494484e8b92e0c8604fb39a51b4887f8 Mon Sep 17 00:00:00 2001
4955bb
From: Peter Hutterer <peter.hutterer@who-t.net>
4955bb
Date: Wed, 24 Oct 2018 10:15:58 +1000
4955bb
Subject: [PATCH 3/4] Split EV_MSC handling out of the EV_SYN handling
4955bb
4955bb
The only thing these two had in common was the reset of the event count on
4955bb
failure. Might as well split them up to make the code more readable.
4955bb
4955bb
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
4955bb
Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
4955bb
(cherry picked from commit 8a6f201fde45b6aef9785bdfbfd0d908ff1c4071)
4955bb
---
4955bb
 src/wcmUSB.c | 68 +++++++++++++++++++++++++++++++---------------------
4955bb
 1 file changed, 41 insertions(+), 27 deletions(-)
4955bb
4955bb
diff --git a/src/wcmUSB.c b/src/wcmUSB.c
4955bb
index be9be6e..cf89ff8 100644
4955bb
--- a/src/wcmUSB.c
4955bb
+++ b/src/wcmUSB.c
4955bb
@@ -59,6 +59,8 @@ static void usbParseEvent(InputInfoPtr pInfo,
4955bb
 	const struct input_event* event);
4955bb
 static void usbParseSynEvent(InputInfoPtr pInfo,
4955bb
 			     const struct input_event *event);
4955bb
+static void usbParseMscEvent(InputInfoPtr pInfo,
4955bb
+			     const struct input_event *event);
4955bb
 static void usbDispatchEvents(InputInfoPtr pInfo);
4955bb
 static int usbChooseChannel(WacomCommonPtr common, int device_type, unsigned int serial);
4955bb
 
4955bb
@@ -994,8 +996,44 @@ static void usbParseEvent(InputInfoPtr pInfo,
4955bb
 	/* save it for later */
4955bb
 	private->wcmEvents[private->wcmEventCnt++] = *event;
4955bb
 
4955bb
-	if (event->type == EV_MSC || event->type == EV_SYN)
4955bb
-		usbParseSynEvent(pInfo, event);
4955bb
+	switch (event->type)
4955bb
+	{
4955bb
+		case EV_MSC:
4955bb
+			usbParseMscEvent(pInfo, event);
4955bb
+			break;
4955bb
+		case EV_SYN:
4955bb
+			usbParseSynEvent(pInfo, event);
4955bb
+			break;
4955bb
+		default:
4955bb
+			break;
4955bb
+	}
4955bb
+}
4955bb
+
4955bb
+static void usbParseMscEvent(InputInfoPtr pInfo,
4955bb
+			     const struct input_event *event)
4955bb
+{
4955bb
+	WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
4955bb
+	WacomCommonPtr common = priv->common;
4955bb
+	wcmUSBData* private = common->private;
4955bb
+
4955bb
+	if (event->code != MSC_SERIAL)
4955bb
+		return;
4955bb
+
4955bb
+	if (event->value != 0)
4955bb
+	{
4955bb
+		/* save the serial number so we can look up the channel number later */
4955bb
+		private->wcmLastToolSerial = event->value;
4955bb
+	}
4955bb
+	else
4955bb
+	{
4955bb
+		/* we don't report serial numbers for some tools but we never report
4955bb
+		 * a serial number with a value of 0 - if that happens drop the
4955bb
+		 * whole frame */
4955bb
+		LogMessageVerbSigSafe(X_ERROR, 0,
4955bb
+				      "%s: usbParse: Ignoring event from invalid serial 0\n",
4955bb
+				      pInfo->name);
4955bb
+		private->wcmEventCnt = 0;
4955bb
+	}
4955bb
 }
4955bb
 
4955bb
 /**
4955bb
@@ -1011,33 +1049,9 @@ static void usbParseSynEvent(InputInfoPtr pInfo,
4955bb
 	WacomCommonPtr common = priv->common;
4955bb
 	wcmUSBData* private = common->private;
4955bb
 
4955bb
-	if ((event->type == EV_MSC) && (event->code == MSC_SERIAL))
4955bb
-	{
4955bb
-		/* we don't report serial numbers for some tools
4955bb
-		 * but we never report a serial number with a value of 0 */
4955bb
-		if (event->value == 0)
4955bb
-		{
4955bb
-			LogMessageVerbSigSafe(X_ERROR, 0,
4955bb
-					      "%s: usbParse: Ignoring event from invalid serial 0\n",
4955bb
-					      pInfo->name);
4955bb
-			goto skipEvent;
4955bb
-		}
4955bb
-
4955bb
-		/* save the serial number so we can look up the channel number later */
4955bb
-		private->wcmLastToolSerial = event->value;
4955bb
-
4955bb
+	if (event->code != SYN_REPORT)
4955bb
 		return;
4955bb
 
4955bb
-	} else if ((event->type == EV_SYN) && (event->code == SYN_REPORT))
4955bb
-	{
4955bb
-		/* end of record. fall through to dispatch */
4955bb
-	}
4955bb
-	else
4955bb
-	{
4955bb
-		/* not a MSC_SERIAL and not a SYN_REPORT, bail out */
4955bb
-		return;
4955bb
-	}
4955bb
-
4955bb
 	/* ignore events without information */
4955bb
 	if ((private->wcmEventCnt < 2) && private->wcmLastToolSerial)
4955bb
 	{
4955bb
-- 
4955bb
2.19.2
4955bb