summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/i8253.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/i8253.c')
-rw-r--r--arch/x86/kernel/i8253.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/arch/x86/kernel/i8253.c b/arch/x86/kernel/i8253.c
index 5cf36c053ac4..da890f03d078 100644
--- a/arch/x86/kernel/i8253.c
+++ b/arch/x86/kernel/i8253.c
@@ -21,8 +21,10 @@ EXPORT_SYMBOL(i8253_lock);
#ifdef CONFIG_X86_32
static void pit_disable_clocksource(void);
+static void pit_enable_clocksource(void);
#else
static inline void pit_disable_clocksource(void) { }
+static inline void pit_enable_clocksource(void) { }
#endif
/*
@@ -67,7 +69,7 @@ static void init_pit_timer(enum clock_event_mode mode,
break;
case CLOCK_EVT_MODE_RESUME:
- /* Nothing to do here */
+ pit_enable_clocksource();
break;
}
spin_unlock(&i8253_lock);
@@ -200,19 +202,27 @@ static struct clocksource pit_cs = {
.shift = 20,
};
+int pit_cs_registered;
static void pit_disable_clocksource(void)
{
- /*
- * Use mult to check whether it is registered or not
- */
- if (pit_cs.mult) {
+ if (pit_cs_registered) {
clocksource_unregister(&pit_cs);
- pit_cs.mult = 0;
+ pit_cs_registered = 0;
+ }
+}
+
+static void pit_enable_clocksource(void)
+{
+ if (!pit_cs_registered && !clocksource_register(&pit_cs)) {
+ pit_cs_registered = 1;
}
}
+
+
static int __init init_pit_clocksource(void)
{
+ int ret;
/*
* Several reasons not to register PIT as a clocksource:
*
@@ -226,7 +236,10 @@ static int __init init_pit_clocksource(void)
pit_cs.mult = clocksource_hz2mult(CLOCK_TICK_RATE, pit_cs.shift);
- return clocksource_register(&pit_cs);
+ ret = clocksource_register(&pit_cs);
+ if (!ret)
+ pit_cs_registered = 1;
+ return ret;
}
arch_initcall(init_pit_clocksource);