aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/kernel/time.c')
-rw-r--r--arch/um/kernel/time.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 90e24e2dbeaa..4fc8c2586b70 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -1,28 +1,19 @@
1/* 1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/kernel.h"
7#include "linux/module.h"
8#include "linux/unistd.h"
9#include "linux/stddef.h"
10#include "linux/spinlock.h"
11#include "linux/time.h"
12#include "linux/sched.h"
13#include "linux/interrupt.h" 6#include "linux/interrupt.h"
14#include "linux/init.h" 7#include "linux/jiffies.h"
15#include "linux/delay.h" 8#include "linux/threads.h"
16#include "linux/hrtimer.h"
17#include "asm/irq.h" 9#include "asm/irq.h"
18#include "asm/param.h" 10#include "asm/param.h"
19#include "asm/current.h"
20#include "kern_util.h" 11#include "kern_util.h"
21#include "os.h" 12#include "os.h"
22 13
23int hz(void) 14int hz(void)
24{ 15{
25 return(HZ); 16 return HZ;
26} 17}
27 18
28/* 19/*
@@ -43,7 +34,7 @@ void timer_irq(struct uml_pt_regs *regs)
43 unsigned long long ticks = 0; 34 unsigned long long ticks = 0;
44#ifdef CONFIG_UML_REAL_TIME_CLOCK 35#ifdef CONFIG_UML_REAL_TIME_CLOCK
45 int c = cpu(); 36 int c = cpu();
46 if(prev_nsecs[c]){ 37 if (prev_nsecs[c]) {
47 /* We've had 1 tick */ 38 /* We've had 1 tick */
48 unsigned long long nsecs = os_nsecs(); 39 unsigned long long nsecs = os_nsecs();
49 40
@@ -51,7 +42,7 @@ void timer_irq(struct uml_pt_regs *regs)
51 prev_nsecs[c] = nsecs; 42 prev_nsecs[c] = nsecs;
52 43
53 /* Protect against the host clock being set backwards */ 44 /* Protect against the host clock being set backwards */
54 if(delta[c] < 0) 45 if (delta[c] < 0)
55 delta[c] = 0; 46 delta[c] = 0;
56 47
57 ticks += (delta[c] * HZ) / BILLION; 48 ticks += (delta[c] * HZ) / BILLION;
@@ -61,7 +52,7 @@ void timer_irq(struct uml_pt_regs *regs)
61#else 52#else
62 ticks = 1; 53 ticks = 1;
63#endif 54#endif
64 while(ticks > 0){ 55 while (ticks > 0) {
65 do_IRQ(TIMER_IRQ, regs); 56 do_IRQ(TIMER_IRQ, regs);
66 ticks--; 57 ticks--;
67 } 58 }
@@ -112,12 +103,12 @@ static void register_timer(void)
112 int err; 103 int err;
113 104
114 err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL); 105 err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL);
115 if(err != 0) 106 if (err != 0)
116 printk(KERN_ERR "register_timer : request_irq failed - " 107 printk(KERN_ERR "register_timer : request_irq failed - "
117 "errno = %d\n", -err); 108 "errno = %d\n", -err);
118 109
119 err = set_interval(1); 110 err = set_interval(1);
120 if(err != 0) 111 if (err != 0)
121 printk(KERN_ERR "register_timer : set_interval failed - " 112 printk(KERN_ERR "register_timer : set_interval failed - "
122 "errno = %d\n", -err); 113 "errno = %d\n", -err);
123} 114}
@@ -144,7 +135,8 @@ void do_gettimeofday(struct timeval *tv)
144 xtime.tv_nsec; 135 xtime.tv_nsec;
145#endif 136#endif
146 tv->tv_sec = nsecs / NSEC_PER_SEC; 137 tv->tv_sec = nsecs / NSEC_PER_SEC;
147 /* Careful about calculations here - this was originally done as 138 /*
139 * Careful about calculations here - this was originally done as
148 * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC 140 * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC
149 * which gave bogus (> 1000000) values. Dunno why, suspect gcc 141 * which gave bogus (> 1000000) values. Dunno why, suspect gcc
150 * (4.0.0) miscompiled it, or there's a subtle 64/32-bit conversion 142 * (4.0.0) miscompiled it, or there's a subtle 64/32-bit conversion
@@ -176,7 +168,7 @@ int do_settimeofday(struct timespec *tv)
176 168
177void timer_handler(int sig, struct uml_pt_regs *regs) 169void timer_handler(int sig, struct uml_pt_regs *regs)
178{ 170{
179 if(current_thread->cpu == 0) 171 if (current_thread->cpu == 0)
180 timer_irq(regs); 172 timer_irq(regs);
181 local_irq_disable(); 173 local_irq_disable();
182 irq_enter(); 174 irq_enter();