Commit 3b98a532 authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] hrtimers: posix-timer: cleanup common_timer_get()

Cleanup common_timer_get() a little.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 44f21475
...@@ -608,39 +608,41 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags) ...@@ -608,39 +608,41 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags)
static void static void
common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
{ {
ktime_t remaining; ktime_t now, remaining, iv;
struct hrtimer *timer = &timr->it.real.timer; struct hrtimer *timer = &timr->it.real.timer;
memset(cur_setting, 0, sizeof(struct itimerspec)); memset(cur_setting, 0, sizeof(struct itimerspec));
remaining = hrtimer_get_remaining(timer);
/* Time left ? or timer pending */ iv = timr->it.real.interval;
if (remaining.tv64 > 0 || hrtimer_active(timer))
goto calci;
/* interval timer ? */ /* interval timer ? */
if (timr->it.real.interval.tv64 == 0) if (iv.tv64)
cur_setting->it_interval = ktime_to_timespec(iv);
else if (!hrtimer_active(timer) &&
(timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
return; return;
now = timer->base->get_time();
/* /*
* When a requeue is pending or this is a SIGEV_NONE timer * When a requeue is pending or this is a SIGEV_NONE
* move the expiry time forward by intervals, so expiry is > * timer move the expiry time forward by intervals, so
* now. * expiry is > now.
*/ */
if (timr->it_requeue_pending & REQUEUE_PENDING || if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING ||
(timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
timr->it_overrun += timr->it_overrun += hrtimer_forward(timer, now, iv);
hrtimer_forward(timer, timer->base->get_time(),
timr->it.real.interval); remaining = ktime_sub(timer->expires, now);
remaining = hrtimer_get_remaining(timer);
}
calci:
/* interval timer ? */
if (timr->it.real.interval.tv64 != 0)
cur_setting->it_interval =
ktime_to_timespec(timr->it.real.interval);
/* Return 0 only, when the timer is expired and not pending */ /* Return 0 only, when the timer is expired and not pending */
if (remaining.tv64 <= 0) if (remaining.tv64 <= 0) {
cur_setting->it_value.tv_nsec = 1; /*
else * A single shot SIGEV_NONE timer must return 0, when
* it is expired !
*/
if ((timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
cur_setting->it_value.tv_nsec = 1;
} else
cur_setting->it_value = ktime_to_timespec(remaining); cur_setting->it_value = ktime_to_timespec(remaining);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment