aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2012-07-13 01:21:55 -0400
committerThomas Gleixner <tglx@linutronix.de>2012-07-15 04:39:06 -0400
commitf2a5a0854efc62abe7f69e9947842cb135837f9a (patch)
tree02db590982e92fb514f2d8b1791a49ec5b02d484 /kernel
parent1f4f948706bcec1b51bf6492bf04057d2e21e273 (diff)
time: Move arch_gettimeoffset() usage into timekeeping_get_ns()
Since we call arch_gettimeoffset() in all the accessor functions, move arch_gettimeoffset() calls into timekeeping_get_ns() and timekeeping_get_ns_raw() to simplify the code. This also makes the code easier to maintain as we don't have to worry about forgetting the arch_gettimeoffset() as has happened in the past. Signed-off-by: John Stultz <johnstul@us.ibm.com> Reviewed-by: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Link: http://lkml.kernel.org/r/1342156917-25092-7-git-send-email-john.stultz@linaro.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/time/timekeeping.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index cb4a433bab97..e43289df28c2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -191,13 +191,17 @@ static inline s64 timekeeping_get_ns(void)
191 cycle_delta = (cycle_now - clock->cycle_last) & clock->mask; 191 cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
192 192
193 nsec = cycle_delta * timekeeper.mult + timekeeper.xtime_nsec; 193 nsec = cycle_delta * timekeeper.mult + timekeeper.xtime_nsec;
194 return nsec >> timekeeper.shift; 194 nsec >>= timekeeper.shift;
195
196 /* If arch requires, add in gettimeoffset() */
197 return nsec + arch_gettimeoffset();
195} 198}
196 199
197static inline s64 timekeeping_get_ns_raw(void) 200static inline s64 timekeeping_get_ns_raw(void)
198{ 201{
199 cycle_t cycle_now, cycle_delta; 202 cycle_t cycle_now, cycle_delta;
200 struct clocksource *clock; 203 struct clocksource *clock;
204 s64 nsec;
201 205
202 /* read clocksource: */ 206 /* read clocksource: */
203 clock = timekeeper.clock; 207 clock = timekeeper.clock;
@@ -206,8 +210,11 @@ static inline s64 timekeeping_get_ns_raw(void)
206 /* calculate the delta since the last update_wall_time: */ 210 /* calculate the delta since the last update_wall_time: */
207 cycle_delta = (cycle_now - clock->cycle_last) & clock->mask; 211 cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
208 212
209 /* return delta convert to nanoseconds. */ 213 /* convert delta to nanoseconds. */
210 return clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift); 214 nsec = clocksource_cyc2ns(cycle_delta, clock->mult, clock->shift);
215
216 /* If arch requires, add in gettimeoffset() */
217 return nsec + arch_gettimeoffset();
211} 218}
212 219
213static void update_rt_offset(void) 220static void update_rt_offset(void)
@@ -282,9 +289,6 @@ void getnstimeofday(struct timespec *ts)
282 ts->tv_sec = timekeeper.xtime_sec; 289 ts->tv_sec = timekeeper.xtime_sec;
283 ts->tv_nsec = timekeeping_get_ns(); 290 ts->tv_nsec = timekeeping_get_ns();
284 291
285 /* If arch requires, add in gettimeoffset() */
286 nsecs += arch_gettimeoffset();
287
288 } while (read_seqretry(&timekeeper.lock, seq)); 292 } while (read_seqretry(&timekeeper.lock, seq));
289 293
290 timespec_add_ns(ts, nsecs); 294 timespec_add_ns(ts, nsecs);
@@ -304,8 +308,6 @@ ktime_t ktime_get(void)
304 timekeeper.wall_to_monotonic.tv_sec; 308 timekeeper.wall_to_monotonic.tv_sec;
305 nsecs = timekeeping_get_ns() + 309 nsecs = timekeeping_get_ns() +
306 timekeeper.wall_to_monotonic.tv_nsec; 310 timekeeper.wall_to_monotonic.tv_nsec;
307 /* If arch requires, add in gettimeoffset() */
308 nsecs += arch_gettimeoffset();
309 311
310 } while (read_seqretry(&timekeeper.lock, seq)); 312 } while (read_seqretry(&timekeeper.lock, seq));
311 /* 313 /*
@@ -336,8 +338,6 @@ void ktime_get_ts(struct timespec *ts)
336 ts->tv_sec = timekeeper.xtime_sec; 338 ts->tv_sec = timekeeper.xtime_sec;
337 ts->tv_nsec = timekeeping_get_ns(); 339 ts->tv_nsec = timekeeping_get_ns();
338 tomono = timekeeper.wall_to_monotonic; 340 tomono = timekeeper.wall_to_monotonic;
339 /* If arch requires, add in gettimeoffset() */
340 ts->tv_nsec += arch_gettimeoffset();
341 341
342 } while (read_seqretry(&timekeeper.lock, seq)); 342 } while (read_seqretry(&timekeeper.lock, seq));
343 343
@@ -365,8 +365,6 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
365 WARN_ON_ONCE(timekeeping_suspended); 365 WARN_ON_ONCE(timekeeping_suspended);
366 366
367 do { 367 do {
368 u32 arch_offset;
369
370 seq = read_seqbegin(&timekeeper.lock); 368 seq = read_seqbegin(&timekeeper.lock);
371 369
372 *ts_raw = timekeeper.raw_time; 370 *ts_raw = timekeeper.raw_time;
@@ -376,11 +374,6 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
376 nsecs_raw = timekeeping_get_ns_raw(); 374 nsecs_raw = timekeeping_get_ns_raw();
377 nsecs_real = timekeeping_get_ns(); 375 nsecs_real = timekeeping_get_ns();
378 376
379 /* If arch requires, add in gettimeoffset() */
380 arch_offset = arch_gettimeoffset();
381 nsecs_raw += arch_offset;
382 nsecs_real += arch_offset;
383
384 } while (read_seqretry(&timekeeper.lock, seq)); 377 } while (read_seqretry(&timekeeper.lock, seq));
385 378
386 timespec_add_ns(ts_raw, nsecs_raw); 379 timespec_add_ns(ts_raw, nsecs_raw);
@@ -1338,8 +1331,6 @@ ktime_t ktime_get_update_offsets(ktime_t *offs_real, ktime_t *offs_boot)
1338 1331
1339 secs = timekeeper.xtime_sec; 1332 secs = timekeeper.xtime_sec;
1340 nsecs = timekeeping_get_ns(); 1333 nsecs = timekeeping_get_ns();
1341 /* If arch requires, add in gettimeoffset() */
1342 nsecs += arch_gettimeoffset();
1343 1334
1344 *offs_real = timekeeper.offs_real; 1335 *offs_real = timekeeper.offs_real;
1345 *offs_boot = timekeeper.offs_boot; 1336 *offs_boot = timekeeper.offs_boot;