diff options
author | john stultz <johnstul@us.ibm.com> | 2009-05-01 16:10:28 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-05-03 04:32:55 -0400 |
commit | 7563431107f6debf57c1dbecfb9498cf31a1c036 (patch) | |
tree | 50e473f8eb90069b6e64675ee582dd3be76fbaef | |
parent | d80498398276ca8eee7ebdbe0d47e06d01317439 (diff) |
time: sh: convert to use arch_getoffset() infrastructure
Convert sh to use GENERIC_TIME via the arch_getoffset() infrastructure.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | arch/sh/Kconfig | 2 | ||||
-rw-r--r-- | arch/sh/include/asm/timer.h | 4 | ||||
-rw-r--r-- | arch/sh/kernel/time_32.c | 63 | ||||
-rw-r--r-- | arch/sh/kernel/time_64.c | 53 | ||||
-rw-r--r-- | arch/sh/kernel/timers/timer-mtu2.c | 2 |
5 files changed, 11 insertions, 113 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 7e96adea9602..6f91478826d5 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig | |||
@@ -75,7 +75,7 @@ config GENERIC_IOMAP | |||
75 | bool | 75 | bool |
76 | 76 | ||
77 | config GENERIC_TIME | 77 | config GENERIC_TIME |
78 | def_bool n | 78 | def_bool y |
79 | 79 | ||
80 | config GENERIC_CLOCKEVENTS | 80 | config GENERIC_CLOCKEVENTS |
81 | def_bool n | 81 | def_bool n |
diff --git a/arch/sh/include/asm/timer.h b/arch/sh/include/asm/timer.h index 8f80a55c04ae..9c968d19cb9b 100644 --- a/arch/sh/include/asm/timer.h +++ b/arch/sh/include/asm/timer.h | |||
@@ -9,7 +9,7 @@ struct sys_timer_ops { | |||
9 | int (*init)(void); | 9 | int (*init)(void); |
10 | int (*start)(void); | 10 | int (*start)(void); |
11 | int (*stop)(void); | 11 | int (*stop)(void); |
12 | #ifndef CONFIG_GENERIC_TIME | 12 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
13 | unsigned long (*get_offset)(void); | 13 | unsigned long (*get_offset)(void); |
14 | #endif | 14 | #endif |
15 | }; | 15 | }; |
@@ -26,7 +26,7 @@ struct sys_timer { | |||
26 | extern struct sys_timer tmu_timer, mtu2_timer; | 26 | extern struct sys_timer tmu_timer, mtu2_timer; |
27 | extern struct sys_timer *sys_timer; | 27 | extern struct sys_timer *sys_timer; |
28 | 28 | ||
29 | #ifndef CONFIG_GENERIC_TIME | 29 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
30 | static inline unsigned long get_timer_offset(void) | 30 | static inline unsigned long get_timer_offset(void) |
31 | { | 31 | { |
32 | return sys_timer->ops->get_offset(); | 32 | return sys_timer->ops->get_offset(); |
diff --git a/arch/sh/kernel/time_32.c b/arch/sh/kernel/time_32.c index 457332116e17..9d34dff14994 100644 --- a/arch/sh/kernel/time_32.c +++ b/arch/sh/kernel/time_32.c | |||
@@ -83,65 +83,12 @@ static int __init rtc_generic_init(void) | |||
83 | } | 83 | } |
84 | module_init(rtc_generic_init); | 84 | module_init(rtc_generic_init); |
85 | 85 | ||
86 | #ifndef CONFIG_GENERIC_TIME | 86 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
87 | void do_gettimeofday(struct timeval *tv) | 87 | u32 arch_gettimeoffset(void) |
88 | { | 88 | { |
89 | unsigned long flags; | 89 | return get_timer_offset() * 1000; |
90 | unsigned long seq; | ||
91 | unsigned long usec, sec; | ||
92 | |||
93 | do { | ||
94 | /* | ||
95 | * Turn off IRQs when grabbing xtime_lock, so that | ||
96 | * the sys_timer get_offset code doesn't have to handle it. | ||
97 | */ | ||
98 | seq = read_seqbegin_irqsave(&xtime_lock, flags); | ||
99 | usec = get_timer_offset(); | ||
100 | sec = xtime.tv_sec; | ||
101 | usec += xtime.tv_nsec / NSEC_PER_USEC; | ||
102 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | ||
103 | |||
104 | while (usec >= 1000000) { | ||
105 | usec -= 1000000; | ||
106 | sec++; | ||
107 | } | ||
108 | |||
109 | tv->tv_sec = sec; | ||
110 | tv->tv_usec = usec; | ||
111 | } | ||
112 | EXPORT_SYMBOL(do_gettimeofday); | ||
113 | |||
114 | int do_settimeofday(struct timespec *tv) | ||
115 | { | ||
116 | time_t wtm_sec, sec = tv->tv_sec; | ||
117 | long wtm_nsec, nsec = tv->tv_nsec; | ||
118 | |||
119 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) | ||
120 | return -EINVAL; | ||
121 | |||
122 | write_seqlock_irq(&xtime_lock); | ||
123 | /* | ||
124 | * This is revolting. We need to set "xtime" correctly. However, the | ||
125 | * value in this location is the value at the most recent update of | ||
126 | * wall time. Discover what correction gettimeofday() would have | ||
127 | * made, and then undo it! | ||
128 | */ | ||
129 | nsec -= get_timer_offset() * NSEC_PER_USEC; | ||
130 | |||
131 | wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); | ||
132 | wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); | ||
133 | |||
134 | set_normalized_timespec(&xtime, sec, nsec); | ||
135 | set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); | ||
136 | |||
137 | ntp_clear(); | ||
138 | write_sequnlock_irq(&xtime_lock); | ||
139 | clock_was_set(); | ||
140 | |||
141 | return 0; | ||
142 | } | 90 | } |
143 | EXPORT_SYMBOL(do_settimeofday); | 91 | #endif /* CONFIG_ARCH_USES_GETTIMEOFFSET */ |
144 | #endif /* !CONFIG_GENERIC_TIME */ | ||
145 | 92 | ||
146 | /* last time the RTC clock got updated */ | 93 | /* last time the RTC clock got updated */ |
147 | static long last_rtc_update; | 94 | static long last_rtc_update; |
@@ -238,7 +185,7 @@ struct clocksource clocksource_sh = { | |||
238 | .name = "SuperH", | 185 | .name = "SuperH", |
239 | }; | 186 | }; |
240 | 187 | ||
241 | #ifdef CONFIG_GENERIC_TIME | 188 | #ifndef CONFIG_ARCH_USES_GETTIMEOFFSET |
242 | unsigned long long sched_clock(void) | 189 | unsigned long long sched_clock(void) |
243 | { | 190 | { |
244 | unsigned long long cycles; | 191 | unsigned long long cycles; |
diff --git a/arch/sh/kernel/time_64.c b/arch/sh/kernel/time_64.c index 988c77c37231..f4f5e8ad5bec 100644 --- a/arch/sh/kernel/time_64.c +++ b/arch/sh/kernel/time_64.c | |||
@@ -144,59 +144,10 @@ static unsigned long usecs_since_tick(void) | |||
144 | return result; | 144 | return result; |
145 | } | 145 | } |
146 | 146 | ||
147 | void do_gettimeofday(struct timeval *tv) | 147 | u32 arch_gettimeoffset(void) |
148 | { | 148 | { |
149 | unsigned long flags; | 149 | return usecs_since_tick() * 1000; |
150 | unsigned long seq; | ||
151 | unsigned long usec, sec; | ||
152 | |||
153 | do { | ||
154 | seq = read_seqbegin_irqsave(&xtime_lock, flags); | ||
155 | usec = usecs_since_tick(); | ||
156 | sec = xtime.tv_sec; | ||
157 | usec += xtime.tv_nsec / 1000; | ||
158 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | ||
159 | |||
160 | while (usec >= 1000000) { | ||
161 | usec -= 1000000; | ||
162 | sec++; | ||
163 | } | ||
164 | |||
165 | tv->tv_sec = sec; | ||
166 | tv->tv_usec = usec; | ||
167 | } | ||
168 | EXPORT_SYMBOL(do_gettimeofday); | ||
169 | |||
170 | int do_settimeofday(struct timespec *tv) | ||
171 | { | ||
172 | time_t wtm_sec, sec = tv->tv_sec; | ||
173 | long wtm_nsec, nsec = tv->tv_nsec; | ||
174 | |||
175 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) | ||
176 | return -EINVAL; | ||
177 | |||
178 | write_seqlock_irq(&xtime_lock); | ||
179 | /* | ||
180 | * This is revolting. We need to set "xtime" correctly. However, the | ||
181 | * value in this location is the value at the most recent update of | ||
182 | * wall time. Discover what correction gettimeofday() would have | ||
183 | * made, and then undo it! | ||
184 | */ | ||
185 | nsec -= 1000 * usecs_since_tick(); | ||
186 | |||
187 | wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); | ||
188 | wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); | ||
189 | |||
190 | set_normalized_timespec(&xtime, sec, nsec); | ||
191 | set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); | ||
192 | |||
193 | ntp_clear(); | ||
194 | write_sequnlock_irq(&xtime_lock); | ||
195 | clock_was_set(); | ||
196 | |||
197 | return 0; | ||
198 | } | 150 | } |
199 | EXPORT_SYMBOL(do_settimeofday); | ||
200 | 151 | ||
201 | /* Dummy RTC ops */ | 152 | /* Dummy RTC ops */ |
202 | static void null_rtc_get_time(struct timespec *tv) | 153 | static void null_rtc_get_time(struct timespec *tv) |
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c index 9b0ef0126479..8a1dcc2c3723 100644 --- a/arch/sh/kernel/timers/timer-mtu2.c +++ b/arch/sh/kernel/timers/timer-mtu2.c | |||
@@ -191,7 +191,7 @@ struct sys_timer_ops mtu2_timer_ops = { | |||
191 | .init = mtu2_timer_init, | 191 | .init = mtu2_timer_init, |
192 | .start = mtu2_timer_start, | 192 | .start = mtu2_timer_start, |
193 | .stop = mtu2_timer_stop, | 193 | .stop = mtu2_timer_stop, |
194 | #ifndef CONFIG_GENERIC_TIME | 194 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET |
195 | .get_offset = mtu2_timer_get_offset, | 195 | .get_offset = mtu2_timer_get_offset, |
196 | #endif | 196 | #endif |
197 | }; | 197 | }; |