aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:03:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:15 -0500
commitc718aa652d3def382a79c25442c2a830263e52ed (patch)
tree7adef67f6031938c442494a985c26371adb26d44
parentbab998d62f12db12b3ddf1e06b2ecd4ed9e7ae45 (diff)
block/loop: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/block/loop.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index c674e5492ec4..f47dccbda1d4 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1624,30 +1624,17 @@ static int loop_add(struct loop_device **l, int i)
1624 if (!lo) 1624 if (!lo)
1625 goto out; 1625 goto out;
1626 1626
1627 if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) 1627 /* allocate id, if @id >= 0, we're requesting that specific id */
1628 goto out_free_dev;
1629
1630 if (i >= 0) { 1628 if (i >= 0) {
1631 int m; 1629 err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL);
1632 1630 if (err == -ENOSPC)
1633 /* create specific i in the index */
1634 err = idr_get_new_above(&loop_index_idr, lo, i, &m);
1635 if (err >= 0 && i != m) {
1636 idr_remove(&loop_index_idr, m);
1637 err = -EEXIST; 1631 err = -EEXIST;
1638 }
1639 } else if (i == -1) {
1640 int m;
1641
1642 /* get next free nr */
1643 err = idr_get_new(&loop_index_idr, lo, &m);
1644 if (err >= 0)
1645 i = m;
1646 } else { 1632 } else {
1647 err = -EINVAL; 1633 err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL);
1648 } 1634 }
1649 if (err < 0) 1635 if (err < 0)
1650 goto out_free_dev; 1636 goto out_free_dev;
1637 i = err;
1651 1638
1652 lo->lo_queue = blk_alloc_queue(GFP_KERNEL); 1639 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
1653 if (!lo->lo_queue) 1640 if (!lo->lo_queue)