aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gleixner2006-03-31 02:31:19 -0800
committerLinus Torvalds2006-03-31 12:18:58 -0800
commit669d7868ae414cdb7b7e5df375dc8e4b47f26f6d (patch)
tree0c78ee0833e10d10a5d2f9fa9b9fe7f71fda6eb7
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>
-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)
/*
* Sleep related functions:
*/
-
static int hrtimer_wakeup(struct hrtimer *timer)
{
struct hrtimer_sleeper *t =
@@ -675,28 +674,9 @@ void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, task_t *task)
sl->task = task;
}
-struct sleep_hrtimer {
- struct hrtimer timer;
- struct task_struct *task;
- int expired;
-};
-
-static int nanosleep_wakeup(struct hrtimer *timer)
+static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
{
- struct sleep_hrtimer *t =
- container_of(timer, struct sleep_hrtimer, timer);
-
- t->expired = 1;
- wake_up_process(t->task);
-
- return HRTIMER_NORESTART;
-}
-
-static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
-{
- t->timer.function = nanosleep_wakeup;
- t->task = current;
- t->expired = 0;
+ hrtimer_init_sleeper(t, current);
do {
set_current_state(TASK_INTERRUPTIBLE);
@@ -704,18 +684,17 @@ static int __sched do_nanosleep(struct sleep_hrtimer *t, enum hrtimer_mode mode)
schedule();
- if (unlikely(!t->expired)) {
- hrtimer_cancel(&t->timer);
- mode = HRTIMER_ABS;
- }
- } while (!t->expired && !signal_pending(current));
+ hrtimer_cancel(&t->timer);
+ mode = HRTIMER_ABS;
+
+ } while (t->task && !signal_pending(current));
- return t->expired;
+ return t->task == NULL;
}
static long __sched nanosleep_restart(struct restart_block *restart)
{
- struct sleep_hrtimer t;
+ struct hrtimer_sleeper t;
struct timespec __user *rmtp;
struct timespec tu;
ktime_t time;
@@ -748,7 +727,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
const enum hrtimer_mode mode, const clockid_t clockid)
{
struct restart_block *restart;
- struct sleep_hrtimer t;
+ struct hrtimer_sleeper t;
struct timespec tu;
ktime_t rem;