aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXunlei Pang <pang.xunlei@linaro.org>2015-04-01 23:34:25 -0400
committerIngo Molnar <mingo@kernel.org>2015-04-03 02:18:22 -0400
commita0c2998f918e7e597d3c686c5f3d5a30d0382dd6 (patch)
tree3463441c1ca89e84d63ccf89caad4156a05cce1a
parenta451570c008b9e19592e29f15cfd295bdf818c7a (diff)
clocksource/drivers/tegra: Provide y2038-safe tegra_read_persistent_clock() replacement
As part of addressing "y2038 problem" for in-kernel uses, this patch adds the y2038-safe tegra_read_persistent_clock64() using timespec64. Because we rely on some subsequent changes to convert arm multiarch support, tegra_read_persistent_clock() will be removed then. Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org> Signed-off-by: John Stultz <john.stultz@linaro.org> Acked-by: Thierry Reding <treding@nvidia.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1427945681-29972-6-git-send-email-john.stultz@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--drivers/clocksource/tegra20_timer.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/clocksource/tegra20_timer.c b/drivers/clocksource/tegra20_timer.c
index d8a3a4eb9f97..4a0a603edecc 100644
--- a/drivers/clocksource/tegra20_timer.c
+++ b/drivers/clocksource/tegra20_timer.c
@@ -51,7 +51,7 @@
51static void __iomem *timer_reg_base; 51static void __iomem *timer_reg_base;
52static void __iomem *rtc_base; 52static void __iomem *rtc_base;
53 53
54static struct timespec persistent_ts; 54static struct timespec64 persistent_ts;
55static u64 persistent_ms, last_persistent_ms; 55static u64 persistent_ms, last_persistent_ms;
56 56
57static struct delay_timer tegra_delay_timer; 57static struct delay_timer tegra_delay_timer;
@@ -120,26 +120,33 @@ static u64 tegra_rtc_read_ms(void)
120} 120}
121 121
122/* 122/*
123 * tegra_read_persistent_clock - Return time from a persistent clock. 123 * tegra_read_persistent_clock64 - Return time from a persistent clock.
124 * 124 *
125 * Reads the time from a source which isn't disabled during PM, the 125 * Reads the time from a source which isn't disabled during PM, the
126 * 32k sync timer. Convert the cycles elapsed since last read into 126 * 32k sync timer. Convert the cycles elapsed since last read into
127 * nsecs and adds to a monotonically increasing timespec. 127 * nsecs and adds to a monotonically increasing timespec64.
128 * Care must be taken that this funciton is not called while the 128 * Care must be taken that this funciton is not called while the
129 * tegra_rtc driver could be executing to avoid race conditions 129 * tegra_rtc driver could be executing to avoid race conditions
130 * on the RTC shadow register 130 * on the RTC shadow register
131 */ 131 */
132static void tegra_read_persistent_clock(struct timespec *ts) 132static void tegra_read_persistent_clock64(struct timespec64 *ts)
133{ 133{
134 u64 delta; 134 u64 delta;
135 struct timespec *tsp = &persistent_ts;
136 135
137 last_persistent_ms = persistent_ms; 136 last_persistent_ms = persistent_ms;
138 persistent_ms = tegra_rtc_read_ms(); 137 persistent_ms = tegra_rtc_read_ms();
139 delta = persistent_ms - last_persistent_ms; 138 delta = persistent_ms - last_persistent_ms;
140 139
141 timespec_add_ns(tsp, delta * NSEC_PER_MSEC); 140 timespec64_add_ns(&persistent_ts, delta * NSEC_PER_MSEC);
142 *ts = *tsp; 141 *ts = persistent_ts;
142}
143
144static void tegra_read_persistent_clock(struct timespec *ts)
145{
146 struct timespec ts64;
147
148 tegra_read_persistent_clock64(&ts64);
149 *ts = timespec64_to_timespec(ts64);
143} 150}
144 151
145static unsigned long tegra_delay_timer_read_counter_long(void) 152static unsigned long tegra_delay_timer_read_counter_long(void)