Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

time: x86: Replace LATCH with PIT_LATCH in i8253 clocksource driver

The i8253 clockevent & clocksource driver uses PIT_LATCH
except for two cases where it uses LATCH:

1)
/* VIA686a test code... reset the latch if count > max + 1 */
if (count > LATCH) {

LATCH is based on CLOCK_TICK_RATE which is defined as
PIT_TICK_RATE on x86 so this should just be the later.

2)
...
switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
/* binary, mode 2, LSB/MSB, ch 0 */
outb_p(0x34, PIT_MODE);
outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
outb_p(LATCH >> 8 , PIT_CH0); /* MSB */
...

MIPS and ARM are the only other arches that use this driver. In
the MIPS case CLOCK_TICK_RATE is defined as the same value as
PIT_TICK_RATE. For ARM, the only machine that uses it is
Footbridge which has a totally bogus CLOCK_TICK_RATE according
to the comments. Furthermore, the clockevent_i8253_init()
initializes the clockevent with PIT_TIC_RATE, so there's
no reason to use the generic LATCH.

This is part of work to remove and depecrate the global
CLOCK_TICK_RATE symbol.

Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>

authored by

Deepak Saxena and committed by
John Stultz
5f724e84 cbf1599b

+3 -3
+3 -3
drivers/clocksource/i8253.c
··· 53 53 count |= inb_p(PIT_CH0) << 8; 54 54 55 55 /* VIA686a test code... reset the latch if count > max + 1 */ 56 - if (count > LATCH) { 56 + if (count > PIT_LATCH) { 57 57 outb_p(0x34, PIT_MODE); 58 58 outb_p(PIT_LATCH & 0xff, PIT_CH0); 59 59 outb_p(PIT_LATCH >> 8, PIT_CH0); ··· 114 114 case CLOCK_EVT_MODE_PERIODIC: 115 115 /* binary, mode 2, LSB/MSB, ch 0 */ 116 116 outb_p(0x34, PIT_MODE); 117 - outb_p(LATCH & 0xff , PIT_CH0); /* LSB */ 118 - outb_p(LATCH >> 8 , PIT_CH0); /* MSB */ 117 + outb_p(PIT_LATCH & 0xff , PIT_CH0); /* LSB */ 118 + outb_p(PIT_LATCH >> 8 , PIT_CH0); /* MSB */ 119 119 break; 120 120 121 121 case CLOCK_EVT_MODE_SHUTDOWN: