Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Linus Torvalds
c8c470af 8550cb2e

+5 -16
+5 -16
drivers/gpu/drm/i915/i915_gem_context.c
··· 139 139 { 140 140 struct drm_i915_private *dev_priv = dev->dev_private; 141 141 struct i915_hw_context *ctx; 142 - int ret, id; 142 + int ret; 143 143 144 144 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 145 145 if (ctx == NULL) ··· 164 164 165 165 ctx->file_priv = file_priv; 166 166 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"); 167 + ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0, 168 + GFP_KERNEL); 169 + if (ret < 0) 171 170 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) 182 - goto err_out; 171 + ctx->id = ret; 183 172 184 173 return ctx; 185 174