[PATCH] uml: timer cleanups
set_interval returns an error instead of panicing if setitimer fails. Some of its callers now check the return. enable_timer is largely tt-mode-specific, so it is marked as such, and the only skas-mode caller is made to call set-interval instead. user_time_init was a no-value-added wrapper around set_interval, so it is gone. Since set_interval is now called from kernel code, callers no longer pass ITIMER_* to it. Instead, they pass a flag which is converted into ITIMER_REAL or ITIMER_VIRTUAL. Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
4b84c69b5f
commit
537ae946e8
@ -17,20 +17,25 @@
|
||||
#include "kern_constants.h"
|
||||
#include "os.h"
|
||||
|
||||
static void set_interval(int timer_type)
|
||||
int set_interval(int is_virtual)
|
||||
{
|
||||
int usec = 1000000/hz();
|
||||
int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL;
|
||||
struct itimerval interval = ((struct itimerval) { { 0, usec },
|
||||
{ 0, usec } });
|
||||
|
||||
if(setitimer(timer_type, &interval, NULL) == -1)
|
||||
panic("setitimer failed - errno = %d\n", errno);
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MODE_TT
|
||||
void enable_timer(void)
|
||||
{
|
||||
set_interval(ITIMER_VIRTUAL);
|
||||
set_interval(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
void disable_timer(void)
|
||||
{
|
||||
@ -74,7 +79,7 @@ void uml_idle_timer(void)
|
||||
|
||||
set_handler(SIGALRM, (__sighandler_t) alarm_handler,
|
||||
SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
|
||||
set_interval(ITIMER_REAL);
|
||||
set_interval(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -94,8 +99,3 @@ void idle_sleep(int secs)
|
||||
ts.tv_nsec = 0;
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
void user_time_init(void)
|
||||
{
|
||||
set_interval(ITIMER_VIRTUAL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user