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...

Reported-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Sergei Shtylyov <[email protected]>

---
This patch is against the 'tip.git' repo's 'timers/core' branch plus the fixup
for the 64-bit machines reposted last Saturday...

 drivers/clocksource/sh_cmt.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: tip/drivers/clocksource/sh_cmt.c
===================================================================
--- tip.orig/drivers/clocksource/sh_cmt.c
+++ tip/drivers/clocksource/sh_cmt.c
@@ -108,7 +108,7 @@ struct sh_cmt_channel {
        raw_spinlock_t lock;
        struct clock_event_device ced;
        struct clocksource cs;
-       unsigned long total_cycles;
+       u64 total_cycles;
        bool cs_enabled;
 };
 
@@ -613,8 +613,8 @@ static u64 sh_cmt_clocksource_read(struc
 {
        struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
        unsigned long flags;
-       unsigned long value;
        u32 has_wrapped;
+       u64 value;
        u32 raw;
 
        raw_spin_lock_irqsave(&ch->lock, flags);
@@ -688,7 +688,7 @@ static int sh_cmt_register_clocksource(s
        cs->disable = sh_cmt_clocksource_disable;
        cs->suspend = sh_cmt_clocksource_suspend;
        cs->resume = sh_cmt_clocksource_resume;
-       cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
+       cs->mask = CLOCKSOURCE_MASK(sizeof(u64) * 8);
        cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
        dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",

Reply via email to