Skip to contentSkip to conversation

dmaengine: sun4i: remove set but unused variable 'linear_mode'

PATCH In review YueHaibing 2 participants 4 messages Feb 5, 2020 – Feb 7, 2020

Subsystems (2)
lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 dmaengine: sun4i: remove set but unused variable 'linear_mode'

drivers/dma/sun4i-dma.c: In function sun4i_dma_prep_dma_cyclic:
drivers/dma/sun4i-dma.c:672:24: warning:
variable linear_mode set but not used [-Wunused-but-set-variable]

commit ffc079a4accc ("dmaengine: sun4i: Add support for cyclic requests with dedicated DMA") involved this unused variable.

---
 drivers/dma/sun4i-dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sun4i-dma.c +1 -3
index bbc2bda..501cd44 100644
@@ -669,7 +669,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
 	dma_addr_t src, dest;
 	u32 endpoints;
 	int nr_periods, offset, plength, i;
-	u8 ram_type, io_mode, linear_mode;
+	u8 ram_type, io_mode;
 
 	if (!is_slave_direction(dir)) {
 		dev_err(chan2dev(chan), "Invalid DMA direction\n");
@@ -684,11 +684,9 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
 
 	if (vchan->is_dedicated) {
 		io_mode = SUN4I_DDMA_ADDR_MODE_IO;
-		linear_mode = SUN4I_DDMA_ADDR_MODE_LINEAR;
 		ram_type = SUN4I_DDMA_DRQ_TYPE_SDRAM;
 	} else {
 		io_mode = SUN4I_NDMA_ADDR_MODE_IO;
-		linear_mode = SUN4I_NDMA_ADDR_MODE_LINEAR;
 		ram_type = SUN4I_NDMA_DRQ_TYPE_SDRAM;
 	}
 
Signature · 1 line
2.7.4
#1 lore raw

Hi,

Quoted 28 lines · YueHaibing

drivers/dma/sun4i-dma.c: In function sun4i_dma_prep_dma_cyclic:
drivers/dma/sun4i-dma.c:672:24: warning:
variable linear_mode set but not used [-Wunused-but-set-variable]

commit ffc079a4accc ("dmaengine: sun4i: Add support for cyclic requests with dedicated DMA") involved this unused variable.

---
 drivers/dma/sun4i-dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sun4i-dma.c +1 -1
index bbc2bda..501cd44 100644
@@ -669,7 +669,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
        dma_addr_t src, dest;
        u32 endpoints;
        int nr_periods, offset, plength, i;
-       u8 ram_type, io_mode, linear_mode;
+       u8 ram_type, io_mode;
 
        if (!is_slave_direction(dir)) {
                dev_err(chan2dev(chan), "Invalid DMA direction\n");

drivers/dma/sun4i-dma.c sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, · line 691

Quoted 10 lines
drivers/dma/sun4i-dma.c +0 -2
@@ -684,11 +684,9 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
 
        if (vchan->is_dedicated) {
                io_mode = SUN4I_DDMA_ADDR_MODE_IO;
-               linear_mode = SUN4I_DDMA_ADDR_MODE_LINEAR;
                ram_type = SUN4I_DDMA_DRQ_TYPE_SDRAM;
        } else {
                io_mode = SUN4I_NDMA_ADDR_MODE_IO;
-               linear_mode = SUN4I_NDMA_ADDR_MODE_LINEAR;
                ram_type = SUN4I_NDMA_DRQ_TYPE_SDRAM;
        }

I think it's better to actually use these values later when composing the value for endpoints, as we do in sun4i_dma_prep_slave_sg().

The code currently works because SUN4I_DDMA_ADDR_MODE_LINEAR == 0. However explicitly using the value makes the code more readable, and doesn't require the reader to have implicit knowledge of default values for parameters not specified in the composition of endpoints.

ChenYu

author
#2 lore raw
Quoted 45 lines · Chen-Yu Tsai

Hi,

Quoted 28 lines · YueHaibing

drivers/dma/sun4i-dma.c: In function sun4i_dma_prep_dma_cyclic:
drivers/dma/sun4i-dma.c:672:24: warning:
variable linear_mode set but not used [-Wunused-but-set-variable]

commit ffc079a4accc ("dmaengine: sun4i: Add support for cyclic requests with dedicated DMA") involved this unused variable.

---
 drivers/dma/sun4i-dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sun4i-dma.c +1 -1
index bbc2bda..501cd44 100644
@@ -669,7 +669,7 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
        dma_addr_t src, dest;
        u32 endpoints;
        int nr_periods, offset, plength, i;
-       u8 ram_type, io_mode, linear_mode;
+       u8 ram_type, io_mode;
 
        if (!is_slave_direction(dir)) {
                dev_err(chan2dev(chan), "Invalid DMA direction\n");

drivers/dma/sun4i-dma.c sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len, · line 691

Quoted 10 lines
drivers/dma/sun4i-dma.c +0 -2
@@ -684,11 +684,9 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
 
        if (vchan->is_dedicated) {
                io_mode = SUN4I_DDMA_ADDR_MODE_IO;
-               linear_mode = SUN4I_DDMA_ADDR_MODE_LINEAR;
                ram_type = SUN4I_DDMA_DRQ_TYPE_SDRAM;
        } else {
                io_mode = SUN4I_NDMA_ADDR_MODE_IO;
-               linear_mode = SUN4I_NDMA_ADDR_MODE_LINEAR;
                ram_type = SUN4I_NDMA_DRQ_TYPE_SDRAM;
        }

I think it's better to actually use these values later when composing the value for endpoints, as we do in sun4i_dma_prep_slave_sg().

Quoted 4 lines

The code currently works because SUN4I_DDMA_ADDR_MODE_LINEAR == 0. However explicitly using the value makes the code more readable, and doesn't require the reader to have implicit knowledge of default values for parameters not specified in the composition of endpoints.

Thanks, will send v2.

Quoted 5 lines

ChenYu

.

author
#3 lore raw

PATCH v2 1/1 dmaengine: sun4i: use 'linear_mode' in sun4i_dma_prep_dma_cyclic

In reply to YueHaibing

drivers/dma/sun4i-dma.c: In function sun4i_dma_prep_dma_cyclic:
drivers/dma/sun4i-dma.c:672:24: warning:
variable linear_mode set but not used [-Wunused-but-set-variable]

commit ffc079a4accc ("dmaengine: sun4i: Add support for cyclic requests with dedicated DMA") involved this, explicitly using the value makes the code more readable.

---
v2: use 'linear_mode' instead of removing

---
 drivers/dma/sun4i-dma.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/sun4i-dma.c +2 -0
index bbc2bda..e87fc7c4 100644
@@ -698,10 +698,12 @@ sun4i_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf, size_t len,
 		endpoints = SUN4I_DMA_CFG_DST_DRQ_TYPE(vchan->endpoint) |
 			    SUN4I_DMA_CFG_DST_ADDR_MODE(io_mode) |
 			    SUN4I_DMA_CFG_SRC_DRQ_TYPE(ram_type);
+			    SUN4I_DMA_CFG_SRC_ADDR_MODE(linear_mode);
 	} else {
 		src = sconfig->src_addr;
 		dest = buf;
 		endpoints = SUN4I_DMA_CFG_DST_DRQ_TYPE(ram_type) |
+			    SUN4I_DMA_CFG_DST_ADDR_MODE(linear_mode) |
 			    SUN4I_DMA_CFG_SRC_DRQ_TYPE(vchan->endpoint) |
 			    SUN4I_DMA_CFG_SRC_ADDR_MODE(io_mode);
 	}
Signature · 1 line
2.7.4