Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c718aa65 authored by Tejun Heo's avatar Tejun Heo Committed by Linus Torvalds
Browse files

block/loop: convert to idr_alloc()



Convert to the much saner new idr interface.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bab998d6
Loading
Loading
Loading
Loading
+5 −18
Original line number Original line Diff line number Diff line
@@ -1624,30 +1624,17 @@ static int loop_add(struct loop_device **l, int i)
	if (!lo)
	if (!lo)
		goto out;
		goto out;


	if (!idr_pre_get(&loop_index_idr, GFP_KERNEL))
	/* allocate id, if @id >= 0, we're requesting that specific id */
		goto out_free_dev;

	if (i >= 0) {
	if (i >= 0) {
		int m;
		err = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL);

		if (err == -ENOSPC)
		/* create specific i in the index */
		err = idr_get_new_above(&loop_index_idr, lo, i, &m);
		if (err >= 0 && i != m) {
			idr_remove(&loop_index_idr, m);
			err = -EEXIST;
			err = -EEXIST;
		}
	} else if (i == -1) {
		int m;

		/* get next free nr */
		err = idr_get_new(&loop_index_idr, lo, &m);
		if (err >= 0)
			i = m;
	} else {
	} else {
		err = -EINVAL;
		err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL);
	}
	}
	if (err < 0)
	if (err < 0)
		goto out_free_dev;
		goto out_free_dev;
	i = err;


	lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
	lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
	if (!lo->lo_queue)
	if (!lo->lo_queue)