[PATCH] uml: fix wall_to_monotonic initialization

From: Jeff Dike <jdike@addtoit.com>

Initialize wall_to_monotonic correctly. This fixes a problem where sleeps
lasted about one secone less than they should. This also called for a bit of
code restructuring, following a patch which Blaisorblade had been keeping.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jeff Dike and committed by Linus Torvalds 5cb38bc4 65e62974

+13 -20
+2 -11
arch/um/include/kern_util.h
··· 120 120 extern void free_irq(unsigned int, void *); 121 121 extern int cpu(void); 122 122 123 + extern void time_init_kern(void); 124 + 123 125 /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */ 124 126 extern int __cant_sleep(void); 125 127 extern void segv_handler(int sig, union uml_pt_regs *regs); 126 128 extern void sigio_handler(int sig, union uml_pt_regs *regs); 127 129 128 130 #endif 129 - 130 - /* 131 - * Overrides for Emacs so that we follow Linus's tabbing style. 132 - * Emacs will notice this stuff at the end of the file and automatically 133 - * adjust the settings for this buffer only. This must remain at the end 134 - * of the file. 135 - * --------------------------------------------------------------------------- 136 - * Local variables: 137 - * c-file-style: "linux" 138 - * End: 139 - */
+10
arch/um/kernel/time_kern.c
··· 84 84 } 85 85 } 86 86 87 + 88 + void time_init_kern(void) 89 + { 90 + unsigned long long nsecs; 91 + 92 + nsecs = os_nsecs(); 93 + set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION, 94 + -nsecs % BILLION); 95 + } 96 + 87 97 void do_boot_timer_handler(struct sigcontext * sc) 88 98 { 89 99 struct pt_regs regs;
+1 -9
arch/um/os-Linux/time.c
··· 81 81 set_interval(ITIMER_REAL); 82 82 } 83 83 84 - extern void ktime_get_ts(struct timespec *ts); 85 - #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) 86 - 87 84 void time_init(void) 88 85 { 89 - struct timespec now; 90 - 91 86 if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR) 92 87 panic("Couldn't set SIGVTALRM handler"); 93 88 set_interval(ITIMER_VIRTUAL); 94 - 95 - do_posix_clock_monotonic_gettime(&now); 96 - wall_to_monotonic.tv_sec = -now.tv_sec; 97 - wall_to_monotonic.tv_nsec = -now.tv_nsec; 89 + time_init_kern(); 98 90 } 99 91 100 92 unsigned long long os_nsecs(void)