aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vfio/vfio.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:19 -0500
commita1c36b166be76763cfab1a4308a00d6ffd8a2cc0 (patch)
tree1f1ac05adc65dcc76450acf770658068d242f3fa /drivers/vfio/vfio.c
parent6d770931291eec7e7be774a5272db28d29899a66 (diff)
vfio: convert to idr_alloc()
Convert to the much saner new idr interface. 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/vfio/vfio.c')
-rw-r--r--drivers/vfio/vfio.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 28e2d5b2c0c7..fcc12f3e60a3 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -139,23 +139,8 @@ EXPORT_SYMBOL_GPL(vfio_unregister_iommu_driver);
139 */ 139 */
140static int vfio_alloc_group_minor(struct vfio_group *group) 140static int vfio_alloc_group_minor(struct vfio_group *group)
141{ 141{
142 int ret, minor;
143
144again:
145 if (unlikely(idr_pre_get(&vfio.group_idr, GFP_KERNEL) == 0))
146 return -ENOMEM;
147
148 /* index 0 is used by /dev/vfio/vfio */ 142 /* index 0 is used by /dev/vfio/vfio */
149 ret = idr_get_new_above(&vfio.group_idr, group, 1, &minor); 143 return idr_alloc(&vfio.group_idr, group, 1, MINORMASK + 1, GFP_KERNEL);
150 if (ret == -EAGAIN)
151 goto again;
152 if (ret || minor > MINORMASK) {
153 if (minor > MINORMASK)
154 idr_remove(&vfio.group_idr, minor);
155 return -ENOSPC;
156 }
157
158 return minor;
159} 144}
160 145
161static void vfio_free_group_minor(int minor) 146static void vfio_free_group_minor(int minor)