From patchwork Thu Apr 18 10:11:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 16194 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f200.google.com (mail-gh0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6629523974 for ; Thu, 18 Apr 2013 10:13:20 +0000 (UTC) Received: by mail-gh0-f200.google.com with SMTP id 10sf1565557ghy.7 for ; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=zEUO2KjyD4Y12vFvq97vQZKKsymmyrISuq+RawKV6Sw=; b=oBePSGclB4GjYIuRLyAW5V8lVnhRpMe0xR4s9XmK2QGPCUKZPgWBx5VaWLsuv8PKFh zT5Dh5NzwDw4E5qzM3Q5hcj+pKL6o+vy4rbZuF68UlkYskhMZEJw+9d+G+jUuRQKek/h GOEYimUqeNZ7vNhJl4vmzEbs98RzBJbrN11zxswbjCLEbQP/uZpJGn5hXL9YtCYw2mRT nH83Q4+esoYHbNN9LU1cZZ00spVXu8r29G8WucHb9U9PapPqcsOCGLvlZqQdykYmsaHW HeILaTCHBMqM3fwhFdUtTNm2j7yS37roNzTZTBiVEMKpWs2gQ8dZboA41VqCxfHQFeCu 60Ng== X-Received: by 10.236.78.103 with SMTP id f67mr5126672yhe.52.1366279963389; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.73.196 with SMTP id n4ls1336006qev.46.gmail; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) X-Received: by 10.58.76.3 with SMTP id g3mr7516727vew.58.1366279963257; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id ex4si6245678vdb.40.2013.04.18.03.12.43 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:12:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id gd11so2264024vcb.17 for ; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr6549071vdb.94.1366279963108; Thu, 18 Apr 2013 03:12:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp115726veb; Thu, 18 Apr 2013 03:12:42 -0700 (PDT) X-Received: by 10.194.158.4 with SMTP id wq4mr7957198wjb.46.1366279962049; Thu, 18 Apr 2013 03:12:42 -0700 (PDT) Received: from mail-we0-x22b.google.com (mail-we0-x22b.google.com [2a00:1450:400c:c03::22b]) by mx.google.com with ESMTPS id m8si3419643wje.256.2013.04.18.03.12.41 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:12:42 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22b is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::22b; Received: by mail-we0-f171.google.com with SMTP id i48so2103169wef.30 for ; Thu, 18 Apr 2013 03:12:41 -0700 (PDT) X-Received: by 10.194.123.168 with SMTP id mb8mr17428620wjb.24.1366279961635; Thu, 18 Apr 2013 03:12:41 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id t7sm30483773wij.2.2013.04.18.03.12.39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:12:40 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Vinod Koul , Dan Williams , Per Forlin , Rabin Vincent Subject: [PATCH 05/32] dmaengine: ste_dma40: Supply macros to resolve 'src' and 'dst' directions Date: Thu, 18 Apr 2013 11:11:47 +0100 Message-Id: <1366279934-30761-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366279934-30761-1-git-send-email-lee.jones@linaro.org> References: <1366279934-30761-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQn4nMQ7gXvgUUgYkJL2Gs4Xth1IJS4fdmJRoUnlDwDJnTCtm10jTDn7nkI/W0XnukZTiCyR X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There are lots of lengthy if() statements located sporadically up and down the driver. This simple macro should make many of them a little simpler to decipher. The remainder have to stay in place, as they detail slightly more specific settings. Cc: Vinod Koul Cc: Dan Williams Cc: Per Forlin Cc: Rabin Vincent Signed-off-by: Lee Jones --- drivers/dma/ste_dma40.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index e50354d..b21a8a3 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -55,6 +55,10 @@ #define MAX(a, b) (((a) < (b)) ? (b) : (a)) +#define D40_IS_SRC(dir) ((dir == STEDMA40_PERIPH_TO_MEM) ? true : false) +#define D40_IS_DST(dir) (((dir == STEDMA40_MEM_TO_PERIPH) || \ + (dir == STEDMA40_MEM_TO_MEM)) ? true : false) + /* Reserved event lines for memcpy only. */ static int dma40_memcpy_channels[] = { 56, 57, 58, 59, 60 }; @@ -823,7 +827,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc) * that uses linked lists. */ if (!(chan->phy_chan->use_soft_lli && - chan->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM)) + D40_IS_SRC(chan->dma_cfg.dir))) curr_lcla = d40_lcla_alloc_one(chan, desc); first_lcla = curr_lcla; @@ -1291,12 +1295,12 @@ static void d40_config_set_event(struct d40_chan *d40c, u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dev_type); /* Enable event line connected to device (or memcpy) */ - if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) || + if (D40_IS_SRC(d40c->dma_cfg.dir) || (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) __d40_config_set_event(d40c, event_type, event, D40_CHAN_REG_SSLNK); - if (d40c->dma_cfg.dir != STEDMA40_PERIPH_TO_MEM) + if (!D40_IS_SRC(d40c->dma_cfg.dir)) __d40_config_set_event(d40c, event_type, event, D40_CHAN_REG_SDLNK); } @@ -1762,7 +1766,7 @@ static int d40_validate_conf(struct d40_chan *d40c, res = -EINVAL; } - if (conf->dir == STEDMA40_PERIPH_TO_MEM && + if (D40_IS_SRC(conf->dir) && d40c->base->plat_data->dev_rx[conf->dev_type] == 0 && d40c->runtime_addr == 0) { chan_err(d40c, "Invalid RX channel address (%d)\n", @@ -1895,17 +1899,17 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) int j; int log_num; int num_phy_chans; + int dir = d40c->dma_cfg.dir; bool is_src; bool is_log = d40c->dma_cfg.mode == STEDMA40_MODE_LOGICAL; phys = d40c->base->phy_res; num_phy_chans = d40c->base->num_phy_chans; - if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) { + if (D40_IS_SRC(dir)) { log_num = 2 * dev_type; is_src = true; - } else if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || - d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { + } else if (D40_IS_DST(dir)) { /* dst event lines are used for logical memcpy */ log_num = 2 * dev_type + 1; is_src = false; @@ -1916,7 +1920,7 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) event_line = D40_TYPE_TO_EVENT(dev_type); if (!is_log) { - if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { + if (dir == STEDMA40_MEM_TO_MEM) { /* Find physical half channel */ if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel; @@ -2053,11 +2057,10 @@ static int d40_free_dma(struct d40_chan *d40c) return -EINVAL; } - if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || - d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) - is_src = false; - else if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) + if (D40_IS_SRC(d40c->dma_cfg.dir)) is_src = true; + else if (D40_IS_DST(d40c->dma_cfg.dir)) + is_src = false; else { chan_err(d40c, "Unknown direction\n"); return -EINVAL; @@ -2118,12 +2121,11 @@ static bool d40_is_paused(struct d40_chan *d40c) goto _exit; } - if (d40c->dma_cfg.dir == STEDMA40_MEM_TO_PERIPH || - d40c->dma_cfg.dir == STEDMA40_MEM_TO_MEM) { - status = readl(chanbase + D40_CHAN_REG_SDLNK); - } else if (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) { + if (D40_IS_SRC(d40c->dma_cfg.dir)) status = readl(chanbase + D40_CHAN_REG_SSLNK); - } else { + else if (D40_IS_DST(d40c->dma_cfg.dir)) + status = readl(chanbase + D40_CHAN_REG_SDLNK); + else { chan_err(d40c, "Unknown direction\n"); goto _exit; } @@ -2394,7 +2396,7 @@ static void d40_set_prio_realtime(struct d40_chan *d40c) if (d40c->base->rev < 3) return; - if ((d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_MEM) || + if (D40_IS_SRC(d40c->dma_cfg.dir) || (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) __d40_set_prio_rt(d40c, d40c->dma_cfg.dev_type, true);