mmc: core: simplify ida handling
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 28 Jan 2017 08:32:35 +0000 (09:32 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 13 Feb 2017 12:20:47 +0000 (13:20 +0100)
ida handling can be simplified by switching to the ida_simple_
functions.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/host.c

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