]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
posix-timers: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:28 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:54 +0000 (16:53 +1100)
Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/posix-timers.c

index 10349d5f2ec311afe81c17ff533aec6ddbd83d09..b51bb086e5f3087d0c4c7418a8170186a42c4dce 100644 (file)
@@ -552,24 +552,22 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
                return -EAGAIN;
 
        spin_lock_init(&new_timer->it_lock);
- retry:
-       if (unlikely(!idr_pre_get(&posix_timers_id, GFP_KERNEL))) {
-               error = -EAGAIN;
-               goto out;
-       }
+
+       idr_preload(GFP_KERNEL);
        spin_lock_irq(&idr_lock);
-       error = idr_get_new(&posix_timers_id, new_timer, &new_timer_id);
+       error = idr_alloc(&posix_timers_id, new_timer, 0, 0, GFP_NOWAIT);
        spin_unlock_irq(&idr_lock);
-       if (error) {
-               if (error == -EAGAIN)
-                       goto retry;
+       idr_preload_end();
+       if (error < 0) {
                /*
                 * Weird looking, but we return EAGAIN if the IDR is
                 * full (proper POSIX return value for this)
                 */
-               error = -EAGAIN;
+               if (error == -ENOSPC)
+                       error = -EAGAIN;
                goto out;
        }
+       new_timer_id = error;
 
        it_id_set = IT_ID_SET;
        new_timer->it_id = (timer_t) new_timer_id;