From patchwork Tue Aug 15 15:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13353892 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 0A8D4C0015E for ; Tue, 15 Aug 2023 15:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LTxtCPXKtKy3PKbk1I0j0TbQ38TasBSs+JHR/DwUXag=; b=NTSqHWx73atLDE 1fdbb8BpoP/z13g8znfCcacv8nV7i1QKNAhOrRnW9QnpzUFnAZZMfYp6Vn3VXRK7/i90ACF00bi5N xl43PbgCMLdlb+H5KbR55D8q1GAagET4nxRDTnVrx5FZYmxoc46h8Yb4dN4G6I05Uj7qJK15JH8LQ GabDLzPGGdhb6VK4wIaLFDZ8AgJIwh8ubdCvFWViDRtLNtSW/+eegVhpV5DNOqj+vWBBMrHHMji7Z PsuIaaM0vDR9qlM/caPSJyqp1ljKI1jjdfWOYewq2bOD1XwZnPpktuJakj1yXgSUTvyIz4bM7AM2F nmUiR/BGt8rzdee7inQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVvkY-001pVd-2l; Tue, 15 Aug 2023 15:14:26 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVvkU-001pUh-33 for linux-arm-kernel@lists.infradead.org; Tue, 15 Aug 2023 15:14:25 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQF7t5rgNztRrD; Tue, 15 Aug 2023 23:10:34 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 23:14:10 +0800 From: Li Zetao To: , , , , , , CC: , , Subject: [PATCH -next] ata: pata_imx: Use helper function devm_clk_get_enabled() Date: Tue, 15 Aug 2023 23:13:52 +0800 Message-ID: <20230815151352.1907861-1-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_081423_241751_653210C7 X-CRM114-Status: GOOD ( 13.07 ) 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 After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare or disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao Reviewed-by: Sergey Shtylyov --- drivers/ata/pata_imx.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c index 91da7ecec0fc..d0aa8fc929b4 100644 --- a/drivers/ata/pata_imx.c +++ b/drivers/ata/pata_imx.c @@ -141,21 +141,15 @@ static int pata_imx_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - priv->clk = devm_clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "Failed to get clock\n"); + dev_err(&pdev->dev, "Failed to get and enable clock\n"); return PTR_ERR(priv->clk); } - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; - host = ata_host_alloc(&pdev->dev, 1); - if (!host) { - ret = -ENOMEM; - goto err; - } + if (!host) + return -ENOMEM; host->private_data = priv; ap = host->ports[0]; @@ -165,10 +159,8 @@ static int pata_imx_probe(struct platform_device *pdev) ap->flags |= ATA_FLAG_SLAVE_POSS; priv->host_regs = devm_platform_get_and_ioremap_resource(pdev, 0, &io_res); - if (IS_ERR(priv->host_regs)) { - ret = PTR_ERR(priv->host_regs); - goto err; - } + if (IS_ERR(priv->host_regs)) + return PTR_ERR(priv->host_regs); ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA; ap->ioaddr.ctl_addr = priv->host_regs + PATA_IMX_DRIVE_CONTROL; @@ -194,13 +186,9 @@ static int pata_imx_probe(struct platform_device *pdev) &pata_imx_sht); if (ret) - goto err; + return ret; return 0; -err: - clk_disable_unprepare(priv->clk); - - return ret; } static void pata_imx_remove(struct platform_device *pdev) @@ -211,8 +199,6 @@ static void pata_imx_remove(struct platform_device *pdev) ata_host_detach(host); __raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN); - - clk_disable_unprepare(priv->clk); } #ifdef CONFIG_PM_SLEEP