]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: dw_mmc: Use devm_mmc_alloc_host() helper
authorBinbin Zhou <zhoubinbin@loongson.cn>
Tue, 3 Jun 2025 12:25:54 +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: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/5179b0e39cf2cabbb41ed2de51190913628a7da0.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/dw_mmc.c

index 988492237707882e2fef23cba1a8ad5a326394f9..c5db92bbb0946f5538f0e38df13556ea38aa02b2 100644 (file)
@@ -3008,7 +3008,7 @@ static int dw_mci_init_slot(struct dw_mci *host)
        struct dw_mci_slot *slot;
        int ret;
 
-       mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), host->dev);
+       mmc = devm_mmc_alloc_host(host->dev, sizeof(*slot));
        if (!mmc)
                return -ENOMEM;
 
@@ -3024,18 +3024,18 @@ static int dw_mci_init_slot(struct dw_mci *host)
        /*if there are external regulators, get them*/
        ret = mmc_regulator_get_supply(mmc);
        if (ret)
-               goto err_host_allocated;
+               return ret;
 
        if (!mmc->ocr_avail)
                mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 
        ret = mmc_of_parse(mmc);
        if (ret)
-               goto err_host_allocated;
+               return ret;
 
        ret = dw_mci_init_slot_caps(slot);
        if (ret)
-               goto err_host_allocated;
+               return ret;
 
        /* Useful defaults if platform data is unset. */
        if (host->use_dma == TRANS_MODE_IDMAC) {
@@ -3065,17 +3065,13 @@ static int dw_mci_init_slot(struct dw_mci *host)
 
        ret = mmc_add_host(mmc);
        if (ret)
-               goto err_host_allocated;
+               return ret;
 
 #if defined(CONFIG_DEBUG_FS)
        dw_mci_init_debugfs(slot);
 #endif
 
        return 0;
-
-err_host_allocated:
-       mmc_free_host(mmc);
-       return ret;
 }
 
 static void dw_mci_cleanup_slot(struct dw_mci_slot *slot)
@@ -3083,7 +3079,6 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot)
        /* Debugfs stuff is cleaned up by mmc core */
        mmc_remove_host(slot->mmc);
        slot->host->slot = NULL;
-       mmc_free_host(slot->mmc);
 }
 
 static void dw_mci_init_dma(struct dw_mci *host)