Skip to content

Commit

Permalink
vfio: convert to idr_alloc()
Browse files Browse the repository at this point in the history
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo <[email protected]>
Acked-by: Alex Williamson <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
htejun authored and torvalds committed Feb 28, 2013
1 parent 6d77093 commit a1c36b1
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions drivers/vfio/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a1c36b1

Please sign in to comment.