]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: cavium: Use devm_mmc_alloc_host() helper
authorBinbin Zhou <zhoubinbin@loongson.cn>
Tue, 3 Jun 2025 12:25:34 +0000 (20:25 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 24 Jun 2025 10:43:22 +0000 (12:43 +0200)
Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Robert Richter <rric@kernel.org>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/9a7715ac3045d925cf2e88e23dca7acb17376468.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/cavium.c

index 95a41983c6c0728026232c14c28a5958675a3bc9..9a55db0e657ce6c70277681158fb4b5f767b0169 100644 (file)
@@ -1012,7 +1012,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
        struct mmc_host *mmc;
        int ret, id;
 
-       mmc = mmc_alloc_host(sizeof(struct cvm_mmc_slot), dev);
+       mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
        if (!mmc)
                return -ENOMEM;
 
@@ -1022,7 +1022,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
 
        ret = cvm_mmc_of_parse(dev, slot);
        if (ret < 0)
-               goto error;
+               return ret;
        id = ret;
 
        /* Set up host parameters */
@@ -1066,12 +1066,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
        if (ret) {
                dev_err(dev, "mmc_add_host() returned %d\n", ret);
                slot->host->slot[id] = NULL;
-               goto error;
        }
-       return 0;
-
-error:
-       mmc_free_host(slot->mmc);
        return ret;
 }
 
@@ -1079,6 +1074,5 @@ int cvm_mmc_of_slot_remove(struct cvm_mmc_slot *slot)
 {
        mmc_remove_host(slot->mmc);
        slot->host->slot[slot->bus_id] = NULL;
-       mmc_free_host(slot->mmc);
        return 0;
 }