Skip to content

Commit

Permalink
drm/vmwgfx: convert to idr_alloc()
Browse files Browse the repository at this point in the history
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Feb 28, 2013
1 parent 36888db commit cc39a8f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit cc39a8f

Please sign in to comment.