diff mbox

[1/2] spi: sh-msiof: Return early in sh_msiof_dma_once() where possible

Message ID 1407413263-20177-1-git-send-email-geert+renesas@glider.be (mailing list archive)
State Accepted
Commit a5e7c719fe257214aeda3dadb502a4cf58209a61
Headers show

Commit Message

Geert Uytterhoeven Aug. 7, 2014, 12:07 p.m. UTC
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
("spi: sh-msiof: Fix leaking of unused DMA descriptors")
---
 drivers/spi/spi-sh-msiof.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Laurent Pinchart Aug. 7, 2014, 12:52 p.m. UTC | #1
Hi Geert,

On Thursday 07 August 2014 14:07:42 Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

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

> ---
> Feel free to fold into commit 4240305f7cbdc7782aa8bc40cc702775d9ac0839
> ("spi: sh-msiof: Fix leaking of unused DMA descriptors")
> ---
>  drivers/spi/spi-sh-msiof.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 887c2084130f..0d9ccd0953de 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -642,18 +642,14 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv
> *p, const void *tx, desc_rx =
> dmaengine_prep_slave_single(p->master->dma_rx,
>  					p->rx_dma_addr, len, DMA_FROM_DEVICE,
>  					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> -		if (!desc_rx) {
> -			ret = -EAGAIN;
> -			goto no_dma_rx;
> -		}
> +		if (!desc_rx)
> +			return -EAGAIN;
> 
>  		desc_rx->callback = sh_msiof_dma_complete;
>  		desc_rx->callback_param = p;
>  		cookie = dmaengine_submit(desc_rx);
> -		if (dma_submit_error(cookie)) {
> -			ret = cookie;
> -			goto no_dma_rx;
> -		}
> +		if (dma_submit_error(cookie))
> +			return cookie;
>  	}
> 
>  	if (tx) {
> @@ -738,7 +734,6 @@ no_dma_tx:
>  	if (rx)
>  		dmaengine_terminate_all(p->master->dma_rx);
>  	sh_msiof_write(p, IER, 0);
> -no_dma_rx:
>  	return ret;
>  }
Mark Brown Aug. 7, 2014, 5:41 p.m. UTC | #2
On Thu, Aug 07, 2014 at 02:07:42PM +0200, Geert Uytterhoeven wrote:
> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied both, thanks.
diff mbox

Patch

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 887c2084130f..0d9ccd0953de 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -642,18 +642,14 @@  static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
 		desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
 					p->rx_dma_addr, len, DMA_FROM_DEVICE,
 					DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-		if (!desc_rx) {
-			ret = -EAGAIN;
-			goto no_dma_rx;
-		}
+		if (!desc_rx)
+			return -EAGAIN;
 
 		desc_rx->callback = sh_msiof_dma_complete;
 		desc_rx->callback_param = p;
 		cookie = dmaengine_submit(desc_rx);
-		if (dma_submit_error(cookie)) {
-			ret = cookie;
-			goto no_dma_rx;
-		}
+		if (dma_submit_error(cookie))
+			return cookie;
 	}
 
 	if (tx) {
@@ -738,7 +734,6 @@  no_dma_tx:
 	if (rx)
 		dmaengine_terminate_all(p->master->dma_rx);
 	sh_msiof_write(p, IER, 0);
-no_dma_rx:
 	return ret;
 }