aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-03-26 04:38:07 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:57:02 -0500
commit3b98a5328171cebc867f70484b20bd34948cd7f6 (patch)
tree11510d45aec22c742baf6b67233dc1ebdfa17ee1 /kernel
parent44f21475511bbc0135b52c66ad74dcc6a9026da3 (diff)
[PATCH] hrtimers: posix-timer: cleanup common_timer_get()
Cleanup common_timer_get() a little. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/posix-timers.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 255657accf02..7c5f44787c8c 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -608,39 +608,41 @@ static struct k_itimer * lock_timer(timer_t timer_id, unsigned long *flags)
608static void 608static void
609common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) 609common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
610{ 610{
611 ktime_t remaining; 611 ktime_t now, remaining, iv;
612 struct hrtimer *timer = &timr->it.real.timer; 612 struct hrtimer *timer = &timr->it.real.timer;
613 613
614 memset(cur_setting, 0, sizeof(struct itimerspec)); 614 memset(cur_setting, 0, sizeof(struct itimerspec));
615 remaining = hrtimer_get_remaining(timer);
616 615
617 /* Time left ? or timer pending */ 616 iv = timr->it.real.interval;
618 if (remaining.tv64 > 0 || hrtimer_active(timer)) 617
619 goto calci;
620 /* interval timer ? */ 618 /* interval timer ? */
621 if (timr->it.real.interval.tv64 == 0) 619 if (iv.tv64)
620 cur_setting->it_interval = ktime_to_timespec(iv);
621 else if (!hrtimer_active(timer) &&
622 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
622 return; 623 return;
624
625 now = timer->base->get_time();
626
623 /* 627 /*
624 * When a requeue is pending or this is a SIGEV_NONE timer 628 * When a requeue is pending or this is a SIGEV_NONE
625 * move the expiry time forward by intervals, so expiry is > 629 * timer move the expiry time forward by intervals, so
626 * now. 630 * expiry is > now.
627 */ 631 */
628 if (timr->it_requeue_pending & REQUEUE_PENDING || 632 if (iv.tv64 && (timr->it_requeue_pending & REQUEUE_PENDING ||
629 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) { 633 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
630 timr->it_overrun += 634 timr->it_overrun += hrtimer_forward(timer, now, iv);
631 hrtimer_forward(timer, timer->base->get_time(), 635
632 timr->it.real.interval); 636 remaining = ktime_sub(timer->expires, now);
633 remaining = hrtimer_get_remaining(timer);
634 }
635 calci:
636 /* interval timer ? */
637 if (timr->it.real.interval.tv64 != 0)
638 cur_setting->it_interval =
639 ktime_to_timespec(timr->it.real.interval);
640 /* Return 0 only, when the timer is expired and not pending */ 637 /* Return 0 only, when the timer is expired and not pending */
641 if (remaining.tv64 <= 0) 638 if (remaining.tv64 <= 0) {
642 cur_setting->it_value.tv_nsec = 1; 639 /*
643 else 640 * A single shot SIGEV_NONE timer must return 0, when
641 * it is expired !
642 */
643 if ((timr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE)
644 cur_setting->it_value.tv_nsec = 1;
645 } else
644 cur_setting->it_value = ktime_to_timespec(remaining); 646 cur_setting->it_value = ktime_to_timespec(remaining);
645} 647}
646 648