]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 7 Feb 2013 01:31:38 +0000 (12:31 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:47:30 +0000 (16:47 +1100)
Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/gpu/drm/i915/i915_gem_context.c

index a3f06bcad551d844c1e3649fee266466a04ff759..27e586ad6b305bbc04bde9ff24711d78aa27f3cf 100644 (file)
@@ -144,7 +144,7 @@ create_hw_context(struct drm_device *dev,
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct i915_hw_context *ctx;
-       int ret, id;
+       int ret;
 
        ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
        if (ctx == NULL)
@@ -169,22 +169,11 @@ create_hw_context(struct drm_device *dev,
 
        ctx->file_priv = file_priv;
 
-again:
-       if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) {
-               ret = -ENOMEM;
-               DRM_DEBUG_DRIVER("idr allocation failed\n");
-               goto err_out;
-       }
-
-       ret = idr_get_new_above(&file_priv->context_idr, ctx,
-                               DEFAULT_CONTEXT_ID + 1, &id);
-       if (ret == 0)
-               ctx->id = id;
-
-       if (ret == -EAGAIN)
-               goto again;
-       else if (ret)
+       ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0,
+                       GFP_KERNEL);
+       if (ret < 0)
                goto err_out;
+       ctx->id = ret;
 
        return ctx;