diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2013-04-25 20:31:44 +0000 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2013-05-16 11:09:14 +0200 |
commit | 09ac369c825d9d593404306d59062d854b321e9b (patch) | |
tree | 0d07679956f56d3203aff526412ec82862083b9a /kernel/time | |
parent | ba919d1caa2e624eb8c6cae1f2ce0a253e697d45 (diff) | |
download | op-kernel-dev-09ac369c825d9d593404306d59062d854b321e9b.zip op-kernel-dev-09ac369c825d9d593404306d59062d854b321e9b.tar.gz |
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.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index da6e10c..933efa4 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -627,11 +627,20 @@ static int change_clocksource(void *data) write_seqcount_begin(&timekeeper_seq); timekeeping_forward_now(tk); - if (!new->enable || new->enable(new) == 0) { - old = tk->clock; - tk_setup_internals(tk, new); - if (old->disable) - old->disable(old); + /* + * If the cs is in module, get a module reference. Succeeds + * for built-in code (owner == NULL) as well. + */ + if (try_module_get(new->owner)) { + if (!new->enable || new->enable(new) == 0) { + old = tk->clock; + tk_setup_internals(tk, new); + if (old->disable) + old->disable(old); + module_put(old->owner); + } else { + module_put(new->owner); + } } timekeeping_update(tk, true, true); |