mmc: core: Remove usage of the deprecated ida_simple_xx() API
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 14 Jan 2024 15:01:57 +0000 (16:01 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 13 Feb 2024 12:37:27 +0000 (13:37 +0100)
ida_alloc() and ida_free() should be preferred to the deprecated
ida_simple_get() and ida_simple_remove().

Note that the upper limit of ida_simple_get() is exclusive, but the one of
ida_alloc_range()/ida_alloc_max() is inclusive. So a -1 has been added when
needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/583c57d0ae09f9d3a1e1a7b80c1e39ada17954b7.1705244502.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/block.c
drivers/mmc/core/host.c

index 32d49100dff5161407f8c811d6fd12657f25700a..a9b60b91e32f6d145bbbca15229a1ff2bfafe11d 100644 (file)
@@ -206,7 +206,7 @@ static void mmc_blk_kref_release(struct kref *ref)
        int devidx;
 
        devidx = mmc_get_devidx(md->disk);
-       ida_simple_remove(&mmc_blk_ida, devidx);
+       ida_free(&mmc_blk_ida, devidx);
 
        mutex_lock(&open_lock);
        md->disk->private_data = NULL;
@@ -2467,7 +2467,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
        bool cache_enabled = false;
        bool fua_enabled = false;
 
-       devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
+       devidx = ida_alloc_max(&mmc_blk_ida, max_devices - 1, GFP_KERNEL);
        if (devidx < 0) {
                /*
                 * We get -ENOSPC because there are no more any available
@@ -2577,7 +2577,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
  err_kfree:
        kfree(md);
  out:
-       ida_simple_remove(&mmc_blk_ida, devidx);
+       ida_free(&mmc_blk_ida, devidx);
        return ERR_PTR(ret);
 }
 
@@ -2703,7 +2703,7 @@ static void mmc_blk_rpmb_device_release(struct device *dev)
 {
        struct mmc_rpmb_data *rpmb = dev_get_drvdata(dev);
 
-       ida_simple_remove(&mmc_rpmb_ida, rpmb->id);
+       ida_free(&mmc_rpmb_ida, rpmb->id);
        kfree(rpmb);
 }
 
@@ -2719,13 +2719,13 @@ static int mmc_blk_alloc_rpmb_part(struct mmc_card *card,
        struct mmc_rpmb_data *rpmb;
 
        /* This creates the minor number for the RPMB char device */
-       devidx = ida_simple_get(&mmc_rpmb_ida, 0, max_devices, GFP_KERNEL);
+       devidx = ida_alloc_max(&mmc_rpmb_ida, max_devices - 1, GFP_KERNEL);
        if (devidx < 0)
                return devidx;
 
        rpmb = kzalloc(sizeof(*rpmb), GFP_KERNEL);
        if (!rpmb) {
-               ida_simple_remove(&mmc_rpmb_ida, devidx);
+               ida_free(&mmc_rpmb_ida, devidx);
                return -ENOMEM;
        }
 
index cf396e8f34e9860adef0ba6e118f8bc554d4a5f4..7cc9a33d28cacb8532e99862db8e973ac5f2b586 100644 (file)
@@ -76,7 +76,7 @@ static void mmc_host_classdev_release(struct device *dev)
        struct mmc_host *host = cls_dev_to_mmc_host(dev);
        wakeup_source_unregister(host->ws);
        if (of_alias_get_id(host->parent->of_node, "mmc") < 0)
-               ida_simple_remove(&mmc_host_ida, host->index);
+               ida_free(&mmc_host_ida, host->index);
        kfree(host);
 }
 
@@ -538,7 +538,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
                min_idx = mmc_first_nonreserved_index();
                max_idx = 0;
 
-               index = ida_simple_get(&mmc_host_ida, min_idx, max_idx, GFP_KERNEL);
+               index = ida_alloc_range(&mmc_host_ida, min_idx, max_idx - 1,
+                                       GFP_KERNEL);
                if (index < 0) {
                        kfree(host);
                        return NULL;