From patchwork Thu Sep 1 19:05:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkatraman S X-Patchwork-Id: 1120302 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p81J7rlf016334 for ; Thu, 1 Sep 2011 19:07:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757660Ab1IATHl (ORCPT ); Thu, 1 Sep 2011 15:07:41 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:45884 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757651Ab1IATHk (ORCPT ); Thu, 1 Sep 2011 15:07:40 -0400 Received: from dlep36.itg.ti.com ([157.170.170.91]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p81J7ZHc004845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Sep 2011 14:07:35 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81J7ZNk011880; Thu, 1 Sep 2011 14:07:35 -0500 (CDT) Received: from DFLE71.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81J7ZOO002005; Thu, 1 Sep 2011 14:07:35 -0500 (CDT) Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle71.ent.ti.com (128.247.5.62) with Microsoft SMTP Server id 14.1.323.3; Thu, 1 Sep 2011 14:07:35 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81J7YAj030526; Thu, 1 Sep 2011 14:07:35 -0500 Received: from localhost (h83-2.vpn.ti.com [172.24.83.2]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id p81J7V008515; Thu, 1 Sep 2011 14:07:31 -0500 (CDT) From: Venkatraman S To: , CC: , , Venkatraman S Subject: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations Date: Fri, 2 Sep 2011 00:35:56 +0530 Message-ID: <1314903957-24408-2-git-send-email-svenkatr@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 01 Sep 2011 19:07:55 +0000 (UTC) Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. Signed-off-by: Venkatraman S --- drivers/mmc/host/omap_hsmmc.c | 20 +++++--------------- 1 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 21e4a79..5b7776c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -999,7 +999,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) { int dma_ch; - host->data->error = errno; + if (host->data) + host->data->error = errno; spin_lock(&host->irq_lock); dma_ch = host->dma_ch; @@ -1007,12 +1008,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) spin_unlock(&host->irq_lock); if (host->use_dma && dma_ch != -1) { - dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, - host->data->sg_len, - omap_hsmmc_get_dma_dir(host, host->data)); omap_free_dma(dma_ch); } - host->data = NULL; } /* @@ -1370,7 +1367,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; - 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", @@ -1394,16 +1391,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) return; } - if (!data->host_cookie) - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_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_dma_cleanup(host, 0); /* If DMA has finished after TC, complete the request */ if (!req_in_progress) { @@ -1575,7 +1565,7 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, struct omap_hsmmc_host *host = mmc_priv(mmc); struct mmc_data *data = mrq->data; - if (host->use_dma) { + if (data->host_cookie) { dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, omap_hsmmc_get_dma_dir(host, data)); data->host_cookie = 0;