diff options
author | Magnus Damm <damm@opensource.se> | 2010-02-02 17:41:41 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-02-05 08:54:10 -0500 |
commit | c54a42b19fbaae4e9f212322ecca25a6bc95c1ba (patch) | |
tree | 2c929d3cde3b4ae864d5f5a50bdda688fd5293eb | |
parent | 17622339af2536b32cf29699ddd4ba0fe79a61d5 (diff) |
clocksource: add suspend callback
Add a clocksource suspend callback. This callback can be used by the
clocksource driver to shutdown and perform any kind of late suspend
activities even though the clocksource driver itself is a non-sysdev
driver.
One example where this is useful is to fix the sh_cmt.c platform driver
that today suspends using the platform bus and shuts down the clocksource
too early.
With this callback in place the sh_cmt driver will suspend using the
clocksource and clockevent hooks and leave the platform device pm
callbacks unused.
Signed-off-by: Magnus Damm <damm@opensource.se>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: john stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/clocksource.h | 3 | ||||
-rw-r--r-- | kernel/time/clocksource.c | 12 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 0de7e72c3995..4bca8b60cdf7 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -154,6 +154,7 @@ extern u64 timecounter_cyc2time(struct timecounter *tc, | |||
154 | * @max_idle_ns: max idle time permitted by the clocksource (nsecs) | 154 | * @max_idle_ns: max idle time permitted by the clocksource (nsecs) |
155 | * @flags: flags describing special properties | 155 | * @flags: flags describing special properties |
156 | * @vread: vsyscall based read | 156 | * @vread: vsyscall based read |
157 | * @suspend: suspend function for the clocksource, if necessary | ||
157 | * @resume: resume function for the clocksource, if necessary | 158 | * @resume: resume function for the clocksource, if necessary |
158 | */ | 159 | */ |
159 | struct clocksource { | 160 | struct clocksource { |
@@ -172,6 +173,7 @@ struct clocksource { | |||
172 | u64 max_idle_ns; | 173 | u64 max_idle_ns; |
173 | unsigned long flags; | 174 | unsigned long flags; |
174 | cycle_t (*vread)(void); | 175 | cycle_t (*vread)(void); |
176 | void (*suspend)(struct clocksource *cs); | ||
175 | void (*resume)(struct clocksource *cs); | 177 | void (*resume)(struct clocksource *cs); |
176 | #ifdef CONFIG_IA64 | 178 | #ifdef CONFIG_IA64 |
177 | void *fsys_mmio; /* used by fsyscall asm code */ | 179 | void *fsys_mmio; /* used by fsyscall asm code */ |
@@ -277,6 +279,7 @@ extern void clocksource_unregister(struct clocksource*); | |||
277 | extern void clocksource_touch_watchdog(void); | 279 | extern void clocksource_touch_watchdog(void); |
278 | extern struct clocksource* clocksource_get_next(void); | 280 | extern struct clocksource* clocksource_get_next(void); |
279 | extern void clocksource_change_rating(struct clocksource *cs, int rating); | 281 | extern void clocksource_change_rating(struct clocksource *cs, int rating); |
282 | extern void clocksource_suspend(void); | ||
280 | extern void clocksource_resume(void); | 283 | extern void clocksource_resume(void); |
281 | extern struct clocksource * __init __weak clocksource_default_clock(void); | 284 | extern struct clocksource * __init __weak clocksource_default_clock(void); |
282 | extern void clocksource_mark_unstable(struct clocksource *cs); | 285 | extern void clocksource_mark_unstable(struct clocksource *cs); |
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 08adacb2a1ed..bd246660902c 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c | |||
@@ -441,6 +441,18 @@ static inline int clocksource_watchdog_kthread(void *data) { return 0; } | |||
441 | #endif /* CONFIG_CLOCKSOURCE_WATCHDOG */ | 441 | #endif /* CONFIG_CLOCKSOURCE_WATCHDOG */ |
442 | 442 | ||
443 | /** | 443 | /** |
444 | * clocksource_suspend - suspend the clocksource(s) | ||
445 | */ | ||
446 | void clocksource_suspend(void) | ||
447 | { | ||
448 | struct clocksource *cs; | ||
449 | |||
450 | list_for_each_entry_reverse(cs, &clocksource_list, list) | ||
451 | if (cs->suspend) | ||
452 | cs->suspend(cs); | ||
453 | } | ||
454 | |||
455 | /** | ||
444 | * clocksource_resume - resume the clocksource(s) | 456 | * clocksource_resume - resume the clocksource(s) |
445 | */ | 457 | */ |
446 | void clocksource_resume(void) | 458 | void clocksource_resume(void) |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 7faaa32fbf4f..843d8a711b16 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -622,6 +622,7 @@ static int timekeeping_suspend(struct sys_device *dev, pm_message_t state) | |||
622 | write_sequnlock_irqrestore(&xtime_lock, flags); | 622 | write_sequnlock_irqrestore(&xtime_lock, flags); |
623 | 623 | ||
624 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); | 624 | clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); |
625 | clocksource_suspend(); | ||
625 | 626 | ||
626 | return 0; | 627 | return 0; |
627 | } | 628 | } |