Skip to content

Commit 4ad4c76

Browse files
john stultztorvalds
authored andcommitted
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>
1 parent ef187fd commit 4ad4c76

File tree

2 files changed

+8
-68
lines changed

2 files changed

+8
-68
lines changed

arch/m68k/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ config HZ
5858
int
5959
default 100
6060

61+
config GENERIC_TIME
62+
def_bool y
63+
64+
config ARCH_USES_GETTIMEOFFSET
65+
def_bool y
66+
6167
mainmenu "Linux/68k Kernel Configuration"
6268

6369
source "init/Kconfig"

arch/m68k/kernel/time.c

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -91,77 +91,11 @@ void __init time_init(void)
9191
mach_sched_init(timer_interrupt);
9292
}
9393

94-
/*
95-
* This version of gettimeofday has near microsecond resolution.
96-
*/
97-
void do_gettimeofday(struct timeval *tv)
94+
u32 arch_gettimeoffset(void)
9895
{
99-
unsigned long flags;
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-
131-
EXPORT_SYMBOL(do_gettimeofday);
132-
133-
int 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;
96+
return mach_gettimeoffset() * 1000;
16097
}
16198

162-
EXPORT_SYMBOL(do_settimeofday);
163-
164-
16599
static int __init rtc_init(void)
166100
{
167101
struct platform_device *pdev;

0 commit comments

Comments
 (0)