Subject: Re: ps/2 mouse timeout problems
To: Martin Husemann <martin@duskware.de>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-kern
Date: 09/03/2002 16:43:59
    Date:        Fri, 30 Aug 2002 20:53:58 +0200
    From:        Martin Husemann <martin@duskware.de>
    Message-ID:  <20020830205358.B12140@night-porter.duskware.de>


  | +	if (max_delay == 0) {
  | +		/* round 25ms up to next value of hz granularity */
  | +		max_delay = (25*hz+999)/1000;	/* calc ticks */
  | +		max_delay *= 1000000/hz;	/* convert to usec */
  | +	}

You don't need all that rounding noise - in this scheme the comparisons
are done using microseconds.

It is perfectly safe to ask for 25000 microseconds, regardless of the
actual timer jumping 0, 10000, 20000, 30000 - when it gets to 30000 it
will be bigger than 25000 and the timeout will go off.

Rounding was needed in the callout method, as that one operates in units
of hz, and with integer division in the conversion from ms to hz, you'd get
truncation, and a smaller timeout than you really wanted (though for this,
just adding 1 to the result of the division would almost certainly be good
enough).

So, all you need is "max_delay = 25 * 1000;"  (convert ms to us).   Or
alternatively, get rid of max_delay (it wasn't there before) and leave the
25000 in the comparison directly.

kre