]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: tmio: Use devm_mmc_alloc_host() helper
authorBinbin Zhou <zhoubinbin@loongson.cn>
Tue, 3 Jun 2025 12:28:05 +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: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/d7d9120fc1ca2eb014cda4e481af5add05be0bf6.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/renesas_sdhi_core.c
drivers/mmc/host/tmio_mmc.h
drivers/mmc/host/tmio_mmc_core.c
drivers/mmc/host/uniphier-sd.c

index e6fa3ed4256060e390cb7fea63b02d762f176fab..4647d86e145eecae06bfe79b4efe77f209476ead 100644 (file)
@@ -1164,7 +1164,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 
        ret = renesas_sdhi_clk_enable(host);
        if (ret)
-               goto efree;
+               return ret;
 
        rcfg.of_node = of_get_available_child_by_name(dev->of_node, "vqmmc-regulator");
        if (rcfg.of_node) {
@@ -1266,9 +1266,6 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 
 edisclk:
        renesas_sdhi_clk_disable(host);
-efree:
-       tmio_mmc_host_free(host);
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(renesas_sdhi_probe);
@@ -1279,7 +1276,6 @@ void renesas_sdhi_remove(struct platform_device *pdev)
 
        tmio_mmc_host_remove(host);
        renesas_sdhi_clk_disable(host);
-       tmio_mmc_host_free(host);
 }
 EXPORT_SYMBOL_GPL(renesas_sdhi_remove);
 
index 41787ea77a13431d64c8effc5a03b437cc8a5bc9..23b0be8e6d7d08afe88f7cab3a44abfd23527816 100644 (file)
@@ -199,7 +199,6 @@ struct tmio_mmc_host {
 
 struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev,
                                          struct tmio_mmc_data *pdata);
-void tmio_mmc_host_free(struct tmio_mmc_host *host);
 int tmio_mmc_host_probe(struct tmio_mmc_host *host);
 void tmio_mmc_host_remove(struct tmio_mmc_host *host);
 void tmio_mmc_do_data_irq(struct tmio_mmc_host *host);
index b71241f55df57be97c5fb9c491fd489e1fe2a30a..c25c5fec3d77c9043979c8fff69a3b6d664874f2 100644 (file)
@@ -1097,7 +1097,7 @@ struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev,
        if (IS_ERR(ctl))
                return ERR_CAST(ctl);
 
-       mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
+       mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
        if (!mmc)
                return ERR_PTR(-ENOMEM);
 
@@ -1110,29 +1110,17 @@ struct tmio_mmc_host *tmio_mmc_host_alloc(struct platform_device *pdev,
        mmc->ops = &host->ops;
 
        ret = mmc_of_parse(host->mmc);
-       if (ret) {
-               host = ERR_PTR(ret);
-               goto free;
-       }
+       if (ret)
+               return ERR_PTR(ret);
 
        tmio_mmc_of_parse(pdev, mmc);
 
        platform_set_drvdata(pdev, host);
 
-       return host;
-free:
-       mmc_free_host(mmc);
-
        return host;
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_host_alloc);
 
-void tmio_mmc_host_free(struct tmio_mmc_host *host)
-{
-       mmc_free_host(host->mmc);
-}
-EXPORT_SYMBOL_GPL(tmio_mmc_host_free);
-
 int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 {
        struct platform_device *pdev = _host->pdev;
index 4ad02cfdc23897d7006beae020734a61c1a22d1f..1eae2f4b6c1f924850b69939f8a0f58a5004d3e7 100644 (file)
@@ -663,8 +663,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
                priv->rst_hw = devm_reset_control_get_exclusive(dev, "hw");
                if (IS_ERR(priv->rst_hw)) {
                        dev_err(dev, "failed to get hw reset\n");
-                       ret = PTR_ERR(priv->rst_hw);
-                       goto free_host;
+                       return PTR_ERR(priv->rst_hw);
                }
                host->ops.card_hw_reset = uniphier_sd_hw_reset;
        }
@@ -694,7 +693,7 @@ static int uniphier_sd_probe(struct platform_device *pdev)
 
        ret = uniphier_sd_clk_enable(host);
        if (ret)
-               goto free_host;
+               return ret;
 
        uniphier_sd_host_init(host);
 
@@ -720,8 +719,6 @@ static int uniphier_sd_probe(struct platform_device *pdev)
 
 disable_clk:
        uniphier_sd_clk_disable(host);
-free_host:
-       tmio_mmc_host_free(host);
 
        return ret;
 }
@@ -732,7 +729,6 @@ static void uniphier_sd_remove(struct platform_device *pdev)
 
        tmio_mmc_host_remove(host);
        uniphier_sd_clk_disable(host);
-       tmio_mmc_host_free(host);
 }
 
 static const struct of_device_id uniphier_sd_match[] = {