Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8c470af authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds
Browse files

drm/i915: convert to idr_alloc()



Convert to the much saner new idr interface.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarDavid Airlie <airlied@linux.ie>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8550cb2e
Loading
Loading
Loading
Loading
+5 −16
Original line number Original line Diff line number Diff line
@@ -139,7 +139,7 @@ create_hw_context(struct drm_device *dev,
{
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct i915_hw_context *ctx;
	struct i915_hw_context *ctx;
	int ret, id;
	int ret;


	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
	if (ctx == NULL)
	if (ctx == NULL)
@@ -164,22 +164,11 @@ create_hw_context(struct drm_device *dev,


	ctx->file_priv = file_priv;
	ctx->file_priv = file_priv;


again:
	ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0,
	if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) {
			GFP_KERNEL);
		ret = -ENOMEM;
	if (ret < 0)
		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)
		goto err_out;
		goto err_out;
	ctx->id = ret;


	return ctx;
	return ctx;