Skip to content

Commit

Permalink
mmc: jz4740: Fix error handling in the probe function
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Sep 3, 2015
1 parent 10353ab commit baa4740
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/mmc/host/jz4740_mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
dev_name(&pdev->dev), host);
if (ret) {
dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
goto err_release_dma;
goto err_free_host;
}

jz4740_mmc_clock_disable(host);
Expand All @@ -1064,16 +1064,18 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
/* It is not important when it times out, it just needs to timeout. */
set_timer_slack(&host->timeout_timer, HZ);

host->use_dma = true;
if (host->use_dma && jz4740_mmc_acquire_dma_channels(host) != 0)
host->use_dma = false;
ret = jz4740_mmc_acquire_dma_channels(host);
if (ret == -EPROBE_DEFER)
goto err_free_irq;

host->use_dma = !ret;

platform_set_drvdata(pdev, host);
ret = mmc_add_host(mmc);

if (ret) {
dev_err(&pdev->dev, "Failed to add mmc host: %d\n", ret);
goto err_free_irq;
goto err_release_dma;
}
dev_info(&pdev->dev, "JZ SD/MMC card driver registered\n");

Expand All @@ -1083,11 +1085,11 @@ static int jz4740_mmc_probe(struct platform_device* pdev)

return 0;

err_free_irq:
free_irq(host->irq, host);
err_release_dma:
if (host->use_dma)
jz4740_mmc_release_dma_channels(host);
err_free_irq:
free_irq(host->irq, host);
err_free_host:
mmc_free_host(mmc);

Expand Down

0 comments on commit baa4740

Please sign in to comment.