clocksource: add enable() and disable() callbacks
Add enable() and disable() callbacks for clocksources. This allows us to put unused clocksources in power save mode. The functions clocksource_enable() and clocksource_disable() wrap the callbacks and are inserted in the timekeeping code to enable before use and disable after switching to a new clocksource. Signed-off-by: Magnus Damm <damm@igel.co.jp> Acked-by: John Stultz <johnstul@us.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
8e19608e8b
commit
4614e6adaf
@ -182,7 +182,7 @@ EXPORT_SYMBOL(do_settimeofday);
|
||||
*/
|
||||
static void change_clocksource(void)
|
||||
{
|
||||
struct clocksource *new;
|
||||
struct clocksource *new, *old;
|
||||
|
||||
new = clocksource_get_next();
|
||||
|
||||
@ -191,11 +191,16 @@ static void change_clocksource(void)
|
||||
|
||||
clocksource_forward_now();
|
||||
|
||||
new->raw_time = clock->raw_time;
|
||||
if (clocksource_enable(new))
|
||||
return;
|
||||
|
||||
new->raw_time = clock->raw_time;
|
||||
old = clock;
|
||||
clock = new;
|
||||
clocksource_disable(old);
|
||||
|
||||
clock->cycle_last = 0;
|
||||
clock->cycle_last = clocksource_read(new);
|
||||
clock->cycle_last = clocksource_read(clock);
|
||||
clock->error = 0;
|
||||
clock->xtime_nsec = 0;
|
||||
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
|
||||
@ -292,6 +297,7 @@ void __init timekeeping_init(void)
|
||||
ntp_init();
|
||||
|
||||
clock = clocksource_get_next();
|
||||
clocksource_enable(clock);
|
||||
clocksource_calculate_interval(clock, NTP_INTERVAL_LENGTH);
|
||||
clock->cycle_last = clocksource_read(clock);
|
||||
|
||||
|
Reference in New Issue
Block a user