Skip to contentSkip to conversation

dmaengine: imx-sdma: Fix: Remove 'always true' comparison

PATCH Applied Fabio Estevam 3 participants 3 messages Jun 21, 2020 – Jun 24, 2020

Subsystems (2)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 dmaengine: imx-sdma: Fix: Remove 'always true' comparison

event_id0 is defined as 'unsigned int', so it is always greater or equal to zero.

Remove the unneeded comparisons to fix the following W=1 build warning:

drivers/dma/imx-sdma.c: In function 'sdma_free_chan_resources':
drivers/dma/imx-sdma.c:1334:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1334 | if (sdmac->event_id0 >= 0)
| ^~
drivers/dma/imx-sdma.c: In function 'sdma_config':
drivers/dma/imx-sdma.c:1635:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1635 | if (sdmac->event_id0 >= 0) {
|

Fixes 25962e1a7f1d ("dmaengine: imx-sdma: Fix the event id check to include RX event for UART6")
---
 drivers/dma/imx-sdma.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/dma/imx-sdma.c +4 -7
index 91774039ae5d..270992c4fe47 100644
@@ -1331,8 +1331,7 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 
 	sdma_channel_synchronize(chan);
 
-	if (sdmac->event_id0 >= 0)
-		sdma_event_disable(sdmac, sdmac->event_id0);
+	sdma_event_disable(sdmac, sdmac->event_id0);
 	if (sdmac->event_id1)
 		sdma_event_disable(sdmac, sdmac->event_id1);
 
@@ -1632,11 +1631,9 @@ static int sdma_config(struct dma_chan *chan,
 	memcpy(&sdmac->slave_config, dmaengine_cfg, sizeof(*dmaengine_cfg));
 
 	/* Set ENBLn earlier to make sure dma request triggered after that */
-	if (sdmac->event_id0 >= 0) {
-		if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
-			return -EINVAL;
-		sdma_event_enable(sdmac, sdmac->event_id0);
-	}
+	if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
+		return -EINVAL;
+	sdma_event_enable(sdmac, sdmac->event_id0);
 
 	if (sdmac->event_id1) {
 		if (sdmac->event_id1 >= sdmac->sdma->drvdata->num_events)
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Fabio Estevam

event_id0 is defined as 'unsigned int', so it is always greater or equal to zero.

Remove the unneeded comparisons to fix the following W=1 build warning:

drivers/dma/imx-sdma.c: In function 'sdma_free_chan_resources':
drivers/dma/imx-sdma.c:1334:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1334 | if (sdmac->event_id0 >= 0)
| ^~
drivers/dma/imx-sdma.c: In function 'sdma_config':
drivers/dma/imx-sdma.c:1635:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1635 | if (sdmac->event_id0 >= 0) {
|

Quoted 3 lines
Fixes 25962e1a7f1d ("dmaengine: imx-sdma: Fix the event id check to include RX event for UART6")

Thanks!

Quoted 34 lines
---
  drivers/dma/imx-sdma.c | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
drivers/dma/imx-sdma.c +4 -7
index 91774039ae5d..270992c4fe47 100644
@@ -1331,8 +1331,7 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
 
  	sdma_channel_synchronize(chan);
 
-	if (sdmac->event_id0 >= 0)
-		sdma_event_disable(sdmac, sdmac->event_id0);
+	sdma_event_disable(sdmac, sdmac->event_id0);
  	if (sdmac->event_id1)
  		sdma_event_disable(sdmac, sdmac->event_id1);
 
@@ -1632,11 +1631,9 @@ static int sdma_config(struct dma_chan *chan,
  	memcpy(&sdmac->slave_config, dmaengine_cfg, sizeof(*dmaengine_cfg));
 
  	/* Set ENBLn earlier to make sure dma request triggered after that */
-	if (sdmac->event_id0 >= 0) {
-		if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
-			return -EINVAL;
-		sdma_event_enable(sdmac, sdmac->event_id0);
-	}
+	if (sdmac->event_id0 >= sdmac->sdma->drvdata->num_events)
+		return -EINVAL;
+	sdma_event_enable(sdmac, sdmac->event_id0);
 
  	if (sdmac->event_id1) {
  		if (sdmac->event_id1 >= sdmac->sdma->drvdata->num_events)
maintainer Applied
#2 lore raw
In reply to Fabio Estevam
Quoted 6 lines · Fabio Estevam

event_id0 is defined as 'unsigned int', so it is always greater or equal to zero.

Remove the unneeded comparisons to fix the following W=1 build warning:

Quoted 8 lines

drivers/dma/imx-sdma.c: In function 'sdma_free_chan_resources':
drivers/dma/imx-sdma.c:1334:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1334 | if (sdmac->event_id0 >= 0)
| ^~
drivers/dma/imx-sdma.c: In function 'sdma_config':
drivers/dma/imx-sdma.c:1635:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] 1635 | if (sdmac->event_id0 >= 0) {
|

Applied, thanks

Signature · 1 line
~Vinod