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

clocksource/drivers/sh_cmt: Fix clocksource width for 32-bit machines

The driver seems to abuse *unsigned long* not only for the (32-bit)
register values but also for the 'sh_cmt_channel::total_cycles' which
needs to always be 64-bit -- as a result, the clocksource's mask is
needlessly clamped down to 32-bits on the 32-bit machines...

Fixes: 19bdc9d061bc ("clocksource: sh_cmt clocksource support")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Sergei Shtylyov and committed by
Daniel Lezcano
37e7742c 22627c6f

+3 -3
+3 -3
drivers/clocksource/sh_cmt.c
··· 100 100 raw_spinlock_t lock; 101 101 struct clock_event_device ced; 102 102 struct clocksource cs; 103 - unsigned long total_cycles; 103 + u64 total_cycles; 104 104 bool cs_enabled; 105 105 }; 106 106 ··· 605 605 { 606 606 struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); 607 607 unsigned long flags; 608 - unsigned long value; 609 608 u32 has_wrapped; 609 + u64 value; 610 610 u32 raw; 611 611 612 612 raw_spin_lock_irqsave(&ch->lock, flags); ··· 680 680 cs->disable = sh_cmt_clocksource_disable; 681 681 cs->suspend = sh_cmt_clocksource_suspend; 682 682 cs->resume = sh_cmt_clocksource_resume; 683 - cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); 683 + cs->mask = CLOCKSOURCE_MASK(sizeof(u64) * 8); 684 684 cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; 685 685 686 686 dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",