linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Liao Yuanhong <liaoyuanhong@vivo.com>
Cc: <vkoul@kernel.org>, <linux-arm-kernel@lists.infradead.org>,
	<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/6] dma:imx-dma:Use devm_clk_get_enabled() helpers
Date: Fri, 23 Aug 2024 13:07:00 +0100	[thread overview]
Message-ID: <20240823130700.00001d6d@Huawei.com> (raw)
In-Reply-To: <20240823101933.9517-4-liaoyuanhong@vivo.com>

On Fri, 23 Aug 2024 18:19:30 +0800
Liao Yuanhong <liaoyuanhong@vivo.com> wrote:

> Use devm_clk_get_enabled() instead of clk functions in imx-dma.
> 
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Straight forward case, but nice to combine this with
use of return dev_err_probe() in the paths where you now have
direct returns.  Other comments below.

 
> ---
>  drivers/dma/imx-dma.c | 38 +++++++++++++-------------------------
>  1 file changed, 13 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
> index ebf7c115d553..1ef926304d0e 100644
> --- a/drivers/dma/imx-dma.c
> +++ b/drivers/dma/imx-dma.c
> @@ -1039,6 +1039,8 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  	struct imxdma_engine *imxdma;
>  	int ret, i;
>  	int irq, irq_err;
> +	struct clk *dma_ahb;
> +	struct clk *dma_ipg;
	struct clk *dma_ahb, *dma_ipg;
should be fine.
>  
>  	imxdma = devm_kzalloc(&pdev->dev, sizeof(*imxdma), GFP_KERNEL);
>  	if (!imxdma)
> @@ -1055,20 +1057,13 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  	if (irq < 0)
>  		return irq;
>  
> -	imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg");
> -	if (IS_ERR(imxdma->dma_ipg))
> -		return PTR_ERR(imxdma->dma_ipg);
> +	dma_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
> +	if (IS_ERR(dma_ipg))
> +		return PTR_ERR(dma_ipg);
>  
> -	imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb");
> -	if (IS_ERR(imxdma->dma_ahb))
> -		return PTR_ERR(imxdma->dma_ahb);
> -
> -	ret = clk_prepare_enable(imxdma->dma_ipg);
> -	if (ret)
> -		return ret;
> -	ret = clk_prepare_enable(imxdma->dma_ahb);
> -	if (ret)
> -		goto disable_dma_ipg_clk;
> +	dma_ahb = devm_clk_get_enabled(&pdev->dev, "ahb");
> +	if (IS_ERR(dma_ahb))
> +		return PTR_ERR(dma_ahb);
>  
>  	/* reset DMA module */
>  	imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR);
> @@ -1078,21 +1073,21 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  				       dma_irq_handler, 0, "DMA", imxdma);
>  		if (ret) {
>  			dev_warn(imxdma->dev, "Can't register IRQ for DMA\n");
> -			goto disable_dma_ahb_clk;
> +			return ret;
Odd not to make that a dev_error given driver fails to probe as a result.
I'd switch to return dev_err_rpobe()
>  		}
>  		imxdma->irq = irq;
>  
>  		irq_err = platform_get_irq(pdev, 1);
>  		if (irq_err < 0) {
>  			ret = irq_err;
> -			goto disable_dma_ahb_clk;
> +			return ret;
>  		}
>  
>  		ret = devm_request_irq(&pdev->dev, irq_err,
>  				       imxdma_err_handler, 0, "DMA", imxdma);
>  		if (ret) {
>  			dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n");
> -			goto disable_dma_ahb_clk;
> +			return ret;
Here as well.

>  		}
>  		imxdma->irq_err = irq_err;
>  	}
> @@ -1130,7 +1125,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  				dev_warn(imxdma->dev, "Can't register IRQ %d "
>  					 "for DMA channel %d\n",
>  					 irq + i, i);
> -				goto disable_dma_ahb_clk;
> +				return ret;
and here.

>  			}
>  
>  			imxdmac->irq = irq + i;
> @@ -1174,7 +1169,7 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  	ret = dma_async_device_register(&imxdma->dma_device);
>  	if (ret) {
>  		dev_err(&pdev->dev, "unable to register\n");
> -		goto disable_dma_ahb_clk;
> +		return ret;
and finaly here.

>  	}
>  
>  	if (pdev->dev.of_node) {
> @@ -1190,10 +1185,6 @@ static int __init imxdma_probe(struct platform_device *pdev)
>  
>  err_of_dma_controller:
>  	dma_async_device_unregister(&imxdma->dma_device);
Maybe use a local callback and 
devm_add_action_or_reset() to get automate handling of this call as well.

> -disable_dma_ahb_clk:
> -	clk_disable_unprepare(imxdma->dma_ahb);
> -disable_dma_ipg_clk:
> -	clk_disable_unprepare(imxdma->dma_ipg);
>  	return ret;
>  }
>  
> @@ -1226,9 +1217,6 @@ static void imxdma_remove(struct platform_device *pdev)
>  
>  	if (pdev->dev.of_node)
>  		of_dma_controller_free(pdev->dev.of_node);
The ordering of the two items above here looks suspicious as it doesn't
reverse order of probably. Maybe worth cleaning that up whilst here.

> -
> -	clk_disable_unprepare(imxdma->dma_ipg);
> -	clk_disable_unprepare(imxdma->dma_ahb);
>  }
>  
>  static struct platform_driver imxdma_driver = {



  reply	other threads:[~2024-08-23 12:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 10:19 [PATCH 0/6] dma:Use devm_clk_get_enabled() helpers Liao Yuanhong
2024-08-23 10:19 ` [PATCH 1/6] dma:at_hdmac:Use " Liao Yuanhong
2024-08-23 11:58   ` Jonathan Cameron
2024-08-23 12:01   ` Nicolas Ferre
2024-08-23 10:19 ` [PATCH 2/6] dma:dma-jz4780:Use " Liao Yuanhong
2024-08-23 12:01   ` Jonathan Cameron
2024-08-23 10:19 ` [PATCH 3/6] dma:imx-dma:Use " Liao Yuanhong
2024-08-23 12:07   ` Jonathan Cameron [this message]
2024-08-26 12:21   ` [PATCH v2 " Liao Yuanhong
2024-08-28 13:00     ` Vinod Koul
2024-08-23 10:19 ` [PATCH 4/6] dma:imx-sdma:Use " Liao Yuanhong
2024-08-23 12:08   ` Jonathan Cameron
2024-08-26 19:27     ` Frank Li
2024-08-28  8:52   ` [PATCH v2 " Liao Yuanhong
2024-08-23 10:19 ` [PATCH 5/6] dma:milbeaut-hdmac:Use " Liao Yuanhong
2024-08-23 12:09   ` Jonathan Cameron
2024-08-23 10:19 ` [PATCH 6/6] dma:uniphier-mdmac:Use " Liao Yuanhong
2024-08-23 12:10   ` Jonathan Cameron

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=20240823130700.00001d6d@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=liaoyuanhong@vivo.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).