Commit 11b8633a authored by Anton Blanchard's avatar Anton Blanchard Committed by Benjamin Herrenschmidt

powerpc/time: Use clocksource_register_hz

Use clocksource_register_hz which calculates the shift/mult
factors for us. Also remove the shift = 22 assumption in
vsyscall_update - thanks to Paul Mackerras and John Stultz for
catching that.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent d8afc6fd
...@@ -86,8 +86,6 @@ static struct clocksource clocksource_rtc = { ...@@ -86,8 +86,6 @@ static struct clocksource clocksource_rtc = {
.rating = 400, .rating = 400,
.flags = CLOCK_SOURCE_IS_CONTINUOUS, .flags = CLOCK_SOURCE_IS_CONTINUOUS,
.mask = CLOCKSOURCE_MASK(64), .mask = CLOCKSOURCE_MASK(64),
.shift = 22,
.mult = 0, /* To be filled in */
.read = rtc_read, .read = rtc_read,
}; };
...@@ -97,8 +95,6 @@ static struct clocksource clocksource_timebase = { ...@@ -97,8 +95,6 @@ static struct clocksource clocksource_timebase = {
.rating = 400, .rating = 400,
.flags = CLOCK_SOURCE_IS_CONTINUOUS, .flags = CLOCK_SOURCE_IS_CONTINUOUS,
.mask = CLOCKSOURCE_MASK(64), .mask = CLOCKSOURCE_MASK(64),
.shift = 22,
.mult = 0, /* To be filled in */
.read = timebase_read, .read = timebase_read,
}; };
...@@ -822,9 +818,8 @@ void update_vsyscall(struct timespec *wall_time, struct timespec *wtm, ...@@ -822,9 +818,8 @@ void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
++vdso_data->tb_update_count; ++vdso_data->tb_update_count;
smp_mb(); smp_mb();
/* XXX this assumes clock->shift == 22 */ /* 19342813113834067 ~= 2^(20+64) / 1e9 */
/* 4611686018 ~= 2^(20+64-22) / 1e9 */ new_tb_to_xs = (u64) mult * (19342813113834067ULL >> clock->shift);
new_tb_to_xs = (u64) mult * 4611686018ULL;
new_stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC; new_stamp_xsec = (u64) wall_time->tv_nsec * XSEC_PER_SEC;
do_div(new_stamp_xsec, 1000000000); do_div(new_stamp_xsec, 1000000000);
new_stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC; new_stamp_xsec += (u64) wall_time->tv_sec * XSEC_PER_SEC;
...@@ -875,9 +870,7 @@ static void __init clocksource_init(void) ...@@ -875,9 +870,7 @@ static void __init clocksource_init(void)
else else
clock = &clocksource_timebase; clock = &clocksource_timebase;
clock->mult = clocksource_hz2mult(tb_ticks_per_sec, clock->shift); if (clocksource_register_hz(clock, tb_ticks_per_sec)) {
if (clocksource_register(clock)) {
printk(KERN_ERR "clocksource: %s is already registered\n", printk(KERN_ERR "clocksource: %s is already registered\n",
clock->name); clock->name);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment