From: Tejun Heo Date: Wed, 20 Feb 2013 02:16:10 +0000 (+1100) Subject: block/loop: convert to idr_alloc() X-Git-Tag: next-20130220~1^2~176 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2c5d1953c738748b4277e80665e7f4ae71bae1eb;p=karo-tx-linux.git block/loop: convert to idr_alloc() Convert to the much saner new idr interface. Signed-off-by: Tejun Heo Acked-by: Jens Axboe Signed-off-by: Andrew Morton --- diff --git a/drivers/block/loop.c b/drivers/block/loop.c index dc3891e6b5e8..56a3963f8a57 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -1611,30 +1611,17 @@ static int loop_add(struct loop_device **l, int i) if (!lo) goto out; - if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) - goto out_free_dev; - + /* allocate id, if @id >= 0, we're requesting that specific id */ if (i >= 0) { - int m; - - /* 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 = idr_alloc(&loop_index_idr, lo, i, i + 1, GFP_KERNEL); + if (err == -ENOSPC) 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 { - err = -EINVAL; + err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL); } if (err < 0) goto out_free_dev; + i = err; lo->lo_queue = blk_alloc_queue(GFP_KERNEL); if (!lo->lo_queue)