aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorXunlei Pang <pang.xunlei@linaro.org>2015-04-01 23:34:24 -0400
committerIngo Molnar <mingo@kernel.org>2015-04-03 02:18:21 -0400
commita451570c008b9e19592e29f15cfd295bdf818c7a (patch)
tree86e5932d0b6c97641b4793d0211a71edb4ddc4b6 /arch/arm/plat-omap
parent3c00a1fe8496ff29ab62764bb3f4ce4b48089004 (diff)
ARM: OMAP: 32k counter: Provide y2038-safe omap_read_persistent_clock() replacement
As part of addressing "y2038 problem" for in-kernel uses, this patch adds the y2038-safe omap_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, omap_read_persistent_clock() will be removed then. Also remove the needless spinlock, because read_persistent_clock() doesn't run simultaneously. Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Acked-by: Tony Lindgren <tony@atomide.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1427945681-29972-5-git-send-email-john.stultz@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/counter_32k.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 43cf74561cfd..b7b7b0793228 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -44,24 +44,20 @@ static u64 notrace omap_32k_read_sched_clock(void)
44} 44}
45 45
46/** 46/**
47 * omap_read_persistent_clock - Return time from a persistent clock. 47 * omap_read_persistent_clock64 - Return time from a persistent clock.
48 * 48 *
49 * Reads the time from a source which isn't disabled during PM, the 49 * Reads the time from a source which isn't disabled during PM, the
50 * 32k sync timer. Convert the cycles elapsed since last read into 50 * 32k sync timer. Convert the cycles elapsed since last read into
51 * nsecs and adds to a monotonically increasing timespec. 51 * nsecs and adds to a monotonically increasing timespec64.
52 */ 52 */
53static struct timespec persistent_ts; 53static struct timespec64 persistent_ts;
54static cycles_t cycles; 54static cycles_t cycles;
55static unsigned int persistent_mult, persistent_shift; 55static unsigned int persistent_mult, persistent_shift;
56static DEFINE_SPINLOCK(read_persistent_clock_lock);
57 56
58static void omap_read_persistent_clock(struct timespec *ts) 57static void omap_read_persistent_clock64(struct timespec64 *ts)
59{ 58{
60 unsigned long long nsecs; 59 unsigned long long nsecs;
61 cycles_t last_cycles; 60 cycles_t last_cycles;
62 unsigned long flags;
63
64 spin_lock_irqsave(&read_persistent_clock_lock, flags);
65 61
66 last_cycles = cycles; 62 last_cycles = cycles;
67 cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0; 63 cycles = sync32k_cnt_reg ? readl_relaxed(sync32k_cnt_reg) : 0;
@@ -69,11 +65,17 @@ static void omap_read_persistent_clock(struct timespec *ts)
69 nsecs = clocksource_cyc2ns(cycles - last_cycles, 65 nsecs = clocksource_cyc2ns(cycles - last_cycles,
70 persistent_mult, persistent_shift); 66 persistent_mult, persistent_shift);
71 67
72 timespec_add_ns(&persistent_ts, nsecs); 68 timespec64_add_ns(&persistent_ts, nsecs);
73 69
74 *ts = persistent_ts; 70 *ts = persistent_ts;
71}
72
73static void omap_read_persistent_clock(struct timespec *ts)
74{
75 struct timespec64 ts64;
75 76
76 spin_unlock_irqrestore(&read_persistent_clock_lock, flags); 77 omap_read_persistent_clock64(&ts64);
78 *ts = timespec64_to_timespec(ts64);
77} 79}
78 80
79/** 81/**