public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: Fix return value check of wait_for_completion_timeout
@ 2022-04-12  2:08 Miaoqian Lin
  2022-04-12  5:01 ` kernel test robot
  0 siblings, 1 reply; 10+ messages in thread
From: Miaoqian Lin @ 2022-04-12  2:08 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Pratyush Yadav, Miaoqian Lin, Alexandre Belloni, Paul Cercueil,
	Guennadi Liakhovetski, Artem Bityutskiy, Bastian Hecht, linux-mtd,
	linux-kernel

wait_for_completion_timeout() returns unsigned long not int.
It returns 0 if timed out, and positive if completed.
The check for <= 0 is ambiguous and should be == 0 here
indicating timeout which is the only error case.

Fixes: 83738d87e3a0 ("mtd: sh_flctl: Add DMA capabilty")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/mtd/nand/raw/sh_flctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c
index b85b9c6fcc42..4f326a2dd170 100644
--- a/drivers/mtd/nand/raw/sh_flctl.c
+++ b/drivers/mtd/nand/raw/sh_flctl.c
@@ -385,6 +385,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
 	dma_cookie_t cookie;
 	uint32_t reg;
 	int ret;
+	unsigned long time_left;
 
 	if (dir == DMA_FROM_DEVICE) {
 		chan = flctl->chan_fifo0_rx;
@@ -425,13 +426,14 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
 		goto out;
 	}
 
-	ret =
+	time_left =
 	wait_for_completion_timeout(&flctl->dma_complete,
 				msecs_to_jiffies(3000));
 
-	if (ret <= 0) {
+	if (time_left == 0) {
 		dmaengine_terminate_all(chan);
 		dev_err(&flctl->pdev->dev, "wait_for_completion_timeout\n");
+		ret = -ETIMEDOUT;
 	}
 
 out:
-- 
2.17.1


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

end of thread, other threads:[~2022-04-21  7:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-12  2:08 [PATCH] mtd: rawnand: Fix return value check of wait_for_completion_timeout Miaoqian Lin
2022-04-12  5:01 ` kernel test robot
2022-04-12  6:36   ` [PATCH v2] " Miaoqian Lin
2022-04-12  7:06     ` Miquel Raynal
2022-04-12  7:42       ` Miaoqian Lin
2022-04-12  7:48         ` Miquel Raynal
2022-04-12  8:23           ` Miaoqian Lin
2022-04-12  8:28             ` Miquel Raynal
2022-04-12  8:34               ` [PATCH v3] " Miaoqian Lin
2022-04-21  7:35                 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox