From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66734C52D7C for ; Fri, 23 Aug 2024 12:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ry4kdDigqawe3rUxmvg556Zl7fYlm8mYVgM5oWcePvQ=; b=d6/v0MaWbpklRgtLKobgCmu1ic SKGEAxS5cdcWPIkBVl45jiJHmTYunyNj95uwC189+hyjVKo9KSq9+shso/ofa0mMiZfbjgJWuOBBU vqDA6N0BvgXFl26DMm8ljhEOk+qPhrc8N2hJdnmFSCyHxu4Icp1pMC6EZuI3Lu4pd5CXIfPbaSRQu umZlf4vLPVbNgMn1UzJiijGj9L1FKD8I53Axjm1MrECeegJ+8j/Irar9I2dVx4AoQe4GaHnuSnyeH t6zL25G7jIbrEtB9prxKfJvSJiXHkrR4thmOuJCXwnPJt7/bpieZ1J8d9bOxgI8O2l5EkYhVH31hn elUeUhoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shT5L-0000000GeEF-1ETi; Fri, 23 Aug 2024 12:08:07 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shT4S-0000000Gdvh-2X5x for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 12:07:15 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WqzH85xDmz6G9Kd; Fri, 23 Aug 2024 20:03:16 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id CF335140594; Fri, 23 Aug 2024 20:07:01 +0800 (CST) Received: from localhost (10.203.177.66) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 23 Aug 2024 13:07:01 +0100 Date: Fri, 23 Aug 2024 13:07:00 +0100 From: Jonathan Cameron To: Liao Yuanhong CC: , , , Subject: Re: [PATCH 3/6] dma:imx-dma:Use devm_clk_get_enabled() helpers Message-ID: <20240823130700.00001d6d@Huawei.com> In-Reply-To: <20240823101933.9517-4-liaoyuanhong@vivo.com> References: <20240823101933.9517-1-liaoyuanhong@vivo.com> <20240823101933.9517-4-liaoyuanhong@vivo.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_050713_020663_5AF7AB5C X-CRM114-Status: GOOD ( 22.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 23 Aug 2024 18:19:30 +0800 Liao Yuanhong wrote: > Use devm_clk_get_enabled() instead of clk functions in imx-dma. > > Signed-off-by: Liao Yuanhong 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 = {