From: Vinod Koul <vkoul@kernel.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Rob Herring <robh+dt@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Phong Hoang <phong.hoang.wz@renesas.com>,
dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper
Date: Tue, 12 Jan 2021 15:49:50 +0530 [thread overview]
Message-ID: <20210112101950.GK2771@vkoul-mobl> (raw)
In-Reply-To: <20210107181524.1947173-3-geert+renesas@glider.be>
On 07-01-21, 19:15, Geert Uytterhoeven wrote:
> 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 <geert+renesas@glider.be>
> ---
> 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++) \
single line to make it more readable? we have limit of 100 now :)
> + 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
--
~Vinod
next prev parent reply other threads:[~2021-01-12 10:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 18:15 [PATCH 0/4] dmaengine: rcar-dmac: Add support for R-Car V3U Geert Uytterhoeven
2021-01-07 18:15 ` [PATCH 1/4] dt-bindings: renesas,rcar-dmac: Add r8a779a0 support Geert Uytterhoeven
2021-01-13 3:23 ` Rob Herring
2021-01-07 18:15 ` [PATCH 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper Geert Uytterhoeven
2021-01-12 10:19 ` Vinod Koul [this message]
2021-01-12 10:26 ` Geert Uytterhoeven
2021-01-12 10:38 ` Vinod Koul
2021-01-12 10:48 ` Geert Uytterhoeven
2021-01-07 18:15 ` [PATCH 3/4] dmaengine: rcar-dmac: Add helpers for clearing DMA channel status Geert Uytterhoeven
2021-01-07 18:15 ` [PATCH 4/4] dmaengine: rcar-dmac: Add support for R-Car V3U Geert Uytterhoeven
2021-01-12 10:36 ` Vinod Koul
2021-01-12 15:54 ` Geert Uytterhoeven
2021-01-12 17:04 ` Vinod Koul
2021-01-25 14:20 ` Geert Uytterhoeven
2021-01-12 15:55 ` [PATCH 0/4] " Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210112101950.GK2771@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=phong.hoang.wz@renesas.com \
--cc=robh+dt@kernel.org \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).