Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage
@ 2025-05-20 11:44 Binbin Zhou
  2025-05-20 11:44 ` [PATCH 01/36] mmc: alcor: Use devm_mmc_alloc_host() helper Binbin Zhou
                   ` (37 more replies)
  0 siblings, 38 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:44 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Hi all:

Since the devm_mmc_alloc_host() helper was already available, I tried to
start cleaning up the use of mmc_alloc_host().

To make it easier to review the patchset, I decided to split it into two parts.
As the first part, this patchset contains cleanup for drivers other than sdhci.

Of course, the sdhci part I have ready in my repository.

Thanks.

Binbin Zhou (36):
  mmc: alcor: Use devm_mmc_alloc_host() helper
  mmc: atmel: Use devm_mmc_alloc_host() helper
  mmc: au1xmmc: Use devm_mmc_alloc_host() helper
  mmc: bcm2835: Use devm_mmc_alloc_host() helper
  mmc: cavium: Use devm_mmc_alloc_host() helper
  mmc: cb710: Use devm_mmc_alloc_host() helper
  mmc: davinci_mmc: Use devm_mmc_alloc_host() helper
  mmc: dw_mmc: Use devm_mmc_alloc_host() helper
  mmc: jz4740: Use devm_mmc_alloc_host() helper
  mmc: litex_mmc: Use devm_mmc_alloc_host() helper
  mmc: meson-mx-sdhc: Use devm_mmc_alloc_host() helper
  mmc: mmci: Use devm_mmc_alloc_host() helper
  mmc: moxart-mmc: Use devm_mmc_alloc_host() helper
  mmc: mvsdio: Use devm_mmc_alloc_host() helper
  mmc: mxcmmc: Use devm_mmc_alloc_host() helper
  mmc: mxs-mmc: Use devm_mmc_alloc_host() helper
  mmc: omap: Use devm_mmc_alloc_host() helper
  mmc: omap_hsmmc: Use devm_mmc_alloc_host() helper
  mmc: owl-mmc: Use devm_mmc_alloc_host() helper
  mmc: pxamci: Use devm_mmc_alloc_host() helper
  mmc: rtsx_pci: Use devm_mmc_alloc_host() helper
  mmc: rtsx_usb_sdmmc: Use devm_mmc_alloc_host() helper
  mmc: sdricoh_cs: Use devm_mmc_alloc_host() helper
  mmc: ish_mmicf: Use devm_mmc_alloc_host() helper
  mmc: tifm_sd: Use devm_mmc_alloc_host() helper
  mmc: toshsd: Use devm_mmc_alloc_host() helper
  mmc: usdhi6ro10: Use devm_mmc_alloc_host() helper
  mmc: ushc: Use devm_mmc_alloc_host() helper
  mmc: via-sdmmc: Use devm_mmc_alloc_host() helper
  mmc: vub300: Use devm_mmc_alloc_host() helper
  mmc: wbsd: Use devm_mmc_alloc_host() helper
  mmc: wmt-sdmmc: Use devm_mmc_alloc_host() helper
  mmc: tmio: Use devm_mmc_alloc_host() helper
  mmc: sunxi: Use devm_mmc_alloc_host() helper
  mmc: mmc_spi: Use devm_mmc_alloc_host() helper
  mmc: meson-mx-sdio: Use devm_mmc_alloc_host() helper

 drivers/mmc/host/alcor.c             | 20 ++++---------
 drivers/mmc/host/atmel-mci.c         |  7 ++---
 drivers/mmc/host/au1xmmc.c           | 14 +++-------
 drivers/mmc/host/bcm2835.c           |  5 +---
 drivers/mmc/host/cavium.c            | 10 ++-----
 drivers/mmc/host/cb710-mmc.c         |  5 +---
 drivers/mmc/host/davinci_mmc.c       | 22 +++++----------
 drivers/mmc/host/dw_mmc.c            | 15 ++++------
 drivers/mmc/host/jz4740_mmc.c        | 40 +++++++++-----------------
 drivers/mmc/host/litex_mmc.c         | 12 +-------
 drivers/mmc/host/meson-mx-sdhc-mmc.c | 13 +--------
 drivers/mmc/host/meson-mx-sdio.c     | 20 ++++++-------
 drivers/mmc/host/mmc_spi.c           |  4 +--
 drivers/mmc/host/mmci.c              | 31 ++++++++------------
 drivers/mmc/host/moxart-mmc.c        | 40 ++++++++++----------------
 drivers/mmc/host/mvsdio.c            | 24 +++++-----------
 drivers/mmc/host/mxcmmc.c            | 31 +++++++-------------
 drivers/mmc/host/mxs-mmc.c           | 31 ++++++++------------
 drivers/mmc/host/omap.c              | 25 ++++++-----------
 drivers/mmc/host/omap_hsmmc.c        | 18 ++++--------
 drivers/mmc/host/owl-mmc.c           | 37 +++++++++---------------
 drivers/mmc/host/pxamci.c            | 42 ++++++++++------------------
 drivers/mmc/host/renesas_sdhi_core.c |  6 +---
 drivers/mmc/host/rtsx_pci_sdmmc.c    |  5 +---
 drivers/mmc/host/rtsx_usb_sdmmc.c    |  4 +--
 drivers/mmc/host/sdricoh_cs.c        | 10 ++-----
 drivers/mmc/host/sh_mmcif.c          | 17 ++++-------
 drivers/mmc/host/sunxi-mmc.c         | 22 ++++++---------
 drivers/mmc/host/tifm_sd.c           |  7 +----
 drivers/mmc/host/tmio_mmc.h          |  1 -
 drivers/mmc/host/tmio_mmc_core.c     | 18 ++----------
 drivers/mmc/host/toshsd.c            |  4 +--
 drivers/mmc/host/uniphier-sd.c       |  8 ++----
 drivers/mmc/host/usdhi6rol0.c        | 30 +++++++-------------
 drivers/mmc/host/ushc.c              |  4 +--
 drivers/mmc/host/via-sdmmc.c         |  7 ++---
 drivers/mmc/host/vub300.c            | 16 ++++-------
 drivers/mmc/host/wbsd.c              |  4 +--
 drivers/mmc/host/wmt-sdmmc.c         |  8 ++----
 39 files changed, 195 insertions(+), 442 deletions(-)


base-commit: eb68ba4af6da720caaf752b5618220efd5cf31dc
-- 
2.47.1


^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH 01/36] mmc: alcor: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
@ 2025-05-20 11:44 ` Binbin Zhou
  2025-05-20 11:44 ` [PATCH 02/36] mmc: atmel: " Binbin Zhou
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:44 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Feng Wei, Shao Mingyin

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Feng Wei <feng.wei8@zte.com.cn>
Cc: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/alcor.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c
index 24abd3a93da9..288c3a91a0af 100644
--- a/drivers/mmc/host/alcor.c
+++ b/drivers/mmc/host/alcor.c
@@ -1084,7 +1084,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	struct alcor_sdmmc_host *host;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc) {
 		dev_err(&pdev->dev, "Can't allocate MMC\n");
 		return -ENOMEM;
@@ -1102,11 +1102,9 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	ret = devm_request_threaded_irq(&pdev->dev, priv->irq,
 			alcor_irq, alcor_irq_thread, IRQF_SHARED,
 			DRV_NAME_ALCOR_PCI_SDMMC, host);
-
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to get irq for data line\n");
-		goto free_host;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to get irq for data line\n");
 
 	mutex_init(&host->cmd_mutex);
 	INIT_DELAYED_WORK(&host->timeout_work, alcor_timeout_timer);
@@ -1115,15 +1113,8 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	alcor_hw_init(host);
 
 	dev_set_drvdata(&pdev->dev, host);
-	ret = mmc_add_host(mmc);
-	if (ret)
-		goto free_host;
 
-	return 0;
-
-free_host:
-	mmc_free_host(mmc);
-	return ret;
+	return mmc_add_host(mmc);
 }
 
 static void alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
@@ -1136,7 +1127,6 @@ static void alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
 
 	alcor_hw_uninit(host);
 	mmc_remove_host(mmc);
-	mmc_free_host(mmc);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 02/36] mmc: atmel: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
  2025-05-20 11:44 ` [PATCH 01/36] mmc: alcor: Use devm_mmc_alloc_host() helper Binbin Zhou
@ 2025-05-20 11:44 ` Binbin Zhou
  2025-05-20 11:44 ` [PATCH 03/36] mmc: au1xmmc: " Binbin Zhou
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:44 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Aubin Constans,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Aubin Constans <aubin.constans@microchip.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/atmel-mci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 14e981b834b6..f72fe4b805f6 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2247,7 +2247,7 @@ static int atmci_init_slot(struct atmel_mci *host,
 	struct atmel_mci_slot		*slot;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -2320,10 +2320,8 @@ static int atmci_init_slot(struct atmel_mci *host,
 	host->slot[id] = slot;
 	mmc_regulator_get_supply(mmc);
 	ret = mmc_add_host(mmc);
-	if (ret) {
-		mmc_free_host(mmc);
+	if (ret)
 		return ret;
-	}
 
 	if (slot->detect_pin) {
 		timer_setup(&slot->detect_timer, atmci_detect_change, 0);
@@ -2361,7 +2359,6 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 	}
 
 	slot->host->slot[id] = NULL;
-	mmc_free_host(slot->mmc);
 }
 
 static int atmci_configure_dma(struct atmel_mci *host)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 03/36] mmc: au1xmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
  2025-05-20 11:44 ` [PATCH 01/36] mmc: alcor: Use devm_mmc_alloc_host() helper Binbin Zhou
  2025-05-20 11:44 ` [PATCH 02/36] mmc: atmel: " Binbin Zhou
@ 2025-05-20 11:44 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 04/36] mmc: bcm2835: " Binbin Zhou
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:44 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Manuel Lauss

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/au1xmmc.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 057d42307832..85470773650d 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -937,11 +937,10 @@ static int au1xmmc_probe(struct platform_device *pdev)
 	struct resource *r;
 	int ret, iflag;
 
-	mmc = mmc_alloc_host(sizeof(struct au1xmmc_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc) {
 		dev_err(&pdev->dev, "no memory for mmc_host\n");
-		ret = -ENOMEM;
-		goto out0;
+		return -ENOMEM;
 	}
 
 	host = mmc_priv(mmc);
@@ -953,14 +952,14 @@ static int au1xmmc_probe(struct platform_device *pdev)
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&pdev->dev, "no mmio defined\n");
-		goto out1;
+		return ret;
 	}
 
 	host->ioarea = request_mem_region(r->start, resource_size(r),
 					   pdev->name);
 	if (!host->ioarea) {
 		dev_err(&pdev->dev, "mmio already in use\n");
-		goto out1;
+		return ret;
 	}
 
 	host->iobase = ioremap(r->start, 0x3c);
@@ -1109,9 +1108,6 @@ static int au1xmmc_probe(struct platform_device *pdev)
 out2:
 	release_resource(host->ioarea);
 	kfree(host->ioarea);
-out1:
-	mmc_free_host(mmc);
-out0:
 	return ret;
 }
 
@@ -1151,8 +1147,6 @@ static void au1xmmc_remove(struct platform_device *pdev)
 		iounmap((void *)host->iobase);
 		release_resource(host->ioarea);
 		kfree(host->ioarea);
-
-		mmc_free_host(host->mmc);
 	}
 }
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 04/36] mmc: bcm2835: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (2 preceding siblings ...)
  2025-05-20 11:44 ` [PATCH 03/36] mmc: au1xmmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 05/36] mmc: cavium: " Binbin Zhou
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Florian Fainelli, Ray Jui,
	Scott Branden

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/bcm2835.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index e5f151d092cd..b75c9c0136d3 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1371,7 +1371,7 @@ static int bcm2835_probe(struct platform_device *pdev)
 	int ret;
 
 	dev_dbg(dev, "%s\n", __func__);
-	mmc = mmc_alloc_host(sizeof(*host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1450,7 +1450,6 @@ static int bcm2835_probe(struct platform_device *pdev)
 	dev_dbg(dev, "%s -> err %d\n", __func__, ret);
 	if (host->dma_chan_rxtx)
 		dma_release_channel(host->dma_chan_rxtx);
-	mmc_free_host(mmc);
 
 	return ret;
 }
@@ -1473,8 +1472,6 @@ static void bcm2835_remove(struct platform_device *pdev)
 
 	if (host->dma_chan_rxtx)
 		dma_release_channel(host->dma_chan_rxtx);
-
-	mmc_free_host(mmc);
 }
 
 static const struct of_device_id bcm2835_match[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 05/36] mmc: cavium: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (3 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 04/36] mmc: bcm2835: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 06/36] mmc: cb710: " Binbin Zhou
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Robert Richter

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Robert Richter <rric@kernel.org>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/cavium.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index 95a41983c6c0..9a55db0e657c 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -1012,7 +1012,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
 	struct mmc_host *mmc;
 	int ret, id;
 
-	mmc = mmc_alloc_host(sizeof(struct cvm_mmc_slot), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*slot));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1022,7 +1022,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
 
 	ret = cvm_mmc_of_parse(dev, slot);
 	if (ret < 0)
-		goto error;
+		return ret;
 	id = ret;
 
 	/* Set up host parameters */
@@ -1066,12 +1066,7 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
 	if (ret) {
 		dev_err(dev, "mmc_add_host() returned %d\n", ret);
 		slot->host->slot[id] = NULL;
-		goto error;
 	}
-	return 0;
-
-error:
-	mmc_free_host(slot->mmc);
 	return ret;
 }
 
@@ -1079,6 +1074,5 @@ int cvm_mmc_of_slot_remove(struct cvm_mmc_slot *slot)
 {
 	mmc_remove_host(slot->mmc);
 	slot->host->slot[slot->bus_id] = NULL;
-	mmc_free_host(slot->mmc);
 	return 0;
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 06/36] mmc: cb710: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (4 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 05/36] mmc: cavium: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-21  9:48   ` Michał Mirosław
  2025-05-20 11:45 ` [PATCH 07/36] mmc: davinci_mmc: " Binbin Zhou
                   ` (31 subsequent siblings)
  37 siblings, 1 reply; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Michał Mirosław

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/cb710-mmc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
index d741c1f9cf87..8787e7f49e94 100644
--- a/drivers/mmc/host/cb710-mmc.c
+++ b/drivers/mmc/host/cb710-mmc.c
@@ -692,7 +692,7 @@ static int cb710_mmc_init(struct platform_device *pdev)
 	int err;
 	u32 val;
 
-	mmc = mmc_alloc_host(sizeof(*reader), cb710_slot_dev(slot));
+	mmc = devm_mmc_alloc_host(cb710_slot_dev(slot), sizeof(*reader));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -741,7 +741,6 @@ static int cb710_mmc_init(struct platform_device *pdev)
 	dev_dbg(cb710_slot_dev(slot), "mmc_add_host() failed: %d\n", err);
 
 	cb710_set_irq_handler(slot, NULL);
-	mmc_free_host(mmc);
 	return err;
 }
 
@@ -764,8 +763,6 @@ static void cb710_mmc_exit(struct platform_device *pdev)
 	cb710_write_port_16(slot, CB710_MMC_CONFIGB_PORT, 0);
 
 	cancel_work_sync(&reader->finish_req_bh_work);
-
-	mmc_free_host(mmc);
 }
 
 static struct platform_driver cb710_mmc_driver = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 07/36] mmc: davinci_mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (5 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 06/36] mmc: cb710: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 08/36] mmc: dw_mmc: " Binbin Zhou
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Bastien Curutchet,
	Bartosz Golaszewski

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Bastien Curutchet <bastien.curutchet@bootlin.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/davinci_mmc.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index cde4c4339ab7..c691f1b60395 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -1203,7 +1203,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
 	if (!mem)
 		return -EBUSY;
 
-	mmc = mmc_alloc_host(sizeof(struct mmc_davinci_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1212,19 +1212,16 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
 
 	host->mem_res = mem;
 	host->base = devm_ioremap(&pdev->dev, mem->start, mem_size);
-	if (!host->base) {
-		ret = -ENOMEM;
-		goto ioremap_fail;
-	}
+	if (!host->base)
+		return -ENOMEM;
 
 	host->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(host->clk)) {
-		ret = PTR_ERR(host->clk);
-		goto clk_get_fail;
-	}
+	if (IS_ERR(host->clk))
+		return PTR_ERR(host->clk);
+
 	ret = clk_prepare_enable(host->clk);
 	if (ret)
-		goto clk_prepare_enable_fail;
+		return ret;
 
 	host->mmc_input_clk = clk_get_rate(host->clk);
 
@@ -1336,10 +1333,6 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
 parse_fail:
 dma_probe_defer:
 	clk_disable_unprepare(host->clk);
-clk_prepare_enable_fail:
-clk_get_fail:
-ioremap_fail:
-	mmc_free_host(mmc);
 
 	return ret;
 }
@@ -1352,7 +1345,6 @@ static void davinci_mmcsd_remove(struct platform_device *pdev)
 	mmc_davinci_cpufreq_deregister(host);
 	davinci_release_dma_channels(host);
 	clk_disable_unprepare(host->clk);
-	mmc_free_host(host->mmc);
 }
 
 #ifdef CONFIG_PM
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 08/36] mmc: dw_mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (6 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 07/36] mmc: davinci_mmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 09/36] mmc: jz4740: " Binbin Zhou
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Jaehoon Chung

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/dw_mmc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

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


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 09/36] mmc: jz4740: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (7 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 08/36] mmc: dw_mmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 10/36] mmc: litex_mmc: " Binbin Zhou
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Paul Cercueil

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/jz4740_mmc.c | 40 ++++++++++++-----------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index bd1662e275d4..3a623323aef3 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -1042,7 +1042,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 	struct mmc_host *mmc;
 	struct jz4740_mmc_host *host;
 
-	mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc) {
 		dev_err(&pdev->dev, "Failed to alloc mmc host structure\n");
 		return -ENOMEM;
@@ -1054,31 +1054,24 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 	host->version = (enum jz4740_mmc_version)device_get_match_data(&pdev->dev);
 
 	ret = mmc_of_parse(mmc);
-	if (ret) {
-		dev_err_probe(&pdev->dev, ret, "could not parse device properties\n");
-		goto err_free_host;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret,
+				     "could not parse device properties\n");
 
 	mmc_regulator_get_supply(mmc);
 
 	host->irq = platform_get_irq(pdev, 0);
-	if (host->irq < 0) {
-		ret = host->irq;
-		goto err_free_host;
-	}
+	if (host->irq < 0)
+		return host->irq;
 
 	host->clk = devm_clk_get(&pdev->dev, "mmc");
-	if (IS_ERR(host->clk)) {
-		ret = PTR_ERR(host->clk);
-		dev_err(&pdev->dev, "Failed to get mmc clock\n");
-		goto err_free_host;
-	}
+	if (IS_ERR(host->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(host->clk),
+				     "Failed to get mmc clock\n");
 
 	host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &host->mem_res);
-	if (IS_ERR(host->base)) {
-		ret = PTR_ERR(host->base);
-		goto err_free_host;
-	}
+	if (IS_ERR(host->base))
+		return PTR_ERR(host->base);
 
 	mmc->ops = &jz4740_mmc_ops;
 	if (!mmc->f_max)
@@ -1118,10 +1111,8 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 
 	ret = request_threaded_irq(host->irq, jz_mmc_irq, jz_mmc_irq_worker, 0,
 			dev_name(&pdev->dev), host);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
-		goto err_free_host;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to request irq\n");
 
 	jz4740_mmc_clock_disable(host);
 	timer_setup(&host->timeout_timer, jz4740_mmc_timeout, 0);
@@ -1152,9 +1143,6 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 		jz4740_mmc_release_dma_channels(host);
 err_free_irq:
 	free_irq(host->irq, host);
-err_free_host:
-	mmc_free_host(mmc);
-
 	return ret;
 }
 
@@ -1172,8 +1160,6 @@ static void jz4740_mmc_remove(struct platform_device *pdev)
 
 	if (host->use_dma)
 		jz4740_mmc_release_dma_channels(host);
-
-	mmc_free_host(host->mmc);
 }
 
 static int jz4740_mmc_suspend(struct device *dev)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 10/36] mmc: litex_mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (8 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 09/36] mmc: jz4740: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 11/36] mmc: meson-mx-sdhc: " Binbin Zhou
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Karol Gugala,
	Mateusz Holenko, Gabriel Somlo, Joel Stanley

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Karol Gugala <kgugala@antmicro.com>
Cc: Mateusz Holenko <mholenko@antmicro.com>
Cc: Gabriel Somlo <gsomlo@gmail.com>
Cc: Joel Stanley <joel@jms.id.au>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/litex_mmc.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c
index b338ccfa8f33..d2f19c2dc673 100644
--- a/drivers/mmc/host/litex_mmc.c
+++ b/drivers/mmc/host/litex_mmc.c
@@ -506,11 +506,6 @@ static int litex_mmc_irq_init(struct platform_device *pdev,
 	return 0;
 }
 
-static void litex_mmc_free_host_wrapper(void *mmc)
-{
-	mmc_free_host(mmc);
-}
-
 static int litex_mmc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -525,15 +520,10 @@ static int litex_mmc_probe(struct platform_device *pdev)
 	 * If for some reason we need to modify max_blk_count, we must also
 	 * re-calculate `max_[req,seg]_size = max_blk_size * max_blk_count;`
 	 */
-	mmc = mmc_alloc_host(sizeof(struct litex_mmc_host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
-	ret = devm_add_action_or_reset(dev, litex_mmc_free_host_wrapper, mmc);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Can't register mmc_free_host action\n");
-
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 11/36] mmc: meson-mx-sdhc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (9 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 10/36] mmc: litex_mmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 12/36] mmc: mmci: " Binbin Zhou
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, linux-amlogic

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-amlogic@lists.infradead.org
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/meson-mx-sdhc-mmc.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/mmc/host/meson-mx-sdhc-mmc.c b/drivers/mmc/host/meson-mx-sdhc-mmc.c
index b4e56ccffca2..fb49ea71289e 100644
--- a/drivers/mmc/host/meson-mx-sdhc-mmc.c
+++ b/drivers/mmc/host/meson-mx-sdhc-mmc.c
@@ -757,11 +757,6 @@ static void meson_mx_sdhc_init_hw(struct mmc_host *mmc)
 	regmap_write(host->regmap, MESON_SDHC_ISTA, MESON_SDHC_ISTA_ALL_IRQS);
 }
 
-static void meason_mx_mmc_free_host(void *data)
-{
-       mmc_free_host(data);
-}
-
 static int meson_mx_sdhc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -770,16 +765,10 @@ static int meson_mx_sdhc_probe(struct platform_device *pdev)
 	void __iomem *base;
 	int ret, irq;
 
-	mmc = mmc_alloc_host(sizeof(*host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
-	ret = devm_add_action_or_reset(dev, meason_mx_mmc_free_host, mmc);
-	if (ret) {
-		dev_err(dev, "Failed to register mmc_free_host action\n");
-		return ret;
-	}
-
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 12/36] mmc: mmci: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (10 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 11/36] mmc: meson-mx-sdhc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 13/36] mmc: moxart-mmc: " Binbin Zhou
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Russell King

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/mmci.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index b790c3c3c8f9..c70c64f8adc4 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -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);
 	}
 }
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 13/36] mmc: moxart-mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (11 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 12/36] mmc: mmci: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 14/36] mmc: mvsdio: " Binbin Zhou
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/moxart-mmc.c | 40 ++++++++++++-----------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index a12048e5de63..3dd8f232052f 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -558,41 +558,33 @@ static int moxart_probe(struct platform_device *pdev)
 	int irq, ret;
 	u32 i;
 
-	mmc = mmc_alloc_host(sizeof(struct moxart_host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc) {
-		dev_err(dev, "mmc_alloc_host failed\n");
-		ret = -ENOMEM;
-		goto out_mmc;
+		dev_err(dev, "devm_mmc_alloc_host failed\n");
+		return -ENOMEM;
 	}
 
 	ret = of_address_to_resource(node, 0, &res_mmc);
-	if (ret) {
-		dev_err(dev, "of_address_to_resource failed\n");
-		goto out_mmc;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "of_address_to_resource failed\n");
 
 	irq = irq_of_parse_and_map(node, 0);
-	if (irq <= 0) {
-		dev_err(dev, "irq_of_parse_and_map failed\n");
-		ret = -EINVAL;
-		goto out_mmc;
-	}
+	if (irq <= 0)
+		return dev_err_probe(dev, -EINVAL,
+				     "irq_of_parse_and_map failed\n");
 
 	clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(clk)) {
-		ret = PTR_ERR(clk);
-		goto out_mmc;
-	}
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
 
 	reg_mmc = devm_ioremap_resource(dev, &res_mmc);
-	if (IS_ERR(reg_mmc)) {
-		ret = PTR_ERR(reg_mmc);
-		goto out_mmc;
-	}
+	if (IS_ERR(reg_mmc))
+		return PTR_ERR(reg_mmc);
 
 	ret = mmc_of_parse(mmc);
 	if (ret)
-		goto out_mmc;
+		return ret;
 
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
@@ -686,9 +678,6 @@ static int moxart_probe(struct platform_device *pdev)
 		dma_release_channel(host->dma_chan_tx);
 	if (!IS_ERR_OR_NULL(host->dma_chan_rx))
 		dma_release_channel(host->dma_chan_rx);
-out_mmc:
-	if (mmc)
-		mmc_free_host(mmc);
 	return ret;
 }
 
@@ -707,7 +696,6 @@ static void moxart_remove(struct platform_device *pdev)
 	writel(0, host->base + REG_POWER_CONTROL);
 	writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
 	       host->base + REG_CLOCK_CONTROL);
-	mmc_free_host(mmc);
 }
 
 static const struct of_device_id moxart_mmc_match[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 14/36] mmc: mvsdio: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (12 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 13/36] mmc: moxart-mmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 15/36] mmc: mxcmmc: " Binbin Zhou
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Nicolas Pitre

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/mvsdio.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c
index 912ffacbad88..5c738862054b 100644
--- a/drivers/mmc/host/mvsdio.c
+++ b/drivers/mmc/host/mvsdio.c
@@ -706,11 +706,9 @@ static int mvsd_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);
-	if (!mmc) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
+	if (!mmc)
+		return -ENOMEM;
 
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
@@ -724,11 +722,9 @@ static int mvsd_probe(struct platform_device *pdev)
 	 * fixed rate clock).
 	 */
 	host->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(host->clk)) {
-		dev_err(&pdev->dev, "no clock associated\n");
-		ret = -EINVAL;
-		goto out;
-	}
+	if (IS_ERR(host->clk))
+		return dev_err_probe(&pdev->dev, -EINVAL, "no clock associated\n");
+
 	clk_prepare_enable(host->clk);
 
 	mmc->ops = &mvsd_ops;
@@ -787,12 +783,7 @@ static int mvsd_probe(struct platform_device *pdev)
 	return 0;
 
 out:
-	if (mmc) {
-		if (!IS_ERR(host->clk))
-			clk_disable_unprepare(host->clk);
-		mmc_free_host(mmc);
-	}
-
+	clk_disable_unprepare(host->clk);
 	return ret;
 }
 
@@ -808,7 +799,6 @@ static void mvsd_remove(struct platform_device *pdev)
 
 	if (!IS_ERR(host->clk))
 		clk_disable_unprepare(host->clk);
-	mmc_free_host(mmc);
 }
 
 static const struct of_device_id mvsdio_dt_ids[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 15/36] mmc: mxcmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (13 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 14/36] mmc: mvsdio: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 16/36] mmc: mxs-mmc: " Binbin Zhou
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Shawn Guo, Sascha Hauer,
	Fabio Estevam

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/mxcmmc.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 95d8d40a06a8..adde0e3cb9f9 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -1005,23 +1005,21 @@ static int mxcmci_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
 	host = mmc_priv(mmc);
 
 	host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(host->base)) {
-		ret = PTR_ERR(host->base);
-		goto out_free;
-	}
+	if (IS_ERR(host->base))
+		return PTR_ERR(host->base);
 
 	host->phys_base = res->start;
 
 	ret = mmc_of_parse(mmc);
 	if (ret)
-		goto out_free;
+		return ret;
 	mmc->ops = &mxcmci_ops;
 
 	/* For devicetree parsing, the bus width is read from devicetree */
@@ -1054,7 +1052,7 @@ static int mxcmci_probe(struct platform_device *pdev)
 
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
-		goto out_free;
+		return ret;
 
 	if (!mmc->ocr_avail) {
 		if (pdata && pdata->ocr_avail)
@@ -1070,20 +1068,16 @@ static int mxcmci_probe(struct platform_device *pdev)
 		host->default_irq_mask = 0;
 
 	host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
-	if (IS_ERR(host->clk_ipg)) {
-		ret = PTR_ERR(host->clk_ipg);
-		goto out_free;
-	}
+	if (IS_ERR(host->clk_ipg))
+		return PTR_ERR(host->clk_ipg);
 
 	host->clk_per = devm_clk_get(&pdev->dev, "per");
-	if (IS_ERR(host->clk_per)) {
-		ret = PTR_ERR(host->clk_per);
-		goto out_free;
-	}
+	if (IS_ERR(host->clk_per))
+		return PTR_ERR(host->clk_per);
 
 	ret = clk_prepare_enable(host->clk_per);
 	if (ret)
-		goto out_free;
+		return ret;
 
 	ret = clk_prepare_enable(host->clk_ipg);
 	if (ret)
@@ -1169,9 +1163,6 @@ static int mxcmci_probe(struct platform_device *pdev)
 out_clk_per_put:
 	clk_disable_unprepare(host->clk_per);
 
-out_free:
-	mmc_free_host(mmc);
-
 	return ret;
 }
 
@@ -1190,8 +1181,6 @@ static void mxcmci_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(host->clk_per);
 	clk_disable_unprepare(host->clk_ipg);
-
-	mmc_free_host(mmc);
 }
 
 static int mxcmci_suspend(struct device *dev)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 16/36] mmc: mxs-mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (14 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 15/36] mmc: mxcmmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:45 ` [PATCH 17/36] mmc: omap: " Binbin Zhou
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Shawn Guo, Sascha Hauer,
	Fabio Estevam

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/mxs-mmc.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 80e6f48c83aa..a6e44e406106 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -569,7 +569,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	if (irq_err < 0)
 		return irq_err;
 
-	mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -577,10 +577,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	ssp = &host->ssp;
 	ssp->dev = &pdev->dev;
 	ssp->base = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(ssp->base)) {
-		ret = PTR_ERR(ssp->base);
-		goto out_mmc_free;
-	}
+	if (IS_ERR(ssp->base))
+		return PTR_ERR(ssp->base);
 
 	ssp->devid = (enum mxs_ssp_id)of_device_get_match_data(&pdev->dev);
 
@@ -590,26 +588,23 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	reg_vmmc = devm_regulator_get(&pdev->dev, "vmmc");
 	if (!IS_ERR(reg_vmmc)) {
 		ret = regulator_enable(reg_vmmc);
-		if (ret) {
-			dev_err(&pdev->dev,
-				"Failed to enable vmmc regulator: %d\n", ret);
-			goto out_mmc_free;
-		}
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret,
+					     "Failed to enable vmmc regulator\n");
 
 		ret = devm_add_action_or_reset(&pdev->dev, mxs_mmc_regulator_disable,
 					       reg_vmmc);
 		if (ret)
-			goto out_mmc_free;
+			return ret;
 	}
 
 	ssp->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(ssp->clk)) {
-		ret = PTR_ERR(ssp->clk);
-		goto out_mmc_free;
-	}
+	if (IS_ERR(ssp->clk))
+		return PTR_ERR(ssp->clk);
+
 	ret = clk_prepare_enable(ssp->clk);
 	if (ret)
-		goto out_mmc_free;
+		return ret;
 
 	ret = mxs_mmc_reset(host);
 	if (ret) {
@@ -668,8 +663,6 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	dma_release_channel(ssp->dmach);
 out_clk_disable:
 	clk_disable_unprepare(ssp->clk);
-out_mmc_free:
-	mmc_free_host(mmc);
 	return ret;
 }
 
@@ -685,8 +678,6 @@ static void mxs_mmc_remove(struct platform_device *pdev)
 		dma_release_channel(ssp->dmach);
 
 	clk_disable_unprepare(ssp->clk);
-
-	mmc_free_host(mmc);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 17/36] mmc: omap: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (15 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 16/36] mmc: mxs-mmc: " Binbin Zhou
@ 2025-05-20 11:45 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 18/36] mmc: omap_hsmmc: " Binbin Zhou
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:45 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Aaro Koskinen, Allen Pais

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Allen Pais <allen.lkml@gmail.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/omap.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index c50617d03709..57699095ae68 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1258,7 +1258,7 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 	struct mmc_host *mmc;
 	int r;
 
-	mmc = mmc_alloc_host(sizeof(struct mmc_omap_slot), host->dev);
+	mmc = devm_mmc_alloc_host(host->dev, sizeof(*slot));
 	if (mmc == NULL)
 		return -ENOMEM;
 
@@ -1272,25 +1272,21 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 	/* Check for some optional GPIO controls */
 	slot->vsd = devm_gpiod_get_index_optional(host->dev, "vsd",
 						  id, GPIOD_OUT_LOW);
-	if (IS_ERR(slot->vsd)) {
-		r = dev_err_probe(host->dev, PTR_ERR(slot->vsd),
+	if (IS_ERR(slot->vsd))
+		return dev_err_probe(host->dev, PTR_ERR(slot->vsd),
 				     "error looking up VSD GPIO\n");
-		goto err_free_host;
-	}
+
 	slot->vio = devm_gpiod_get_index_optional(host->dev, "vio",
 						  id, GPIOD_OUT_LOW);
-	if (IS_ERR(slot->vio)) {
-		r = dev_err_probe(host->dev, PTR_ERR(slot->vio),
+	if (IS_ERR(slot->vio))
+		return dev_err_probe(host->dev, PTR_ERR(slot->vio),
 				     "error looking up VIO GPIO\n");
-		goto err_free_host;
-	}
+
 	slot->cover = devm_gpiod_get_index_optional(host->dev, "cover",
 						    id, GPIOD_IN);
-	if (IS_ERR(slot->cover)) {
-		r = dev_err_probe(host->dev, PTR_ERR(slot->cover),
+	if (IS_ERR(slot->cover))
+		return dev_err_probe(host->dev, PTR_ERR(slot->cover),
 				     "error looking up cover switch GPIO\n");
-		goto err_free_host;
-	}
 
 	host->slots[id] = slot;
 
@@ -1350,8 +1346,6 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id)
 		device_remove_file(&mmc->class_dev, &dev_attr_slot_name);
 err_remove_host:
 	mmc_remove_host(mmc);
-err_free_host:
-	mmc_free_host(mmc);
 	return r;
 }
 
@@ -1369,7 +1363,6 @@ static void mmc_omap_remove_slot(struct mmc_omap_slot *slot)
 	flush_workqueue(slot->host->mmc_omap_wq);
 
 	mmc_remove_host(mmc);
-	mmc_free_host(mmc);
 }
 
 static int mmc_omap_probe(struct platform_device *pdev)
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 18/36] mmc: omap_hsmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (16 preceding siblings ...)
  2025-05-20 11:45 ` [PATCH 17/36] mmc: omap: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 19/36] mmc: owl-mmc: " Binbin Zhou
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/omap_hsmmc.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 59e36e0ebbbf..688a8ec81924 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1798,15 +1798,13 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev);
-	if (!mmc) {
-		ret = -ENOMEM;
-		goto err;
-	}
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
+	if (!mmc)
+		return -ENOMEM;
 
 	ret = mmc_of_parse(mmc);
 	if (ret)
-		goto err1;
+		return ret;
 
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
@@ -1840,9 +1838,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 
 	host->fclk = devm_clk_get(&pdev->dev, "fck");
 	if (IS_ERR(host->fclk)) {
-		ret = PTR_ERR(host->fclk);
 		host->fclk = NULL;
-		goto err1;
+		return PTR_ERR(host->fclk);
 	}
 
 	if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
@@ -1973,9 +1970,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	pm_runtime_put_sync(host->dev);
 	pm_runtime_disable(host->dev);
 	clk_disable_unprepare(host->dbclk);
-err1:
-	mmc_free_host(mmc);
-err:
 	return ret;
 }
 
@@ -1995,8 +1989,6 @@ static void omap_hsmmc_remove(struct platform_device *pdev)
 	pm_runtime_disable(host->dev);
 	device_init_wakeup(&pdev->dev, false);
 	clk_disable_unprepare(host->dbclk);
-
-	mmc_free_host(host->mmc);
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 19/36] mmc: owl-mmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (17 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 18/36] mmc: omap_hsmmc: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 20/36] mmc: pxamci: " Binbin Zhou
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Andreas Färber,
	Manivannan Sadhasivam

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: "Andreas Färber" <afaerber@suse.de>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/owl-mmc.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/host/owl-mmc.c b/drivers/mmc/host/owl-mmc.c
index 797ef48d9204..dc585726b66e 100644
--- a/drivers/mmc/host/owl-mmc.c
+++ b/drivers/mmc/host/owl-mmc.c
@@ -567,7 +567,7 @@ static int owl_mmc_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(struct owl_mmc_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*owl_host));
 	if (!mmc) {
 		dev_err(&pdev->dev, "mmc alloc host failed\n");
 		return -ENOMEM;
@@ -580,24 +580,18 @@ static int owl_mmc_probe(struct platform_device *pdev)
 	spin_lock_init(&owl_host->lock);
 
 	owl_host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(owl_host->base)) {
-		ret = PTR_ERR(owl_host->base);
-		goto err_free_host;
-	}
+	if (IS_ERR(owl_host->base))
+		return PTR_ERR(owl_host->base);
 
 	owl_host->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(owl_host->clk)) {
-		dev_err(&pdev->dev, "No clock defined\n");
-		ret = PTR_ERR(owl_host->clk);
-		goto err_free_host;
-	}
+	if (IS_ERR(owl_host->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(owl_host->clk),
+				     "No clock defined\n");
 
 	owl_host->reset = devm_reset_control_get_exclusive(&pdev->dev, NULL);
-	if (IS_ERR(owl_host->reset)) {
-		dev_err(&pdev->dev, "Could not get reset control\n");
-		ret = PTR_ERR(owl_host->reset);
-		goto err_free_host;
-	}
+	if (IS_ERR(owl_host->reset))
+		return dev_err_probe(&pdev->dev, PTR_ERR(owl_host->reset),
+				     "Could not get reset control\n");
 
 	mmc->ops		= &owl_mmc_ops;
 	mmc->max_blk_count	= 512;
@@ -616,16 +610,14 @@ static int owl_mmc_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(mmc);
 	if (ret)
-		goto err_free_host;
+		return ret;
 
 	pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 	pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
 	owl_host->dma = dma_request_chan(&pdev->dev, "mmc");
-	if (IS_ERR(owl_host->dma)) {
-		dev_err(owl_host->dev, "Failed to get external DMA channel.\n");
-		ret = PTR_ERR(owl_host->dma);
-		goto err_free_host;
-	}
+	if (IS_ERR(owl_host->dma))
+		return dev_err_probe(&pdev->dev, PTR_ERR(owl_host->dma),
+				     "Failed to get external DMA channel.\n");
 
 	dev_info(&pdev->dev, "Using %s for DMA transfers\n",
 		 dma_chan_name(owl_host->dma));
@@ -662,8 +654,6 @@ static int owl_mmc_probe(struct platform_device *pdev)
 
 err_release_channel:
 	dma_release_channel(owl_host->dma);
-err_free_host:
-	mmc_free_host(mmc);
 
 	return ret;
 }
@@ -676,7 +666,6 @@ static void owl_mmc_remove(struct platform_device *pdev)
 	mmc_remove_host(mmc);
 	disable_irq(owl_host->irq);
 	dma_release_channel(owl_host->dma);
-	mmc_free_host(mmc);
 }
 
 static const struct of_device_id owl_mmc_of_match[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 20/36] mmc: pxamci: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (18 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 19/36] mmc: owl-mmc: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 21/36] mmc: rtsx_pci: " Binbin Zhou
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/pxamci.c | 42 ++++++++++++++-------------------------
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 2d0ad006913d..26d03352af63 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -615,11 +615,9 @@ static int pxamci_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	mmc = mmc_alloc_host(sizeof(struct pxamci_host), dev);
-	if (!mmc) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
+	if (!mmc)
+		return -ENOMEM;
 
 	mmc->ops = &pxamci_ops;
 
@@ -646,7 +644,7 @@ static int pxamci_probe(struct platform_device *pdev)
 
 	ret = pxamci_of_init(pdev, mmc);
 	if (ret)
-		goto out;
+		return ret;
 
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
@@ -655,9 +653,8 @@ static int pxamci_probe(struct platform_device *pdev)
 
 	host->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(host->clk)) {
-		ret = PTR_ERR(host->clk);
 		host->clk = NULL;
-		goto out;
+		return PTR_ERR(host->clk);
 	}
 
 	host->clkrate = clk_get_rate(host->clk);
@@ -670,7 +667,7 @@ static int pxamci_probe(struct platform_device *pdev)
 
 	ret = pxamci_init_ocr(host);
 	if (ret < 0)
-		goto out;
+		return ret;
 
 	mmc->caps = 0;
 	host->cmdat = 0;
@@ -686,10 +683,8 @@ static int pxamci_probe(struct platform_device *pdev)
 	host->imask = MMC_I_MASK_ALL;
 
 	host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
-	if (IS_ERR(host->base)) {
-		ret = PTR_ERR(host->base);
-		goto out;
-	}
+	if (IS_ERR(host->base))
+		return PTR_ERR(host->base);
 	host->res = r;
 
 	/*
@@ -704,16 +699,15 @@ static int pxamci_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, pxamci_irq, 0,
 			       DRIVER_NAME, host);
 	if (ret)
-		goto out;
+		return ret;
 
 	platform_set_drvdata(pdev, mmc);
 
 	host->dma_chan_rx = dma_request_chan(dev, "rx");
 	if (IS_ERR(host->dma_chan_rx)) {
-		dev_err(dev, "unable to request rx dma channel\n");
-		ret = PTR_ERR(host->dma_chan_rx);
 		host->dma_chan_rx = NULL;
-		goto out;
+		return dev_err_probe(dev, PTR_ERR(host->dma_chan_rx),
+				     "unable to request rx dma channel\n");
 	}
 
 	host->dma_chan_tx = dma_request_chan(dev, "tx");
@@ -771,14 +765,10 @@ static int pxamci_probe(struct platform_device *pdev)
 	return 0;
 
 out:
-	if (host) {
-		if (host->dma_chan_rx)
-			dma_release_channel(host->dma_chan_rx);
-		if (host->dma_chan_tx)
-			dma_release_channel(host->dma_chan_tx);
-	}
-	if (mmc)
-		mmc_free_host(mmc);
+	if (host->dma_chan_rx)
+		dma_release_channel(host->dma_chan_rx);
+	if (host->dma_chan_tx)
+		dma_release_channel(host->dma_chan_tx);
 	return ret;
 }
 
@@ -803,8 +793,6 @@ static void pxamci_remove(struct platform_device *pdev)
 		dmaengine_terminate_all(host->dma_chan_tx);
 		dma_release_channel(host->dma_chan_rx);
 		dma_release_channel(host->dma_chan_tx);
-
-		mmc_free_host(mmc);
 	}
 }
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 21/36] mmc: rtsx_pci: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (19 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 20/36] mmc: pxamci: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 22/36] mmc: rtsx_usb_sdmmc: " Binbin Zhou
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/rtsx_pci_sdmmc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
index 0c6eb60a95fd..dc2587ff8519 100644
--- a/drivers/mmc/host/rtsx_pci_sdmmc.c
+++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
@@ -1498,7 +1498,7 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
 
 	dev_dbg(&(pdev->dev), ": Realtek PCI-E SDMMC controller found\n");
 
-	mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1529,7 +1529,6 @@ static int rtsx_pci_sdmmc_drv_probe(struct platform_device *pdev)
 	if (ret) {
 		pm_runtime_dont_use_autosuspend(&pdev->dev);
 		pm_runtime_disable(&pdev->dev);
-		mmc_free_host(mmc);
 		return ret;
 	}
 
@@ -1572,8 +1571,6 @@ static void rtsx_pci_sdmmc_drv_remove(struct platform_device *pdev)
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	mmc_free_host(mmc);
-
 	dev_dbg(&(pdev->dev),
 		": Realtek PCI-E SDMMC controller has been removed\n");
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 22/36] mmc: rtsx_usb_sdmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (20 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 21/36] mmc: rtsx_pci: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 23/36] mmc: sdricoh_cs: " Binbin Zhou
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index d229c2b83ea9..9c5d695d04b1 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1334,7 +1334,7 @@ static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
 
 	dev_dbg(&(pdev->dev), ": Realtek USB SD/MMC controller found\n");
 
-	mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1368,7 +1368,6 @@ static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
 #ifdef RTSX_USB_USE_LEDS_CLASS
 		led_classdev_unregister(&host->led);
 #endif
-		mmc_free_host(mmc);
 		pm_runtime_disable(&pdev->dev);
 		return ret;
 	}
@@ -1406,7 +1405,6 @@ static void rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev)
 	led_classdev_unregister(&host->led);
 #endif
 
-	mmc_free_host(mmc);
 	pm_runtime_disable(&pdev->dev);
 	platform_set_drvdata(pdev, NULL);
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 23/36] mmc: sdricoh_cs: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (21 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 22/36] mmc: rtsx_usb_sdmmc: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 24/36] mmc: ish_mmicf: " Binbin Zhou
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/sdricoh_cs.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index 57b8c1a96756..481cb552c2b4 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -403,9 +403,9 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 	}
 	/* allocate privdata */
 	mmc = pcmcia_dev->priv =
-	    mmc_alloc_host(sizeof(struct sdricoh_host), &pcmcia_dev->dev);
+	    devm_mmc_alloc_host(&pcmcia_dev->dev, sizeof(*host));
 	if (!mmc) {
-		dev_err(dev, "mmc_alloc_host failed\n");
+		dev_err(dev, "devm_mmc_alloc_host failed\n");
 		result = -ENOMEM;
 		goto unmap_io;
 	}
@@ -431,7 +431,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 	if (sdricoh_reset(host)) {
 		dev_dbg(dev, "could not reset\n");
 		result = -EIO;
-		goto free_host;
+		goto unmap_io;
 	}
 
 	result = mmc_add_host(mmc);
@@ -440,8 +440,6 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 		dev_dbg(dev, "mmc host registered\n");
 		return 0;
 	}
-free_host:
-	mmc_free_host(mmc);
 unmap_io:
 	pci_iounmap(pci_dev, iobase);
 	return result;
@@ -483,10 +481,8 @@ static void sdricoh_pcmcia_detach(struct pcmcia_device *link)
 		mmc_remove_host(mmc);
 		pci_iounmap(host->pci_dev, host->iobase);
 		pci_dev_put(host->pci_dev);
-		mmc_free_host(mmc);
 	}
 	pcmcia_disable_device(link);
-
 }
 
 #ifdef CONFIG_PM
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 24/36] mmc: ish_mmicf: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (22 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 23/36] mmc: sdricoh_cs: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 25/36] mmc: tifm_sd: " Binbin Zhou
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/sh_mmcif.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index ce60cec26b98..19f84584ecfa 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1444,13 +1444,13 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 	if (IS_ERR(reg))
 		return PTR_ERR(reg);
 
-	mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
-		goto err_host;
+		return ret;
 
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
@@ -1481,15 +1481,13 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, host);
 
 	host->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(host->clk)) {
-		ret = PTR_ERR(host->clk);
-		dev_err(dev, "cannot get clock: %d\n", ret);
-		goto err_host;
-	}
+	if (IS_ERR(host->clk))
+		return dev_err_probe(dev, PTR_ERR(host->clk),
+				     "cannot get clock\n");
 
 	ret = clk_prepare_enable(host->clk);
 	if (ret < 0)
-		goto err_host;
+		return ret;
 
 	sh_mmcif_clk_setup(host);
 
@@ -1542,8 +1540,6 @@ static int sh_mmcif_probe(struct platform_device *pdev)
 	clk_disable_unprepare(host->clk);
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
-err_host:
-	mmc_free_host(mmc);
 	return ret;
 }
 
@@ -1568,7 +1564,6 @@ static void sh_mmcif_remove(struct platform_device *pdev)
 	cancel_delayed_work_sync(&host->timeout_work);
 
 	clk_disable_unprepare(host->clk);
-	mmc_free_host(host->mmc);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 25/36] mmc: tifm_sd: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (23 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 24/36] mmc: ish_mmicf: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 26/36] mmc: toshsd: " Binbin Zhou
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Alex Dubov

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/tifm_sd.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index 713223f2d377..92b438003576 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -947,7 +947,7 @@ static int tifm_sd_probe(struct tifm_dev *sock)
 		return rc;
 	}
 
-	mmc = mmc_alloc_host(sizeof(struct tifm_sd), &sock->dev);
+	mmc = devm_mmc_alloc_host(&sock->dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -982,10 +982,7 @@ static int tifm_sd_probe(struct tifm_dev *sock)
 
 	if (!rc)
 		rc = mmc_add_host(mmc);
-	if (!rc)
-		return 0;
 
-	mmc_free_host(mmc);
 	return rc;
 }
 
@@ -1015,8 +1012,6 @@ static void tifm_sd_remove(struct tifm_dev *sock)
 	spin_unlock_irqrestore(&sock->lock, flags);
 	mmc_remove_host(mmc);
 	dev_dbg(&sock->dev, "after remove\n");
-
-	mmc_free_host(mmc);
 }
 
 #ifdef CONFIG_PM
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 26/36] mmc: toshsd: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (24 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 25/36] mmc: tifm_sd: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 27/36] mmc: usdhi6ro10: " Binbin Zhou
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/toshsd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/toshsd.c b/drivers/mmc/host/toshsd.c
index 497791ffada6..e5f7f8abafc0 100644
--- a/drivers/mmc/host/toshsd.c
+++ b/drivers/mmc/host/toshsd.c
@@ -612,7 +612,7 @@ static int toshsd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		return ret;
 
-	mmc = mmc_alloc_host(sizeof(struct toshsd_host), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
 	if (!mmc) {
 		ret = -ENOMEM;
 		goto err;
@@ -669,7 +669,6 @@ static int toshsd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 release:
 	pci_release_regions(pdev);
 free:
-	mmc_free_host(mmc);
 	pci_set_drvdata(pdev, NULL);
 err:
 	pci_disable_device(pdev);
@@ -685,7 +684,6 @@ static void toshsd_remove(struct pci_dev *pdev)
 	free_irq(pdev->irq, host);
 	pci_iounmap(pdev, host->ioaddr);
 	pci_release_regions(pdev);
-	mmc_free_host(host->mmc);
 	pci_set_drvdata(pdev, NULL);
 	pci_disable_device(pdev);
 }
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 27/36] mmc: usdhi6ro10: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (25 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 26/36] mmc: toshsd: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-22  7:48   ` Jesper Nilsson
  2025-05-20 11:46 ` [PATCH 28/36] mmc: ushc: " Binbin Zhou
                   ` (10 subsequent siblings)
  37 siblings, 1 reply; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Jesper Nilsson, Lars Persson

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Lars Persson <lars.persson@axis.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/usdhi6rol0.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 49efb960a052..85b49c07918b 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1762,17 +1762,17 @@ static int usdhi6_probe(struct platform_device *pdev)
 	if (irq_sdio < 0)
 		return irq_sdio;
 
-	mmc = mmc_alloc_host(sizeof(struct usdhi6_host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
-		goto e_free_mmc;
+		return ret;
 
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
-		goto e_free_mmc;
+		return ret;
 
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
@@ -1785,30 +1785,24 @@ static int usdhi6_probe(struct platform_device *pdev)
 	mmc->max_busy_timeout = USDHI6_REQ_TIMEOUT_MS;
 
 	host->pinctrl = devm_pinctrl_get(&pdev->dev);
-	if (IS_ERR(host->pinctrl)) {
-		ret = PTR_ERR(host->pinctrl);
-		goto e_free_mmc;
-	}
+	if (IS_ERR(host->pinctrl))
+		return PTR_ERR(host->pinctrl);
 
 	host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
 
 	host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
-	if (IS_ERR(host->base)) {
-		ret = PTR_ERR(host->base);
-		goto e_free_mmc;
-	}
+	if (IS_ERR(host->base))
+		return PTR_ERR(host->base);
 
 	host->clk = devm_clk_get(dev, NULL);
-	if (IS_ERR(host->clk)) {
-		ret = PTR_ERR(host->clk);
-		goto e_free_mmc;
-	}
+	if (IS_ERR(host->clk))
+		return PTR_ERR(host->clk);
 
 	host->imclk = clk_get_rate(host->clk);
 
 	ret = clk_prepare_enable(host->clk);
 	if (ret < 0)
-		goto e_free_mmc;
+		return ret;
 
 	version = usdhi6_read(host, USDHI6_VERSION);
 	if ((version & 0xfff) != 0xa0d) {
@@ -1878,9 +1872,6 @@ static int usdhi6_probe(struct platform_device *pdev)
 	usdhi6_dma_release(host);
 e_clk_off:
 	clk_disable_unprepare(host->clk);
-e_free_mmc:
-	mmc_free_host(mmc);
-
 	return ret;
 }
 
@@ -1894,7 +1885,6 @@ static void usdhi6_remove(struct platform_device *pdev)
 	cancel_delayed_work_sync(&host->timeout_work);
 	usdhi6_dma_release(host);
 	clk_disable_unprepare(host->clk);
-	mmc_free_host(host->mmc);
 }
 
 static struct platform_driver usdhi6_driver = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 28/36] mmc: ushc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (26 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 27/36] mmc: usdhi6ro10: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 29/36] mmc: via-sdmmc: " Binbin Zhou
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/ushc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c
index 9a6358fd9512..2b7456e942f7 100644
--- a/drivers/mmc/host/ushc.c
+++ b/drivers/mmc/host/ushc.c
@@ -404,8 +404,6 @@ static void ushc_clean_up(struct ushc_data *ushc)
 	kfree(ushc->int_data);
 	kfree(ushc->cbw);
 	kfree(ushc->csw);
-
-	mmc_free_host(ushc->mmc);
 }
 
 static const struct mmc_host_ops ushc_ops = {
@@ -425,7 +423,7 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
 	if (intf->cur_altsetting->desc.bNumEndpoints < 1)
 		return -ENODEV;
 
-	mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev);
+	mmc = devm_mmc_alloc_host(&intf->dev, sizeof(*ushc));
 	if (mmc == NULL)
 		return -ENOMEM;
 	ushc = mmc_priv(mmc);
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 29/36] mmc: via-sdmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (27 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 28/36] mmc: ushc: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 30/36] mmc: vub300: " Binbin Zhou
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/via-sdmmc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c
index 909d80a02824..083ab9836311 100644
--- a/drivers/mmc/host/via-sdmmc.c
+++ b/drivers/mmc/host/via-sdmmc.c
@@ -1100,7 +1100,7 @@ static int via_sd_probe(struct pci_dev *pcidev,
 	pci_write_config_byte(pcidev, VIA_CRDR_PCI_WORK_MODE, 0);
 	pci_write_config_byte(pcidev, VIA_CRDR_PCI_DBG_MODE, 0);
 
-	mmc = mmc_alloc_host(sizeof(struct via_crdr_mmc_host), &pcidev->dev);
+	mmc = devm_mmc_alloc_host(&pcidev->dev, sizeof(*sdhost));
 	if (!mmc) {
 		ret = -ENOMEM;
 		goto release;
@@ -1115,7 +1115,7 @@ static int via_sd_probe(struct pci_dev *pcidev,
 	sdhost->mmiobase = ioremap(base, len);
 	if (!sdhost->mmiobase) {
 		ret = -ENOMEM;
-		goto free_mmc_host;
+		goto release;
 	}
 
 	sdhost->sdhc_mmiobase =
@@ -1160,8 +1160,6 @@ static int via_sd_probe(struct pci_dev *pcidev,
 
 unmap:
 	iounmap(sdhost->mmiobase);
-free_mmc_host:
-	mmc_free_host(mmc);
 release:
 	pci_release_regions(pcidev);
 disable:
@@ -1212,7 +1210,6 @@ static void via_sd_remove(struct pci_dev *pcidev)
 	writeb(gatt, sdhost->pcictrl_mmiobase + VIA_CRDR_PCICLKGATT);
 
 	iounmap(sdhost->mmiobase);
-	mmc_free_host(sdhost->mmc);
 	pci_release_regions(pcidev);
 	pci_disable_device(pcidev);
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 30/36] mmc: vub300: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (28 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 29/36] mmc: via-sdmmc: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 31/36] mmc: wbsd: " Binbin Zhou
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/vub300.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
index dd71e5b8e1a5..5a5eeeaa4321 100644
--- a/drivers/mmc/host/vub300.c
+++ b/drivers/mmc/host/vub300.c
@@ -369,13 +369,11 @@ struct vub300_mmc_host {
 static void vub300_delete(struct kref *kref)
 {				/* kref callback - softirq */
 	struct vub300_mmc_host *vub300 = kref_to_vub300_mmc_host(kref);
-	struct mmc_host *mmc = vub300->mmc;
 	usb_free_urb(vub300->command_out_urb);
 	vub300->command_out_urb = NULL;
 	usb_free_urb(vub300->command_res_urb);
 	vub300->command_res_urb = NULL;
 	usb_put_dev(vub300->udev);
-	mmc_free_host(mmc);
 	/*
 	 * and hence also frees vub300
 	 * which is contained at the end of struct mmc
@@ -2114,7 +2112,7 @@ static int vub300_probe(struct usb_interface *interface,
 		goto error1;
 	}
 	/* this also allocates memory for our VUB300 mmc host device */
-	mmc = mmc_alloc_host(sizeof(struct vub300_mmc_host), &udev->dev);
+	mmc = devm_mmc_alloc_host(&udev->dev, sizeof(*vub300));
 	if (!mmc) {
 		retval = -ENOMEM;
 		dev_err(&udev->dev, "not enough memory for the mmc_host\n");
@@ -2271,7 +2269,7 @@ static int vub300_probe(struct usb_interface *interface,
 		dev_err(&vub300->udev->dev,
 		    "Could not find two sets of bulk-in/out endpoint pairs\n");
 		retval = -EINVAL;
-		goto error5;
+		goto error4;
 	}
 	retval =
 		usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0),
@@ -2280,14 +2278,14 @@ static int vub300_probe(struct usb_interface *interface,
 				0x0000, 0x0000, &vub300->hc_info,
 				sizeof(vub300->hc_info), 1000);
 	if (retval < 0)
-		goto error5;
+		goto error4;
 	retval =
 		usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
 				SET_ROM_WAIT_STATES,
 				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
 				firmware_rom_wait_states, 0x0000, NULL, 0, 1000);
 	if (retval < 0)
-		goto error5;
+		goto error4;
 	dev_info(&vub300->udev->dev,
 		 "operating_mode = %s %s %d MHz %s %d byte USB packets\n",
 		 (mmc->caps & MMC_CAP_SDIO_IRQ) ? "IRQs" : "POLL",
@@ -2302,7 +2300,7 @@ static int vub300_probe(struct usb_interface *interface,
 				0x0000, 0x0000, &vub300->system_port_status,
 				sizeof(vub300->system_port_status), 1000);
 	if (retval < 0) {
-		goto error5;
+		goto error4;
 	} else if (sizeof(vub300->system_port_status) == retval) {
 		vub300->card_present =
 			(0x0001 & vub300->system_port_status.port_flags) ? 1 : 0;
@@ -2310,7 +2308,7 @@ static int vub300_probe(struct usb_interface *interface,
 			(0x0010 & vub300->system_port_status.port_flags) ? 1 : 0;
 	} else {
 		retval = -EINVAL;
-		goto error5;
+		goto error4;
 	}
 	usb_set_intfdata(interface, vub300);
 	INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread);
@@ -2340,8 +2338,6 @@ static int vub300_probe(struct usb_interface *interface,
 	return 0;
 error6:
 	timer_delete_sync(&vub300->inactivity_timer);
-error5:
-	mmc_free_host(mmc);
 	/*
 	 * and hence also frees vub300
 	 * which is contained at the end of struct mmc
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 31/36] mmc: wbsd: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (29 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 30/36] mmc: vub300: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 11:46 ` [PATCH 32/36] mmc: wmt-sdmmc: " Binbin Zhou
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Pierre Ossman

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Pierre Ossman <pierre@ossman.eu>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/wbsd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index d5974b355a5a..392522a29430 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -1190,7 +1190,7 @@ static int wbsd_alloc_mmc(struct device *dev)
 	/*
 	 * Allocate MMC structure.
 	 */
-	mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
+	mmc = devm_mmc_alloc_host(dev, sizeof(*host));
 	if (!mmc)
 		return -ENOMEM;
 
@@ -1262,8 +1262,6 @@ static void wbsd_free_mmc(struct device *dev)
 	BUG_ON(host == NULL);
 
 	timer_delete_sync(&host->ignore_timer);
-
-	mmc_free_host(mmc);
 }
 
 /*
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 32/36] mmc: wmt-sdmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (30 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 31/36] mmc: wbsd: " Binbin Zhou
@ 2025-05-20 11:46 ` Binbin Zhou
  2025-05-20 20:23   ` Alexey Charkov
  2025-05-20 11:47 ` [PATCH 33/36] mmc: tmio: " Binbin Zhou
                   ` (5 subsequent siblings)
  37 siblings, 1 reply; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:46 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Alexey Charkov

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Alexey Charkov <alchark@gmail.com>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/wmt-sdmmc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
index cdb36a9f9e38..0d2929cfe397 100644
--- a/drivers/mmc/host/wmt-sdmmc.c
+++ b/drivers/mmc/host/wmt-sdmmc.c
@@ -774,7 +774,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
 		goto fail1;
 	}
 
-	mmc = mmc_alloc_host(sizeof(struct wmt_mci_priv), &pdev->dev);
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*priv));
 	if (!mmc) {
 		dev_err(&pdev->dev, "Failed to allocate mmc_host\n");
 		ret = -ENOMEM;
@@ -808,7 +808,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
 	if (!priv->sdmmc_base) {
 		dev_err(&pdev->dev, "Failed to map IO space\n");
 		ret = -ENOMEM;
-		goto fail2;
+		goto fail1;
 	}
 
 	priv->irq_regular = regular_irq;
@@ -873,8 +873,6 @@ static int wmt_mci_probe(struct platform_device *pdev)
 	free_irq(regular_irq, priv);
 fail3:
 	iounmap(priv->sdmmc_base);
-fail2:
-	mmc_free_host(mmc);
 fail1:
 	return ret;
 }
@@ -910,8 +908,6 @@ static void wmt_mci_remove(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk_sdmmc);
 	clk_put(priv->clk_sdmmc);
 
-	mmc_free_host(mmc);
-
 	dev_info(&pdev->dev, "WMT MCI device removed\n");
 }
 
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 33/36] mmc: tmio: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (31 preceding siblings ...)
  2025-05-20 11:46 ` [PATCH 32/36] mmc: wmt-sdmmc: " Binbin Zhou
@ 2025-05-20 11:47 ` Binbin Zhou
  2025-05-20 11:47 ` [PATCH 34/36] mmc: sunxi: " Binbin Zhou
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:47 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Wolfram Sang,
	Kunihiko Hayashi, Masami Hiramatsu

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>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/renesas_sdhi_core.c |  6 +-----
 drivers/mmc/host/tmio_mmc.h          |  1 -
 drivers/mmc/host/tmio_mmc_core.c     | 18 +++---------------
 drivers/mmc/host/uniphier-sd.c       |  8 ++------
 4 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index e6fa3ed42560..4647d86e145e 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -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);
 
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 41787ea77a13..23b0be8e6d7d 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -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);
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index b71241f55df5..c25c5fec3d77 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -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;
diff --git a/drivers/mmc/host/uniphier-sd.c b/drivers/mmc/host/uniphier-sd.c
index 4ad02cfdc238..1eae2f4b6c1f 100644
--- a/drivers/mmc/host/uniphier-sd.c
+++ b/drivers/mmc/host/uniphier-sd.c
@@ -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[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 34/36] mmc: sunxi: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (32 preceding siblings ...)
  2025-05-20 11:47 ` [PATCH 33/36] mmc: tmio: " Binbin Zhou
@ 2025-05-20 11:47 ` Binbin Zhou
  2025-05-20 11:47 ` [PATCH 35/36] mmc: mmc_spi: " Binbin Zhou
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:47 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, linux-sunxi

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: linux-sunxi@lists.linux.dev
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/sunxi-mmc.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

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


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 35/36] mmc: mmc_spi: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (33 preceding siblings ...)
  2025-05-20 11:47 ` [PATCH 34/36] mmc: sunxi: " Binbin Zhou
@ 2025-05-20 11:47 ` Binbin Zhou
  2025-05-20 11:47 ` [PATCH 36/36] mmc: meson-mx-sdio: " Binbin Zhou
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:47 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson; +Cc: Huacai Chen, linux-mmc, Binbin Zhou

Use new function devm_mmc_alloc_host() to simplify the code.

Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/mmc_spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 47443fb5eb33..35b0ad273b4f 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1185,7 +1185,7 @@ static int mmc_spi_probe(struct spi_device *spi)
 		goto nomem;
 	memset(ones, 0xff, MMC_SPI_BLOCKSIZE);
 
-	mmc = mmc_alloc_host(sizeof(*host), &spi->dev);
+	mmc = devm_mmc_alloc_host(&spi->dev, sizeof(*host));
 	if (!mmc)
 		goto nomem;
 
@@ -1305,7 +1305,6 @@ static int mmc_spi_probe(struct spi_device *spi)
 	kfree(host->data);
 fail_nobuf1:
 	mmc_spi_put_pdata(spi);
-	mmc_free_host(mmc);
 nomem:
 	kfree(ones);
 	return status;
@@ -1328,7 +1327,6 @@ static void mmc_spi_remove(struct spi_device *spi)
 
 	spi->max_speed_hz = mmc->f_max;
 	mmc_spi_put_pdata(spi);
-	mmc_free_host(mmc);
 }
 
 static const struct spi_device_id mmc_spi_dev_ids[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 36/36] mmc: meson-mx-sdio: Use devm_mmc_alloc_host() helper
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (34 preceding siblings ...)
  2025-05-20 11:47 ` [PATCH 35/36] mmc: mmc_spi: " Binbin Zhou
@ 2025-05-20 11:47 ` Binbin Zhou
  2025-05-20 19:46   ` Martin Blumenstingl
  2025-05-20 12:42 ` [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Ulf Hansson
  2025-05-20 12:58 ` Huacai Chen
  37 siblings, 1 reply; 43+ messages in thread
From: Binbin Zhou @ 2025-05-20 11:47 UTC (permalink / raw)
  To: Binbin Zhou, Huacai Chen, Ulf Hansson
  Cc: Huacai Chen, linux-mmc, Binbin Zhou, Neil Armstrong, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, linux-amlogic

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-amlogic@lists.infradead.org
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
---
 drivers/mmc/host/meson-mx-sdio.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c
index e0ae5a0c9670..b6cb475f1a5f 100644
--- a/drivers/mmc/host/meson-mx-sdio.c
+++ b/drivers/mmc/host/meson-mx-sdio.c
@@ -640,7 +640,7 @@ static int meson_mx_mmc_probe(struct platform_device *pdev)
 	else if (IS_ERR(slot_pdev))
 		return PTR_ERR(slot_pdev);
 
-	mmc = mmc_alloc_host(sizeof(*host), &slot_pdev->dev);
+	mmc = devm_mmc_alloc_host(&slot_pdev->dev, sizeof(*host));
 	if (!mmc) {
 		ret = -ENOMEM;
 		goto error_unregister_slot_pdev;
@@ -658,13 +658,13 @@ static int meson_mx_mmc_probe(struct platform_device *pdev)
 	host->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(host->base)) {
 		ret = PTR_ERR(host->base);
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		ret = irq;
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 	}
 
 	ret = devm_request_threaded_irq(host->controller_dev, irq,
@@ -672,28 +672,28 @@ static int meson_mx_mmc_probe(struct platform_device *pdev)
 					meson_mx_mmc_irq_thread, IRQF_ONESHOT,
 					NULL, host);
 	if (ret)
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 
 	host->core_clk = devm_clk_get(host->controller_dev, "core");
 	if (IS_ERR(host->core_clk)) {
 		ret = PTR_ERR(host->core_clk);
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 	}
 
 	host->parent_clk = devm_clk_get(host->controller_dev, "clkin");
 	if (IS_ERR(host->parent_clk)) {
 		ret = PTR_ERR(host->parent_clk);
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 	}
 
 	ret = meson_mx_mmc_register_clks(host);
 	if (ret)
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 
 	ret = clk_prepare_enable(host->core_clk);
 	if (ret) {
 		dev_err(host->controller_dev, "Failed to enable core clock\n");
-		goto error_free_mmc;
+		goto error_unregister_slot_pdev;
 	}
 
 	ret = clk_prepare_enable(host->cfg_div_clk);
@@ -721,8 +721,6 @@ static int meson_mx_mmc_probe(struct platform_device *pdev)
 	clk_disable_unprepare(host->cfg_div_clk);
 error_disable_core_clk:
 	clk_disable_unprepare(host->core_clk);
-error_free_mmc:
-	mmc_free_host(mmc);
 error_unregister_slot_pdev:
 	of_platform_device_destroy(&slot_pdev->dev, NULL);
 	return ret;
@@ -741,8 +739,6 @@ static void meson_mx_mmc_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(host->cfg_div_clk);
 	clk_disable_unprepare(host->core_clk);
-
-	mmc_free_host(host->mmc);
 }
 
 static const struct of_device_id meson_mx_mmc_of_match[] = {
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (35 preceding siblings ...)
  2025-05-20 11:47 ` [PATCH 36/36] mmc: meson-mx-sdio: " Binbin Zhou
@ 2025-05-20 12:42 ` Ulf Hansson
  2025-05-20 12:58 ` Huacai Chen
  37 siblings, 0 replies; 43+ messages in thread
From: Ulf Hansson @ 2025-05-20 12:42 UTC (permalink / raw)
  To: Binbin Zhou; +Cc: Binbin Zhou, Huacai Chen, Huacai Chen, linux-mmc

On Tue, 20 May 2025 at 13:45, Binbin Zhou <zhoubinbin@loongson.cn> wrote:
>
> Hi all:
>
> Since the devm_mmc_alloc_host() helper was already available, I tried to
> start cleaning up the use of mmc_alloc_host().
>
> To make it easier to review the patchset, I decided to split it into two parts.
> As the first part, this patchset contains cleanup for drivers other than sdhci.
>
> Of course, the sdhci part I have ready in my repository.
>
> Thanks.
>
> Binbin Zhou (36):
>   mmc: alcor: Use devm_mmc_alloc_host() helper
>   mmc: atmel: Use devm_mmc_alloc_host() helper
>   mmc: au1xmmc: Use devm_mmc_alloc_host() helper
>   mmc: bcm2835: Use devm_mmc_alloc_host() helper
>   mmc: cavium: Use devm_mmc_alloc_host() helper
>   mmc: cb710: Use devm_mmc_alloc_host() helper
>   mmc: davinci_mmc: Use devm_mmc_alloc_host() helper
>   mmc: dw_mmc: Use devm_mmc_alloc_host() helper
>   mmc: jz4740: Use devm_mmc_alloc_host() helper
>   mmc: litex_mmc: Use devm_mmc_alloc_host() helper
>   mmc: meson-mx-sdhc: Use devm_mmc_alloc_host() helper
>   mmc: mmci: Use devm_mmc_alloc_host() helper
>   mmc: moxart-mmc: Use devm_mmc_alloc_host() helper
>   mmc: mvsdio: Use devm_mmc_alloc_host() helper
>   mmc: mxcmmc: Use devm_mmc_alloc_host() helper
>   mmc: mxs-mmc: Use devm_mmc_alloc_host() helper
>   mmc: omap: Use devm_mmc_alloc_host() helper
>   mmc: omap_hsmmc: Use devm_mmc_alloc_host() helper
>   mmc: owl-mmc: Use devm_mmc_alloc_host() helper
>   mmc: pxamci: Use devm_mmc_alloc_host() helper
>   mmc: rtsx_pci: Use devm_mmc_alloc_host() helper
>   mmc: rtsx_usb_sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: sdricoh_cs: Use devm_mmc_alloc_host() helper
>   mmc: ish_mmicf: Use devm_mmc_alloc_host() helper
>   mmc: tifm_sd: Use devm_mmc_alloc_host() helper
>   mmc: toshsd: Use devm_mmc_alloc_host() helper
>   mmc: usdhi6ro10: Use devm_mmc_alloc_host() helper
>   mmc: ushc: Use devm_mmc_alloc_host() helper
>   mmc: via-sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: vub300: Use devm_mmc_alloc_host() helper
>   mmc: wbsd: Use devm_mmc_alloc_host() helper
>   mmc: wmt-sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: tmio: Use devm_mmc_alloc_host() helper
>   mmc: sunxi: Use devm_mmc_alloc_host() helper
>   mmc: mmc_spi: Use devm_mmc_alloc_host() helper
>   mmc: meson-mx-sdio: Use devm_mmc_alloc_host() helper
>
>  drivers/mmc/host/alcor.c             | 20 ++++---------
>  drivers/mmc/host/atmel-mci.c         |  7 ++---
>  drivers/mmc/host/au1xmmc.c           | 14 +++-------
>  drivers/mmc/host/bcm2835.c           |  5 +---
>  drivers/mmc/host/cavium.c            | 10 ++-----
>  drivers/mmc/host/cb710-mmc.c         |  5 +---
>  drivers/mmc/host/davinci_mmc.c       | 22 +++++----------
>  drivers/mmc/host/dw_mmc.c            | 15 ++++------
>  drivers/mmc/host/jz4740_mmc.c        | 40 +++++++++-----------------
>  drivers/mmc/host/litex_mmc.c         | 12 +-------
>  drivers/mmc/host/meson-mx-sdhc-mmc.c | 13 +--------
>  drivers/mmc/host/meson-mx-sdio.c     | 20 ++++++-------
>  drivers/mmc/host/mmc_spi.c           |  4 +--
>  drivers/mmc/host/mmci.c              | 31 ++++++++------------
>  drivers/mmc/host/moxart-mmc.c        | 40 ++++++++++----------------
>  drivers/mmc/host/mvsdio.c            | 24 +++++-----------
>  drivers/mmc/host/mxcmmc.c            | 31 +++++++-------------
>  drivers/mmc/host/mxs-mmc.c           | 31 ++++++++------------
>  drivers/mmc/host/omap.c              | 25 ++++++-----------
>  drivers/mmc/host/omap_hsmmc.c        | 18 ++++--------
>  drivers/mmc/host/owl-mmc.c           | 37 +++++++++---------------
>  drivers/mmc/host/pxamci.c            | 42 ++++++++++------------------
>  drivers/mmc/host/renesas_sdhi_core.c |  6 +---
>  drivers/mmc/host/rtsx_pci_sdmmc.c    |  5 +---
>  drivers/mmc/host/rtsx_usb_sdmmc.c    |  4 +--
>  drivers/mmc/host/sdricoh_cs.c        | 10 ++-----
>  drivers/mmc/host/sh_mmcif.c          | 17 ++++-------
>  drivers/mmc/host/sunxi-mmc.c         | 22 ++++++---------
>  drivers/mmc/host/tifm_sd.c           |  7 +----
>  drivers/mmc/host/tmio_mmc.h          |  1 -
>  drivers/mmc/host/tmio_mmc_core.c     | 18 ++----------
>  drivers/mmc/host/toshsd.c            |  4 +--
>  drivers/mmc/host/uniphier-sd.c       |  8 ++----
>  drivers/mmc/host/usdhi6rol0.c        | 30 +++++++-------------
>  drivers/mmc/host/ushc.c              |  4 +--
>  drivers/mmc/host/via-sdmmc.c         |  7 ++---
>  drivers/mmc/host/vub300.c            | 16 ++++-------
>  drivers/mmc/host/wbsd.c              |  4 +--
>  drivers/mmc/host/wmt-sdmmc.c         |  8 ++----
>  39 files changed, 195 insertions(+), 442 deletions(-)

That's a nice changelog. :-)

I have looked through the changes and they all look good to me. Just a
minor typo in the commit-msg-header of patch24, which I took care of.

So, applied for next, thanks!

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage
  2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
                   ` (36 preceding siblings ...)
  2025-05-20 12:42 ` [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Ulf Hansson
@ 2025-05-20 12:58 ` Huacai Chen
  37 siblings, 0 replies; 43+ messages in thread
From: Huacai Chen @ 2025-05-20 12:58 UTC (permalink / raw)
  To: Binbin Zhou; +Cc: Binbin Zhou, Huacai Chen, Ulf Hansson, linux-mmc

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

On Tue, May 20, 2025 at 7:45 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
>
> Hi all:
>
> Since the devm_mmc_alloc_host() helper was already available, I tried to
> start cleaning up the use of mmc_alloc_host().
>
> To make it easier to review the patchset, I decided to split it into two parts.
> As the first part, this patchset contains cleanup for drivers other than sdhci.
>
> Of course, the sdhci part I have ready in my repository.
>
> Thanks.
>
> Binbin Zhou (36):
>   mmc: alcor: Use devm_mmc_alloc_host() helper
>   mmc: atmel: Use devm_mmc_alloc_host() helper
>   mmc: au1xmmc: Use devm_mmc_alloc_host() helper
>   mmc: bcm2835: Use devm_mmc_alloc_host() helper
>   mmc: cavium: Use devm_mmc_alloc_host() helper
>   mmc: cb710: Use devm_mmc_alloc_host() helper
>   mmc: davinci_mmc: Use devm_mmc_alloc_host() helper
>   mmc: dw_mmc: Use devm_mmc_alloc_host() helper
>   mmc: jz4740: Use devm_mmc_alloc_host() helper
>   mmc: litex_mmc: Use devm_mmc_alloc_host() helper
>   mmc: meson-mx-sdhc: Use devm_mmc_alloc_host() helper
>   mmc: mmci: Use devm_mmc_alloc_host() helper
>   mmc: moxart-mmc: Use devm_mmc_alloc_host() helper
>   mmc: mvsdio: Use devm_mmc_alloc_host() helper
>   mmc: mxcmmc: Use devm_mmc_alloc_host() helper
>   mmc: mxs-mmc: Use devm_mmc_alloc_host() helper
>   mmc: omap: Use devm_mmc_alloc_host() helper
>   mmc: omap_hsmmc: Use devm_mmc_alloc_host() helper
>   mmc: owl-mmc: Use devm_mmc_alloc_host() helper
>   mmc: pxamci: Use devm_mmc_alloc_host() helper
>   mmc: rtsx_pci: Use devm_mmc_alloc_host() helper
>   mmc: rtsx_usb_sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: sdricoh_cs: Use devm_mmc_alloc_host() helper
>   mmc: ish_mmicf: Use devm_mmc_alloc_host() helper
>   mmc: tifm_sd: Use devm_mmc_alloc_host() helper
>   mmc: toshsd: Use devm_mmc_alloc_host() helper
>   mmc: usdhi6ro10: Use devm_mmc_alloc_host() helper
>   mmc: ushc: Use devm_mmc_alloc_host() helper
>   mmc: via-sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: vub300: Use devm_mmc_alloc_host() helper
>   mmc: wbsd: Use devm_mmc_alloc_host() helper
>   mmc: wmt-sdmmc: Use devm_mmc_alloc_host() helper
>   mmc: tmio: Use devm_mmc_alloc_host() helper
>   mmc: sunxi: Use devm_mmc_alloc_host() helper
>   mmc: mmc_spi: Use devm_mmc_alloc_host() helper
>   mmc: meson-mx-sdio: Use devm_mmc_alloc_host() helper
>
>  drivers/mmc/host/alcor.c             | 20 ++++---------
>  drivers/mmc/host/atmel-mci.c         |  7 ++---
>  drivers/mmc/host/au1xmmc.c           | 14 +++-------
>  drivers/mmc/host/bcm2835.c           |  5 +---
>  drivers/mmc/host/cavium.c            | 10 ++-----
>  drivers/mmc/host/cb710-mmc.c         |  5 +---
>  drivers/mmc/host/davinci_mmc.c       | 22 +++++----------
>  drivers/mmc/host/dw_mmc.c            | 15 ++++------
>  drivers/mmc/host/jz4740_mmc.c        | 40 +++++++++-----------------
>  drivers/mmc/host/litex_mmc.c         | 12 +-------
>  drivers/mmc/host/meson-mx-sdhc-mmc.c | 13 +--------
>  drivers/mmc/host/meson-mx-sdio.c     | 20 ++++++-------
>  drivers/mmc/host/mmc_spi.c           |  4 +--
>  drivers/mmc/host/mmci.c              | 31 ++++++++------------
>  drivers/mmc/host/moxart-mmc.c        | 40 ++++++++++----------------
>  drivers/mmc/host/mvsdio.c            | 24 +++++-----------
>  drivers/mmc/host/mxcmmc.c            | 31 +++++++-------------
>  drivers/mmc/host/mxs-mmc.c           | 31 ++++++++------------
>  drivers/mmc/host/omap.c              | 25 ++++++-----------
>  drivers/mmc/host/omap_hsmmc.c        | 18 ++++--------
>  drivers/mmc/host/owl-mmc.c           | 37 +++++++++---------------
>  drivers/mmc/host/pxamci.c            | 42 ++++++++++------------------
>  drivers/mmc/host/renesas_sdhi_core.c |  6 +---
>  drivers/mmc/host/rtsx_pci_sdmmc.c    |  5 +---
>  drivers/mmc/host/rtsx_usb_sdmmc.c    |  4 +--
>  drivers/mmc/host/sdricoh_cs.c        | 10 ++-----
>  drivers/mmc/host/sh_mmcif.c          | 17 ++++-------
>  drivers/mmc/host/sunxi-mmc.c         | 22 ++++++---------
>  drivers/mmc/host/tifm_sd.c           |  7 +----
>  drivers/mmc/host/tmio_mmc.h          |  1 -
>  drivers/mmc/host/tmio_mmc_core.c     | 18 ++----------
>  drivers/mmc/host/toshsd.c            |  4 +--
>  drivers/mmc/host/uniphier-sd.c       |  8 ++----
>  drivers/mmc/host/usdhi6rol0.c        | 30 +++++++-------------
>  drivers/mmc/host/ushc.c              |  4 +--
>  drivers/mmc/host/via-sdmmc.c         |  7 ++---
>  drivers/mmc/host/vub300.c            | 16 ++++-------
>  drivers/mmc/host/wbsd.c              |  4 +--
>  drivers/mmc/host/wmt-sdmmc.c         |  8 ++----
>  39 files changed, 195 insertions(+), 442 deletions(-)
>
>
> base-commit: eb68ba4af6da720caaf752b5618220efd5cf31dc
> --
> 2.47.1
>

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 36/36] mmc: meson-mx-sdio: Use devm_mmc_alloc_host() helper
  2025-05-20 11:47 ` [PATCH 36/36] mmc: meson-mx-sdio: " Binbin Zhou
@ 2025-05-20 19:46   ` Martin Blumenstingl
  0 siblings, 0 replies; 43+ messages in thread
From: Martin Blumenstingl @ 2025-05-20 19:46 UTC (permalink / raw)
  To: Binbin Zhou
  Cc: Binbin Zhou, Huacai Chen, Ulf Hansson, Huacai Chen, linux-mmc,
	Neil Armstrong, Kevin Hilman, Jerome Brunet, linux-amlogic

Hello,

On Tue, May 20, 2025 at 1:47 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
[...]
> -       mmc = mmc_alloc_host(sizeof(*host), &slot_pdev->dev);
> +       mmc = devm_mmc_alloc_host(&slot_pdev->dev, sizeof(*host));
Last time I tried this I had some problems. I don't fully recall the
issues (I can test in the next few days).
In the meantime: could you please double-check the driver code to see
if you spot any issues (the special bit here is that the struct device
is created by of_platform_device_create())?


Best regards,
Martin

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 32/36] mmc: wmt-sdmmc: Use devm_mmc_alloc_host() helper
  2025-05-20 11:46 ` [PATCH 32/36] mmc: wmt-sdmmc: " Binbin Zhou
@ 2025-05-20 20:23   ` Alexey Charkov
  0 siblings, 0 replies; 43+ messages in thread
From: Alexey Charkov @ 2025-05-20 20:23 UTC (permalink / raw)
  To: Binbin Zhou; +Cc: Binbin Zhou, Huacai Chen, Ulf Hansson, Huacai Chen, linux-mmc

On Tue, May 20, 2025 at 3:47 PM Binbin Zhou <zhoubinbin@loongson.cn> wrote:
>
> Use new function devm_mmc_alloc_host() to simplify the code.
>
> Cc: Alexey Charkov <alchark@gmail.com>
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
>  drivers/mmc/host/wmt-sdmmc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)

Tested on my VIA APC Rock board (WonderMedia WM8950 based).

Acked-by: Alexey Charkov <alchark@gmail.com>

Thanks a lot!

Best regards,
Alexey

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 06/36] mmc: cb710: Use devm_mmc_alloc_host() helper
  2025-05-20 11:45 ` [PATCH 06/36] mmc: cb710: " Binbin Zhou
@ 2025-05-21  9:48   ` Michał Mirosław
  0 siblings, 0 replies; 43+ messages in thread
From: Michał Mirosław @ 2025-05-21  9:48 UTC (permalink / raw)
  To: Binbin Zhou; +Cc: Binbin Zhou, Huacai Chen, Ulf Hansson, Huacai Chen, linux-mmc

On Tue, May 20, 2025 at 07:45:07PM +0800, Binbin Zhou wrote:
> Use new function devm_mmc_alloc_host() to simplify the code.

Acked-by: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>


> Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
> ---
>  drivers/mmc/host/cb710-mmc.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
> index d741c1f9cf87..8787e7f49e94 100644
> --- a/drivers/mmc/host/cb710-mmc.c
> +++ b/drivers/mmc/host/cb710-mmc.c
> @@ -692,7 +692,7 @@ static int cb710_mmc_init(struct platform_device *pdev)
>  	int err;
>  	u32 val;
>  
> -	mmc = mmc_alloc_host(sizeof(*reader), cb710_slot_dev(slot));
> +	mmc = devm_mmc_alloc_host(cb710_slot_dev(slot), sizeof(*reader));
>  	if (!mmc)
>  		return -ENOMEM;
>  
> @@ -741,7 +741,6 @@ static int cb710_mmc_init(struct platform_device *pdev)
>  	dev_dbg(cb710_slot_dev(slot), "mmc_add_host() failed: %d\n", err);
>  
>  	cb710_set_irq_handler(slot, NULL);
> -	mmc_free_host(mmc);
>  	return err;
>  }
>  
> @@ -764,8 +763,6 @@ static void cb710_mmc_exit(struct platform_device *pdev)
>  	cb710_write_port_16(slot, CB710_MMC_CONFIGB_PORT, 0);
>  
>  	cancel_work_sync(&reader->finish_req_bh_work);
> -
> -	mmc_free_host(mmc);
>  }
>  
>  static struct platform_driver cb710_mmc_driver = {
> -- 
> 2.47.1
> 

-- 
Michał Mirosław

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 27/36] mmc: usdhi6ro10: Use devm_mmc_alloc_host() helper
  2025-05-20 11:46 ` [PATCH 27/36] mmc: usdhi6ro10: " Binbin Zhou
@ 2025-05-22  7:48   ` Jesper Nilsson
  0 siblings, 0 replies; 43+ messages in thread
From: Jesper Nilsson @ 2025-05-22  7:48 UTC (permalink / raw)
  To: Binbin Zhou
  Cc: Binbin Zhou, Huacai Chen, Ulf Hansson, Huacai Chen, linux-mmc,
	Jesper Nilsson, Lars Persson

On Tue, May 20, 2025 at 07:46:34PM +0800, Binbin Zhou wrote
> [Some people who received this message don't often get email from zhoubinbin@loongson.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> Use new function devm_mmc_alloc_host() to simplify the code.

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2025-05-22  7:48 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-20 11:44 [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Binbin Zhou
2025-05-20 11:44 ` [PATCH 01/36] mmc: alcor: Use devm_mmc_alloc_host() helper Binbin Zhou
2025-05-20 11:44 ` [PATCH 02/36] mmc: atmel: " Binbin Zhou
2025-05-20 11:44 ` [PATCH 03/36] mmc: au1xmmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 04/36] mmc: bcm2835: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 05/36] mmc: cavium: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 06/36] mmc: cb710: " Binbin Zhou
2025-05-21  9:48   ` Michał Mirosław
2025-05-20 11:45 ` [PATCH 07/36] mmc: davinci_mmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 08/36] mmc: dw_mmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 09/36] mmc: jz4740: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 10/36] mmc: litex_mmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 11/36] mmc: meson-mx-sdhc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 12/36] mmc: mmci: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 13/36] mmc: moxart-mmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 14/36] mmc: mvsdio: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 15/36] mmc: mxcmmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 16/36] mmc: mxs-mmc: " Binbin Zhou
2025-05-20 11:45 ` [PATCH 17/36] mmc: omap: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 18/36] mmc: omap_hsmmc: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 19/36] mmc: owl-mmc: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 20/36] mmc: pxamci: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 21/36] mmc: rtsx_pci: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 22/36] mmc: rtsx_usb_sdmmc: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 23/36] mmc: sdricoh_cs: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 24/36] mmc: ish_mmicf: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 25/36] mmc: tifm_sd: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 26/36] mmc: toshsd: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 27/36] mmc: usdhi6ro10: " Binbin Zhou
2025-05-22  7:48   ` Jesper Nilsson
2025-05-20 11:46 ` [PATCH 28/36] mmc: ushc: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 29/36] mmc: via-sdmmc: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 30/36] mmc: vub300: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 31/36] mmc: wbsd: " Binbin Zhou
2025-05-20 11:46 ` [PATCH 32/36] mmc: wmt-sdmmc: " Binbin Zhou
2025-05-20 20:23   ` Alexey Charkov
2025-05-20 11:47 ` [PATCH 33/36] mmc: tmio: " Binbin Zhou
2025-05-20 11:47 ` [PATCH 34/36] mmc: sunxi: " Binbin Zhou
2025-05-20 11:47 ` [PATCH 35/36] mmc: mmc_spi: " Binbin Zhou
2025-05-20 11:47 ` [PATCH 36/36] mmc: meson-mx-sdio: " Binbin Zhou
2025-05-20 19:46   ` Martin Blumenstingl
2025-05-20 12:42 ` [PATCH 00/36] mmc: Cleanup mmc_alloc_host() usage Ulf Hansson
2025-05-20 12:58 ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox