From patchwork Wed May 27 14:01:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 6489931 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5504C0020 for ; Wed, 27 May 2015 14:06:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CC70206A1 for ; Wed, 27 May 2015 14:06:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 467152068F for ; Wed, 27 May 2015 14:06:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752556AbbE0OFH (ORCPT ); Wed, 27 May 2015 10:05:07 -0400 Received: from down.free-electrons.com ([37.187.137.238]:33310 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752190AbbE0OFE (ORCPT ); Wed, 27 May 2015 10:05:04 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id C3D5E365; Wed, 27 May 2015 16:05:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6863D12B; Wed, 27 May 2015 16:05:07 +0200 (CEST) From: Maxime Ripard To: Vinod Koul Cc: dmaengine@vger.kernel.org, Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Thomas Petazzoni , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Maxime Ripard Subject: [PATCH 1/2] dmaengine: Move icg helpers to global header Date: Wed, 27 May 2015 16:01:52 +0200 Message-Id: <1432735313-481-2-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1432735313-481-1-git-send-email-maxime.ripard@free-electrons.com> References: <1432735313-481-1-git-send-email-maxime.ripard@free-electrons.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we can have ICGs set for both the source and destination (using the icg field of struct data_chunk) or for only the source or the destination (using the dst_icg or src_icg respectively), and that these fields can be ignored depending on other parameters (src_inc, src_sgl, etc.), the logic to get the actual ICG value can be quite tricky. The XDMAC driver was already implementing it, but since we will need it in other drivers, we can move it to the main header file. Signed-off-by: Maxime Ripard Acked-by: Ludovic Desroches --- drivers/dma/at_xdmac.c | 46 ++++------------------------------------------ include/linux/dmaengine.h | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 42 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 9b602a67d40d..80e46e571bdd 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -862,20 +862,8 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan, desc->lld.mbr_sa = src; desc->lld.mbr_da = dst; - - if (xt->src_inc && xt->src_sgl) { - if (chunk->src_icg) - desc->lld.mbr_sus = chunk->src_icg; - else - desc->lld.mbr_sus = chunk->icg; - } - - if (xt->dst_inc && xt->dst_sgl) { - if (chunk->dst_icg) - desc->lld.mbr_dus = chunk->dst_icg; - else - desc->lld.mbr_dus = chunk->icg; - } + desc->lld.mbr_sus = dmaengine_get_src_icg(xt, chunk); + desc->lld.mbr_dus = dmaengine_get_dst_icg(xt, chunk); desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3 | AT_XDMAC_MBR_UBC_NDEN @@ -895,32 +883,6 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan, return desc; } -static size_t at_xdmac_get_icg(bool inc, bool sgl, size_t icg, size_t dir_icg) -{ - if (inc) { - if (dir_icg) - return dir_icg; - else if (sgl) - return icg; - } - - return 0; -} - -static size_t at_xdmac_get_dst_icg(struct dma_interleaved_template *xt, - struct data_chunk *chunk) -{ - return at_xdmac_get_icg(xt->dst_inc, xt->dst_sgl, - chunk->icg, chunk->dst_icg); -} - -static size_t at_xdmac_get_src_icg(struct dma_interleaved_template *xt, - struct data_chunk *chunk) -{ - return at_xdmac_get_icg(xt->src_inc, xt->src_sgl, - chunk->icg, chunk->src_icg); -} - static struct dma_async_tx_descriptor * at_xdmac_prep_interleaved(struct dma_chan *chan, struct dma_interleaved_template *xt, @@ -950,8 +912,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan, chunk = xt->sgl + i; - dst_icg = at_xdmac_get_dst_icg(xt, chunk); - src_icg = at_xdmac_get_src_icg(xt, chunk); + dst_icg = dmaengine_get_dst_icg(xt, chunk); + src_icg = dmaengine_get_src_icg(xt, chunk); src_skip = chunk->size + src_icg; dst_skip = chunk->size + dst_icg; diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 8faf6a2dd9d8..43a9a397b2d7 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -899,6 +899,33 @@ static inline int dma_maxpq(struct dma_device *dma, enum dma_ctrl_flags flags) BUG(); } +static inline size_t dmaengine_get_icg(bool inc, bool sgl, size_t icg, + size_t dir_icg) +{ + if (inc) { + if (dir_icg) + return dir_icg; + else if (sgl) + return icg; + } + + return 0; +} + +static inline size_t dmaengine_get_dst_icg(struct dma_interleaved_template *xt, + struct data_chunk *chunk) +{ + return dmaengine_get_icg(xt->dst_inc, xt->dst_sgl, + chunk->icg, chunk->dst_icg); +} + +static inline size_t dmaengine_get_src_icg(struct dma_interleaved_template *xt, + struct data_chunk *chunk) +{ + return dmaengine_get_icg(xt->src_inc, xt->src_sgl, + chunk->icg, chunk->src_icg); +} + /* --- public DMA engine API --- */ #ifdef CONFIG_DMA_ENGINE