aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2006-03-31 05:31:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-31 15:18:58 -0500
commit669d7868ae414cdb7b7e5df375dc8e4b47f26f6d (patch)
tree0c78ee0833e10d10a5d2f9fa9b9fe7f71fda6eb7 /kernel
parent00362e33f65f1cb5d15e62ea5509520ce2770360 (diff)
[PATCH] hrtimer: use generic sleeper for nanosleep
Replace the nanosleep private sleeper functionality by the generic hrtimer sleeper. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/hrtimer.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 877cdf9678bf..49cbf7cffebd 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -655,7 +655,6 @@ void hrtimer_run_queues(void)
655/* 655/*
656 * Sleep related functions: 656 * Sleep related functions:
657 */ 657 */
658
659static int hrtimer_wakeup(struct hrtimer *timer) 658static int hrtimer_wakeup(struct hrtimer *timer)
660{ 659{
661 struct hrtimer_sleeper *t = 660 struct hrtimer_sleeper *t =
@@ -675,28 +674,9 @@ void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task)
675 sl->task = task; 674 sl->task = task;
676} 675}
677 676
678struct sleep_hrtimer { 677static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
679 struct hrtimer timer;
680 struct task_struct *task;
681 int expired;
682};
683
684static int nanosleep_wakeup(struct hrtimer *timer)
685{ 678{
686 struct sleep_hrtimer *t = 679 hrtimer_init_sleeper(t, current);
687 container_of(timer, struct sleep_hrtimer, timer);
688
689 t->expired = 1;
690 wake_up_process(t->task);
691
692 return HRTIMER_NORESTART;
693}
694
695static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
696{
697 t->timer.function = nanosleep_wakeup;
698 t->task = current;
699 t->expired = 0;
700 680
701 do { 681 do {
702 set_current_state(TASK_INTERRUPTIBLE); 682 set_current_state(TASK_INTERRUPTIBLE);
@@ -704,18 +684,17 @@ static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
704 684
705 schedule(); 685 schedule();
706 686
707 if (unlikely(!t->expired)) { 687 hrtimer_cancel(&t->timer);
708 hrtimer_cancel(&t->timer); 688 mode = HRTIMER_ABS;
709 mode = HRTIMER_ABS; 689
710 } 690 } while (t->task && !signal_pending(current));
711 } while (!t->expired && !signal_pending(current));
712 691
713 return t->expired; 692 return t->task == NULL;
714} 693}
715 694
716static long __sched nanosleep_restart(struct restart_block *restart) 695static long __sched nanosleep_restart(struct restart_block *restart)
717{ 696{
718 struct sleep_hrtimer t; 697 struct hrtimer_sleeper t;
719 struct timespec __user *rmtp; 698 struct timespec __user *rmtp;
720 struct timespec tu; 699 struct timespec tu;
721 ktime_t time; 700 ktime_t time;
@@ -748,7 +727,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
748 const enum hrtimer_mode mode, const clockid_t clockid) 727 const enum hrtimer_mode mode, const clockid_t clockid)
749{ 728{
750 struct restart_block *restart; 729 struct restart_block *restart;
751 struct sleep_hrtimer t; 730 struct hrtimer_sleeper t;
752 struct timespec tu; 731 struct timespec tu;
753 ktime_t rem; 732 ktime_t rem;
754 733