Commit a04848c7 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Ulf Hansson

mmc: core: switch to ida_simple_ functions in block.c

ida code in block.c can be significantly simplified by switching to
the ida_simple_ functions.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent a53210f5
...@@ -90,7 +90,6 @@ static int max_devices; ...@@ -90,7 +90,6 @@ static int max_devices;
#define MAX_DEVICES 256 #define MAX_DEVICES 256
static DEFINE_IDA(mmc_blk_ida); static DEFINE_IDA(mmc_blk_ida);
static DEFINE_SPINLOCK(mmc_blk_lock);
/* /*
* There is one mmc_blk_data per slot. * There is one mmc_blk_data per slot.
...@@ -163,11 +162,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) ...@@ -163,11 +162,7 @@ static void mmc_blk_put(struct mmc_blk_data *md)
if (md->usage == 0) { if (md->usage == 0) {
int devidx = mmc_get_devidx(md->disk); int devidx = mmc_get_devidx(md->disk);
blk_cleanup_queue(md->queue.queue); blk_cleanup_queue(md->queue.queue);
ida_simple_remove(&mmc_blk_ida, devidx);
spin_lock(&mmc_blk_lock);
ida_remove(&mmc_blk_ida, devidx);
spin_unlock(&mmc_blk_lock);
put_disk(md->disk); put_disk(md->disk);
kfree(md); kfree(md);
} }
...@@ -1839,23 +1834,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, ...@@ -1839,23 +1834,9 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
struct mmc_blk_data *md; struct mmc_blk_data *md;
int devidx, ret; int devidx, ret;
again: devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
if (!ida_pre_get(&mmc_blk_ida, GFP_KERNEL)) if (devidx < 0)
return ERR_PTR(-ENOMEM); return ERR_PTR(devidx);
spin_lock(&mmc_blk_lock);
ret = ida_get_new(&mmc_blk_ida, &devidx);
spin_unlock(&mmc_blk_lock);
if (ret == -EAGAIN)
goto again;
else if (ret)
return ERR_PTR(ret);
if (devidx >= max_devices) {
ret = -ENOSPC;
goto out;
}
md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL); md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
if (!md) { if (!md) {
...@@ -1944,9 +1925,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, ...@@ -1944,9 +1925,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
err_kfree: err_kfree:
kfree(md); kfree(md);
out: out:
spin_lock(&mmc_blk_lock); ida_simple_remove(&mmc_blk_ida, devidx);
ida_remove(&mmc_blk_ida, devidx);
spin_unlock(&mmc_blk_lock);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment