Originally, timers were ticks based, and it made sense to add ticks to current time to know when to trigger an alarm.
But since commit: 7447545 change all other clock references to use nanosecond resolution accessors All timers use nanoseconds and we need to convert ticks to nanoseconds, by doing something like: y = muldiv64(x, get_ticks_per_sec(), TIMER_FREQ) where x is the number of device ticks and y the number of system ticks. y is used as nanoseconds in timer functions, it works because 1 tick is 1 nanosecond. (get_ticks_per_sec() is 10^9) But if get_ticks_per_sec() / TIMER_FREQ is an integer, we can do: y = x * TIMER_PERIOD; Laurent Vivier (7): PCI: remove muldiv64() mips: remove muldiv64() openrisc: remove muldiv64() arm: remove muldiv64() hpet: remove muldiv64() bt: remove muldiv64() net: remove muldiv64() hw/bt/hci.c | 4 ++-- hw/mips/cputimer.c | 19 ++++++++----------- hw/net/pcnet.c | 3 +-- hw/net/rtl8139.c | 14 ++++++-------- hw/openrisc/cputimer.c | 7 +++---- hw/timer/hpet.c | 6 +++--- hw/watchdog/wdt_i6300esb.c | 11 +++-------- include/hw/timer/hpet.h | 4 ++-- net/dump.c | 2 +- target-arm/helper.c | 9 +++------ tests/rtl8139-test.c | 2 +- 11 files changed, 33 insertions(+), 48 deletions(-) -- 2.1.0