Skip to contentSkip to conversation

dmaengine: imx-sdma: remove always true comparisons

PATCH In review Vinod Koul 2 participants 3 messages Jul 15, 2020

Subsystems (2)
lore
Share & tools
lore

Vinod Koul

author maintainer
#0 lore raw

PATCH 1/1 dmaengine: imx-sdma: remove always true comparisons

sdmac->event_id0 is of type unsigned int and hence can never be less than zero. Driver compares this at couple of places with greater than or equal to zero, these are always true so should be dropped

drivers/dma/imx-sdma.c:1336:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] drivers/dma/imx-sdma.c:1637:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

---
 drivers/dma/imx-sdma.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/dma/imx-sdma.c +4 -7
index b8cfc9d5f1a2..4f8d8f5e1132 100644
@@ -1333,8 +1333,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);
 
@@ -1634,11 +1633,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.26.2
reviewer
#1 lore raw

Hi Vinod,

Quoted 9 lines · Vinod Koul

sdmac->event_id0 is of type unsigned int and hence can never be less than zero. Driver compares this at couple of places with greater than or equal to zero, these are always true so should be dropped

drivers/dma/imx-sdma.c:1336:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] drivers/dma/imx-sdma.c:1637:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

I have already fixed this problem and you have already applied my patch:
https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git/commit/?h=next&id=2f57b8d57673af2c2caf8c2c7bef01be940a5c2c

author maintainer
#2 lore raw

Hi Fabio,

Quoted 8 lines · Fabio Estevam

Hi Vinod,

Quoted 5 lines · Vinod Koul

sdmac->event_id0 is of type unsigned int and hence can never be less than zero. Driver compares this at couple of places with greater than or equal to zero, these are always true so should be dropped

Quoted 7 lines
Quoted 4 lines

drivers/dma/imx-sdma.c:1336:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] drivers/dma/imx-sdma.c:1637:23: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

I have already fixed this problem and you have already applied my patch:
https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git/commit/?h=next&id=2f57b8d57673af2c2caf8c2c7bef01be940a5c2c

My bad that I didnt run this on -next :-)

Signature · 1 line
~Vinod