Skip to content

Commit

Permalink
mtd: rawnand: Fix return value check of wait_for_completion_timeout
Browse files Browse the repository at this point in the history
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: 83738d8 ("mtd: sh_flctl: Add DMA capabilty")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
  • Loading branch information
Yuuoniy authored and intel-lab-lkp committed Apr 12, 2022
1 parent 51a4a71 commit 3de25b4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/mtd/nand/raw/sh_flctl.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3de25b4

Please sign in to comment.