Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751347AbbEAXUR (ORCPT ); Fri, 1 May 2015 19:20:17 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:39176 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750804AbbEAXUO (ORCPT ); Fri, 1 May 2015 19:20:14 -0400 From: Laurent Pinchart To: Nicholas Mc Guire Cc: David Woodhouse , Brian Norris , Vinod Koul , Laurent Pinchart , Kuninori Morimoto , Wolfram Sang , Arnd Bergmann , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] mtd: sh_flctl: fixup wait_for_completion_timeout return handling Date: Sat, 02 May 2015 02:20:36 +0300 Message-ID: <1840948.DRGdB3Gx66@avalon> User-Agent: KMail/4.14.3 (Linux/3.18.11-gentoo; KDE/4.14.3; x86_64; ; ) In-Reply-To: <1430489763-18417-1-git-send-email-hofrat@osadl.org> References: <1430489763-18417-1-git-send-email-hofrat@osadl.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2749 Lines: 86 Hi Nicholas, Thank you for the patch. On Friday 01 May 2015 16:16:01 Nicholas Mc Guire wrote: > 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 > --- > > 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 */ I'd go one step further and make this function return < 0 on error and 0 on success, like usually done through the kernel API. You could then simplify the code using something like if (!wait_for_completion_timeout(&flctl->dma_complete, msecs_to_jiffies(3000))) { dmaengine_terminate_all(chan); dev_err(&flctl->pdev->dev, "wait_for_completion_timeout\n"); ret = -ETIMEDOUT; } (pre-initializing ret to 0) > > out: > reg = readl(FLINTDMACR(flctl)); -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/