aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2013-04-25 16:31:44 -0400
committerThomas Gleixner <tglx@linutronix.de>2013-05-16 05:09:14 -0400
commit09ac369c825d9d593404306d59062d854b321e9b (patch)
tree0d07679956f56d3203aff526412ec82862083b9a /kernel/time
parentba919d1caa2e624eb8c6cae1f2ce0a253e697d45 (diff)
clocksource: Add module refcount
Add a module refcount, so the current clocksource cannot be removed unconditionally. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Magnus Damm <magnus.damm@gmail.com> Link: http://lkml.kernel.org/r/20130425143435.762417789@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index da6e10c7a378..933efa4071c3 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -627,11 +627,20 @@ static int change_clocksource(void *data)
627 write_seqcount_begin(&timekeeper_seq); 627 write_seqcount_begin(&timekeeper_seq);
628 628
629 timekeeping_forward_now(tk); 629 timekeeping_forward_now(tk);
630 if (!new->enable || new->enable(new) == 0) { 630 /*
631 old = tk->clock; 631 * If the cs is in module, get a module reference. Succeeds
632 tk_setup_internals(tk, new); 632 * for built-in code (owner == NULL) as well.
633 if (old->disable) 633 */
634 old->disable(old); 634 if (try_module_get(new->owner)) {
635 if (!new->enable || new->enable(new) == 0) {
636 old = tk->clock;
637 tk_setup_internals(tk, new);
638 if (old->disable)
639 old->disable(old);
640 module_put(old->owner);
641 } else {
642 module_put(new->owner);
643 }
635 } 644 }
636 timekeeping_update(tk, true, true); 645 timekeeping_update(tk, true, true);
637 646