Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp505392pxu; Thu, 7 Jan 2021 10:20:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcijUmL462FlmcvpQBEYynjGxjIB5a6dCLIhtL9iLQF8b+vasUfjY9TvOmHmSuz8WToB1Z X-Received: by 2002:a17:907:da7:: with SMTP id go39mr73044ejc.58.1610043630316; Thu, 07 Jan 2021 10:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610043630; cv=none; d=google.com; s=arc-20160816; b=B5I7xYcLx+osWgzhke4tuHGF71Oy0ABax8B9eiosiAHRXZsnKayy7Opd0uqInzenUR ZXGJdEejWgQ1apd5Nmks7w/JX4S523LO2DIWnMPKfepM66DPVkWbqTL6SZ/DBdYwX2yt ZpEcWzu3fFHqfcCtSQ8/3KYWHh9SoAkaUvNWfe9iXnaO+Ci7dQpOo2Ol6ENT4hzcHiPa goI7kQuZZnxre31VS/F4eSVuWMZJgnzXwthzfv3A7egO9r5HTohfJT4RDQoN2i+e3kA6 4+7bXu4K53CR469PXYrMoGZUxrgFVE0ofozMV/J0kMQm7jWaahlQ2aVWHiPwoR5JSK95 5XFQ== 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=x5ejo684HxB97OBnT/45XjZnfo97SQnp7rxN2h2+ArI=; b=wT2TQv1cVQCiWOrIEIujVVBz8M87qwIYcg4hzkyf0kpZrLjslGn3kHYn0X1htlg0HN DEQd3ZX6V513vmodP2BArTmjBjEzLobEqPpMIA6R1h1AljFXe81Hmm1gAYjVcrmTjky+ gLtQ+NPJmNrI8Gu3/c9uCwllTRO2vlKg2mzs7aE48jq1Vf/3H9qa2OfnjfpoHWVLf015 XZz+15mUT5VbO/xfH8nVHRiOwEwbkyupDrMFYWG7V5mTRaWMY+7xTHUY/aSnygUg2ry6 iRCVpn9qaaw3dfxYZVGR06UZfIZTQShkNqfsz3BElCHWGlxkmpnE6u5a4UI00Z1MUY4n YSZA== 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 p31si2824433edd.471.2021.01.07.10.20.06; Thu, 07 Jan 2021 10:20:30 -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 S1729205AbhAGSQt (ORCPT + 99 others); Thu, 7 Jan 2021 13:16:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729189AbhAGSQs (ORCPT ); Thu, 7 Jan 2021 13:16:48 -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 4A675C061285 for ; Thu, 7 Jan 2021 10:15:29 -0800 (PST) Received: from ramsan.of.borg ([84.195.186.194]) by baptiste.telenet-ops.be with bizsmtp id DuFT240034C55Sk01uFTHy; Thu, 07 Jan 2021 19:15:27 +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 1kxZok-001v2o-PA; Thu, 07 Jan 2021 19:15:26 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1kxZok-008AYy-ED; Thu, 07 Jan 2021 19:15:26 +0100 From: Geert Uytterhoeven To: Vinod Koul , Rob Herring Cc: Dan Williams , Yoshihiro Shimoda , Phong Hoang , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper Date: Thu, 7 Jan 2021 19:15:22 +0100 Message-Id: <20210107181524.1947173-3-geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107181524.1947173-1-geert+renesas@glider.be> References: <20210107181524.1947173-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 and 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 --- drivers/dma/sh/rcar-dmac.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index a57705356e8bb796..71cdaf446fcaeba5 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -209,6 +209,11 @@ struct rcar_dmac { #define to_rcar_dmac(d) container_of(d, struct rcar_dmac, engine) +#define for_each_rcar_dmac_chan(i, chan, dmac) \ + 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 +822,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, chan, dmac) { /* Stop and reinitialize the channel. */ spin_lock_irq(&chan->lock); rcar_dmac_chan_halt(chan); @@ -1828,9 +1829,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 +1918,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, chan, dmac) { + ret = rcar_dmac_chan_probe(dmac, chan, data, i); if (ret < 0) goto error; } -- 2.25.1