aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorjohn stultz <johnstul@us.ibm.com>2009-09-21 20:04:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:43 -0400
commit4ad4c76b7afb71774b846b322ad2ae42f814331a (patch)
treeeae834caeb70f70c1112113628cf6f94a0bdfd14 /arch/m68k
parentef187fd799c50e15dbb56a0286c81bf467bd0201 (diff)
m68k: convert to use arch_gettimeoffset()
Convert m68k to use GENERIC_TIME via the arch_getoffset() infrastructure, reducing the amount of arch specific code we need to maintain. I've taken my best swing at converting this, but I'm not 100% confident I got it right. My cross-compiler is now out of date (gcc4.2) so I wasn't able to check if it compiled. Any assistance from arch maintainers or testers to get this merged would be great. Signed-off-by: John Stultz <johnstul@us.ibm.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/Kconfig6
-rw-r--r--arch/m68k/kernel/time.c70
2 files changed, 8 insertions, 68 deletions
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index fb87c08c6b5..29dd8489ffe 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -58,6 +58,12 @@ config HZ
58 int 58 int
59 default 100 59 default 100
60 60
61config GENERIC_TIME
62 def_bool y
63
64config ARCH_USES_GETTIMEOFFSET
65 def_bool y
66
61mainmenu "Linux/68k Kernel Configuration" 67mainmenu "Linux/68k Kernel Configuration"
62 68
63source "init/Kconfig" 69source "init/Kconfig"
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 54d980795fc..17dc2a31a7c 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -91,77 +91,11 @@ void __init time_init(void)
91 mach_sched_init(timer_interrupt); 91 mach_sched_init(timer_interrupt);
92} 92}
93 93
94/* 94u32 arch_gettimeoffset(void)
95 * This version of gettimeofday has near microsecond resolution.
96 */
97void do_gettimeofday(struct timeval *tv)
98{ 95{
99 unsigned long flags; 96 return mach_gettimeoffset() * 1000;
100 unsigned long seq;
101 unsigned long usec, sec;
102 unsigned long max_ntp_tick = tick_usec - tickadj;
103
104 do {
105 seq = read_seqbegin_irqsave(&xtime_lock, flags);
106
107 usec = mach_gettimeoffset();
108
109 /*
110 * If time_adjust is negative then NTP is slowing the clock
111 * so make sure not to go into next possible interval.
112 * Better to lose some accuracy than have time go backwards..
113 */
114 if (unlikely(time_adjust < 0))
115 usec = min(usec, max_ntp_tick);
116
117 sec = xtime.tv_sec;
118 usec += xtime.tv_nsec/1000;
119 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
120
121
122 while (usec >= 1000000) {
123 usec -= 1000000;
124 sec++;
125 }
126
127 tv->tv_sec = sec;
128 tv->tv_usec = usec;
129}
130
131EXPORT_SYMBOL(do_gettimeofday);
132
133int do_settimeofday(struct timespec *tv)
134{
135 time_t wtm_sec, sec = tv->tv_sec;
136 long wtm_nsec, nsec = tv->tv_nsec;
137
138 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
139 return -EINVAL;
140
141 write_seqlock_irq(&xtime_lock);
142 /* This is revolting. We need to set the xtime.tv_nsec
143 * correctly. However, the value in this location is
144 * is value at the last tick.
145 * Discover what correction gettimeofday
146 * would have done, and then undo it!
147 */
148 nsec -= 1000 * mach_gettimeoffset();
149
150 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
151 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
152
153 set_normalized_timespec(&xtime, sec, nsec);
154 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
155
156 ntp_clear();
157 write_sequnlock_irq(&xtime_lock);
158 clock_was_set();
159 return 0;
160} 97}
161 98
162EXPORT_SYMBOL(do_settimeofday);
163
164
165static int __init rtc_init(void) 99static int __init rtc_init(void)
166{ 100{
167 struct platform_device *pdev; 101 struct platform_device *pdev;