linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mtd: sh_flctl: fixup wait_for_completion_timeout return handling
@ 2015-05-01 14:16 Nicholas Mc Guire
  2015-05-01 14:16 ` [PATCH 2/3] mtd: sh_flctl: fix alignment of function argument Nicholas Mc Guire
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nicholas Mc Guire @ 2015-05-01 14:16 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Brian Norris, Vinod Koul, Laurent Pinchart, Kuninori Morimoto,
	Wolfram Sang, Arnd Bergmann, linux-mtd, linux-kernel,
	Nicholas Mc Guire

wait_for_completion_timeout() returns unsigned long not int so the check 
for <= should be == and the type unsigned long. This fixes up the return 
value handling and returns -ETIMEDOUT on timeout rather than 0 and 1 on 
on success rather than a more or less random remaining number of jiffies.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

call sites:
read_fiforeg,write_ec_fiforeg assume > 0 == success
and the comment in flctl_dma_fifo0_transfe states
        /* ret > 0 is success */
        return ret;
since it is only checking for > 0 in the call-sites
returning -ETIMEDOUT should be fine.

Patch was compile tested with ap325rxa_defconfig (implies
CONFIG_MTD_NAND_SH_FLCTL=y)

Patch is against 4.1-rc1 (localversion-next is -next-20150501)

 drivers/mtd/nand/sh_flctl.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index c3ce81c..4450864 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -354,6 +354,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf,
 	dma_cookie_t cookie = -EINVAL;
 	uint32_t reg;
 	int ret;
+	unsigned long time_left;
 
 	if (dir == DMA_FROM_DEVICE) {
 		chan = flctl->chan_fifo0_rx;
@@ -388,14 +389,16 @@ 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;
+	} else
+		ret = 1;	/* completion succeeded */
 
 out:
 	reg = readl(FLINTDMACR(flctl));
-- 
1.7.10.4


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

end of thread, other threads:[~2015-05-02  6:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-01 14:16 [PATCH 1/3] mtd: sh_flctl: fixup wait_for_completion_timeout return handling Nicholas Mc Guire
2015-05-01 14:16 ` [PATCH 2/3] mtd: sh_flctl: fix alignment of function argument Nicholas Mc Guire
2015-05-01 23:08   ` Laurent Pinchart
2015-05-01 14:16 ` [PATCH 3/3] mtd: sh_flctl: remove unused variable and assignment Nicholas Mc Guire
2015-05-01 23:07   ` Laurent Pinchart
2015-05-01 23:20 ` [PATCH 1/3] mtd: sh_flctl: fixup wait_for_completion_timeout return handling Laurent Pinchart
2015-05-02  6:49   ` Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).