Merge tag v3.9-rc1 into for-3.9/upstream-fixes
[cascardo/linux.git] / drivers / infiniband / core / ucma.c
index 2709ff5..5ca44cd 100644 (file)
@@ -145,7 +145,6 @@ static void ucma_put_ctx(struct ucma_context *ctx)
 static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
 {
        struct ucma_context *ctx;
-       int ret;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (!ctx)
@@ -156,17 +155,10 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
        INIT_LIST_HEAD(&ctx->mc_list);
        ctx->file = file;
 
-       do {
-               ret = idr_pre_get(&ctx_idr, GFP_KERNEL);
-               if (!ret)
-                       goto error;
-
-               mutex_lock(&mut);
-               ret = idr_get_new(&ctx_idr, ctx, &ctx->id);
-               mutex_unlock(&mut);
-       } while (ret == -EAGAIN);
-
-       if (ret)
+       mutex_lock(&mut);
+       ctx->id = idr_alloc(&ctx_idr, ctx, 0, 0, GFP_KERNEL);
+       mutex_unlock(&mut);
+       if (ctx->id < 0)
                goto error;
 
        list_add_tail(&ctx->list, &file->ctx_list);
@@ -180,23 +172,15 @@ error:
 static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
 {
        struct ucma_multicast *mc;
-       int ret;
 
        mc = kzalloc(sizeof(*mc), GFP_KERNEL);
        if (!mc)
                return NULL;
 
-       do {
-               ret = idr_pre_get(&multicast_idr, GFP_KERNEL);
-               if (!ret)
-                       goto error;
-
-               mutex_lock(&mut);
-               ret = idr_get_new(&multicast_idr, mc, &mc->id);
-               mutex_unlock(&mut);
-       } while (ret == -EAGAIN);
-
-       if (ret)
+       mutex_lock(&mut);
+       mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
+       mutex_unlock(&mut);
+       if (mc->id < 0)
                goto error;
 
        mc->ctx = ctx;