public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Nicholas Mc Guire <hofrat@osadl.org>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Wolfram Sang <wsa@the-dreams.de>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 1/4] mtd: sh_flctl: let flctl_dma_fifo0_transfer return 0 on success
Date: Sun, 03 May 2015 22:35:47 +0300	[thread overview]
Message-ID: <2970495.e6NA0vdFiS@avalon> (raw)
In-Reply-To: <1430553430-21396-1-git-send-email-hofrat@osadl.org>

Hi Nicholas,

Thank you for the patch.

On Saturday 02 May 2015 09:57:07 Nicholas Mc Guire wrote:
> wait_for_completion_timeout() returns unsigned long not int so the check
> for <= should be == and the type unsigned long. With that fixup the return
> value of flctl_dma_fifo0_transfer can be changed to 0 for success. This
> changes the failure return value for wait_for_completion_timeout to
> -ETIMEDOUT and implicitly 0 on success by initializing ret to 0.
> The call-sites are fixed up to check for == 0 rather than > 0 as well.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

I would squash patches 3/4 and 4/4 into this one, there isn't much point in 
having indentation fixes as separate patches when this one already touches the 
same lines of code. Then,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
> V2: As suggested by Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>     the expected success return value is 0 so rather than just fixing up
>     wait_for_completion_timeout return handling the return value of
>     flctl_dma_fifo0_transfer should be adjusted.
> 
> call sites:
> read_fiforeg,write_ec_fiforeg assume > 0 == success
> are fixed up to check for == 0 for success
> and the comment in flctl_dma_fifo0_transfe
>         /* ret > 0 is success */
>         return ret;
> is dropped since returning 0 on success is the expected.
> 
> 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 |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
> index c3ce81c..9b032dd 100644
> --- a/drivers/mtd/nand/sh_flctl.c
> +++ b/drivers/mtd/nand/sh_flctl.c
> @@ -353,7 +353,8 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl
> *flctl, unsigned long *buf, dma_addr_t dma_addr;
>  	dma_cookie_t cookie = -EINVAL;
>  	uint32_t reg;
> -	int ret;
> +	int ret = 0;
> +	unsigned long time_left;
> 
>  	if (dir == DMA_FROM_DEVICE) {
>  		chan = flctl->chan_fifo0_rx;
> @@ -388,13 +389,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:
> @@ -404,7 +406,6 @@ out:
> 
>  	dma_unmap_single(chan->device->dev, dma_addr, len, dir);
> 
> -	/* ret > 0 is success */
>  	return ret;
>  }
> 
> @@ -428,7 +429,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int
> rlen, int offset)
> 
>  	/* initiate DMA transfer */
>  	if (flctl->chan_fifo0_rx && rlen >= 32 &&
> -		flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_DEV_TO_MEM) > 0)
> +		flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_DEV_TO_MEM) == 0)
>  			goto convert;	/* DMA success */
> 
>  	/* do polling transfer */
> @@ -487,7 +488,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int
> rlen,
> 
>  	/* initiate DMA transfer */
>  	if (flctl->chan_fifo0_tx && rlen >= 32 &&
> -		flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_MEM_TO_DEV) > 0)
> +		flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_MEM_TO_DEV) == 0)
>  			return;	/* DMA success */
> 
>  	/* do polling transfer */

-- 
Regards,

Laurent Pinchart

      parent reply	other threads:[~2015-05-03 19:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  7:57 [PATCH 1/4] mtd: sh_flctl: let flctl_dma_fifo0_transfer return 0 on success Nicholas Mc Guire
2015-05-02  7:57 ` [PATCH 2/4] mtd: sh_flctl: drop unused variable Nicholas Mc Guire
2015-05-03 19:33   ` Laurent Pinchart
2015-05-04  5:17     ` Vinod Koul
2015-05-04  6:03       ` Nicholas Mc Guire
2015-05-04  7:53         ` Laurent Pinchart
2015-05-10 13:49           ` Nicholas Mc Guire
2015-05-02  7:57 ` [PATCH 3/4] mtd: sh_flctl: fix function parameter alignment Nicholas Mc Guire
2015-05-02  7:57 ` [PATCH 4/4] mtd: sh_flctl: fix wrapped condition alignment Nicholas Mc Guire
2015-05-04  5:21   ` Vinod Koul
2015-05-04  5:43     ` Nicholas Mc Guire
2015-05-04  7:05     ` Joe Perches
2015-05-03 19:35 ` Laurent Pinchart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2970495.e6NA0vdFiS@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=arnd@arndb.de \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=hofrat@osadl.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=vinod.koul@intel.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox