omap_hsmmc: free dma on errors
[pandora-kernel.git] / drivers / mmc / host / omap_hsmmc.c
index 348f577..3c4a0e4 100644 (file)
@@ -1039,6 +1039,19 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
                omap_hsmmc_request_done(host, cmd->mrq);
 }
 
+static void omap_hsmmc_free_dma(struct omap_hsmmc_host *host)
+{
+       int dma_ch;
+
+       dma_ch = xchg(&host->dma_ch_tx, -1);
+       if (dma_ch != -1)
+               omap_free_dma(dma_ch);
+
+       dma_ch = xchg(&host->dma_ch_rx, -1);
+       if (dma_ch != -1)
+               omap_free_dma(dma_ch);
+}
+
 /*
  * DMA clean up for command errors
  */
@@ -1059,6 +1072,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
                        omap_hsmmc_get_dma_dir(host, host->data));
                host->data->host_cookie = 0;
        }
+       omap_hsmmc_free_dma(host);
        host->data = NULL;
 }
 
@@ -2346,18 +2360,11 @@ static int omap_hsmmc_resume(struct device *dev)
 static int omap_hsmmc_runtime_suspend(struct device *dev)
 {
        struct omap_hsmmc_host *host;
-       int dma_ch;
 
        host = platform_get_drvdata(to_platform_device(dev));
        omap_hsmmc_context_save(host);
 
-       dma_ch = xchg(&host->dma_ch_tx, -1);
-       if (dma_ch != -1)
-               omap_free_dma(dma_ch);
-
-       dma_ch = xchg(&host->dma_ch_rx, -1);
-       if (dma_ch != -1)
-               omap_free_dma(dma_ch);
+       omap_hsmmc_free_dma(host);
 
        dev_dbg(mmc_dev(host->mmc), "disabled\n");