From patchwork Sun Aug 11 17:59:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2842797 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0ECEABF546 for ; Sun, 11 Aug 2013 18:04:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4167F202BC for ; Sun, 11 Aug 2013 18:04:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66FE3202AE for ; Sun, 11 Aug 2013 18:04:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754740Ab3HKSEZ (ORCPT ); Sun, 11 Aug 2013 14:04:25 -0400 Received: from mail-bk0-f53.google.com ([209.85.214.53]:52915 "EHLO mail-bk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754533Ab3HKR7q (ORCPT ); Sun, 11 Aug 2013 13:59:46 -0400 Received: by mail-bk0-f53.google.com with SMTP id d7so1870835bkh.26 for ; Sun, 11 Aug 2013 10:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sJKsscDXYvfkGCj8L8h+jBCCSGw3z7M8BlaL2KDzv8A=; b=ZV3EACNngOmOPdF0PtU5U2DAUYKPuxDdP3rnRBYLCHfNKoyJ/+mNKg/JP9ry+v1gBh oKvmIh3fds1aZfeXgVJOjNLkRtYRFseNjiCLnbOPfebJsADjyCThJIWgHXtlYypvteAr pRVDEOtC2u7nRllP1HUxcQDGu2wVUE95qHED0vPgiqWiFUsIMVif8XHSfKwrcqdifJqR 6irprnjNYhmBq9dADqh3AoYxalNIjAY1aZ6CY/sLxrFY924bWrGCmSlhALVpyy/yem1Z 52mPC4sq+OSVK8FO7Qq4C/8hcV8bbXV5PA8/Zc51x1VTTFD+Qd2F7nfP9gbnQtBW6K7W fXdA== X-Received: by 10.204.228.76 with SMTP id jd12mr3175390bkb.133.1376243984926; Sun, 11 Aug 2013 10:59:44 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id nv4sm4838824bkb.3.2013.08.11.10.59.42 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 11 Aug 2013 10:59:44 -0700 (PDT) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, Dan Williams , Jaroslav Kysela , Kukjin Kim , Liam Girdwood , Linus Walleij , Mark Brown , Mike Turquette , Padmavathi Venna , Russell King , Sangbeom Kim , Takashi Iwai , Vinod Koul , Tomasz Figa Subject: [PATCH 01/18] dmaengine: PL08x: Refactor pl08x_getbytes_chan() to lower indentation Date: Sun, 11 Aug 2013 19:59:13 +0200 Message-Id: <1376243970-6489-2-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1376243970-6489-1-git-send-email-tomasz.figa@gmail.com> References: <1376243970-6489-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Further patch will introduce support for PL080S, which requires some things to be done conditionally, thus increasing indentation level of some functions even more. This patch reduces indentation level of pl08x_getbytes_chan() function by inverting several conditions and returning from function wherever possible. Signed-off-by: Tomasz Figa Reviewed-by: Linus Walleij --- drivers/dma/amba-pl08x.c | 53 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index 06fe45c..6a12392 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c @@ -469,47 +469,52 @@ static inline u32 get_bytes_in_cctl(u32 cctl) /* The channel should be paused when calling this */ static u32 pl08x_getbytes_chan(struct pl08x_dma_chan *plchan) { + struct pl08x_lli *llis_va; struct pl08x_phy_chan *ch; + dma_addr_t llis_bus; struct pl08x_txd *txd; - size_t bytes = 0; + size_t bytes; + int index; + u32 clli; ch = plchan->phychan; txd = plchan->at; + if (!ch || !txd) + return 0; + /* * Follow the LLIs to get the number of remaining * bytes in the currently active transaction. */ - if (ch && txd) { - u32 clli = readl(ch->base + PL080_CH_LLI) & ~PL080_LLI_LM_AHB2; + clli = readl(ch->base + PL080_CH_LLI) & ~PL080_LLI_LM_AHB2; - /* First get the remaining bytes in the active transfer */ - bytes = get_bytes_in_cctl(readl(ch->base + PL080_CH_CONTROL)); + /* First get the remaining bytes in the active transfer */ + bytes = get_bytes_in_cctl(readl(ch->base + PL080_CH_CONTROL)); - if (clli) { - struct pl08x_lli *llis_va = txd->llis_va; - dma_addr_t llis_bus = txd->llis_bus; - int index; + if (!clli) + return bytes; - BUG_ON(clli < llis_bus || clli >= llis_bus + + llis_va = txd->llis_va; + llis_bus = txd->llis_bus; + + BUG_ON(clli < llis_bus || clli >= llis_bus + sizeof(struct pl08x_lli) * MAX_NUM_TSFR_LLIS); - /* - * Locate the next LLI - as this is an array, - * it's simple maths to find. - */ - index = (clli - llis_bus) / sizeof(struct pl08x_lli); + /* + * Locate the next LLI - as this is an array, + * it's simple maths to find. + */ + index = (clli - llis_bus) / sizeof(struct pl08x_lli); - for (; index < MAX_NUM_TSFR_LLIS; index++) { - bytes += get_bytes_in_cctl(llis_va[index].cctl); + for (; index < MAX_NUM_TSFR_LLIS; index++) { + bytes += get_bytes_in_cctl(llis_va[index].cctl); - /* - * A LLI pointer of 0 terminates the LLI list - */ - if (!llis_va[index].lli) - break; - } - } + /* + * A LLI pointer of 0 terminates the LLI list + */ + if (!llis_va[index].lli) + break; } return bytes;