diff options
author | Johannes Berg <johannes.berg@intel.com> | 2019-05-27 10:34:26 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2019-07-02 23:27:29 +0200 |
commit | c7c6f3b95303c7de5d52af56c902fcb5abe827df (patch) | |
tree | e48fa523e8d88879b53967d660e0795d4df8e139 /arch/um/os-Linux | |
parent | um: Remove drivers/ssl.h (diff) | |
download | linux-c7c6f3b95303c7de5d52af56c902fcb5abe827df.tar.xz linux-c7c6f3b95303c7de5d52af56c902fcb5abe827df.zip |
um: Pass nsecs to os timer functions
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 <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/time.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index ea720149f5b8..6d94ff52362c 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c @@ -50,18 +50,15 @@ 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; @@ -69,12 +66,11 @@ int os_timer_set_interval(void) 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 |