Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dmaengine: rcar-dmac: Add for_each_rcar_dmac_chan() helper

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 <geert+renesas@glider.be>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20210128084455.2237256-3-geert+renesas@glider.be
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Geert Uytterhoeven and committed by
Vinod Koul
d249b5fb 72ec393b

+10 -12
+10 -12
drivers/dma/sh/rcar-dmac.c
··· 209 209 210 210 #define to_rcar_dmac(d) container_of(d, struct rcar_dmac, engine) 211 211 212 + #define for_each_rcar_dmac_chan(i, dmac, chan) \ 213 + for (i = 0, chan = &(dmac)->channels[0]; i < (dmac)->n_channels; i++, chan++) \ 214 + if (!((dmac)->channels_mask & BIT(i))) continue; else 215 + 212 216 /* 213 217 * struct rcar_dmac_of_data - This driver's OF data 214 218 * @chan_offset_base: DMAC channels base offset ··· 821 817 822 818 static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac) 823 819 { 820 + struct rcar_dmac_chan *chan; 824 821 unsigned int i; 825 822 826 823 /* Stop all channels. */ 827 - for (i = 0; i < dmac->n_channels; ++i) { 828 - struct rcar_dmac_chan *chan = &dmac->channels[i]; 829 - 830 - if (!(dmac->channels_mask & BIT(i))) 831 - continue; 832 - 824 + for_each_rcar_dmac_chan(i, dmac, chan) { 833 825 /* Stop and reinitialize the channel. */ 834 826 spin_lock_irq(&chan->lock); 835 827 rcar_dmac_chan_halt(chan); ··· 1828 1828 DMA_SLAVE_BUSWIDTH_2_BYTES | DMA_SLAVE_BUSWIDTH_4_BYTES | 1829 1829 DMA_SLAVE_BUSWIDTH_8_BYTES | DMA_SLAVE_BUSWIDTH_16_BYTES | 1830 1830 DMA_SLAVE_BUSWIDTH_32_BYTES | DMA_SLAVE_BUSWIDTH_64_BYTES; 1831 + const struct rcar_dmac_of_data *data; 1832 + struct rcar_dmac_chan *chan; 1831 1833 struct dma_device *engine; 1832 1834 struct rcar_dmac *dmac; 1833 - const struct rcar_dmac_of_data *data; 1834 1835 unsigned int i; 1835 1836 int ret; 1836 1837 ··· 1917 1916 1918 1917 INIT_LIST_HEAD(&engine->channels); 1919 1918 1920 - for (i = 0; i < dmac->n_channels; ++i) { 1921 - if (!(dmac->channels_mask & BIT(i))) 1922 - continue; 1923 - 1924 - ret = rcar_dmac_chan_probe(dmac, &dmac->channels[i], data, i); 1919 + for_each_rcar_dmac_chan(i, dmac, chan) { 1920 + ret = rcar_dmac_chan_probe(dmac, chan, data, i); 1925 1921 if (ret < 0) 1926 1922 goto error; 1927 1923 }