diff mbox series

dmaengine: imx-sdma: remove always true comparisons

Message ID 20200715130122.39873-1-vkoul@kernel.org (mailing list archive)
State Not Applicable
Headers show
Series dmaengine: imx-sdma: remove always true comparisons | expand

Commit Message

Vinod Koul July 15, 2020, 1:01 p.m. UTC
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]

Signed-off-by: Vinod Koul <vkoul@kernel.org>
---
 drivers/dma/imx-sdma.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Fabio Estevam July 15, 2020, 1:16 p.m. UTC | #1
Hi Vinod,

On Wed, Jul 15, 2020 at 10:01 AM Vinod Koul <vkoul@kernel.org> wrote:
>
> 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]
>
> Signed-off-by: Vinod Koul <vkoul@kernel.org>

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
Vinod Koul July 15, 2020, 3:27 p.m. UTC | #2
Hi Fabio,

On 15-07-20, 10:16, Fabio Estevam wrote:
> Hi Vinod,
> 
> On Wed, Jul 15, 2020 at 10:01 AM Vinod Koul <vkoul@kernel.org> wrote:
> >
> > 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]
> >
> > Signed-off-by: Vinod Koul <vkoul@kernel.org>
> 
> 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 :-)
diff mbox series

Patch

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index b8cfc9d5f1a2..4f8d8f5e1132 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -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)