mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Frank Li <Frank.Li@nxp.com>, Vinod Koul <vkoul@kernel.org>,
	Dong Aisheng <aisheng.dong@nxp.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-i2c@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, carlos.song@nxp.com
Subject: Re: [PATCH 2/2] i2c: lpi2c: Use cleanup helper for dma_async_tx_descriptor error handling
Date: Thu, 2 Oct 2025 22:10:16 +0200	[thread overview]
Message-ID: <3c07c2f0-d069-46d1-b2a6-e2c071198cb6@wanadoo.fr> (raw)
In-Reply-To: <20251002-dma_chan_free-v1-2-4dbf116c2b19@nxp.com>

Le 02/10/2025 à 21:49, Frank Li a écrit :
> Use the cleanup helper to simplify dma_async_tx_descriptor error handling.
> 
> No functional change.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>   drivers/i2c/busses/i2c-imx-lpi2c.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index 03b5a7e8c361abe1d75fb4d31f9614bbc6387d93..b1d035ca8002e9648b67bfe4d674578373394710 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -722,7 +722,7 @@ static void lpi2c_dma_callback(void *data)
>   
>   static int lpi2c_dma_rx_cmd_submit(struct lpi2c_imx_struct *lpi2c_imx)
>   {
> -	struct dma_async_tx_descriptor *rx_cmd_desc;
> +	struct dma_async_tx_descriptor *rx_cmd_desc __free(dma_async_tx_descriptor) = NULL;
>   	struct lpi2c_imx_dma *dma = lpi2c_imx->dma;
>   	struct dma_chan *txchan = dma->chan_tx;
>   	dma_cookie_t cookie;
> @@ -746,10 +746,11 @@ static int lpi2c_dma_rx_cmd_submit(struct lpi2c_imx_struct *lpi2c_imx)
>   	cookie = dmaengine_submit(rx_cmd_desc);
>   	if (dma_submit_error(cookie)) {
>   		dev_err(&lpi2c_imx->adapter.dev, "submitting DMA failed, use pio\n");
> -		goto submit_err_exit;
> +		return dma_submit_error(cookie);

I don't know if it matters or not, but this may change the returned 
value in this error handling path.

>   	}
>   
>   	dma_async_issue_pending(txchan);
> +	retain_and_null_ptr(rx_cmd_desc);
>   
>   	return 0;
>   
> @@ -757,12 +758,6 @@ static int lpi2c_dma_rx_cmd_submit(struct lpi2c_imx_struct *lpi2c_imx)
>   	dma_unmap_single(txchan->device->dev, dma->dma_tx_addr,
>   			 dma->rx_cmd_buf_len, DMA_TO_DEVICE);
>   	return -EINVAL;
> -
> -submit_err_exit:
> -	dma_unmap_single(txchan->device->dev, dma->dma_tx_addr,
> -			 dma->rx_cmd_buf_len, DMA_TO_DEVICE);

dma_unmap_single() is not needed anymore?

> -	dmaengine_desc_free(rx_cmd_desc);
> -	return -EINVAL;
>   }
>   
>   static int lpi2c_dma_submit(struct lpi2c_imx_struct *lpi2c_imx)
> 


  reply	other threads:[~2025-10-02 20:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 19:49 [PATCH 0/2] dmaengine: Add cleanup to simple code Frank Li
2025-10-02 19:49 ` [PATCH 1/2] dmaengine: Add cleanup FREE defines for dma_async_tx_descriptor Frank Li
2025-10-02 19:49 ` [PATCH 2/2] i2c: lpi2c: Use cleanup helper for dma_async_tx_descriptor error handling Frank Li
2025-10-02 20:10   ` Christophe JAILLET [this message]
2025-10-02 20:51     ` Frank Li

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=3c07c2f0-d069-46d1-b2a6-e2c071198cb6@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=Frank.Li@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=andi.shyti@kernel.org \
    --cc=carlos.song@nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=vkoul@kernel.org \
    /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

all inboxes | Powered by JetHome®