/*
  * Sleep related functions:
  */
-
 static int hrtimer_wakeup(struct hrtimer *timer)
 {
        struct hrtimer_sleeper *t =
        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);
 
                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;
                       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;