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

Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: linux-sunxi@lists.linux.dev
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/ee7726b1ea37084258a5d8cec67cad12473152c2.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sunxi-mmc.c

index 1508eead5d0178ca8d486eddf5b85bfad6c828ee..ee4a65b0a22dceb8fb5c05dafd85435c21464fdb 100644 (file)
@@ -1369,11 +1369,10 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
        struct mmc_host *mmc;
        int ret;
 
-       mmc = mmc_alloc_host(sizeof(struct sunxi_mmc_host), &pdev->dev);
-       if (!mmc) {
-               dev_err(&pdev->dev, "mmc alloc host failed\n");
-               return -ENOMEM;
-       }
+       mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
+       if (!mmc)
+               return dev_err_probe(&pdev->dev, -ENOMEM,
+                                    "mmc alloc host failed\n");
        platform_set_drvdata(pdev, mmc);
 
        host = mmc_priv(mmc);
@@ -1383,15 +1382,13 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
        ret = sunxi_mmc_resource_request(host, pdev);
        if (ret)
-               goto error_free_host;
+               return ret;
 
        host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
                                          &host->sg_dma, GFP_KERNEL);
-       if (!host->sg_cpu) {
-               dev_err(&pdev->dev, "Failed to allocate DMA descriptor mem\n");
-               ret = -ENOMEM;
-               goto error_free_host;
-       }
+       if (!host->sg_cpu)
+               return dev_err_probe(&pdev->dev, -ENOMEM,
+                                    "Failed to allocate DMA descriptor mem\n");
 
        if (host->cfg->ccu_has_timings_switch) {
                /*
@@ -1481,8 +1478,6 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 error_free_dma:
        dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
-error_free_host:
-       mmc_free_host(mmc);
        return ret;
 }
 
@@ -1498,7 +1493,6 @@ static void sunxi_mmc_remove(struct platform_device *pdev)
                sunxi_mmc_disable(host);
        }
        dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
-       mmc_free_host(mmc);
 }
 
 #ifdef CONFIG_PM