]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mmc: mmci: Use devm_mmc_alloc_host() helper
authorBinbin Zhou <zhoubinbin@loongson.cn>
Tue, 3 Jun 2025 12:26:13 +0000 (20:26 +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: Russell King <linux@armlinux.org.uk>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/f2da882c5c41c25372d82b769506a7dd60fd0d4d.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/mmci.c

index b790c3c3c8f99772010c13497969dfb7edb8020c..c70c64f8adc4d32ae2793735eb00d70a25b10718 100644 (file)
@@ -2223,7 +2223,7 @@ static int mmci_probe(struct amba_device *dev,
                        return -ENOMEM;
        }
 
-       mmc = mmc_alloc_host(sizeof(struct mmci_host), &dev->dev);
+       mmc = devm_mmc_alloc_host(&dev->dev, sizeof(*host));
        if (!mmc)
                return -ENOMEM;
 
@@ -2234,7 +2234,7 @@ static int mmci_probe(struct amba_device *dev,
 
        ret = mmci_of_parse(np, mmc);
        if (ret)
-               goto host_free;
+               return ret;
 
        /*
         * Some variant (STM32) doesn't have opendrain bit, nevertheless
@@ -2242,19 +2242,15 @@ static int mmci_probe(struct amba_device *dev,
         */
        if (!variant->opendrain) {
                host->pinctrl = devm_pinctrl_get(&dev->dev);
-               if (IS_ERR(host->pinctrl)) {
-                       dev_err(&dev->dev, "failed to get pinctrl");
-                       ret = PTR_ERR(host->pinctrl);
-                       goto host_free;
-               }
+               if (IS_ERR(host->pinctrl))
+                       return dev_err_probe(&dev->dev, PTR_ERR(host->pinctrl),
+                                            "failed to get pinctrl\n");
 
                host->pins_opendrain = pinctrl_lookup_state(host->pinctrl,
                                                            MMCI_PINCTRL_STATE_OPENDRAIN);
-               if (IS_ERR(host->pins_opendrain)) {
-                       dev_err(mmc_dev(mmc), "Can't select opendrain pins\n");
-                       ret = PTR_ERR(host->pins_opendrain);
-                       goto host_free;
-               }
+               if (IS_ERR(host->pins_opendrain))
+                       return dev_err_probe(&dev->dev, PTR_ERR(host->pins_opendrain),
+                                            "Can't select opendrain pins\n");
        }
 
        host->hw_designer = amba_manf(dev);
@@ -2263,14 +2259,12 @@ static int mmci_probe(struct amba_device *dev,
        dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision);
 
        host->clk = devm_clk_get(&dev->dev, NULL);
-       if (IS_ERR(host->clk)) {
-               ret = PTR_ERR(host->clk);
-               goto host_free;
-       }
+       if (IS_ERR(host->clk))
+               return PTR_ERR(host->clk);
 
        ret = clk_prepare_enable(host->clk);
        if (ret)
-               goto host_free;
+               return ret;
 
        if (variant->qcom_fifo)
                host->get_rx_fifocnt = mmci_qcom_get_rx_fifocnt;
@@ -2491,8 +2485,6 @@ static int mmci_probe(struct amba_device *dev,
 
  clk_disable:
        clk_disable_unprepare(host->clk);
- host_free:
-       mmc_free_host(mmc);
        return ret;
 }
 
@@ -2522,7 +2514,6 @@ static void mmci_remove(struct amba_device *dev)
 
                mmci_dma_release(host);
                clk_disable_unprepare(host->clk);
-               mmc_free_host(mmc);
        }
 }