diff options
Diffstat (limited to 'include/linux/clocksource.h')
| -rw-r--r-- | include/linux/clocksource.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 5a40d14daa9f..1219be4fb42e 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
| @@ -288,7 +288,20 @@ static inline cycle_t clocksource_read(struct clocksource *cs) | |||
| 288 | */ | 288 | */ |
| 289 | static inline int clocksource_enable(struct clocksource *cs) | 289 | static inline int clocksource_enable(struct clocksource *cs) |
| 290 | { | 290 | { |
| 291 | return cs->enable ? cs->enable(cs) : 0; | 291 | int ret = 0; |
| 292 | |||
| 293 | if (cs->enable) | ||
| 294 | ret = cs->enable(cs); | ||
| 295 | |||
| 296 | /* | ||
| 297 | * The frequency may have changed while the clocksource | ||
| 298 | * was disabled. If so the code in ->enable() must update | ||
| 299 | * the mult value to reflect the new frequency. Make sure | ||
| 300 | * mult_orig follows this change. | ||
| 301 | */ | ||
| 302 | cs->mult_orig = cs->mult; | ||
| 303 | |||
| 304 | return ret; | ||
| 292 | } | 305 | } |
| 293 | 306 | ||
| 294 | /** | 307 | /** |
| @@ -301,6 +314,13 @@ static inline int clocksource_enable(struct clocksource *cs) | |||
| 301 | */ | 314 | */ |
| 302 | static inline void clocksource_disable(struct clocksource *cs) | 315 | static inline void clocksource_disable(struct clocksource *cs) |
| 303 | { | 316 | { |
| 317 | /* | ||
| 318 | * Save mult_orig in mult so clocksource_enable() can | ||
| 319 | * restore the value regardless if ->enable() updates | ||
| 320 | * the value of mult or not. | ||
| 321 | */ | ||
| 322 | cs->mult = cs->mult_orig; | ||
| 323 | |||
| 304 | if (cs->disable) | 324 | if (cs->disable) |
| 305 | cs->disable(cs); | 325 | cs->disable(cs); |
| 306 | } | 326 | } |
