Skip to contentSkip to conversation

mmc: Cleanup sdhci_pltfm_free()/sdhci_free_host() usage

PATCH Superseded Binbin Zhou 7 participants 42 messages May 29, 2025 – Jun 3, 2025

Subsystems (30)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover mmc: Cleanup sdhci_pltfm_free()/sdhci_free_host() usage

Hi all:

After the first part of the cleanup[1], there are sdhci related drivers that need further cleanup.

This patchset is the second part of the cleanup series, and since sdhci has sdhci_alloc_host() as the general interface, our main job is to clean up sdhci_pltfm_free() and sdhci_free_host().

[1]:https://lore.kernel.org/all/[email protected]/

Thanks.

-----
V2:
- Collect Reviewed-by and Acked-by tags.
Patch-01:
- Set sdhci_free_host() to empty, rather than dropping it.
Patch-07:
- Set sdhci_pltfm_free() to empty, rather than dropping it.
Patch-22:
- As requested by Yixun, keep the goto scheme.
Patch-35:
- New patch;
- Since all calls have been cleaned up, sdhci_pltfm_free()/sdhci_free_host() are now dropped directly;

Link to V1:
https://lore.kernel.org/all/[email protected]/

Binbin Zhou (35):
mmc: sdhci: Use devm_mmc_alloc_host() helper
mmc: sdhci-acpi: Drop the use of sdhci_free_host()
mmc: sdhci-milbeaut: Drop the use of sdhci_free_host()
mmc: sdhci-pci: Drop the use of sdhci_free_host()
mmc: sdhci-s3c: Drop the use of sdhci_free_host()
mmc: sdhci-spear: Drop the use of sdhci_free_host()
mmc: sdhci-pltfm: Drop the use of sdhci_pltfm_free()
mmc: sdhci-bcm-kona: Drop the use of sdhci_pltfm_free()
mmc: sdhci-brcmstb: Drop the use of sdhci_pltfm_free()
mmc: sdhci-cadence: Drop the use of sdhci_pltfm_free()
mmc: sdhci-dove: Drop the use of sdhci_pltfm_free()
mmc: sdhci-esdhc-imx: Drop the use of sdhci_pltfm_free()
mmc: sdhci-esdhc-mcf: Drop the use of sdhci_pltfm_free()
mmc: sdhci-iproc: Drop the use of sdhci_pltfm_free()
mmc: sdhci-msm: Drop the use of sdhci_pltfm_free()
mmc: sdhci-npcm: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-arasan: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-aspeed: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-at91: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-dwcmshc: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-esdhc: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-k1: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-ma35d1: Drop the use of sdhci_pltfm_free()
mmc: sdhci-of-sparx5: Drop the use of sdhci_pltfm_free()
mmc: sdhci-omap: Drop the use of sdhci_pltfm_free()
mmc: sdhci-pic32: Drop the use of sdhci_pltfm_free()
mmc: sdhci-pxav2: Drop the use of sdhci_pltfm_free()
mmc: sdhci-pxav3: Drop the use of sdhci_pltfm_free()
mmc: sdhci-sprd: Drop the use of sdhci_pltfm_free()
mmc: sdhci-st: Drop the use of sdhci_pltfm_free()
mmc: sdhci-tegra: Drop the use of sdhci_pltfm_free()
mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()
mmc: sdhci_am654: Drop the use of sdhci_pltfm_free()
mmc: sdhci_f_sdh30: Drop the use of sdhci_pltfm_free()
mmc: sdhci: Drop sdhci_free_host()/sdhci_pltfm_free() definitions

 drivers/mmc/host/sdhci-acpi.c       |  3 ---
 drivers/mmc/host/sdhci-bcm-kona.c   |  2 --
 drivers/mmc/host/sdhci-brcmstb.c    |  1 -
 drivers/mmc/host/sdhci-cadence.c    | 21 ++++++------------
 drivers/mmc/host/sdhci-dove.c       | 12 ++---------
 drivers/mmc/host/sdhci-esdhc-imx.c  |  3 ---
 drivers/mmc/host/sdhci-esdhc-mcf.c  | 25 ++++++----------------
 drivers/mmc/host/sdhci-iproc.c      | 18 ++++------------
 drivers/mmc/host/sdhci-milbeaut.c   | 19 ++++++-----------
 drivers/mmc/host/sdhci-msm.c        | 11 ++++------
 drivers/mmc/host/sdhci-npcm.c       | 15 +++----------
 drivers/mmc/host/sdhci-of-arasan.c  | 26 +++++++----------------
 drivers/mmc/host/sdhci-of-aspeed.c  | 10 ++-------
 drivers/mmc/host/sdhci-of-at91.c    | 23 +++++++-------------
 drivers/mmc/host/sdhci-of-dwcmshc.c | 14 +++++-------
 drivers/mmc/host/sdhci-of-esdhc.c   | 11 ++--------
 drivers/mmc/host/sdhci-of-k1.c      |  1 -
 drivers/mmc/host/sdhci-of-ma35d1.c  | 23 +++++++-------------
 drivers/mmc/host/sdhci-of-sparx5.c  | 24 +++++++--------------
 drivers/mmc/host/sdhci-omap.c       | 21 ++++++------------
 drivers/mmc/host/sdhci-pci-core.c   |  9 ++------
 drivers/mmc/host/sdhci-pic32.c      |  9 +++-----
 drivers/mmc/host/sdhci-pltfm.c      | 16 +-------------
 drivers/mmc/host/sdhci-pltfm.h      |  1 -
 drivers/mmc/host/sdhci-pxav2.c      | 26 ++++++-----------------
 drivers/mmc/host/sdhci-pxav3.c      |  7 +-----
 drivers/mmc/host/sdhci-s3c.c        | 16 ++++----------
 drivers/mmc/host/sdhci-spear.c      | 11 ++++------
 drivers/mmc/host/sdhci-sprd.c       | 33 +++++++++--------------------
 drivers/mmc/host/sdhci-st.c         |  6 ++----
 drivers/mmc/host/sdhci-tegra.c      |  9 +++-----
 drivers/mmc/host/sdhci-xenon.c      |  9 ++------
 drivers/mmc/host/sdhci.c            |  9 +-------
 drivers/mmc/host/sdhci.h            |  1 -
 drivers/mmc/host/sdhci_am654.c      | 20 ++++++-----------
 drivers/mmc/host/sdhci_f_sdh30.c    | 13 ++++--------
 36 files changed, 129 insertions(+), 349 deletions(-)

base-commit: d2c6acff6386f43ed307822454b970c831c48f1b

Signature · 1 line
2.47.1
#1 lore raw

PATCH v2 1/35 mmc: sdhci: Use devm_mmc_alloc_host() helper

Use new function devm_mmc_alloc_host() to simplify the code.

Although sdhci_free_host() is no longer needed, to avoid drivers that still use this function from failing to compile, sdhci_free_host() is temporarily set to empty. Finally, it will be removed when there are no more callers.

---
 drivers/mmc/host/sdhci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +1 -2
index 32fa0b2bb912..ee5a5ae4db31 100644
@@ -4076,7 +4076,7 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 
 	WARN_ON(dev == NULL);
 
-	mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(struct sdhci_host) + priv_size);
 	if (!mmc)
 		return ERR_PTR(-ENOMEM);
 
@@ -5002,7 +5002,6 @@ EXPORT_SYMBOL_GPL(sdhci_remove_host);
 
 void sdhci_free_host(struct sdhci_host *host)
 {
-	mmc_free_host(host->mmc);
 }
 
 EXPORT_SYMBOL_GPL(sdhci_free_host);
Signature · 1 line
2.47.1
#2 lore raw

PATCH v2 2/35 mmc: sdhci-acpi: Drop the use of sdhci_free_host()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_free_host() is no longer needed.

---
 drivers/mmc/host/sdhci-acpi.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/mmc/host/sdhci-acpi.c +0 -3
index e6c5c82f64fa..1e38a881a859 100644
@@ -948,7 +948,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
 	if (c->slot && c->slot->free_slot)
 		c->slot->free_slot(pdev);
 
-	sdhci_free_host(c->host);
 	return err;
 }
 
@@ -972,8 +971,6 @@ static void sdhci_acpi_remove(struct platform_device *pdev)
 
 	if (c->slot && c->slot->free_slot)
 		c->slot->free_slot(pdev);
-
-	sdhci_free_host(c->host);
 }
 
 static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
Signature · 1 line
2.47.1
#3 lore raw

PATCH v2 3/35 mmc: sdhci-milbeaut: Drop the use of sdhci_free_host()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_free_host() is no longer needed.

Cc Taichi Sugaya <[email protected]>
Cc Takao Orito <[email protected]>
---
 drivers/mmc/host/sdhci-milbeaut.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-milbeaut.c +6 -13
index a4675456f9c7..bda71d5966dc 100644
@@ -258,7 +258,7 @@ static int sdhci_milbeaut_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err;
+		return ret;
 
 	platform_set_drvdata(pdev, host);
 
@@ -267,23 +267,19 @@ static int sdhci_milbeaut_probe(struct platform_device *pdev)
 	host->irq = irq;
 
 	host->ioaddr = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(host->ioaddr)) {
-		ret = PTR_ERR(host->ioaddr);
-		goto err;
-	}
+	if (IS_ERR(host->ioaddr))
+		return PTR_ERR(host->ioaddr);
 
 	if (dev_of_node(dev)) {
 		sdhci_get_of_property(pdev);
 
 		priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
-		if (IS_ERR(priv->clk_iface)) {
-			ret = PTR_ERR(priv->clk_iface);
-			goto err;
-		}
+		if (IS_ERR(priv->clk_iface))
+			return PTR_ERR(priv->clk_iface);
 
 		ret = clk_prepare_enable(priv->clk_iface);
 		if (ret)
-			goto err;
+			return ret;
 
 		priv->clk = devm_clk_get(&pdev->dev, "core");
 		if (IS_ERR(priv->clk)) {
@@ -308,8 +304,6 @@ static int sdhci_milbeaut_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk);
 err_clk:
 	clk_disable_unprepare(priv->clk_iface);
-err:
-	sdhci_free_host(host);
 	return ret;
 }
 
@@ -324,7 +318,6 @@ static void sdhci_milbeaut_remove(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk_iface);
 	clk_disable_unprepare(priv->clk);
 
-	sdhci_free_host(host);
 	platform_set_drvdata(pdev, NULL);
 }
 
Signature · 1 line
2.47.1
#4 lore raw

PATCH v2 4/35 mmc: sdhci-pci: Drop the use of sdhci_free_host()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_free_host() is no longer needed.

---
 drivers/mmc/host/sdhci-pci-core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-pci-core.c +2 -7
index 13a84b9309e0..9f567b768c42 100644
@@ -2173,7 +2173,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	ret = pcim_iomap_regions(pdev, BIT(bar), mmc_hostname(host->mmc));
 	if (ret) {
 		dev_err(&pdev->dev, "cannot request region\n");
-		goto cleanup;
+		return ERR_PTR(ret);
 	}
 
 	host->ioaddr = pcim_iomap_table(pdev)[bar];
@@ -2181,7 +2181,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	if (chip->fixes && chip->fixes->probe_slot) {
 		ret = chip->fixes->probe_slot(slot);
 		if (ret)
-			goto cleanup;
+			return ERR_PTR(ret);
 	}
 
 	host->mmc->pm_caps = MMC_PM_KEEP_POWER;
@@ -2242,9 +2242,6 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	if (chip->fixes && chip->fixes->remove_slot)
 		chip->fixes->remove_slot(slot, 0);
 
-cleanup:
-	sdhci_free_host(host);
-
 	return ERR_PTR(ret);
 }
 
@@ -2265,8 +2262,6 @@ static void sdhci_pci_remove_slot(struct sdhci_pci_slot *slot)
 
 	if (slot->chip->fixes && slot->chip->fixes->remove_slot)
 		slot->chip->fixes->remove_slot(slot, dead);
-
-	sdhci_free_host(slot->host);
 }
 
 int sdhci_pci_uhs2_add_host(struct sdhci_pci_slot *slot)
Signature · 1 line
2.47.1
#5 lore raw

PATCH v2 5/35 mmc: sdhci-s3c: Drop the use of sdhci_free_host()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_free_host() is no longer needed.

Cc Ben Dooks <[email protected]>
Cc Jaehoon Chung <[email protected]>
---
 drivers/mmc/host/sdhci-s3c.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-s3c.c +4 -12
index bdf4dc0d6b77..51d20d483acd 100644
@@ -507,15 +507,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 	sc = sdhci_priv(host);
 
 	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		ret = -ENOMEM;
-		goto err_pdata_io_clk;
-	}
+	if (!pdata)
+		return -ENOMEM;
 
 	if (pdev->dev.of_node) {
 		ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata);
 		if (ret)
-			goto err_pdata_io_clk;
+			return ret;
 	} else {
 		memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata));
 	}
@@ -532,8 +530,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 	sc->clk_io = devm_clk_get(dev, "hsmmc");
 	if (IS_ERR(sc->clk_io)) {
 		dev_err(dev, "failed to get io clock\n");
-		ret = PTR_ERR(sc->clk_io);
-		goto err_pdata_io_clk;
+		return PTR_ERR(sc->clk_io);
 	}
 
 	/* enable the local io clock and keep it running for the moment. */
@@ -661,9 +658,6 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
  err_no_busclks:
 	clk_disable_unprepare(sc->clk_io);
 
- err_pdata_io_clk:
-	sdhci_free_host(host);
-
 	return ret;
 }
 
@@ -685,8 +679,6 @@ static void sdhci_s3c_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 
 	clk_disable_unprepare(sc->clk_io);
-
-	sdhci_free_host(host);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#6 lore raw

PATCH v2 6/35 mmc: sdhci-spear: Drop the use of sdhci_free_host()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_free_host() is no longer needed.

---
 drivers/mmc/host/sdhci-spear.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-spear.c +4 -7
index 770dc12b9ae9..fa0f8aeb7ee0 100644
@@ -59,7 +59,7 @@ static int sdhci_probe(struct platform_device *pdev)
 	if (IS_ERR(host->ioaddr)) {
 		ret = PTR_ERR(host->ioaddr);
 		dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret);
-		goto err_host;
+		goto err;
 	}
 
 	host->hw_name = "sdhci";
@@ -67,7 +67,7 @@ static int sdhci_probe(struct platform_device *pdev)
 	host->irq = platform_get_irq(pdev, 0);
 	if (host->irq < 0) {
 		ret = host->irq;
-		goto err_host;
+		goto err;
 	}
 	host->quirks = SDHCI_QUIRK_BROKEN_ADMA;
 
@@ -78,13 +78,13 @@ static int sdhci_probe(struct platform_device *pdev)
 	if (IS_ERR(sdhci->clk)) {
 		ret = PTR_ERR(sdhci->clk);
 		dev_dbg(&pdev->dev, "Error getting clock\n");
-		goto err_host;
+		goto err;
 	}
 
 	ret = clk_prepare_enable(sdhci->clk);
 	if (ret) {
 		dev_dbg(&pdev->dev, "Error enabling clock\n");
-		goto err_host;
+		goto err;
 	}
 
 	ret = clk_set_rate(sdhci->clk, 50000000);
@@ -110,8 +110,6 @@ static int sdhci_probe(struct platform_device *pdev)
 
 disable_clk:
 	clk_disable_unprepare(sdhci->clk);
-err_host:
-	sdhci_free_host(host);
 err:
 	dev_err(&pdev->dev, "spear-sdhci probe failed: %d\n", ret);
 	return ret;
@@ -130,7 +128,6 @@ static void sdhci_remove(struct platform_device *pdev)
 
 	sdhci_remove_host(host, dead);
 	clk_disable_unprepare(sdhci->clk);
-	sdhci_free_host(host);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#7 lore raw

PATCH v2 7/35 mmc: sdhci-pltfm: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

To avoid causing drivers that still use sdhci_pltfm_free() to fail to compile, it has been temporarily set to empty. And it will be removed when there are no longer any callers.

---
 drivers/mmc/host/sdhci-pltfm.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +1 -10
index 62753d72198a..aedbcd32713a 100644
@@ -148,9 +148,6 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_init);
 
 void sdhci_pltfm_free(struct platform_device *pdev)
 {
-	struct sdhci_host *host = platform_get_drvdata(pdev);
-
-	sdhci_free_host(host);
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_free);
 
@@ -159,7 +156,6 @@ int sdhci_pltfm_init_and_add_host(struct platform_device *pdev,
 				  size_t priv_size)
 {
 	struct sdhci_host *host;
-	int ret = 0;
 
 	host = sdhci_pltfm_init(pdev, pdata, priv_size);
 	if (IS_ERR(host))
@@ -167,11 +163,7 @@ int sdhci_pltfm_init_and_add_host(struct platform_device *pdev,
 
 	sdhci_get_property(pdev);
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		sdhci_pltfm_free(pdev);
-
-	return ret;
+	return sdhci_add_host(host);
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_init_and_add_host);
 
@@ -181,7 +173,6 @@ void sdhci_pltfm_remove(struct platform_device *pdev)
 	int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
 
 	sdhci_remove_host(host, dead);
-	sdhci_pltfm_free(pdev);
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_remove);
 
Signature · 1 line
2.47.1
#8 lore raw

PATCH v2 8/35 mmc: sdhci-bcm-kona: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Florian Fainelli <[email protected]>
Cc Ray Jui <[email protected]>
Cc Scott Branden <[email protected]>
---
 drivers/mmc/host/sdhci-bcm-kona.c | 2 --
 1 file changed, 2 deletions(-)
drivers/mmc/host/sdhci-bcm-kona.c +0 -2
index fda911fb28e5..0f2a84f769b6 100644
@@ -304,8 +304,6 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
 	clk_disable_unprepare(pltfm_priv->clk);
 
 err_pltfm_free:
-	sdhci_pltfm_free(pdev);
-
 	dev_err(dev, "Probing of sdhci-pltfm failed: %d\n", ret);
 	return ret;
 }
Signature · 1 line
2.47.1
#9 lore raw

PATCH v2 9/35 mmc: sdhci-brcmstb: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Kamal Dasu <[email protected]>
Cc Al Cooper <[email protected]>
Cc Florian Fainelli <[email protected]>
---
 drivers/mmc/host/sdhci-brcmstb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +0 -1
index 48cdcba0f39c..efc2f3bdc631 100644
@@ -485,7 +485,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	return res;
 
 err:
-	sdhci_pltfm_free(pdev);
 	clk_disable_unprepare(base_clk);
 	return res;
 }
Signature · 1 line
2.47.1
#10 lore raw

PATCH v2 10/35 mmc: sdhci-cadence: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-cadence.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/mmc/host/sdhci-cadence.c +6 -15
index a94b297fcf2a..a37e6a1f5127 100644
@@ -515,7 +515,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	if (data->init) {
 		ret = data->init(pdev);
 		if (ret)
-			goto free;
+			return ret;
 	}
 	sdhci_enable_v4_mode(host);
 	__sdhci_read_caps(host, &version, NULL, NULL);
@@ -524,33 +524,24 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto free;
+		return ret;
 
 	sdhci_cdns_phy_param_parse(dev->of_node, priv);
 
 	ret = sdhci_cdns_phy_init(priv);
 	if (ret)
-		goto free;
+		return ret;
 
 	if (host->mmc->caps & MMC_CAP_HW_RESET) {
 		priv->rst_hw = devm_reset_control_get_optional_exclusive(dev, NULL);
-		if (IS_ERR(priv->rst_hw)) {
-			ret = dev_err_probe(mmc_dev(host->mmc), PTR_ERR(priv->rst_hw),
+		if (IS_ERR(priv->rst_hw))
+			return dev_err_probe(mmc_dev(host->mmc), PTR_ERR(priv->rst_hw),
 					    "reset controller error\n");
-			goto free;
-		}
 		if (priv->rst_hw)
 			host->mmc_host_ops.card_hw_reset = sdhci_cdns_mmc_hw_reset;
 	}
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto free;
-
-	return 0;
-free:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#11 lore raw

PATCH v2 11/35 mmc: sdhci-dove: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-dove.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-dove.c +2 -10
index 77034b13fa66..dbfaee4a5ada 100644
@@ -79,17 +79,9 @@ static int sdhci_dove_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err_sdhci_add;
+		return ret;
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto err_sdhci_add;
-
-	return 0;
-
-err_sdhci_add:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 static const struct of_device_id sdhci_dove_of_match_table[] = {
Signature · 1 line
2.47.1
#12 lore raw

PATCH v2 12/35 mmc: sdhci-esdhc-imx: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Haibo Chen <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -3
index ac187a8798b7..011b60d21a80 100644
@@ -1973,7 +1973,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 free_sdhci:
 	if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
-	sdhci_pltfm_free(pdev);
 	return err;
 }
 
@@ -1997,8 +1996,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device *pdev)
 
 	if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
-
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
maintainer Reviewed-by on v2 12/35
#13 lore raw

RE: [PATCH v2 12/35] mmc: sdhci-esdhc-imx: Drop the use of sdhci_pltfm_free()

Quoted 14 lines

-----Original Message-----
From: Binbin Zhou <[email protected]>
Sent: 2025年5月29日 20:59
To: Binbin Zhou <[email protected]>; Huacai Chen <[email protected]>; Ulf Hansson <[email protected]>; Adrian Hunter <[email protected]>
Cc: Huacai Chen <[email protected]>; [email protected]; Andrew Jeffery <[email protected]>; Binbin Zhou <[email protected]>; Bough Chen <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Fabio Estevam <[email protected]>; [email protected]
Subject: [PATCH v2 12/35] mmc: sdhci-esdhc-imx: Drop the use of sdhci_pltfm_free()

Quoted 2 lines

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Thanks
Haibo

Quoted 37 lines
Cc Haibo Chen <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -3
index ac187a8798b7..011b60d21a80 100644
@@ -1973,7 +1973,6 @@ static int sdhci_esdhc_imx_probe(struct
 platform_device *pdev)
 free_sdhci:
 	if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
-	sdhci_pltfm_free(pdev);
 	return err;
 }
@@ -1997,8 +1996,6 @@ static void sdhci_esdhc_imx_remove(struct
 platform_device *pdev)
 
 	if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
-
-	sdhci_pltfm_free(pdev);
 }
 

#ifdef CONFIG_PM_SLEEP
--
2.47.1

#14 lore raw

PATCH v2 13/35 mmc: sdhci-esdhc-mcf: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-esdhc-mcf.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/mmc/host/sdhci-esdhc-mcf.c +7 -18
index 327662ba5bd9..375fce5639d7 100644
@@ -426,28 +426,22 @@ static int sdhci_esdhc_mcf_probe(struct platform_device *pdev)
 	host->flags |= SDHCI_AUTO_CMD12;
 
 	mcf_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(mcf_data->clk_ipg)) {
-		err = PTR_ERR(mcf_data->clk_ipg);
-		goto err_exit;
-	}
+	if (IS_ERR(mcf_data->clk_ipg))
+		return PTR_ERR(mcf_data->clk_ipg);
 
 	mcf_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
-	if (IS_ERR(mcf_data->clk_ahb)) {
-		err = PTR_ERR(mcf_data->clk_ahb);
-		goto err_exit;
-	}
+	if (IS_ERR(mcf_data->clk_ahb))
+		return PTR_ERR(mcf_data->clk_ahb);
 
 	mcf_data->clk_per = devm_clk_get(&pdev->dev, "per");
-	if (IS_ERR(mcf_data->clk_per)) {
-		err = PTR_ERR(mcf_data->clk_per);
-		goto err_exit;
-	}
+	if (IS_ERR(mcf_data->clk_per))
+		return PTR_ERR(mcf_data->clk_per);
 
 	pltfm_host->clk = mcf_data->clk_per;
 	pltfm_host->clock = clk_get_rate(pltfm_host->clk);
 	err = clk_prepare_enable(mcf_data->clk_per);
 	if (err)
-		goto err_exit;
+		return err;
 
 	err = clk_prepare_enable(mcf_data->clk_ipg);
 	if (err)
@@ -485,9 +479,6 @@ static int sdhci_esdhc_mcf_probe(struct platform_device *pdev)
 	clk_disable_unprepare(mcf_data->clk_ipg);
 unprep_per:
 	clk_disable_unprepare(mcf_data->clk_per);
-err_exit:
-	sdhci_pltfm_free(pdev);
-
 	return err;
 }
 
@@ -502,8 +493,6 @@ static void sdhci_esdhc_mcf_remove(struct platform_device *pdev)
 	clk_disable_unprepare(mcf_data->clk_ipg);
 	clk_disable_unprepare(mcf_data->clk_ahb);
 	clk_disable_unprepare(mcf_data->clk_per);
-
-	sdhci_pltfm_free(pdev);
 }
 
 static struct platform_driver sdhci_esdhc_mcf_driver = {
Signature · 1 line
2.47.1
#15 lore raw

PATCH v2 14/35 mmc: sdhci-iproc: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Ray Jui <[email protected]>
Cc Scott Branden <[email protected]>
---
 drivers/mmc/host/sdhci-iproc.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci-iproc.c +4 -14
index 80b2567a488b..35ef5c5f5146 100644
@@ -379,7 +379,7 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err;
+		return ret;
 
 	sdhci_get_property(pdev);
 
@@ -387,10 +387,8 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
 
 	if (dev->of_node) {
 		pltfm_host->clk = devm_clk_get_enabled(dev, NULL);
-		if (IS_ERR(pltfm_host->clk)) {
-			ret = PTR_ERR(pltfm_host->clk);
-			goto err;
-		}
+		if (IS_ERR(pltfm_host->clk))
+			return PTR_ERR(pltfm_host->clk);
 	}
 
 	if (iproc_host->data->missing_caps) {
@@ -399,15 +397,7 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
 				  &iproc_host->data->caps1);
 	}
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto err;
-
-	return 0;
-
-err:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 static void sdhci_iproc_shutdown(struct platform_device *pdev)
Signature · 1 line
2.47.1
#16 lore raw

PATCH v2 15/35 mmc: sdhci-msm: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-msm.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-msm.c +4 -7
index 57bd49eea777..d60454f28b86 100644
@@ -2530,7 +2530,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto pltfm_free;
+		return ret;
 
 	/*
 	 * Based on the compatible string, load the required msm host info from
@@ -2552,7 +2552,7 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 
 	ret = sdhci_msm_gcc_reset(&pdev->dev, host);
 	if (ret)
-		goto pltfm_free;
+		return ret;
 
 	/* Setup SDCC bus voter clock. */
 	msm_host->bus_clk = devm_clk_get(&pdev->dev, "bus");
@@ -2560,10 +2560,10 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 		/* Vote for max. clk rate for max. performance */
 		ret = clk_set_rate(msm_host->bus_clk, INT_MAX);
 		if (ret)
-			goto pltfm_free;
+			return ret;
 		ret = clk_prepare_enable(msm_host->bus_clk);
 		if (ret)
-			goto pltfm_free;
+			return ret;
 	}
 
 	/* Setup main peripheral bus clock */
@@ -2769,8 +2769,6 @@ static int sdhci_msm_probe(struct platform_device *pdev)
 bus_clk_disable:
 	if (!IS_ERR(msm_host->bus_clk))
 		clk_disable_unprepare(msm_host->bus_clk);
-pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -2792,7 +2790,6 @@ static void sdhci_msm_remove(struct platform_device *pdev)
 				   msm_host->bulk_clks);
 	if (!IS_ERR(msm_host->bus_clk))
 		clk_disable_unprepare(msm_host->bus_clk);
-	sdhci_pltfm_free(pdev);
 }
 
 static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev)
Signature · 1 line
2.47.1
#17 lore raw

PATCH v2 16/35 mmc: sdhci-npcm: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Avi Fishman <[email protected]>
Cc Tomer Maimon <[email protected]>
Cc Tali Perry <[email protected]>
Cc Patrick Venture <[email protected]>
Cc Nancy Yuen <[email protected]>
Cc Benjamin Fair <[email protected]>
---
 drivers/mmc/host/sdhci-npcm.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-npcm.c +3 -12
index bee0585ba5c1..71b635dfdf1d 100644
@@ -48,8 +48,7 @@ static int npcm_sdhci_probe(struct platform_device *pdev)
 
 	pltfm_host->clk = devm_clk_get_optional_enabled(dev, NULL);
 	if (IS_ERR(pltfm_host->clk)) {
-		ret = PTR_ERR(pltfm_host->clk);
-		goto err_sdhci;
+		return PTR_ERR(pltfm_host->clk);
 	}
 
 	caps = sdhci_readl(host, SDHCI_CAPABILITIES);
@@ -58,17 +57,9 @@ static int npcm_sdhci_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err_sdhci;
+		return ret;
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto err_sdhci;
-
-	return 0;
-
-err_sdhci:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 static const struct of_device_id npcm_sdhci_of_match[] = {
Signature · 1 line
2.47.1
#18 lore raw

PATCH v2 17/35 mmc: sdhci-of-arasan: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-of-arasan.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)
drivers/mmc/host/sdhci-of-arasan.c +8 -18
index 8c29676ab662..42878474e56e 100644
@@ -1883,34 +1883,26 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 		sdhci_arasan->soc_ctl_base = syscon_node_to_regmap(node);
 		of_node_put(node);
 
-		if (IS_ERR(sdhci_arasan->soc_ctl_base)) {
-			ret = dev_err_probe(dev,
+		if (IS_ERR(sdhci_arasan->soc_ctl_base))
+			return dev_err_probe(dev,
 					    PTR_ERR(sdhci_arasan->soc_ctl_base),
 					    "Can't get syscon\n");
-			goto err_pltfm_free;
-		}
 	}
 
 	sdhci_get_of_property(pdev);
 
 	sdhci_arasan->clk_ahb = devm_clk_get(dev, "clk_ahb");
-	if (IS_ERR(sdhci_arasan->clk_ahb)) {
-		ret = dev_err_probe(dev, PTR_ERR(sdhci_arasan->clk_ahb),
+	if (IS_ERR(sdhci_arasan->clk_ahb))
+		return dev_err_probe(dev, PTR_ERR(sdhci_arasan->clk_ahb),
 				    "clk_ahb clock not found.\n");
-		goto err_pltfm_free;
-	}
 
 	clk_xin = devm_clk_get(dev, "clk_xin");
-	if (IS_ERR(clk_xin)) {
-		ret = dev_err_probe(dev, PTR_ERR(clk_xin), "clk_xin clock not found.\n");
-		goto err_pltfm_free;
-	}
+	if (IS_ERR(clk_xin))
+		return dev_err_probe(dev, PTR_ERR(clk_xin), "clk_xin clock not found.\n");
 
 	ret = clk_prepare_enable(sdhci_arasan->clk_ahb);
-	if (ret) {
-		dev_err(dev, "Unable to enable AHB clock.\n");
-		goto err_pltfm_free;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Unable to enable AHB clock.\n");
 
 	/* If clock-frequency property is set, use the provided value */
 	if (pltfm_host->clock &&
@@ -2029,8 +2021,6 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
 	clk_disable_unprepare(clk_xin);
 clk_dis_ahb:
 	clk_disable_unprepare(sdhci_arasan->clk_ahb);
-err_pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
Signature · 1 line
2.47.1
#19 lore raw

PATCH v2 18/35 mmc: sdhci-of-aspeed: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-of-aspeed.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci-of-aspeed.c +2 -8
index d6de010551b9..ca97b01996b1 100644
@@ -425,10 +425,8 @@ static int aspeed_sdhci_probe(struct platform_device *pdev)
 		return PTR_ERR(pltfm_host->clk);
 
 	ret = clk_prepare_enable(pltfm_host->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Unable to enable SDIO clock\n");
-		goto err_pltfm_free;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Unable to enable SDIO clock\n");
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
@@ -445,8 +443,6 @@ static int aspeed_sdhci_probe(struct platform_device *pdev)
 
 err_sdhci_add:
 	clk_disable_unprepare(pltfm_host->clk);
-err_pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -461,8 +457,6 @@ static void aspeed_sdhci_remove(struct platform_device *pdev)
 	sdhci_remove_host(host, 0);
 
 	clk_disable_unprepare(pltfm_host->clk);
-
-	sdhci_pltfm_free(pdev);
 }
 
 static const struct aspeed_sdhci_pdata ast2400_sdhci_pdata = {
Signature · 1 line
2.47.1
#20 lore raw

PATCH v2 19/35 mmc: sdhci-of-at91: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Aubin Constans <[email protected]>
Cc Eugen Hristev <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Claudiu Beznea <[email protected]>
---
 drivers/mmc/host/sdhci-of-at91.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +8 -15
index 97988ed37467..0b7d7db79139 100644
@@ -337,28 +337,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
 			priv->mainck = NULL;
 		} else {
 			dev_err(&pdev->dev, "failed to get baseclk\n");
-			ret = PTR_ERR(priv->mainck);
-			goto sdhci_pltfm_free;
+			return PTR_ERR(priv->mainck);
 		}
 	}
 
 	priv->hclock = devm_clk_get(&pdev->dev, "hclock");
-	if (IS_ERR(priv->hclock)) {
-		dev_err(&pdev->dev, "failed to get hclock\n");
-		ret = PTR_ERR(priv->hclock);
-		goto sdhci_pltfm_free;
-	}
+	if (IS_ERR(priv->hclock))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->hclock),
+				     "failed to get hclock\n");
 
 	priv->gck = devm_clk_get(&pdev->dev, "multclk");
-	if (IS_ERR(priv->gck)) {
-		dev_err(&pdev->dev, "failed to get multclk\n");
-		ret = PTR_ERR(priv->gck);
-		goto sdhci_pltfm_free;
-	}
+	if (IS_ERR(priv->gck))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->gck),
+				     "failed to get multclk\n");
 
 	ret = sdhci_at91_set_clks_presets(&pdev->dev);
 	if (ret)
-		goto sdhci_pltfm_free;
+		return ret;
 
 	priv->restore_needed = false;
 
@@ -438,8 +433,6 @@ static int sdhci_at91_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->gck);
 	clk_disable_unprepare(priv->mainck);
 	clk_disable_unprepare(priv->hclock);
-sdhci_pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
Signature · 1 line
2.47.1
maintainer
#21 lore raw

Re: [PATCH v2 19/35] mmc: sdhci-of-at91: Drop the use of sdhci_pltfm_free()

Hi Binbin,

Thank you for the change.

Quoted 18 lines · Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Aubin Constans <[email protected]>
Cc Eugen Hristev <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Claudiu Beznea <[email protected]>
---
  drivers/mmc/host/sdhci-of-at91.c | 23 ++++++++---------------
  1 file changed, 8 insertions(+), 15 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +0 -0
index 97988ed37467..0b7d7db79139 100644

drivers/mmc/host/sdhci-of-at91.c static int sdhci_at91_probe(struct platform_device *pdev) · line 342

Quoted 8 lines
drivers/mmc/host/sdhci-of-at91.c +1 -2
@@ -337,28 +337,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
                         priv->mainck = NULL;
                 } else {
                         dev_err(&pdev->dev, "failed to get baseclk\n");
-                       ret = PTR_ERR(priv->mainck);
-                       goto sdhci_pltfm_free;
+                       return PTR_ERR(priv->mainck);
                 }
         }

For consistency with the changes below, please use dev_err_probe() as well. Doing so, you can remove the brackets in both if/else blocks. Or preserve these brackets may you wish to keep the changes minimal.

Regards
Aubin

Quoted 40 lines
drivers/mmc/host/sdhci-of-at91.c +7 -14
         priv->hclock = devm_clk_get(&pdev->dev, "hclock");
-       if (IS_ERR(priv->hclock)) {
-               dev_err(&pdev->dev, "failed to get hclock\n");
-               ret = PTR_ERR(priv->hclock);
-               goto sdhci_pltfm_free;
-       }
+       if (IS_ERR(priv->hclock))
+               return dev_err_probe(&pdev->dev, PTR_ERR(priv->hclock),
+                                    "failed to get hclock\n");
 
         priv->gck = devm_clk_get(&pdev->dev, "multclk");
-       if (IS_ERR(priv->gck)) {
-               dev_err(&pdev->dev, "failed to get multclk\n");
-               ret = PTR_ERR(priv->gck);
-               goto sdhci_pltfm_free;
-       }
+       if (IS_ERR(priv->gck))
+               return dev_err_probe(&pdev->dev, PTR_ERR(priv->gck),
+                                    "failed to get multclk\n");
 
         ret = sdhci_at91_set_clks_presets(&pdev->dev);
         if (ret)
-               goto sdhci_pltfm_free;
+               return ret;
 
         priv->restore_needed = false;
 
@@ -438,8 +433,6 @@ static int sdhci_at91_probe(struct platform_device *pdev)
         clk_disable_unprepare(priv->gck);
         clk_disable_unprepare(priv->mainck);
         clk_disable_unprepare(priv->hclock);
-sdhci_pltfm_free:
-       sdhci_pltfm_free(pdev);
         return ret;
  }
 
--

2.47.1

#22 lore raw

Re: [PATCH v2 19/35] mmc: sdhci-of-at91: Drop the use of sdhci_pltfm_free()

Hi Aubin:

Thanks for your reply.

Quoted 28 lines · Aubin Constans

Hi Binbin,

Thank you for the change.

Quoted 22 lines · Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Aubin Constans <[email protected]>
Cc Eugen Hristev <[email protected]>
Cc Nicolas Ferre <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Claudiu Beznea <[email protected]>
---
  drivers/mmc/host/sdhci-of-at91.c | 23 ++++++++---------------
  1 file changed, 8 insertions(+), 15 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +0 -1
index 97988ed37467..0b7d7db79139 100644
@@ -337,28 +337,23 @@ static int sdhci_at91_probe(struct platform_device *pdev)
                         priv->mainck = NULL;
                 } else {
                         dev_err(&pdev->dev, "failed to get baseclk\n");
-                       ret = PTR_ERR(priv->mainck);
Quoted 8 lines

drivers/mmc/host/sdhci-of-at91.c static int sdhci_at91_probe(struct platform_device *pdev) · line 342

Quoted 4 lines
drivers/mmc/host/sdhci-of-at91.c +1 -1
-                       goto sdhci_pltfm_free;
+                       return PTR_ERR(priv->mainck);
                 }
         }

For consistency with the changes below, please use dev_err_probe() as well. Doing so, you can remove the brackets in both if/else blocks. Or preserve these brackets may you wish to keep the changes minimal.

I will use dev_err_probe() to cleanup the code.

Quoted 45 lines

Regards
Aubin

Quoted 40 lines
drivers/mmc/host/sdhci-of-at91.c +7 -14
         priv->hclock = devm_clk_get(&pdev->dev, "hclock");
-       if (IS_ERR(priv->hclock)) {
-               dev_err(&pdev->dev, "failed to get hclock\n");
-               ret = PTR_ERR(priv->hclock);
-               goto sdhci_pltfm_free;
-       }
+       if (IS_ERR(priv->hclock))
+               return dev_err_probe(&pdev->dev, PTR_ERR(priv->hclock),
+                                    "failed to get hclock\n");
 
         priv->gck = devm_clk_get(&pdev->dev, "multclk");
-       if (IS_ERR(priv->gck)) {
-               dev_err(&pdev->dev, "failed to get multclk\n");
-               ret = PTR_ERR(priv->gck);
-               goto sdhci_pltfm_free;
-       }
+       if (IS_ERR(priv->gck))
+               return dev_err_probe(&pdev->dev, PTR_ERR(priv->gck),
+                                    "failed to get multclk\n");
 
         ret = sdhci_at91_set_clks_presets(&pdev->dev);
         if (ret)
-               goto sdhci_pltfm_free;
+               return ret;
 
         priv->restore_needed = false;
 
@@ -438,8 +433,6 @@ static int sdhci_at91_probe(struct platform_device *pdev)
         clk_disable_unprepare(priv->gck);
         clk_disable_unprepare(priv->mainck);
         clk_disable_unprepare(priv->hclock);
-sdhci_pltfm_free:
-       sdhci_pltfm_free(pdev);
         return ret;
  }
 
--

2.47.1

Signature · 2 lines
Thanks.
Binbin
#23 lore raw

PATCH v2 20/35 mmc: sdhci-of-dwcmshc: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-of-dwcmshc.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci-of-dwcmshc.c +5 -9
index a20d03fdd6a9..ee6b1096f709 100644
@@ -1387,14 +1387,13 @@ static int dwcmshc_probe(struct platform_device *pdev)
 
 	if (dev->of_node) {
 		pltfm_host->clk = devm_clk_get(dev, "core");
-		if (IS_ERR(pltfm_host->clk)) {
-			err = PTR_ERR(pltfm_host->clk);
-			dev_err(dev, "failed to get core clk: %d\n", err);
-			goto free_pltfm;
-		}
+		if (IS_ERR(pltfm_host->clk))
+			return dev_err_probe(dev, PTR_ERR(pltfm_host->clk),
+					     "failed to get core clk\n");
+
 		err = clk_prepare_enable(pltfm_host->clk);
 		if (err)
-			goto free_pltfm;
+			return err;
 
 		priv->bus_clk = devm_clk_get(dev, "bus");
 		if (!IS_ERR(priv->bus_clk))
@@ -1467,8 +1466,6 @@ static int dwcmshc_probe(struct platform_device *pdev)
 	clk_disable_unprepare(pltfm_host->clk);
 	clk_disable_unprepare(priv->bus_clk);
 	clk_bulk_disable_unprepare(priv->num_other_clks, priv->other_clks);
-free_pltfm:
-	sdhci_pltfm_free(pdev);
 	return err;
 }
 
@@ -1500,7 +1497,6 @@ static void dwcmshc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pltfm_host->clk);
 	clk_disable_unprepare(priv->bus_clk);
 	clk_bulk_disable_unprepare(priv->num_other_clks, priv->other_clks);
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#24 lore raw

PATCH v2 21/35 mmc: sdhci-of-esdhc: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-of-esdhc.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +2 -9
index 002d0d59b992..c6ee0099ead0 100644
@@ -1499,18 +1499,11 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
 	/* call to generic mmc_of_parse to support additional capabilities */
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err;
+		return ret;
 
 	mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto err;
-
-	return 0;
- err:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 static struct platform_driver sdhci_esdhc_driver = {
Signature · 1 line
2.47.1
#25 lore raw

PATCH v2 22/35 mmc: sdhci-of-k1: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-of-k1.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mmc/host/sdhci-of-k1.c +0 -1
index 6880d3e9ab62..026dc79af292 100644
@@ -286,7 +286,6 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
 	return 0;
 
 err_pltfm:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
Signature · 1 line
2.47.1
Reviewed-by on v2 22/35
#26 lore raw

Re: [PATCH v2 22/35] mmc: sdhci-of-k1: Drop the use of sdhci_pltfm_free()

Quoted 7 lines · Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Quoted 19 lines
---
 drivers/mmc/host/sdhci-of-k1.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mmc/host/sdhci-of-k1.c +0 -1
index 6880d3e9ab62..026dc79af292 100644
@@ -286,7 +286,6 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
 	return 0;
 
 err_pltfm:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
Signature · 1 line
2.47.1
Signature · 1 line
Yixun Lan (dlan)
#27 lore raw

PATCH v2 23/35 mmc: sdhci-of-ma35d1: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Jacky Huang <[email protected]>
Cc Shan-Chun Hung <[email protected]>
---
 drivers/mmc/host/sdhci-of-ma35d1.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/mmc/host/sdhci-of-ma35d1.c +8 -15
index 1e6d180100ad..287026422616 100644
@@ -211,20 +211,18 @@ static int ma35_probe(struct platform_device *pdev)
 	priv = sdhci_pltfm_priv(pltfm_host);
 
 	pltfm_host->clk = devm_clk_get_optional_enabled(dev, NULL);
-	if (IS_ERR(pltfm_host->clk)) {
-		err = dev_err_probe(dev, PTR_ERR(pltfm_host->clk), "failed to get clk\n");
-		goto err_sdhci;
-	}
+	if (IS_ERR(pltfm_host->clk))
+		return dev_err_probe(dev, PTR_ERR(pltfm_host->clk),
+				     "failed to get clk\n");
 
 	err = mmc_of_parse(host->mmc);
 	if (err)
-		goto err_sdhci;
+		return err;
 
 	priv->rst = devm_reset_control_get_exclusive(dev, NULL);
-	if (IS_ERR(priv->rst)) {
-		err = dev_err_probe(dev, PTR_ERR(priv->rst), "failed to get reset control\n");
-		goto err_sdhci;
-	}
+	if (IS_ERR(priv->rst))
+		return dev_err_probe(dev, PTR_ERR(priv->rst),
+				     "failed to get reset control\n");
 
 	sdhci_get_of_property(pdev);
 
@@ -255,7 +253,7 @@ static int ma35_probe(struct platform_device *pdev)
 
 	err = sdhci_add_host(host);
 	if (err)
-		goto err_sdhci;
+		return err;
 
 	/*
 	 * Split data into chunks of 16 or 8 bytes for transmission.
@@ -268,10 +266,6 @@ static int ma35_probe(struct platform_device *pdev)
 	sdhci_writew(host, ctl, MA35_SDHCI_MBIUCTL);
 
 	return 0;
-
-err_sdhci:
-	sdhci_pltfm_free(pdev);
-	return err;
 }
 
 static void ma35_disable_card_clk(struct sdhci_host *host)
@@ -291,7 +285,6 @@ static void ma35_remove(struct platform_device *pdev)
 
 	sdhci_remove_host(host, 0);
 	ma35_disable_card_clk(host);
-	sdhci_pltfm_free(pdev);
 }
 
 static const struct of_device_id sdhci_ma35_dt_ids[] = {
Signature · 1 line
2.47.1
#28 lore raw

PATCH v2 24/35 mmc: sdhci-of-sparx5: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Steen Hegelund <[email protected]>
Cc Daniel Machon <[email protected]>
---
 drivers/mmc/host/sdhci-of-sparx5.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/mmc/host/sdhci-of-sparx5.c +8 -16
index d2aa684e786f..b3db1e2c4c0e 100644
@@ -185,11 +185,9 @@ static int sdhci_sparx5_probe(struct platform_device *pdev)
 	sdhci_sparx5->host = host;
 
 	pltfm_host->clk = devm_clk_get_enabled(&pdev->dev, "core");
-	if (IS_ERR(pltfm_host->clk)) {
-		ret = PTR_ERR(pltfm_host->clk);
-		dev_err(&pdev->dev, "failed to get and enable core clk: %d\n", ret);
-		goto free_pltfm;
-	}
+	if (IS_ERR(pltfm_host->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(pltfm_host->clk),
+				     "failed to get and enable core clk\n");
 
 	if (!of_property_read_u32(np, "microchip,clock-delay", &value) &&
 	    (value > 0 && value <= MSHC_DLY_CC_MAX))
@@ -199,14 +197,12 @@ static int sdhci_sparx5_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto free_pltfm;
+		return ret;
 
 	sdhci_sparx5->cpu_ctrl = syscon_regmap_lookup_by_compatible(syscon);
-	if (IS_ERR(sdhci_sparx5->cpu_ctrl)) {
-		dev_err(&pdev->dev, "No CPU syscon regmap !\n");
-		ret = PTR_ERR(sdhci_sparx5->cpu_ctrl);
-		goto free_pltfm;
-	}
+	if (IS_ERR(sdhci_sparx5->cpu_ctrl))
+		return dev_err_probe(&pdev->dev, PTR_ERR(sdhci_sparx5->cpu_ctrl),
+				     "No CPU syscon regmap !\n");
 
 	if (sdhci_sparx5->delay_clock >= 0)
 		sparx5_set_delay(host, sdhci_sparx5->delay_clock);
@@ -222,7 +218,7 @@ static int sdhci_sparx5_probe(struct platform_device *pdev)
 
 	ret = sdhci_add_host(host);
 	if (ret)
-		goto free_pltfm;
+		return ret;
 
 	/* Set AXI bus master to use un-cached access (for DMA) */
 	if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA) &&
@@ -235,10 +231,6 @@ static int sdhci_sparx5_probe(struct platform_device *pdev)
 		 mmc_hostname(host->mmc), sdhci_readl(host, MSHC2_TYPE));
 
 	return ret;
-
-free_pltfm:
-	sdhci_pltfm_free(pdev);
-	return ret;
 }
 
 static const struct of_device_id sdhci_sparx5_of_match[] = {
Signature · 1 line
2.47.1
#29 lore raw

PATCH v2 25/35 mmc: sdhci-omap: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Vignesh Raghavendra <[email protected]>
---
 drivers/mmc/host/sdhci-omap.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci-omap.c +7 -14
index 8897839ab2aa..429d8a517fb6 100644
@@ -1257,7 +1257,7 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 	sdhci_get_of_property(pdev);
 	ret = mmc_of_parse(mmc);
 	if (ret)
-		goto err_pltfm_free;
+		return ret;
 
 	soc = soc_device_match(sdhci_omap_soc_devices);
 	if (soc) {
@@ -1274,22 +1274,19 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 		mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
 
 	pltfm_host->clk = devm_clk_get(dev, "fck");
-	if (IS_ERR(pltfm_host->clk)) {
-		ret = PTR_ERR(pltfm_host->clk);
-		goto err_pltfm_free;
-	}
+	if (IS_ERR(pltfm_host->clk))
+		return PTR_ERR(pltfm_host->clk);
 
 	ret = clk_set_rate(pltfm_host->clk, mmc->f_max);
-	if (ret) {
-		dev_err(dev, "failed to set clock to %d\n", mmc->f_max);
-		goto err_pltfm_free;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to set clock to %d\n", mmc->f_max);
 
 	omap_host->pbias = devm_regulator_get_optional(dev, "pbias");
 	if (IS_ERR(omap_host->pbias)) {
 		ret = PTR_ERR(omap_host->pbias);
 		if (ret != -ENODEV)
-			goto err_pltfm_free;
+			return ret;
 		dev_dbg(dev, "unable to get pbias regulator %d\n", ret);
 	}
 	omap_host->pbias_enabled = false;
@@ -1387,9 +1384,6 @@ static int sdhci_omap_probe(struct platform_device *pdev)
 err_rpm_disable:
 	pm_runtime_dont_use_autosuspend(dev);
 	pm_runtime_disable(dev);
-
-err_pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -1406,7 +1400,6 @@ static void sdhci_omap_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(dev);
 	/* Ensure device gets disabled despite userspace sysfs config */
 	pm_runtime_force_suspend(dev);
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM
Signature · 1 line
2.47.1
#30 lore raw

PATCH v2 26/35 mmc: sdhci-pic32: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-pic32.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-pic32.c +3 -6
index d6a299f49900..7ddac0befed8 100644
@@ -157,20 +157,20 @@ static int pic32_sdhci_probe(struct platform_device *pdev)
 		ret = plat_data->setup_dma(ADMA_FIFO_RD_THSHLD,
 					   ADMA_FIFO_WR_THSHLD);
 		if (ret)
-			goto err_host;
+			goto err;
 	}
 
 	sdhci_pdata->sys_clk = devm_clk_get(&pdev->dev, "sys_clk");
 	if (IS_ERR(sdhci_pdata->sys_clk)) {
 		ret = PTR_ERR(sdhci_pdata->sys_clk);
 		dev_err(&pdev->dev, "Error getting clock\n");
-		goto err_host;
+		goto err;
 	}
 
 	ret = clk_prepare_enable(sdhci_pdata->sys_clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Error enabling clock\n");
-		goto err_host;
+		goto err;
 	}
 
 	sdhci_pdata->base_clk = devm_clk_get(&pdev->dev, "base_clk");
@@ -203,8 +203,6 @@ static int pic32_sdhci_probe(struct platform_device *pdev)
 	clk_disable_unprepare(sdhci_pdata->base_clk);
 err_sys_clk:
 	clk_disable_unprepare(sdhci_pdata->sys_clk);
-err_host:
-	sdhci_pltfm_free(pdev);
 err:
 	dev_err(&pdev->dev, "pic32-sdhci probe failed: %d\n", ret);
 	return ret;
@@ -220,7 +218,6 @@ static void pic32_sdhci_remove(struct platform_device *pdev)
 	sdhci_remove_host(host, scratch == (u32)~0);
 	clk_disable_unprepare(sdhci_pdata->base_clk);
 	clk_disable_unprepare(sdhci_pdata->sys_clk);
-	sdhci_pltfm_free(pdev);
 }
 
 static const struct of_device_id pic32_sdhci_id_table[] = {
Signature · 1 line
2.47.1
#31 lore raw

PATCH v2 27/35 mmc: sdhci-pxav2: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-pxav2.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci-pxav2.c +6 -20
index 45b6f0891c47..76346353dc55 100644
@@ -258,7 +258,6 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
 	struct sdhci_host *host = NULL;
 	const struct sdhci_pxa_variant *variant;
 
-	int ret;
 	struct clk *clk, *clk_core;
 
 	host = sdhci_pltfm_init(pdev, NULL, sizeof(*pxav2_host));
@@ -271,19 +270,14 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
 	clk = devm_clk_get_optional_enabled(dev, "io");
 	if (!clk)
 		clk = devm_clk_get_enabled(dev, NULL);
-	if (IS_ERR(clk)) {
-		ret = PTR_ERR(clk);
-		dev_err_probe(dev, ret, "failed to get io clock\n");
-		goto free;
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "failed to get io clock\n");
 	pltfm_host->clk = clk;
 
 	clk_core = devm_clk_get_optional_enabled(dev, "core");
-	if (IS_ERR(clk_core)) {
-		ret = PTR_ERR(clk_core);
-		dev_err_probe(dev, ret, "failed to enable core clock\n");
-		goto free;
-	}
+	if (IS_ERR(clk_core))
+		return dev_err_probe(dev, PTR_ERR(clk_core),
+				     "failed to enable core clock\n");
 
 	host->quirks = SDHCI_QUIRK_BROKEN_ADMA
 		| SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
@@ -332,15 +326,7 @@ static int sdhci_pxav2_probe(struct platform_device *pdev)
 		pxav2_host->pinctrl = NULL;
 	}
 
-	ret = sdhci_add_host(host);
-	if (ret)
-		goto free;
-
-	return 0;
-
-free:
-	sdhci_pltfm_free(pdev);
-	return ret;
+	return sdhci_add_host(host);
 }
 
 static struct platform_driver sdhci_pxav2_driver = {
Signature · 1 line
2.47.1
#32 lore raw

PATCH v2 28/35 mmc: sdhci-pxav3: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-pxav3.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +1 -6
index 3fb56face3d8..7173a0296738 100644
@@ -389,8 +389,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
 		pxa->clk_io = devm_clk_get(dev, NULL);
 	if (IS_ERR(pxa->clk_io)) {
 		dev_err(dev, "failed to get io clock\n");
-		ret = PTR_ERR(pxa->clk_io);
-		goto err_clk_get;
+		return PTR_ERR(pxa->clk_io);
 	}
 	pltfm_host->clk = pxa->clk_io;
 	clk_prepare_enable(pxa->clk_io);
@@ -466,8 +465,6 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
 err_mbus_win:
 	clk_disable_unprepare(pxa->clk_io);
 	clk_disable_unprepare(pxa->clk_core);
-err_clk_get:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -485,8 +482,6 @@ static void sdhci_pxav3_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(pxa->clk_io);
 	clk_disable_unprepare(pxa->clk_core);
-
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#33 lore raw

PATCH v2 29/35 mmc: sdhci-sprd: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-sprd.c | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)
drivers/mmc/host/sdhci-sprd.c +10 -23
index db5e253b0f79..a5dec1a0e934 100644
@@ -764,7 +764,7 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto pltfm_free;
+		return ret;
 
 	if (!mmc_card_is_removable(host->mmc))
 		host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic;
@@ -778,34 +778,26 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 	if (!IS_ERR(sprd_host->pinctrl)) {
 		sprd_host->pins_uhs =
 			pinctrl_lookup_state(sprd_host->pinctrl, "state_uhs");
-		if (IS_ERR(sprd_host->pins_uhs)) {
-			ret = PTR_ERR(sprd_host->pins_uhs);
-			goto pltfm_free;
-		}
+		if (IS_ERR(sprd_host->pins_uhs))
+			return PTR_ERR(sprd_host->pins_uhs);
 
 		sprd_host->pins_default =
 			pinctrl_lookup_state(sprd_host->pinctrl, "default");
-		if (IS_ERR(sprd_host->pins_default)) {
-			ret = PTR_ERR(sprd_host->pins_default);
-			goto pltfm_free;
-		}
+		if (IS_ERR(sprd_host->pins_default))
+			return PTR_ERR(sprd_host->pins_default);
 	}
 
 	clk = devm_clk_get(&pdev->dev, "sdio");
-	if (IS_ERR(clk)) {
-		ret = PTR_ERR(clk);
-		goto pltfm_free;
-	}
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 	sprd_host->clk_sdio = clk;
 	sprd_host->base_rate = clk_get_rate(sprd_host->clk_sdio);
 	if (!sprd_host->base_rate)
 		sprd_host->base_rate = SDHCI_SPRD_CLK_DEF_RATE;
 
 	clk = devm_clk_get(&pdev->dev, "enable");
-	if (IS_ERR(clk)) {
-		ret = PTR_ERR(clk);
-		goto pltfm_free;
-	}
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 	sprd_host->clk_enable = clk;
 
 	clk = devm_clk_get(&pdev->dev, "2x_enable");
@@ -814,7 +806,7 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
 	ret = clk_prepare_enable(sprd_host->clk_sdio);
 	if (ret)
-		goto pltfm_free;
+		return ret;
 
 	ret = clk_prepare_enable(sprd_host->clk_enable);
 	if (ret)
@@ -891,9 +883,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
 
 clk_disable:
 	clk_disable_unprepare(sprd_host->clk_sdio);
-
-pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -907,8 +896,6 @@ static void sdhci_sprd_remove(struct platform_device *pdev)
 	clk_disable_unprepare(sprd_host->clk_sdio);
 	clk_disable_unprepare(sprd_host->clk_enable);
 	clk_disable_unprepare(sprd_host->clk_2x_enable);
-
-	sdhci_pltfm_free(pdev);
 }
 
 static const struct of_device_id sdhci_sprd_of_match[] = {
Signature · 1 line
2.47.1
#34 lore raw

PATCH v2 30/35 mmc: sdhci-st: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Patrice Chotard <[email protected]>
---
 drivers/mmc/host/sdhci-st.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-st.c +2 -4
index 4973e08a98f8..9157342ff7a4 100644
@@ -380,13 +380,13 @@ static int sdhci_st_probe(struct platform_device *pdev)
 	ret = mmc_of_parse(host->mmc);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed mmc_of_parse\n");
-		goto err_of;
+		goto err_pltfm_init;
 	}
 
 	ret = clk_prepare_enable(clk);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to prepare clock\n");
-		goto err_of;
+		goto err_pltfm_init;
 	}
 
 	ret = clk_prepare_enable(icnclk);
@@ -423,8 +423,6 @@ static int sdhci_st_probe(struct platform_device *pdev)
 	clk_disable_unprepare(icnclk);
 err_icnclk:
 	clk_disable_unprepare(clk);
-err_of:
-	sdhci_pltfm_free(pdev);
 err_pltfm_init:
 	reset_control_assert(rstc);
 
Signature · 1 line
2.47.1
#35 lore raw

PATCH v2 31/35 mmc: sdhci-tegra: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

Cc Thierry Reding <[email protected]>
Cc Jonathan Hunter <[email protected]>
---
 drivers/mmc/host/sdhci-tegra.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-tegra.c +3 -6
index b2f5c3f8b839..c811297185d8 100644
@@ -1693,7 +1693,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 
 	rc = mmc_of_parse(host->mmc);
 	if (rc)
-		goto err_parse_dt;
+		return rc;
 
 	if (tegra_host->soc_data->nvquirks & NVQUIRK_ENABLE_DDR50)
 		host->mmc->caps |= MMC_CAP_1_8V_DDR;
@@ -1739,7 +1739,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 		if (IS_ERR(clk)) {
 			rc = PTR_ERR(clk);
 			if (rc == -EPROBE_DEFER)
-				goto err_power_req;
+				return rc;
 
 			dev_warn(&pdev->dev, "failed to get tmclk: %d\n", rc);
 			clk = NULL;
@@ -1750,7 +1750,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 		if (rc) {
 			dev_err(&pdev->dev,
 				"failed to enable tmclk: %d\n", rc);
-			goto err_power_req;
+			return rc;
 		}
 
 		tegra_host->tmclk = clk;
@@ -1811,8 +1811,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
 err_clk_get:
 	clk_disable_unprepare(tegra_host->tmclk);
 err_power_req:
-err_parse_dt:
-	sdhci_pltfm_free(pdev);
 	return rc;
 }
 
@@ -1831,7 +1829,6 @@ static void sdhci_tegra_remove(struct platform_device *pdev)
 	pm_runtime_force_suspend(&pdev->dev);
 
 	clk_disable_unprepare(tegra_host->tmclk);
-	sdhci_pltfm_free(pdev);
 }
 
 static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev)
Signature · 1 line
2.47.1
#36 lore raw

PATCH v2 32/35 mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci-xenon.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-xenon.c +2 -7
index 098f0ea45cbe..20efb0225d3a 100644
@@ -533,13 +533,12 @@ static int xenon_probe(struct platform_device *pdev)
 	if (dev->of_node) {
 		pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
 		if (IS_ERR(pltfm_host->clk)) {
-			err = PTR_ERR(pltfm_host->clk);
 			dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
-			goto free_pltfm;
+			return PTR_ERR(pltfm_host->clk);
 		}
 		err = clk_prepare_enable(pltfm_host->clk);
 		if (err)
-			goto free_pltfm;
+			return err;
 
 		priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
 		if (IS_ERR(priv->axi_clk)) {
@@ -603,8 +602,6 @@ static int xenon_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->axi_clk);
 err_clk:
 	clk_disable_unprepare(pltfm_host->clk);
-free_pltfm:
-	sdhci_pltfm_free(pdev);
 	return err;
 }
 
@@ -623,8 +620,6 @@ static void xenon_remove(struct platform_device *pdev)
 	xenon_sdhc_unprepare(host);
 	clk_disable_unprepare(priv->axi_clk);
 	clk_disable_unprepare(pltfm_host->clk);
-
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.47.1
#37 lore raw

Re: [PATCH v2 32/35] mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()

kernel test robot noticed the following build warnings:

Hi Binbin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on d2c6acff6386f43ed307822454b970c831c48f1b]

url:    https://github.com/intel-lab-lkp/linux/commits/Binbin-Zhou/mmc-sdhci-Use-devm_mmc_alloc_host-helper/20250529-212928
base:   d2c6acff6386f43ed307822454b970c831c48f1b
patch link:    https://lore.kernel.org/r/b79920fa8bff8f7cf2f407863846446344d2eab7.1748515612.git.zhoubinbin%40loongson.cn
patch subject: [PATCH v2 32/35] mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()
config: arm-randconfig-004-20250530 (https://download.01.org/0day-ci/archive/20250530/[email protected]/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250530/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/mmc/host/sdhci-xenon.c:536:59: warning: variable 'err' is uninitialized when used here [-Wuninitialized]
     536 |                         dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
         |                                                                                ^~~
   include/linux/dev_printk.h:154:65: note: expanded from macro 'dev_err'
     154 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                        ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                                     ^~~~~~~~~~~
   drivers/mmc/host/sdhci-xenon.c:515:9: note: initialize the variable 'err' to silence this warning
     515 |         int err;
         |                ^
         |                 = 0

1 warning generated.

vim +/err +536 drivers/mmc/host/sdhci-xenon.c

3a3748dba881ed Hu Ziji         2017-03-30  508  
3a3748dba881ed Hu Ziji         2017-03-30  509  static int xenon_probe(struct platform_device *pdev)
3a3748dba881ed Hu Ziji         2017-03-30  510  {
3a3748dba881ed Hu Ziji         2017-03-30  511  	struct sdhci_pltfm_host *pltfm_host;
1542488031deed Marcin Wojtas   2020-12-04  512  	struct device *dev = &pdev->dev;
3a3748dba881ed Hu Ziji         2017-03-30  513  	struct sdhci_host *host;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  514  	struct xenon_priv *priv;
3a3748dba881ed Hu Ziji         2017-03-30  515  	int err;
3a3748dba881ed Hu Ziji         2017-03-30  516  
3a3748dba881ed Hu Ziji         2017-03-30  517  	host = sdhci_pltfm_init(pdev, &sdhci_xenon_pdata,
3a3748dba881ed Hu Ziji         2017-03-30  518  				sizeof(struct xenon_priv));
3a3748dba881ed Hu Ziji         2017-03-30  519  	if (IS_ERR(host))
3a3748dba881ed Hu Ziji         2017-03-30  520  		return PTR_ERR(host);
3a3748dba881ed Hu Ziji         2017-03-30  521  
3a3748dba881ed Hu Ziji         2017-03-30  522  	pltfm_host = sdhci_priv(host);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  523  	priv = sdhci_pltfm_priv(pltfm_host);
3a3748dba881ed Hu Ziji         2017-03-30  524  
f75fda3730728e Marcin Wojtas   2020-12-04  525  	priv->hw_version = (unsigned long)device_get_match_data(&pdev->dev);
f75fda3730728e Marcin Wojtas   2020-12-04  526  
3a3748dba881ed Hu Ziji         2017-03-30  527  	/*
3a3748dba881ed Hu Ziji         2017-03-30  528  	 * Link Xenon specific mmc_host_ops function,
3a3748dba881ed Hu Ziji         2017-03-30  529  	 * to replace standard ones in sdhci_ops.
3a3748dba881ed Hu Ziji         2017-03-30  530  	 */
3a3748dba881ed Hu Ziji         2017-03-30  531  	xenon_replace_mmc_host_ops(host);
3a3748dba881ed Hu Ziji         2017-03-30  532  
1542488031deed Marcin Wojtas   2020-12-04  533  	if (dev->of_node) {
3a3748dba881ed Hu Ziji         2017-03-30  534  		pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
3a3748dba881ed Hu Ziji         2017-03-30  535  		if (IS_ERR(pltfm_host->clk)) {
3a3748dba881ed Hu Ziji         2017-03-30 @536  			dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
6773eb1cf68bcb Binbin Zhou     2025-05-29  537  			return PTR_ERR(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  538  		}
3a3748dba881ed Hu Ziji         2017-03-30  539  		err = clk_prepare_enable(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  540  		if (err)
6773eb1cf68bcb Binbin Zhou     2025-05-29  541  			return err;
3a3748dba881ed Hu Ziji         2017-03-30  542  
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  543  		priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  544  		if (IS_ERR(priv->axi_clk)) {
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  545  			err = PTR_ERR(priv->axi_clk);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  546  			if (err == -EPROBE_DEFER)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  547  				goto err_clk;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  548  		} else {
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  549  			err = clk_prepare_enable(priv->axi_clk);
3a3748dba881ed Hu Ziji         2017-03-30  550  			if (err)
3a3748dba881ed Hu Ziji         2017-03-30  551  				goto err_clk;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  552  		}
1542488031deed Marcin Wojtas   2020-12-04  553  	}
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  554  
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  555  	err = mmc_of_parse(host->mmc);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  556  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  557  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  558  
f29bf660bf4137 Marcin Wojtas   2020-12-04  559  	sdhci_get_property(pdev);
3a3748dba881ed Hu Ziji         2017-03-30  560  
3a3748dba881ed Hu Ziji         2017-03-30  561  	xenon_set_acg(host, false);
3a3748dba881ed Hu Ziji         2017-03-30  562  
f29bf660bf4137 Marcin Wojtas   2020-12-04  563  	/* Xenon specific parameters parse */
f29bf660bf4137 Marcin Wojtas   2020-12-04  564  	err = xenon_probe_params(pdev);
3a3748dba881ed Hu Ziji         2017-03-30  565  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  566  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  567  
3a3748dba881ed Hu Ziji         2017-03-30  568  	err = xenon_sdhc_prepare(host);
3a3748dba881ed Hu Ziji         2017-03-30  569  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  570  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  571  
a027b2c5fed788 Zhoujie Wu      2017-08-29  572  	pm_runtime_get_noresume(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  573  	pm_runtime_set_active(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  574  	pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
a027b2c5fed788 Zhoujie Wu      2017-08-29  575  	pm_runtime_use_autosuspend(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  576  	pm_runtime_enable(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  577  	pm_suspend_ignore_children(&pdev->dev, 1);
a027b2c5fed788 Zhoujie Wu      2017-08-29  578  
3a3748dba881ed Hu Ziji         2017-03-30  579  	err = sdhci_add_host(host);
3a3748dba881ed Hu Ziji         2017-03-30  580  	if (err)
3a3748dba881ed Hu Ziji         2017-03-30  581  		goto remove_sdhc;
3a3748dba881ed Hu Ziji         2017-03-30  582  
a027b2c5fed788 Zhoujie Wu      2017-08-29  583  	pm_runtime_put_autosuspend(&pdev->dev);
5d40213347480e Elad Nachman    2024-01-04  584  	/*
5d40213347480e Elad Nachman    2024-01-04  585  	 * If we previously detected AC5 with over 2GB of memory,
5d40213347480e Elad Nachman    2024-01-04  586  	 * then we disable ADMA and 64-bit DMA.
5d40213347480e Elad Nachman    2024-01-04  587  	 * This means generic SDHCI driver has set the DMA mask to
5d40213347480e Elad Nachman    2024-01-04  588  	 * 32-bit. Since DDR starts at 0x2_0000_0000, we must use
5d40213347480e Elad Nachman    2024-01-04  589  	 * 34-bit DMA mask to access this DDR memory:
5d40213347480e Elad Nachman    2024-01-04  590  	 */
5d40213347480e Elad Nachman    2024-01-04  591  	if (priv->hw_version == XENON_AC5 &&
5d40213347480e Elad Nachman    2024-01-04  592  	    host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA)
5d40213347480e Elad Nachman    2024-01-04  593  		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
a027b2c5fed788 Zhoujie Wu      2017-08-29  594  
3a3748dba881ed Hu Ziji         2017-03-30  595  	return 0;
3a3748dba881ed Hu Ziji         2017-03-30  596  
3a3748dba881ed Hu Ziji         2017-03-30  597  remove_sdhc:
a027b2c5fed788 Zhoujie Wu      2017-08-29  598  	pm_runtime_disable(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  599  	pm_runtime_put_noidle(&pdev->dev);
3a3748dba881ed Hu Ziji         2017-03-30  600  	xenon_sdhc_unprepare(host);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  601  err_clk_axi:
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  602  	clk_disable_unprepare(priv->axi_clk);
3a3748dba881ed Hu Ziji         2017-03-30  603  err_clk:
3a3748dba881ed Hu Ziji         2017-03-30  604  	clk_disable_unprepare(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  605  	return err;
3a3748dba881ed Hu Ziji         2017-03-30  606  }
3a3748dba881ed Hu Ziji         2017-03-30  607  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
build bot
#38 lore raw

Re: [PATCH v2 32/35] mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou
BCC: [email protected] CC: [email protected] In-Reply-To: <b79920fa8bff8f7cf2f407863846446344d2eab7.1748515612.git.zhoubinbin@loongson.cn> References…

BCC: [email protected]
CC: [email protected]
In-Reply-To: <b79920fa8bff8f7cf2f407863846446344d2eab7.1748515612.git.zhoubinbin@loongson.cn>
References: <b79920fa8bff8f7cf2f407863846446344d2eab7.1748515612.git.zhoubinbin@loongson.cn>
TO: Binbin Zhou <[email protected]>
TO: Binbin Zhou <[email protected]>
TO: Huacai Chen <[email protected]>
TO: Ulf Hansson <[email protected]>
TO: Adrian Hunter <[email protected]>
CC: [email protected]
CC: Andrew Jeffery <[email protected]>
CC: Hu Ziji <[email protected]>

Hi Binbin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on d2c6acff6386f43ed307822454b970c831c48f1b]

url:    https://github.com/intel-lab-lkp/linux/commits/Binbin-Zhou/mmc-sdhci-Use-devm_mmc_alloc_host-helper/20250529-212928
base:   d2c6acff6386f43ed307822454b970c831c48f1b
patch link:    https://lore.kernel.org/r/b79920fa8bff8f7cf2f407863846446344d2eab7.1748515612.git.zhoubinbin%40loongson.cn
patch subject: [PATCH v2 32/35] mmc: sdhci-xenon: Drop the use of sdhci_pltfm_free()

:::::: branch date: 32 hours ago
:::::: commit date: 32 hours ago
config: i386-randconfig-141-20250530 (https://download.01.org/0day-ci/archive/20250531/[email protected]/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/mmc/host/sdhci-xenon.c:536 xenon_probe() error: uninitialized symbol 'err'.

vim +/err +536 drivers/mmc/host/sdhci-xenon.c

3a3748dba881ed Hu Ziji         2017-03-30  508  
3a3748dba881ed Hu Ziji         2017-03-30  509  static int xenon_probe(struct platform_device *pdev)
3a3748dba881ed Hu Ziji         2017-03-30  510  {
3a3748dba881ed Hu Ziji         2017-03-30  511  	struct sdhci_pltfm_host *pltfm_host;
1542488031deed Marcin Wojtas   2020-12-04  512  	struct device *dev = &pdev->dev;
3a3748dba881ed Hu Ziji         2017-03-30  513  	struct sdhci_host *host;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  514  	struct xenon_priv *priv;
3a3748dba881ed Hu Ziji         2017-03-30  515  	int err;
3a3748dba881ed Hu Ziji         2017-03-30  516  
3a3748dba881ed Hu Ziji         2017-03-30  517  	host = sdhci_pltfm_init(pdev, &sdhci_xenon_pdata,
3a3748dba881ed Hu Ziji         2017-03-30  518  				sizeof(struct xenon_priv));
3a3748dba881ed Hu Ziji         2017-03-30  519  	if (IS_ERR(host))
3a3748dba881ed Hu Ziji         2017-03-30  520  		return PTR_ERR(host);
3a3748dba881ed Hu Ziji         2017-03-30  521  
3a3748dba881ed Hu Ziji         2017-03-30  522  	pltfm_host = sdhci_priv(host);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  523  	priv = sdhci_pltfm_priv(pltfm_host);
3a3748dba881ed Hu Ziji         2017-03-30  524  
f75fda3730728e Marcin Wojtas   2020-12-04  525  	priv->hw_version = (unsigned long)device_get_match_data(&pdev->dev);
f75fda3730728e Marcin Wojtas   2020-12-04  526  
3a3748dba881ed Hu Ziji         2017-03-30  527  	/*
3a3748dba881ed Hu Ziji         2017-03-30  528  	 * Link Xenon specific mmc_host_ops function,
3a3748dba881ed Hu Ziji         2017-03-30  529  	 * to replace standard ones in sdhci_ops.
3a3748dba881ed Hu Ziji         2017-03-30  530  	 */
3a3748dba881ed Hu Ziji         2017-03-30  531  	xenon_replace_mmc_host_ops(host);
3a3748dba881ed Hu Ziji         2017-03-30  532  
1542488031deed Marcin Wojtas   2020-12-04  533  	if (dev->of_node) {
3a3748dba881ed Hu Ziji         2017-03-30  534  		pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
3a3748dba881ed Hu Ziji         2017-03-30  535  		if (IS_ERR(pltfm_host->clk)) {
3a3748dba881ed Hu Ziji         2017-03-30 @536  			dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err);
6773eb1cf68bcb Binbin Zhou     2025-05-29  537  			return PTR_ERR(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  538  		}
3a3748dba881ed Hu Ziji         2017-03-30  539  		err = clk_prepare_enable(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  540  		if (err)
6773eb1cf68bcb Binbin Zhou     2025-05-29  541  			return err;
3a3748dba881ed Hu Ziji         2017-03-30  542  
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  543  		priv->axi_clk = devm_clk_get(&pdev->dev, "axi");
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  544  		if (IS_ERR(priv->axi_clk)) {
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  545  			err = PTR_ERR(priv->axi_clk);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  546  			if (err == -EPROBE_DEFER)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  547  				goto err_clk;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  548  		} else {
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  549  			err = clk_prepare_enable(priv->axi_clk);
3a3748dba881ed Hu Ziji         2017-03-30  550  			if (err)
3a3748dba881ed Hu Ziji         2017-03-30  551  				goto err_clk;
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  552  		}
1542488031deed Marcin Wojtas   2020-12-04  553  	}
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  554  
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  555  	err = mmc_of_parse(host->mmc);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  556  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  557  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  558  
f29bf660bf4137 Marcin Wojtas   2020-12-04  559  	sdhci_get_property(pdev);
3a3748dba881ed Hu Ziji         2017-03-30  560  
3a3748dba881ed Hu Ziji         2017-03-30  561  	xenon_set_acg(host, false);
3a3748dba881ed Hu Ziji         2017-03-30  562  
f29bf660bf4137 Marcin Wojtas   2020-12-04  563  	/* Xenon specific parameters parse */
f29bf660bf4137 Marcin Wojtas   2020-12-04  564  	err = xenon_probe_params(pdev);
3a3748dba881ed Hu Ziji         2017-03-30  565  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  566  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  567  
3a3748dba881ed Hu Ziji         2017-03-30  568  	err = xenon_sdhc_prepare(host);
3a3748dba881ed Hu Ziji         2017-03-30  569  	if (err)
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  570  		goto err_clk_axi;
3a3748dba881ed Hu Ziji         2017-03-30  571  
a027b2c5fed788 Zhoujie Wu      2017-08-29  572  	pm_runtime_get_noresume(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  573  	pm_runtime_set_active(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  574  	pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
a027b2c5fed788 Zhoujie Wu      2017-08-29  575  	pm_runtime_use_autosuspend(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  576  	pm_runtime_enable(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  577  	pm_suspend_ignore_children(&pdev->dev, 1);
a027b2c5fed788 Zhoujie Wu      2017-08-29  578  
3a3748dba881ed Hu Ziji         2017-03-30  579  	err = sdhci_add_host(host);
3a3748dba881ed Hu Ziji         2017-03-30  580  	if (err)
3a3748dba881ed Hu Ziji         2017-03-30  581  		goto remove_sdhc;
3a3748dba881ed Hu Ziji         2017-03-30  582  
a027b2c5fed788 Zhoujie Wu      2017-08-29  583  	pm_runtime_put_autosuspend(&pdev->dev);
5d40213347480e Elad Nachman    2024-01-04  584  	/*
5d40213347480e Elad Nachman    2024-01-04  585  	 * If we previously detected AC5 with over 2GB of memory,
5d40213347480e Elad Nachman    2024-01-04  586  	 * then we disable ADMA and 64-bit DMA.
5d40213347480e Elad Nachman    2024-01-04  587  	 * This means generic SDHCI driver has set the DMA mask to
5d40213347480e Elad Nachman    2024-01-04  588  	 * 32-bit. Since DDR starts at 0x2_0000_0000, we must use
5d40213347480e Elad Nachman    2024-01-04  589  	 * 34-bit DMA mask to access this DDR memory:
5d40213347480e Elad Nachman    2024-01-04  590  	 */
5d40213347480e Elad Nachman    2024-01-04  591  	if (priv->hw_version == XENON_AC5 &&
5d40213347480e Elad Nachman    2024-01-04  592  	    host->quirks2 & SDHCI_QUIRK2_BROKEN_64_BIT_DMA)
5d40213347480e Elad Nachman    2024-01-04  593  		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
a027b2c5fed788 Zhoujie Wu      2017-08-29  594  
3a3748dba881ed Hu Ziji         2017-03-30  595  	return 0;
3a3748dba881ed Hu Ziji         2017-03-30  596  
3a3748dba881ed Hu Ziji         2017-03-30  597  remove_sdhc:
a027b2c5fed788 Zhoujie Wu      2017-08-29  598  	pm_runtime_disable(&pdev->dev);
a027b2c5fed788 Zhoujie Wu      2017-08-29  599  	pm_runtime_put_noidle(&pdev->dev);
3a3748dba881ed Hu Ziji         2017-03-30  600  	xenon_sdhc_unprepare(host);
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  601  err_clk_axi:
bb16ea1742c8f3 Gregory CLEMENT 2017-10-02  602  	clk_disable_unprepare(priv->axi_clk);
3a3748dba881ed Hu Ziji         2017-03-30  603  err_clk:
3a3748dba881ed Hu Ziji         2017-03-30  604  	clk_disable_unprepare(pltfm_host->clk);
3a3748dba881ed Hu Ziji         2017-03-30  605  	return err;
3a3748dba881ed Hu Ziji         2017-03-30  606  }
3a3748dba881ed Hu Ziji         2017-03-30  607  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#39 lore raw

PATCH v2 33/35 mmc: sdhci_am654: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci_am654.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci_am654.c +6 -14
index 73385ff4c0f3..58258e275dbb 100644
@@ -942,35 +942,30 @@ static int sdhci_am654_probe(struct platform_device *pdev)
 	clk_xin = devm_clk_get(dev, "clk_xin");
 	if (IS_ERR(clk_xin)) {
 		dev_err(dev, "clk_xin clock not found.\n");
-		ret = PTR_ERR(clk_xin);
-		goto err_pltfm_free;
+		return PTR_ERR(clk_xin);
 	}
 
 	pltfm_host->clk = clk_xin;
 
 	base = devm_platform_ioremap_resource(pdev, 1);
 	if (IS_ERR(base)) {
-		ret = PTR_ERR(base);
-		goto err_pltfm_free;
+		return PTR_ERR(base);
 	}
 
 	sdhci_am654->base = devm_regmap_init_mmio(dev, base,
 						  &sdhci_am654_regmap_config);
 	if (IS_ERR(sdhci_am654->base)) {
 		dev_err(dev, "Failed to initialize regmap\n");
-		ret = PTR_ERR(sdhci_am654->base);
-		goto err_pltfm_free;
+		return PTR_ERR(sdhci_am654->base);
 	}
 
 	ret = sdhci_am654_get_of_property(pdev, sdhci_am654);
 	if (ret)
-		goto err_pltfm_free;
+		return ret;
 
 	ret = mmc_of_parse(host->mmc);
-	if (ret) {
-		dev_err_probe(dev, ret, "parsing dt failed\n");
-		goto err_pltfm_free;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "parsing dt failed\n");
 
 	host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch;
 	host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
@@ -1001,8 +996,6 @@ static int sdhci_am654_probe(struct platform_device *pdev)
 	pm_runtime_disable(dev);
 pm_put:
 	pm_runtime_put_noidle(dev);
-err_pltfm_free:
-	sdhci_pltfm_free(pdev);
 	return ret;
 }
 
@@ -1021,7 +1014,6 @@ static void sdhci_am654_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pltfm_host->clk);
 	pm_runtime_disable(dev);
 	pm_runtime_put_noidle(dev);
-	sdhci_pltfm_free(pdev);
 }
 
 #ifdef CONFIG_PM
Signature · 1 line
2.47.1
#40 lore raw

PATCH v2 34/35 mmc: sdhci_f_sdh30: Drop the use of sdhci_pltfm_free()

In reply to Binbin Zhou

Since the devm_mmc_alloc_host() helper is already in use, sdhci_pltfm_free() is no longer needed.

---
 drivers/mmc/host/sdhci_f_sdh30.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci_f_sdh30.c +4 -9
index ee66e4f3683d..e9b934e159ad 100644
@@ -133,20 +133,18 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(host->mmc);
 	if (ret)
-		goto err;
+		return ret;
 
 	if (dev_of_node(dev)) {
 		sdhci_get_of_property(pdev);
 
 		priv->clk_iface = devm_clk_get(&pdev->dev, "iface");
-		if (IS_ERR(priv->clk_iface)) {
-			ret = PTR_ERR(priv->clk_iface);
-			goto err;
-		}
+		if (IS_ERR(priv->clk_iface))
+			return PTR_ERR(priv->clk_iface);
 
 		ret = clk_prepare_enable(priv->clk_iface);
 		if (ret)
-			goto err;
+			return ret;
 
 		priv->clk = devm_clk_get(&pdev->dev, "core");
 		if (IS_ERR(priv->clk)) {
@@ -200,9 +198,6 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk);
 err_clk:
 	clk_disable_unprepare(priv->clk_iface);
-err:
-	sdhci_pltfm_free(pdev);
-
 	return ret;
 }
 
Signature · 1 line
2.47.1
#41 lore raw

PATCH v2 35/35 mmc: sdhci: Drop sdhci_free_host()/sdhci_pltfm_free() definitions

In reply to Binbin Zhou

From now on, all calls to sdhci_free_host()/sdhci_pltfm_free() have been cleaned up, so we can just delete their definitions.

---
 drivers/mmc/host/sdhci-pltfm.c | 5 -----
 drivers/mmc/host/sdhci-pltfm.h | 1 -
 drivers/mmc/host/sdhci.c       | 6 ------
 drivers/mmc/host/sdhci.h       | 1 -
 4 files changed, 13 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +0 -5
index aedbcd32713a..7f6ac636f040 100644
@@ -146,11 +146,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_init);
 
-void sdhci_pltfm_free(struct platform_device *pdev)
-{
-}
-EXPORT_SYMBOL_GPL(sdhci_pltfm_free);
-
 int sdhci_pltfm_init_and_add_host(struct platform_device *pdev,
 				  const struct sdhci_pltfm_data *pdata,
 				  size_t priv_size)
drivers/mmc/host/sdhci-pltfm.h +0 -1
index b81d5b0fd616..9c32e8a289d6 100644
@@ -97,7 +97,6 @@ static inline void sdhci_get_of_property(struct platform_device *pdev)
 extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 					  const struct sdhci_pltfm_data *pdata,
 					  size_t priv_size);
-extern void sdhci_pltfm_free(struct platform_device *pdev);
 
 extern int sdhci_pltfm_init_and_add_host(struct platform_device *pdev,
 					 const struct sdhci_pltfm_data *pdata,
drivers/mmc/host/sdhci.c +0 -6
index ee5a5ae4db31..c40caa3f003f 100644
@@ -5000,12 +5000,6 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
 
 EXPORT_SYMBOL_GPL(sdhci_remove_host);
 
-void sdhci_free_host(struct sdhci_host *host)
-{
-}
-
-EXPORT_SYMBOL_GPL(sdhci_free_host);
-
 /*****************************************************************************\
  *                                                                           *
  * Driver init/exit                                                          *
drivers/mmc/host/sdhci.h +0 -1
index f9d65dd0f2b2..58291a6f093d 100644
@@ -811,7 +811,6 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
 #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
 
 struct sdhci_host *sdhci_alloc_host(struct device *dev, size_t priv_size);
-void sdhci_free_host(struct sdhci_host *host);
 
 static inline void *sdhci_priv(struct sdhci_host *host)
 {
Signature · 1 line
2.47.1