]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
vfio: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Thu, 7 Feb 2013 01:31:48 +0000 (12:31 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:47:37 +0000 (16:47 +1100)
Convert to the much saner new idr interface.

Only compile tested.

v2: Restore accidentally dropped "index 0" comment as suggested by
    Alex.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/vfio/vfio.c

index 28e2d5b2c0c759515ba733648c79aeef23ac05e9..fcc12f3e60a30d1f315c2ce7c715aa58629f317c 100644 (file)
@@ -139,23 +139,8 @@ EXPORT_SYMBOL_GPL(vfio_unregister_iommu_driver);
  */
 static int vfio_alloc_group_minor(struct vfio_group *group)
 {
-       int ret, minor;
-
-again:
-       if (unlikely(idr_pre_get(&vfio.group_idr, GFP_KERNEL) == 0))
-               return -ENOMEM;
-
        /* index 0 is used by /dev/vfio/vfio */
-       ret = idr_get_new_above(&vfio.group_idr, group, 1, &minor);
-       if (ret == -EAGAIN)
-               goto again;
-       if (ret || minor > MINORMASK) {
-               if (minor > MINORMASK)
-                       idr_remove(&vfio.group_idr, minor);
-               return -ENOSPC;
-       }
-
-       return minor;
+       return idr_alloc(&vfio.group_idr, group, 1, MINORMASK + 1, GFP_KERNEL);
 }
 
 static void vfio_free_group_minor(int minor)