Commit 7413d1f5 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Ulf Hansson

mmc: core: simplify ida handling

ida handling can be 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 543c576d
...@@ -34,14 +34,11 @@ ...@@ -34,14 +34,11 @@
#define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev)
static DEFINE_IDA(mmc_host_ida); static DEFINE_IDA(mmc_host_ida);
static DEFINE_SPINLOCK(mmc_host_lock);
static void mmc_host_classdev_release(struct device *dev) static void mmc_host_classdev_release(struct device *dev)
{ {
struct mmc_host *host = cls_dev_to_mmc_host(dev); struct mmc_host *host = cls_dev_to_mmc_host(dev);
spin_lock(&mmc_host_lock); ida_simple_remove(&mmc_host_ida, host->index);
ida_remove(&mmc_host_ida, host->index);
spin_unlock(&mmc_host_lock);
kfree(host); kfree(host);
} }
...@@ -356,22 +353,13 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) ...@@ -356,22 +353,13 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
/* scanning will be enabled when we're ready */ /* scanning will be enabled when we're ready */
host->rescan_disable = 1; host->rescan_disable = 1;
again: err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { if (err < 0) {
kfree(host); kfree(host);
return NULL; return NULL;
} }
spin_lock(&mmc_host_lock); host->index = err;
err = ida_get_new(&mmc_host_ida, &host->index);
spin_unlock(&mmc_host_lock);
if (err == -EAGAIN) {
goto again;
} else if (err) {
kfree(host);
return NULL;
}
dev_set_name(&host->class_dev, "mmc%d", host->index); dev_set_name(&host->class_dev, "mmc%d", host->index);
......
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