Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Linus Torvalds
c718aa65 bab998d6

+5 -18
+5 -18
drivers/block/loop.c
··· 1624 1624 if (!lo) 1625 1625 goto out; 1626 1626 1627 - if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) 1628 - goto out_free_dev; 1629 - 1627 + /* allocate id, if @id >= 0, we're requesting that specific id */ 1630 1628 if (i >= 0) { 1631 - int m; 1632 - 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); 1629 + err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL); 1630 + if (err == -ENOSPC) 1637 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 1632 } else { 1647 - err = -EINVAL; 1633 + err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL); 1648 1634 } 1649 1635 if (err < 0) 1650 1636 goto out_free_dev; 1637 + i = err; 1651 1638 1652 1639 lo->lo_queue = blk_alloc_queue(GFP_KERNEL); 1653 1640 if (!lo->lo_queue)