All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kishore Kadiyala <kishore.kadiyala@ti.com>
To: linux-mmc@vger.kernel.org, linux-omap@vger.kernel.org
Cc: tony@atomide.com, cjb@laptop.org, madhu.cr@ti.com,
	Kishore Kadiyala <kishore.kadiyala@ti.com>
Subject: [PATCH 2/4] omap: hsmmc: Rename and cleanup omap_hsmmc_dma_cleanup
Date: Tue, 18 Jan 2011 22:56:29 +0530	[thread overview]
Message-ID: <1295371591-13610-3-git-send-email-kishore.kadiyala@ti.com> (raw)
In-Reply-To: <1295371591-13610-1-git-send-email-kishore.kadiyala@ti.com>

Renaming omap_hsmmc_dma_cleanup as omap_hsmmc_xfer_cleanup and doing some
cleanup by handling the error & success scenarios during a transfer for
different xfer_type.

Signed-off-by: Kishore Kadiyala <kishore.kadiyala@ti.com>
Reviewed-by: Sukumar Ghorai <s-ghorai@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   52 ++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 8fb8586..7cf0383 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -935,25 +935,37 @@ omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
 }
 
 /*
- * DMA clean up for command errors
+ * SDMA clean up during SDMA transfers.
+ * Also unmapping of sg list in case of error/transfer done during
+ * SDMA/ADMA transfers.
  */
-static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
+static void omap_hsmmc_xfer_cleanup(struct omap_hsmmc_host *host, int errno)
 {
 	int dma_ch;
+	struct mmc_data *data = errno ? host->data : host->mrq->data;
 
-	host->data->error = errno;
-
-	spin_lock(&host->irq_lock);
-	dma_ch = host->dma_ch;
-	host->dma_ch = -1;
-	spin_unlock(&host->irq_lock);
-
-	if (host->xfer_type && dma_ch != -1) {
-		dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, host->dma_len,
-			omap_hsmmc_get_dma_dir(host, host->data));
+	switch (host->xfer_type) {
+	case OMAP_HSMMC_USE_SDMA_XFER:
+		spin_lock(&host->irq_lock);
+		dma_ch = host->dma_ch;
+		host->dma_ch = -1;
+		spin_unlock(&host->irq_lock);
+		if (dma_ch != -1)
+			dma_unmap_sg(mmc_dev(host->mmc), data->sg,
+				host->dma_len,
+				omap_hsmmc_get_dma_dir(host, data));
 		omap_free_dma(dma_ch);
+		break;
+	case OMAP_HSMMC_USE_PIO_XFER:
+		/* TODO */
+		break;
+	default:
+		dev_dbg(mmc_dev(host->mmc), "Unknown xfer_type\n");
+	}
+	if (errno) {
+		host->data->error = errno;
+		host->data = NULL;
 	}
-	host->data = NULL;
 }
 
 /*
@@ -1059,7 +1071,7 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 			}
 			if (host->data || host->response_busy) {
 				if (host->data)
-					omap_hsmmc_dma_cleanup(host,
+					omap_hsmmc_xfer_cleanup(host,
 								-ETIMEDOUT);
 				host->response_busy = 0;
 				omap_hsmmc_reset_controller_fsm(host, SRD);
@@ -1072,7 +1084,7 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 						-ETIMEDOUT : -EILSEQ;
 
 				if (host->data)
-					omap_hsmmc_dma_cleanup(host, err);
+					omap_hsmmc_xfer_cleanup(host, err);
 				else
 					host->mrq->cmd->error = err;
 				host->response_busy = 0;
@@ -1310,7 +1322,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
 {
 	struct omap_hsmmc_host *host = cb_data;
 	struct mmc_data *data = host->mrq->data;
-	int dma_ch, req_in_progress;
+	int req_in_progress;
 
 	if (!(ch_status & OMAP_DMA_BLOCK_IRQ)) {
 		dev_warn(mmc_dev(host->mmc), "unexpected dma status %x\n",
@@ -1332,16 +1344,10 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
 		spin_unlock(&host->irq_lock);
 		return;
 	}
-
-	dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len,
-		omap_hsmmc_get_dma_dir(host, data));
-
 	req_in_progress = host->req_in_progress;
-	dma_ch = host->dma_ch;
-	host->dma_ch = -1;
 	spin_unlock(&host->irq_lock);
 
-	omap_free_dma(dma_ch);
+	omap_hsmmc_xfer_cleanup(host, 0);
 
 	/* If DMA has finished after TC, complete the request */
 	if (!req_in_progress) {
-- 
1.7.1


  parent reply	other threads:[~2011-01-18 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18 17:26 [PATCH 0/4] omap4: hsmmc: Adding ADMA support Kishore Kadiyala
2011-01-18 17:26 ` [PATCH 1/4] omap: hsmmc: Rename use_dma to xfer_type and define possible transfers Kishore Kadiyala
2011-01-18 17:26 ` Kishore Kadiyala [this message]
2011-01-18 17:26 ` [PATCH 3/4] omap4: hsmmc: Adding ADMA support for MMC1 & MMC2 controllers Kishore Kadiyala
2011-01-18 17:26 ` [PATCH 4/4] omap4: hsmmc: enable ADMA for MMC1 & MMC2 Kishore Kadiyala
2011-01-20 17:42 ` [PATCH 0/4] omap4: hsmmc: Adding ADMA support Tony Lindgren
2011-02-03  6:14   ` Kadiyala, Kishore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1295371591-13610-3-git-send-email-kishore.kadiyala@ti.com \
    --to=kishore.kadiyala@ti.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=madhu.cr@ti.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.