aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/kernel/time.c')
-rw-r--r--arch/sh/kernel/time.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 57e708d7b52d..c55d6f217a46 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -50,15 +50,20 @@ unsigned long long __attribute__ ((weak)) sched_clock(void)
50#ifndef CONFIG_GENERIC_TIME 50#ifndef CONFIG_GENERIC_TIME
51void do_gettimeofday(struct timeval *tv) 51void do_gettimeofday(struct timeval *tv)
52{ 52{
53 unsigned long flags;
53 unsigned long seq; 54 unsigned long seq;
54 unsigned long usec, sec; 55 unsigned long usec, sec;
55 56
56 do { 57 do {
57 seq = read_seqbegin(&xtime_lock); 58 /*
59 * Turn off IRQs when grabbing xtime_lock, so that
60 * the sys_timer get_offset code doesn't have to handle it.
61 */
62 seq = read_seqbegin_irqsave(&xtime_lock, flags);
58 usec = get_timer_offset(); 63 usec = get_timer_offset();
59 sec = xtime.tv_sec; 64 sec = xtime.tv_sec;
60 usec += xtime.tv_nsec / 1000; 65 usec += xtime.tv_nsec / NSEC_PER_USEC;
61 } while (read_seqretry(&xtime_lock, seq)); 66 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
62 67
63 while (usec >= 1000000) { 68 while (usec >= 1000000) {
64 usec -= 1000000; 69 usec -= 1000000;
@@ -85,7 +90,7 @@ int do_settimeofday(struct timespec *tv)
85 * wall time. Discover what correction gettimeofday() would have 90 * wall time. Discover what correction gettimeofday() would have
86 * made, and then undo it! 91 * made, and then undo it!
87 */ 92 */
88 nsec -= 1000 * get_timer_offset(); 93 nsec -= get_timer_offset() * NSEC_PER_USEC;
89 94
90 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); 95 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
91 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); 96 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);