[tip:timers/urgent] clocksource: save mult_orig in clocksource_disable()

From: tip-bot for Magnus Damm
Date: Thu Jul 30 2009 - 15:58:13 EST


Commit-ID: a52c77102626951144165c53a6b54f1e812360d5
Gitweb: http://git.kernel.org/tip/a52c77102626951144165c53a6b54f1e812360d5
Author: Magnus Damm <magnus.damm@xxxxxxxxx>
AuthorDate: Tue, 28 Jul 2009 14:09:55 -0700
Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitDate: Thu, 30 Jul 2009 21:55:47 +0200

clocksource: save mult_orig in clocksource_disable()

Save clocksource mult_orig in clocksource_disable().

To fix the common case where ->enable() does not setup
mult, make sure mult_orig is saved in mult on disable.

Also add comments to explain why we do this.

Signed-off-by: Magnus Damm <damm@xxxxxxxxxx>
Cc: johnstul@xxxxxxxxxx
Cc: lethal@xxxxxxxxxxxx
Cc: akpm@xxxxxxxxxxxxxxxxxxxx
LKML-Reference: <20090618152432.10136.9932.sendpatchset@xxxxxxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>


---
include/linux/clocksource.h | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index c56457c..aff9f01 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -293,7 +293,11 @@ static inline int clocksource_enable(struct clocksource *cs)
if (cs->enable)
ret = cs->enable(cs);

- /* save mult_orig on enable */
+ /* The frequency may have changed while the clocksource
+ * was disabled. If so the code in ->enable() must update
+ * the mult value to reflect the new frequency. Make sure
+ * mult_orig follows this change.
+ */
cs->mult_orig = cs->mult;

return ret;
@@ -309,6 +313,12 @@ static inline int clocksource_enable(struct clocksource *cs)
*/
static inline void clocksource_disable(struct clocksource *cs)
{
+ /* Save mult_orig in mult so clocksource_enable() can
+ * restore the value regardless if ->enable() updates
+ * the value of mult or not.
+ */
+ cs->mult = cs->mult_orig;
+
if (cs->disable)
cs->disable(cs);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/