Skip to content

Commit

Permalink
um: Pass nsecs to os timer functions
Browse files Browse the repository at this point in the history
This makes the code clearer and lets the time travel patch have
the actual time used for these functions in just one place.

Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
jmberg-intel authored and richardweinberger committed Jul 2, 2019
1 parent b00bdd3 commit c7c6f3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions arch/um/include/shared/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ extern void os_warn(const char *fmt, ...)
/* time.c */
extern void os_idle_sleep(unsigned long long nsecs);
extern int os_timer_create(void);
extern int os_timer_set_interval(void);
extern int os_timer_one_shot(unsigned long ticks);
extern int os_timer_set_interval(unsigned long long nsecs);
extern int os_timer_one_shot(unsigned long long nsecs);
extern void os_timer_disable(void);
extern void uml_idle_timer(void);
extern long long os_persistent_clock_emulation(void);
Expand Down
4 changes: 2 additions & 2 deletions arch/um/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ static int itimer_shutdown(struct clock_event_device *evt)

static int itimer_set_periodic(struct clock_event_device *evt)
{
os_timer_set_interval();
os_timer_set_interval(NSEC_PER_SEC / HZ);
return 0;
}

static int itimer_next_event(unsigned long delta,
struct clock_event_device *evt)
{
return os_timer_one_shot(delta);
return os_timer_one_shot(delta + 1);
}

static int itimer_one_shot(struct clock_event_device *evt)
Expand Down
20 changes: 8 additions & 12 deletions arch/um/os-Linux/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,27 @@ int os_timer_create(void)
return 0;
}

int os_timer_set_interval(void)
int os_timer_set_interval(unsigned long long nsecs)
{
struct itimerspec its;
unsigned long long nsec;

nsec = UM_NSEC_PER_SEC / UM_HZ;
its.it_value.tv_sec = nsecs / UM_NSEC_PER_SEC;
its.it_value.tv_nsec = nsecs % UM_NSEC_PER_SEC;

its.it_value.tv_sec = 0;
its.it_value.tv_nsec = nsec;

its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = nsec;
its.it_interval.tv_sec = nsecs / UM_NSEC_PER_SEC;
its.it_interval.tv_nsec = nsecs % UM_NSEC_PER_SEC;

if (timer_settime(event_high_res_timer, 0, &its, NULL) == -1)
return -errno;

return 0;
}

int os_timer_one_shot(unsigned long ticks)
int os_timer_one_shot(unsigned long long nsecs)
{
unsigned long long nsec = ticks + 1;
struct itimerspec its = {
.it_value.tv_sec = nsec / UM_NSEC_PER_SEC,
.it_value.tv_nsec = nsec % UM_NSEC_PER_SEC,
.it_value.tv_sec = nsecs / UM_NSEC_PER_SEC,
.it_value.tv_nsec = nsecs % UM_NSEC_PER_SEC,

.it_interval.tv_sec = 0,
.it_interval.tv_nsec = 0, // we cheat here
Expand Down

0 comments on commit c7c6f3b

Please sign in to comment.