Skip to content

Commit

Permalink
clocksource: add suspend callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Magnus Damm authored and Thomas Gleixner committed Feb 5, 2010
1 parent 1762233 commit c54a42b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/linux/clocksource.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extern u64 timecounter_cyc2time(struct timecounter *tc,
* @max_idle_ns: max idle time permitted by the clocksource (nsecs)
* @flags: flags describing special properties
* @vread: vsyscall based read
* @suspend: suspend function for the clocksource, if necessary
* @resume: resume function for the clocksource, if necessary
*/
struct clocksource {
Expand All @@ -172,6 +173,7 @@ struct clocksource {
u64 max_idle_ns;
unsigned long flags;
cycle_t (*vread)(void);
void (*suspend)(struct clocksource *cs);
void (*resume)(struct clocksource *cs);
#ifdef CONFIG_IA64
void *fsys_mmio; /* used by fsyscall asm code */
Expand Down Expand Up @@ -277,6 +279,7 @@ extern void clocksource_unregister(struct clocksource*);
extern void clocksource_touch_watchdog(void);
extern struct clocksource* clocksource_get_next(void);
extern void clocksource_change_rating(struct clocksource *cs, int rating);
extern void clocksource_suspend(void);
extern void clocksource_resume(void);
extern struct clocksource * __init __weak clocksource_default_clock(void);
extern void clocksource_mark_unstable(struct clocksource *cs);
Expand Down
12 changes: 12 additions & 0 deletions kernel/time/clocksource.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,18 @@ static inline int clocksource_watchdog_kthread(void *data) { return 0; }

#endif /* CONFIG_CLOCKSOURCE_WATCHDOG */

/**
* clocksource_suspend - suspend the clocksource(s)
*/
void clocksource_suspend(void)
{
struct clocksource *cs;

list_for_each_entry_reverse(cs, &clocksource_list, list)
if (cs->suspend)
cs->suspend(cs);
}

/**
* clocksource_resume - resume the clocksource(s)
*/
Expand Down
1 change: 1 addition & 0 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ static int timekeeping_suspend(struct sys_device *dev, pm_message_t state)
write_sequnlock_irqrestore(&xtime_lock, flags);

clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
clocksource_suspend();

return 0;
}
Expand Down

0 comments on commit c54a42b

Please sign in to comment.