diff options
author | Marco Felsch <m.felsch@pengutronix.de> | 2019-09-11 17:07:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-09-12 10:30:12 +0200 |
commit | 8b76032fdf83521c3df55cae50fba286e23746ae (patch) | |
tree | 122f88df465396f0368a368221836ccf130460ea /drivers/mci | |
parent | 2e16c52ea277dd002235835a10f349233c31d965 (diff) | |
download | barebox-8b76032fdf83521c3df55cae50fba286e23746ae.tar.gz barebox-8b76032fdf83521c3df55cae50fba286e23746ae.tar.xz |
mci: imx-esdhc: fix error handling during probe
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci')
-rw-r--r-- | drivers/mci/imx-esdhc.c | 30 |
1 files 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 = { |