mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: imx-esdhc: fix error handling during probe
@ 2019-09-11 15:07 Marco Felsch
  2019-09-12  6:43 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Marco Felsch @ 2019-09-11 15:07 UTC (permalink / raw)
  To: barebox

Currently the the driver don't handle any error and return immediately.
Handling the errors correctly is a must to support defered probing.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/mci/imx-esdhc.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index f71ca539ed..db3450a26d 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -653,20 +653,24 @@ static int fsl_esdhc_probe(struct device_d *dev)
 	dma_set_mask(dev, DMA_BIT_MASK(32));
 
 	host->clk = clk_get(dev, socdata->clkidx);
-	if (IS_ERR(host->clk))
-		return PTR_ERR(host->clk);
+	if (IS_ERR(host->clk)) {
+		ret = PTR_ERR(host->clk);
+		goto err_free;
+	}
 
 	ret = clk_enable(host->clk);
 	if (ret) {
 		dev_err(dev, "Failed to enable clock: %s\n",
 			strerror(ret));
-		return ret;
+		goto err_clk_put;
 	}
 
 	host->dev = dev;
 	iores = dev_request_mem_resource(dev, 0);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
+	if (IS_ERR(iores)) {
+		ret = PTR_ERR(iores);
+		goto err_clk_disable;
+	}
 	host->regs = IOMEM(iores->start);
 
 	caps = esdhc_read32(host, SDHCI_CAPABILITIES);
@@ -709,7 +713,21 @@ static int fsl_esdhc_probe(struct device_d *dev)
 
 	dev->priv = host;
 
-	return mci_register(&host->mci);
+	ret = mci_register(&host->mci);
+	if (ret)
+		goto err_release_res;
+
+	return 0;
+
+err_release_res:
+	release_region(iores);
+err_clk_disable:
+	clk_disable(host->clk);
+err_clk_put:
+	clk_put(host->clk);
+err_free:
+	free(host);
+	return ret;
 }
 
 static struct esdhc_soc_data esdhc_imx25_data = {
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] mci: imx-esdhc: fix error handling during probe
  2019-09-11 15:07 [PATCH] mci: imx-esdhc: fix error handling during probe Marco Felsch
@ 2019-09-12  6:43 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-09-12  6:43 UTC (permalink / raw)
  To: Marco Felsch; +Cc: barebox, Lucas Stach

On Wed, Sep 11, 2019 at 05:07:06PM +0200, Marco Felsch wrote:
> Currently the the driver don't handle any error and return immediately.
> Handling the errors correctly is a must to support defered probing.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  drivers/mci/imx-esdhc.c | 30 ++++++++++++++++++++++++------
>  1 file changed, 24 insertions(+), 6 deletions(-)

Applied, thanks

Lucas, it gets time for your probe-devices-on-demand series ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-09-12  6:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 15:07 [PATCH] mci: imx-esdhc: fix error handling during probe Marco Felsch
2019-09-12  6:43 ` Sascha Hauer

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