]> nv-tegra.nvidia Code Review - linux-3.10.git/commit
[PATCH] HPET: make frequency calculations 32 bit safe
authorClemens Ladisch <clemens@ladisch.de>
Sun, 30 Oct 2005 23:03:31 +0000 (15:03 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 31 Oct 2005 01:37:29 +0000 (17:37 -0800)
commitba3f213f8a31af953b7e86b1d102c919e9935cd4
tree1056de1ccb2af403005aa05d5c52399aa36dd6ba
parent9090e6db87e3bdb2a2c187ebc0f9175a9f9e5c6f
[PATCH] HPET: make frequency calculations 32 bit safe

On 32-bit architectures, the multiplication in the argument for
hpet_time_div() often overflows.  In the typical case of a 14.32 MHz timer,
this happens when the desired frequency exceeds 61 Hz.

To avoid this multiplication, we can precompute and store the hardware
timer frequency, instead of the period, in the device structure, which
leaves us with a simple division when computing the number of timer ticks.

As a side effect, this also removes a theoretical bug where the timer
interpolator's frequency would be computed as a 32-bit value even if the
HPET frequency is greater than 2^32 Hz (the HPET spec allows up to 10 GHz).

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/hpet.c