Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp831719pxb; Thu, 28 Jan 2021 00:59:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbjOKK/IX9/txhrUMdpBczYUMiiW90REClf9BRtqqjpTUrBISc0VIuyWtjBt+YIoCxiE1I X-Received: by 2002:a17:906:58d3:: with SMTP id e19mr1223723ejs.373.1611824355859; Thu, 28 Jan 2021 00:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611824355; cv=none; d=google.com; s=arc-20160816; b=ua7YQr2dtwMcUE2X6UxPsZ5H3/BDqUEHV3eKhuUkVvGRURRRPRJGO6OAaJVCObTpBv lPnqtaBtimJ8T31JsXnOs0kBDg331at0TivlqSf5d9kiDg/4Dr8zYX0RUOnPRBWK50SQ CvN7lUNwWidf1CGmsR7d3V0oGQYutw7C6l9V1iUAw1e6qV1sV58tfMLHdBGJj9jMFu0a G3inipyfp7l3nwC4+IN/70N+J/0QPHM7EengNU1aHiQLWuDrM1fko64MfypJhjDdhKOE NxeoLQ5OTypD8aibYASuBxLh4vl+keJyhU/6T7PdaVFfRXQnigWN9/YoxTXOpSUJepXY XxfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gZnqz0eOhZfjFyrOAwlLM1X0Mynw+ltRpD5OGkgCO98=; b=MHipGMZPY6Bl9lqQnEkb55x18cRrA5LPlfp1WwXPcEVM+ViqEZA5R2ZEjVsww51rcQ MAtgWnT9mPUhHVEsLfeSQ77J4btRtCLJwWDWF92EOcvppGBAhiykB1W/fisZb39ULwKC jMlSBK2Vj1W+hEXG7g4wqrdihI52tr0erylxQYK1j472QzfJFIsm6A1bfiar2yZsvCDG GSERyAg2MUjQxWgeAPNnZhNvIDFi1nifDogUffE4DECJyvcE+EZu3MeF64V9ad7P7h3L +4Fq4L+u0k9ZFHdUGT6n2eYcvL8t/MvFnupn4Tidpv7bsCL9bvOxiWjCn18APOJH4MMz CjFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si2178610ejs.369.2021.01.28.00.58.51; Thu, 28 Jan 2021 00:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232342AbhA1Iyr (ORCPT + 99 others); Thu, 28 Jan 2021 03:54:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbhA1Ip3 (ORCPT ); Thu, 28 Jan 2021 03:45:29 -0500 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABBC1C06178B for ; Thu, 28 Jan 2021 00:45:01 -0800 (PST) Received: from ramsan.of.borg ([84.195.186.194]) by baptiste.telenet-ops.be with bizsmtp id N8kx2400N4C55Sk018kx72; Thu, 28 Jan 2021 09:44:59 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l52vB-001JYQ-CR; Thu, 28 Jan 2021 09:44:57 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1l52vA-009O1k-Vs; Thu, 28 Jan 2021 09:44:56 +0100 From: Geert Uytterhoeven To: Vinod Koul Cc: Rob Herring , Dan Williams , Laurent Pinchart , Wolfram Sang , Yoshihiro Shimoda , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper Date: Thu, 28 Jan 2021 09:44:53 +0100 Message-Id: <20210128084455.2237256-3-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128084455.2237256-1-geert+renesas@glider.be> References: <20210128084455.2237256-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper macro for iterating over all DMAC channels, taking into account the channel mask. Use it where appropriate, to simplify code. Restore "reverse Christmas tree" order of local variables while adding a new variable. Signed-off-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Reviewed-by: Laurent Pinchart Tested-by: Wolfram Sang --- v3: - Add Reviewed-by, Tested-by, - Place iterator after container being iterated, v2: - Put the full loop control of for_each_rcar_dmac_chan() on a single line, to improve readability. --- drivers/dma/sh/rcar-dmac.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 4524718d4f90920e..83c9a5bd1077db3a 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -209,6 +209,10 @@ struct rcar_dmac { #define to_rcar_dmac(d) container_of(d, struct rcar_dmac, engine) +#define for_each_rcar_dmac_chan(i, dmac, chan) \ + for (i = 0, chan = &(dmac)->channels[0]; i < (dmac)->n_channels; i++, chan++) \ + if (!((dmac)->channels_mask & BIT(i))) continue; else + /* * struct rcar_dmac_of_data - This driver's OF data * @chan_offset_base: DMAC channels base offset @@ -817,15 +821,11 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan) static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac) { + struct rcar_dmac_chan *chan; unsigned int i; /* Stop all channels. */ - for (i = 0; i < dmac->n_channels; ++i) { - struct rcar_dmac_chan *chan = &dmac->channels[i]; - - if (!(dmac->channels_mask & BIT(i))) - continue; - + for_each_rcar_dmac_chan(i, dmac, chan) { /* Stop and reinitialize the channel. */ spin_lock_irq(&chan->lock); rcar_dmac_chan_halt(chan); @@ -1828,9 +1828,10 @@ static int rcar_dmac_probe(struct platform_device *pdev) DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES | DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES | DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES; + const struct rcar_dmac_of_data *data; + struct rcar_dmac_chan *chan; struct dma_device *engine; struct rcar_dmac *dmac; - const struct rcar_dmac_of_data *data; unsigned int i; int ret; @@ -1916,11 +1917,8 @@ static int rcar_dmac_probe(struct platform_device *pdev) INIT_LIST_HEAD(&engine->channels); - for (i = 0; i < dmac->n_channels; ++i) { - if (!(dmac->channels_mask & BIT(i))) - continue; - - ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], data, i); + for_each_rcar_dmac_chan(i, dmac, chan) { + ret = rcar_dmac_chan_probe(dmac, chan, data, i); if (ret < 0) goto error; } -- 2.25.1