Skip to content

Commit 37e7742

Browse files
Sergei Shtylyovdlezcano
authored andcommitted
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: 19bdc9d ("clocksource: sh_cmt clocksource support") Reported-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Sergei Shtylyov <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
1 parent 22627c6 commit 37e7742

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/clocksource/sh_cmt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct sh_cmt_channel {
100100
raw_spinlock_t lock;
101101
struct clock_event_device ced;
102102
struct clocksource cs;
103-
unsigned long total_cycles;
103+
u64 total_cycles;
104104
bool cs_enabled;
105105
};
106106

@@ -605,8 +605,8 @@ static u64 sh_cmt_clocksource_read(struct clocksource *cs)
605605
{
606606
struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
607607
unsigned long flags;
608-
unsigned long value;
609608
u32 has_wrapped;
609+
u64 value;
610610
u32 raw;
611611

612612
raw_spin_lock_irqsave(&ch->lock, flags);
@@ -680,7 +680,7 @@ static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch,
680680
cs->disable = sh_cmt_clocksource_disable;
681681
cs->suspend = sh_cmt_clocksource_suspend;
682682
cs->resume = sh_cmt_clocksource_resume;
683-
cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
683+
cs->mask = CLOCKSOURCE_MASK(sizeof(u64) * 8);
684684
cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
685685

686686
dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",

0 commit comments

Comments
 (0)