Something wrong with mouse timeouts

From: Pavel Machek
Date: Wed Apr 28 2004 - 15:49:51 EST


Hi!

Code is at least *very* confusing in psmouse_command; I think its
buggy:

if (command == PSMOUSE_CMD_RESET_BAT)
B => timeout = 4000000; /* 4 sec */

/* initialize cmdbuf with preset values from param */
if (receive)
for (i = 0; i < receive; i++)
psmouse->cmdbuf[(receive - 1) - i] = param[i];

if (command & 0xff)
if (psmouse_sendbyte(psmouse, command & 0xff))
return (psmouse->cmdcnt = 0) - 1;

for (i = 0; i < send; i++)
if (psmouse_sendbyte(psmouse, param[i]))
return (psmouse->cmdcnt = 0) - 1;

while (psmouse->cmdcnt && timeout--) {

C => if (psmouse->cmdcnt == 1 && command == PSMOUSE_CMD_RESET_BAT &&
timeout > 100000) /* do not run in a endless loop */
A => timeout = 100000; /* 1 sec */


if (psmouse->cmdcnt == 1 && command == PSMOUSE_CMD_GETID &&
psmouse->cmdbuf[1] != 0xab && psmouse->cmdbuf[1] != 0xac) {
psmouse->cmdcnt = 0;
break;
}

udelay(1);
}

In A), it says that it sets timeout to 1 sec, when it in fact sets it
to 100msec. Whats more, for CMD_RESET_BAT, timeout is explicitely set
to 4sec B); but in C), there is extra code to reset it to 100msec?
Why? Is it trying to set shorter timeout for last byte of reply or
something similar?

It speaks about endless loops, but 4 sec is certainly not endless if
you ask me.
Pavel
--
934a471f20d6580d5aad759bf0d97ddc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/