diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2016-04-07 12:40:59 +0300 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2016-05-02 11:33:36 +0300 |
commit | 5674a9baba32dfff9585bd50e604a06bc9b1c2b8 (patch) | |
tree | 968fa9dc113cf63382b10556b825c11de9cba1cd /drivers/mmc | |
parent | 74479c5d5009ebe28de69dd67b769c05ad953a5c (diff) | |
download | linux-5674a9baba32dfff9585bd50e604a06bc9b1c2b8.tar.xz |
mmc: core: Convert from IDR to IDA for host indexes
As IDA is more lightweight than IDR, let's convert to use that instead.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/host.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6e4c55a4aab5..e0a3ee16c0d3 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -33,14 +33,14 @@ #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) -static DEFINE_IDR(mmc_host_idr); +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); - idr_remove(&mmc_host_idr, host->index); + ida_remove(&mmc_host_ida, host->index); spin_unlock(&mmc_host_lock); kfree(host); } @@ -321,14 +321,20 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) /* scanning will be enabled when we're ready */ host->rescan_disable = 1; - idr_preload(GFP_KERNEL); + +again: + if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { + kfree(host); + return NULL; + } + spin_lock(&mmc_host_lock); - err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); - if (err >= 0) - host->index = err; + err = ida_get_new(&mmc_host_ida, &host->index); spin_unlock(&mmc_host_lock); - idr_preload_end(); - if (err < 0) { + + if (err == -EAGAIN) { + goto again; + } else if (err) { kfree(host); return NULL; } |