Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.git] / drivers / gpu / drm / drm_stub.c
index 200e104..7d30802 100644 (file)
@@ -109,7 +109,6 @@ EXPORT_SYMBOL(drm_ut_debug_printk);
 
 static int drm_minor_get_id(struct drm_device *dev, int type)
 {
-       int new_id;
        int ret;
        int base = 0, limit = 63;
 
@@ -121,25 +120,11 @@ static int drm_minor_get_id(struct drm_device *dev, int type)
                 limit = base + 255;
         }
 
-again:
-       if (idr_pre_get(&drm_minors_idr, GFP_KERNEL) == 0) {
-               DRM_ERROR("Out of memory expanding drawable idr\n");
-               return -ENOMEM;
-       }
        mutex_lock(&dev->struct_mutex);
-       ret = idr_get_new_above(&drm_minors_idr, NULL,
-                               base, &new_id);
+       ret = idr_alloc(&drm_minors_idr, NULL, base, limit, GFP_KERNEL);
        mutex_unlock(&dev->struct_mutex);
-       if (ret == -EAGAIN)
-               goto again;
-       else if (ret)
-               return ret;
 
-       if (new_id >= limit) {
-               idr_remove(&drm_minors_idr, new_id);
-               return -EINVAL;
-       }
-       return new_id;
+       return ret == -ENOSPC ? -EINVAL : ret;
 }
 
 struct drm_master *drm_master_create(struct drm_minor *minor)