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

clocksource: Fix clocksource_mmio_readX_down

For some clocksource devices, for example, the registers are 32-bit, while
the lower 16-bit is used for timer counting(And reading the upper 16-bit
will return 0).

For example, when the counter value is 0x00001111, and then the
~readl_relaxed(to_mmio_clksrc(c)->reg) will return the value of 0xFFFFEEEE,
but it should be 0x0000EEEE.

So just using the c->mask to mask the unused bits.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Xiubo Li and committed by
Daniel Lezcano
95c19a06 4a3ae074

+2 -2
+2 -2
drivers/clocksource/mmio.c
··· 27 27 28 28 cycle_t clocksource_mmio_readl_down(struct clocksource *c) 29 29 { 30 - return ~(cycle_t)readl_relaxed(to_mmio_clksrc(c)->reg); 30 + return ~(cycle_t)readl_relaxed(to_mmio_clksrc(c)->reg) & c->mask; 31 31 } 32 32 33 33 cycle_t clocksource_mmio_readw_up(struct clocksource *c) ··· 37 37 38 38 cycle_t clocksource_mmio_readw_down(struct clocksource *c) 39 39 { 40 - return ~(cycle_t)readw_relaxed(to_mmio_clksrc(c)->reg); 40 + return ~(cycle_t)readw_relaxed(to_mmio_clksrc(c)->reg) & c->mask; 41 41 } 42 42 43 43 /**