dmaengine Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] dmaengine: imx-sdma: remove always true comparisons
@ 2020-07-15 13:01 Vinod Koul
  2020-07-15 13:16 ` Fabio Estevam
  0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2020-07-15 13:01 UTC (permalink / raw)
  To: dmaengine
  Cc: Vinod Koul, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-kernel

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(-)

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)
-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: imx-sdma: remove always true comparisons
  2020-07-15 13:01 [PATCH] dmaengine: imx-sdma: remove always true comparisons Vinod Koul
@ 2020-07-15 13:16 ` Fabio Estevam
  2020-07-15 15:27   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2020-07-15 13:16 UTC (permalink / raw)
  To: Vinod Koul
  Cc: dmaengine, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: imx-sdma: remove always true comparisons
  2020-07-15 13:16 ` Fabio Estevam
@ 2020-07-15 15:27   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2020-07-15 15:27 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: dmaengine, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-kernel

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 :-)

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 13:01 [PATCH] dmaengine: imx-sdma: remove always true comparisons Vinod Koul
2020-07-15 13:16 ` Fabio Estevam
2020-07-15 15:27   ` Vinod Koul

dmaengine Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dmaengine/0 dmaengine/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dmaengine dmaengine/ https://lore.kernel.org/dmaengine \
		dmaengine@vger.kernel.org
	public-inbox-index dmaengine

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.dmaengine


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git