Skip to content

Commit c8c470a

Browse files
htejuntorvalds
authored andcommitted
drm/i915: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> 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>
1 parent 8550cb2 commit c8c470a

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

‎drivers/gpu/drm/i915/i915_gem_context.c‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ create_hw_context(struct drm_device *dev,
139139
{
140140
struct drm_i915_private *dev_priv = dev->dev_private;
141141
struct i915_hw_context *ctx;
142-
int ret, id;
142+
int ret;
143143

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

165165
ctx->file_priv = file_priv;
166166

167-
again:
168-
if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) {
169-
ret = -ENOMEM;
170-
DRM_DEBUG_DRIVER("idr allocation failed\n");
171-
goto err_out;
172-
}
173-
174-
ret = idr_get_new_above(&file_priv->context_idr, ctx,
175-
DEFAULT_CONTEXT_ID + 1, &id);
176-
if (ret == 0)
177-
ctx->id = id;
178-
179-
if (ret == -EAGAIN)
180-
goto again;
181-
else if (ret)
167+
ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0,
168+
GFP_KERNEL);
169+
if (ret < 0)
182170
goto err_out;
171+
ctx->id = ret;
183172

184173
return ctx;
185174

0 commit comments

Comments
 (0)