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

clocksource/drivers/timer_sun5i: Replace code by clocksource_mmio_init

The current code to initialize, register and read the clocksource is
already factored out in mmio.c via the clocksource_mmio_init function.

The only difference is the readl vs readl_relaxed.

Factor out the code with the clocksource_mmio_init function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

+2 -14
+2 -14
drivers/clocksource/timer-sun5i.c
··· 152 152 return IRQ_HANDLED; 153 153 } 154 154 155 - static cycle_t sun5i_clksrc_read(struct clocksource *clksrc) 156 - { 157 - struct sun5i_timer_clksrc *cs = to_sun5i_timer_clksrc(clksrc); 158 - 159 - return ~readl(cs->timer.base + TIMER_CNTVAL_LO_REG(1)); 160 - } 161 - 162 155 static int sun5i_rate_cb_clksrc(struct notifier_block *nb, 163 156 unsigned long event, void *data) 164 157 { ··· 210 217 writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD, 211 218 base + TIMER_CTL_REG(1)); 212 219 213 - cs->clksrc.name = node->name; 214 - cs->clksrc.rating = 340; 215 - cs->clksrc.read = sun5i_clksrc_read; 216 - cs->clksrc.mask = CLOCKSOURCE_MASK(32); 217 - cs->clksrc.flags = CLOCK_SOURCE_IS_CONTINUOUS; 218 - 219 - ret = clocksource_register_hz(&cs->clksrc, rate); 220 + ret = clocksource_mmio_init(base + TIMER_CNTVAL_LO_REG(1), node->name, 221 + rate, 340, 32, clocksource_mmio_readl_down); 220 222 if (ret) { 221 223 pr_err("Couldn't register clock source.\n"); 222 224 goto err_remove_notifier;