]> Pileus Git - ~andy/linux/commitdiff
clocksource: Let timekeeping_notify return success/error
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 Apr 2013 20:31:44 +0000 (20:31 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 May 2013 09:09:14 +0000 (11:09 +0200)
timekeeping_notify() can fail due cs->enable() failure. Though the
caller does not notice and happily keeps the wrong clocksource as the
current one.

Let the caller know about failure, so the current clocksource will be
shown correctly in sysfs.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <john.stultz@linaro.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Link: http://lkml.kernel.org/r/20130425143435.696321912@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/clocksource.h
kernel/time/clocksource.c
kernel/time/timekeeping.c

index 7279b94c01da3fdb31108e9ca3d3e8fb5202e923..aa6ba44e75d541e32ef9bf77899a21e04a6ae65b 100644 (file)
@@ -321,7 +321,7 @@ static inline void __clocksource_updatefreq_khz(struct clocksource *cs, u32 khz)
 }
 
 
-extern void timekeeping_notify(struct clocksource *clock);
+extern int timekeeping_notify(struct clocksource *clock);
 
 extern cycle_t clocksource_mmio_readl_up(struct clocksource *);
 extern cycle_t clocksource_mmio_readl_down(struct clocksource *);
index dda5c7130d9359edf2ff0bfc9e17827a5ca3ca8e..1923a340bd91038d21579fee4acd5fe55f32389e 100644 (file)
@@ -611,10 +611,10 @@ static void clocksource_select(void)
                        best = cs;
                break;
        }
-       if (curr_clocksource != best) {
-               printk(KERN_INFO "Switching to clocksource %s\n", best->name);
+
+       if (curr_clocksource != best && !timekeeping_notify(best)) {
+               pr_info("Switched to clocksource %s\n", best->name);
                curr_clocksource = best;
-               timekeeping_notify(curr_clocksource);
        }
 }
 
index 98cd470bbe4901569dad2a8ffb4a85f7945c5fca..da6e10c7a37823ad55c16f71ed883074a7cfcb7f 100644 (file)
@@ -648,14 +648,15 @@ static int change_clocksource(void *data)
  * This function is called from clocksource.c after a new, better clock
  * source has been registered. The caller holds the clocksource_mutex.
  */
-void timekeeping_notify(struct clocksource *clock)
+int timekeeping_notify(struct clocksource *clock)
 {
        struct timekeeper *tk = &timekeeper;
 
        if (tk->clock == clock)
-               return;
+               return 0;
        stop_machine(change_clocksource, clock, NULL);
        tick_clock_notify();
+       return tk->clock == clock ? 0 : -1;
 }
 
 /**