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

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c

index 16556170fb32e663cf7e80f004488206571fba0e..bc784254e78ef60db12eb5922d7babaa50d9ff17 100644 (file)
@@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res)
 
        BUG_ON(res->id != -1);
 
-       do {
-               if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
-                       return -ENOMEM;
-
-               write_lock(&dev_priv->resource_lock);
-               ret = idr_get_new_above(idr, res, 1, &res->id);
-               write_unlock(&dev_priv->resource_lock);
+       idr_preload(GFP_KERNEL);
+       write_lock(&dev_priv->resource_lock);
 
-       } while (ret == -EAGAIN);
+       ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT);
+       if (ret >= 0)
+               res->id = ret;
 
-       return ret;
+       write_unlock(&dev_priv->resource_lock);
+       idr_preload_end();
+       return ret < 0 ? ret : 0;
 }
 
 /**