Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95c19a06 authored by Xiubo Li's avatar Xiubo Li Committed by Daniel Lezcano
Browse files

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: default avatarXiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 4a3ae074
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ cycle_t clocksource_mmio_readl_up(struct clocksource *c)

cycle_t clocksource_mmio_readl_down(struct clocksource *c)
{
	return ~(cycle_t)readl_relaxed(to_mmio_clksrc(c)->reg);
	return ~(cycle_t)readl_relaxed(to_mmio_clksrc(c)->reg) & c->mask;
}

cycle_t clocksource_mmio_readw_up(struct clocksource *c)
@@ -37,7 +37,7 @@ cycle_t clocksource_mmio_readw_up(struct clocksource *c)

cycle_t clocksource_mmio_readw_down(struct clocksource *c)
{
	return ~(cycle_t)readw_relaxed(to_mmio_clksrc(c)->reg);
	return ~(cycle_t)readw_relaxed(to_mmio_clksrc(c)->reg) & c->mask;
}

/**