From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Vinod Koul <vkoul@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
dmaengine@vger.kernel.org, devicetree@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper
Date: Tue, 26 Jan 2021 23:54:40 +0200 [thread overview]
Message-ID: <YBCPoOKGRZYkdfPn@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20210125142431.1049668-3-geert+renesas@glider.be>
Hi Geert,
Thank you for the patch.
On Mon, Jan 25, 2021 at 03:24:29PM +0100, Geert Uytterhoeven wrote:
> Add and helper macro for iterating over all DMAC channels, taking into
s/and helper/a helper/
> 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>
> ---
> 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 a57705356e8bb796..537550b4121bbc22 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, chan, dmac) \
I would have placed the iterator (chan) after the container being
iterated (dmac), but it seems there are some for_each_* macros doing it
the other way around (they may be older though).
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + 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, chan, dmac) {
> /* 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, chan, dmac) {
> + ret = rcar_dmac_chan_probe(dmac, chan, data, i);
> if (ret < 0)
> goto error;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2021-01-27 4:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 14:24 [PATCH v2 0/4] dmaengine: rcar-dmac: Add support for R-Car V3U Geert Uytterhoeven
2021-01-25 14:24 ` [PATCH v2 1/4] dt-bindings: renesas,rcar-dmac: Add r8a779a0 support Geert Uytterhoeven
2021-01-26 21:48 ` Laurent Pinchart
2021-01-25 14:24 ` [PATCH v2 2/4] dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper Geert Uytterhoeven
2021-01-26 16:18 ` Wolfram Sang
2021-01-26 21:54 ` Laurent Pinchart [this message]
2021-01-27 7:58 ` Geert Uytterhoeven
2021-01-25 14:24 ` [PATCH v2 3/4] dmaengine: rcar-dmac: Add helpers for clearing DMA channel status Geert Uytterhoeven
2021-01-26 16:21 ` Wolfram Sang
2021-01-26 21:55 ` Laurent Pinchart
2021-01-25 14:24 ` [PATCH v2 4/4] dmaengine: rcar-dmac: Add support for R-Car V3U Geert Uytterhoeven
2021-01-26 16:25 ` Wolfram Sang
2021-01-26 22:00 ` Laurent Pinchart
2021-01-27 8:10 ` Geert Uytterhoeven
2021-01-27 13:43 ` Laurent Pinchart
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=YBCPoOKGRZYkdfPn@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--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=linux-renesas-soc@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.