[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220412020834.7161-1-linmq006@gmail.com>
Date: Tue, 12 Apr 2022 02:08:30 +0000
From: Miaoqian Lin <linmq006@...il.com>
To: Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
Pratyush Yadav <p.yadav@...com>,
Miaoqian Lin <linmq006@...il.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Paul Cercueil <paul@...pouillou.net>,
Guennadi Liakhovetski <g.liakhovetski@....de>,
Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>,
Bastian Hecht <hechtb@...glemail.com>,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] mtd: rawnand: Fix return value check of wait_for_completion_timeout
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@...il.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
Powered by blists - more mailing lists