Skip to contentSkip to conversation

Improve error recovery in serial mouse driver

PATCH Applied Peter Osterlund 3 participants 3 messages Mar 15, 2007 – Mar 16, 2007 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve error recovery in serial mouse driver

If bytes get lost in the communication with a serial mouse using the MS protocol, the kernel driver could do a better job getting back in sync. The first byte in a packet has bit 6 set, and no other bytes have that bit set. Therefore, if a byte is received with bit 6 cleared when the driver thinks it is at byte 0 in the packet, the driver thinks wrong and the byte should just be ignored.

This fix prevents spurious left/right button events when the serial communication is disturbed by a CPU-hungry real-time process.

---

 drivers/input/mouse/sermouse.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/mouse/sermouse.c +1 -0
index a85d747..24bed4b 100644
@@ -108,6 +108,7 @@ static void sermouse_process_ms(struct sermouse *sermouse, signed char data)
 	signed char *buf = sermouse->buf;
 
 	if (data & 0x40) sermouse->count = 0;
+	else if (sermouse->count == 0) return;
 
 	switch (sermouse->count) {
 
Signature · 2 lines
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340
#1 lore raw
Quoted 11 lines · Peter Osterlund

If bytes get lost in the communication with a serial mouse using the MS protocol, the kernel driver could do a better job getting back in sync. The first byte in a packet has bit 6 set, and no other bytes have that bit set. Therefore, if a byte is received with bit 6 cleared when the driver thinks it is at byte 0 in the packet, the driver thinks wrong and the byte should just be ignored.

This fix prevents spurious left/right button events when the serial communication is disturbed by a CPU-hungry real-time process.

Applied, thank you Peter.

Signature · 1 line
Dmitry
#2 lore raw
In reply to Peter Osterlund

drivers/input/mouse/sermouse.c static void sermouse_process_ms(struct sermouse *sermouse, signed char data) · line 111

Quoted 2 lines · Peter Osterlund
drivers/input/mouse/sermouse.c +1 -0
 	if (data & 0x40) sermouse->count = 0;
+	else if (sermouse->count == 0) return;
	if (data & 0x40)
		sermouse->count = 0;
	else
		if (sermouse->count == 0)
			return;

?

Would have been a good time to clean that one up...