From patchwork Tue Aug 22 13:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360685 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 C34BCEE49A3 for ; Tue, 22 Aug 2023 13:13: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:References:In-Reply-To: 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: List-Owner; bh=WG974oHcBegSayqreAlFZ/63x6UaF6l9wDjKhYsC65g=; b=PX7Aro6OCu2XGk wA6PPPvqr1qGFr9YHVuC7dYDO480UlSdg1OPaBJjFnQL2hVTE1eLftHlyv7r787LLIGzxa/ZpRHhX SgzcjThFEGxLB1TPIydw0+x4cFYEC48U3vYi/BxhdUb2KYKdvMxxtHjZiIZxLk1N3zyULllpQXokN T2Iv8PEFNByKfYmBntvVkuG+HIrseLVLvFPCr9Dqfn5afQWDZEjqiOvDOADsB9eUs2FtMaY07lHpU 6B7HfFkASLXEKmaVqLkutL36jt9nZH30l+DLDroy/vhg+LZBJ/3tT9InoBkfpXYEmB+zNaBuSwc2e 9zXF3S4KvQmJ7I4JU2Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCU-00Fy8s-1g; Tue, 22 Aug 2023 13:13:38 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRBw-00FxY0-2r; Tue, 22 Aug 2023 13:13:06 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8R3ZmjzTmN3; Tue, 22 Aug 2023 21:10:47 +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, 22 Aug 2023 21:13:01 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 12/25] spi: dw-mmio: Use helper function devm_clk_get_*() Date: Tue, 22 Aug 2023 21:12:24 +0800 Message-ID: <20230822131237.1022815-13-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822131237.1022815-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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-20230822_061305_450130_7C6632FF X-CRM114-Status: GOOD ( 10.54 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables (and possibly prepares) the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Also, devm_clk_get_optional() and clk_prepare_enable() can now be replaced by devm_clk_get_optional_enabled(). Moreover, the lable "out_clk" no longer makes sense, rename it to "out_reset". Signed-off-by: Li Zetao --- drivers/spi/spi-dw-mmio.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 805264c9c65c..6d9f64ecbfd6 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -340,28 +340,22 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) if (dws->irq < 0) return dws->irq; /* -ENXIO */ - dwsmmio->clk = devm_clk_get(&pdev->dev, NULL); + dwsmmio->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dwsmmio->clk)) return PTR_ERR(dwsmmio->clk); - ret = clk_prepare_enable(dwsmmio->clk); - if (ret) - return ret; /* Optional clock needed to access the registers */ - dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); + dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); if (IS_ERR(dwsmmio->pclk)) { ret = PTR_ERR(dwsmmio->pclk); - goto out_clk; + goto out_reset; } - ret = clk_prepare_enable(dwsmmio->pclk); - if (ret) - goto out_clk; /* find an optional reset controller */ dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi"); if (IS_ERR(dwsmmio->rstc)) { ret = PTR_ERR(dwsmmio->rstc); - goto out_clk; + goto out_reset; } reset_control_deassert(dwsmmio->rstc); @@ -397,9 +391,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) out: pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(dwsmmio->pclk); -out_clk: - clk_disable_unprepare(dwsmmio->clk); +out_reset: reset_control_assert(dwsmmio->rstc); return ret; @@ -411,8 +403,6 @@ static void dw_spi_mmio_remove(struct platform_device *pdev) dw_spi_remove_host(&dwsmmio->dws); pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(dwsmmio->pclk); - clk_disable_unprepare(dwsmmio->clk); reset_control_assert(dwsmmio->rstc); }