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 2/6] dma:dma-jz4780:Use devm_clk_get_enabled() helpers
Date: Fri, 23 Aug 2024 13:01:17 +0100 [thread overview]
Message-ID: <20240823130117.00007e25@Huawei.com> (raw)
In-Reply-To: <20240823101933.9517-3-liaoyuanhong@vivo.com>
On Fri, 23 Aug 2024 18:19:29 +0800
Liao Yuanhong <liaoyuanhong@vivo.com> wrote:
> Use devm_clk_get_enabled() instead of clk functions in dma-jz4780.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
Original code has some odd ordering. The error path order
and remove order should be the same and aren't.
Even with that tidied up this reorders clock disable and tasklet
killing. So I think this is fine, but needs more eyes on it.
> ---
> drivers/dma/dma-jz4780.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
> index c9cfa341db51..151a85516419 100644
> --- a/drivers/dma/dma-jz4780.c
> +++ b/drivers/dma/dma-jz4780.c
> @@ -149,7 +149,6 @@ struct jz4780_dma_dev {
> struct dma_device dma_device;
> void __iomem *chn_base;
> void __iomem *ctrl_base;
> - struct clk *clk;
> unsigned int irq;
> const struct jz4780_dma_soc_data *soc_data;
>
> @@ -857,6 +856,7 @@ static int jz4780_dma_probe(struct platform_device *pdev)
> struct dma_device *dd;
> struct resource *res;
> int i, ret;
> + struct clk *clk;
>
> if (!dev->of_node) {
> dev_err(dev, "This driver must be probed from devicetree\n");
> @@ -896,15 +896,13 @@ static int jz4780_dma_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - jzdma->clk = devm_clk_get(dev, NULL);
> - if (IS_ERR(jzdma->clk)) {
> + clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(clk)) {
> dev_err(dev, "failed to get clock\n");
> - ret = PTR_ERR(jzdma->clk);
> + ret = PTR_ERR(clk);
> return ret;
> }
>
> - clk_prepare_enable(jzdma->clk);
> -
> /* Property is optional, if it doesn't exist the value will remain 0. */
> of_property_read_u32_index(dev->of_node, "ingenic,reserved-channels",
> 0, &jzdma->chan_reserved);
> @@ -972,7 +970,7 @@ static int jz4780_dma_probe(struct platform_device *pdev)
>
> ret = platform_get_irq(pdev, 0);
> if (ret < 0)
> - goto err_disable_clk;
> + return ret;
>
> jzdma->irq = ret;
>
> @@ -980,7 +978,7 @@ static int jz4780_dma_probe(struct platform_device *pdev)
> jzdma);
> if (ret) {
> dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
> - goto err_disable_clk;
> + return ret;
> }
>
> ret = dmaenginem_async_device_register(dd);
> @@ -1002,9 +1000,6 @@ static int jz4780_dma_probe(struct platform_device *pdev)
>
> err_free_irq:
> free_irq(jzdma->irq, jzdma);
> -
> -err_disable_clk:
> - clk_disable_unprepare(jzdma->clk);
> return ret;
> }
>
> @@ -1015,7 +1010,6 @@ static void jz4780_dma_remove(struct platform_device *pdev)
>
> of_dma_controller_free(pdev->dev.of_node);
>
> - clk_disable_unprepare(jzdma->clk);
> free_irq(jzdma->irq, jzdma);
Hmm. Ordering wise this is not great.
>
> for (i = 0; i < jzdma->soc_data->nb_channels; i++)
next prev parent reply other threads:[~2024-08-23 12:02 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 [this message]
2024-08-23 10:19 ` [PATCH 3/6] dma:imx-dma:Use " Liao Yuanhong
2024-08-23 12:07 ` Jonathan Cameron
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=20240823130117.00007e25@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).