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 3BFFBC3DA66 for ; Wed, 23 Aug 2023 17:15:42 +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: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=DP9NQXS1buh8gyutO5X2fL5szqImW0J6oUFfmQrjstg=; b=Uvv0P226qH9rWE 4QGVzXfsp5inklgQ9HLEwxAM5ZrlaOqv0VHzePGiETBbaKb7hbeyZ1LZ0w5DeQJXyfd/vhsKSpPBx FXvevw75DbEYaPbyT3dqv5L0wA3bVjemMejTjdTTV5TXRP1TD4e7VD1+wVJ1A01Zt4BcuHgoAECpo 7aorZptHKOK81JwlJ9kHZ6LuKpIRLoRUtTw1VQfoZUalg9sIDbjN8mqWxouW9Xbqtvz2XS8DL6onB 8PqvasXSyLbAQZ1+DhFuBykUbkODfXeuRMz2KaOhoNIjlaEk+P/eJEOSFHmh2+PgKDaGmaxWPwd/b ibAmIkSokj8A1vF5wi8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYrRr-001CDM-1K; Wed, 23 Aug 2023 17:15:15 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYrRn-001CCD-2d; Wed, 23 Aug 2023 17:15:13 +0000 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RWCR621vMz67Ldy; Thu, 24 Aug 2023 01:10:58 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 23 Aug 2023 18:15:07 +0100 Date: Wed, 23 Aug 2023 18:15:06 +0100 From: Jonathan Cameron To: Serge Semin CC: Li Zetao , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH -next v2 12/25] spi: dw-mmio: Use helper function devm_clk_get_*() Message-ID: <20230823181506.00007731@Huawei.com> In-Reply-To: References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> <20230823133938.1359106-13-lizetao1@huawei.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 X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_101512_140532_3DB4D656 X-CRM114-Status: GOOD ( 23.58 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 23 Aug 2023 17:20:12 +0300 Serge Semin wrote: > On Wed, Aug 23, 2023 at 09:39:25PM +0800, Li Zetao wrote: > > 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 > > --- > > v1 -> v2: Return directly instead of calling reset_control_deassert() > > before the reset control handler has been requested. And use the > > "out_reset" label instead of "out" before calling pm_runtime_enable(). > > LGTM. Thanks! > Acked-by: Serge Semin Agreed - looks much better now. Reviewed-by: Jonathan Cameron > > -Serge(y) > > > > > drivers/spi/spi-dw-mmio.c | 31 +++++++++---------------------- > > 1 file changed, 9 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c > > index 805264c9c65c..46801189a651 100644 > > --- a/drivers/spi/spi-dw-mmio.c > > +++ b/drivers/spi/spi-dw-mmio.c > > @@ -340,29 +340,20 @@ 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"); > > - if (IS_ERR(dwsmmio->pclk)) { > > - ret = PTR_ERR(dwsmmio->pclk); > > - goto out_clk; > > - } > > - ret = clk_prepare_enable(dwsmmio->pclk); > > - if (ret) > > - goto out_clk; > > + dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); > > + if (IS_ERR(dwsmmio->pclk)) > > + return PTR_ERR(dwsmmio->pclk); > > > > /* 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; > > - } > > + if (IS_ERR(dwsmmio->rstc)) > > + return PTR_ERR(dwsmmio->rstc); > > + > > reset_control_deassert(dwsmmio->rstc); > > > > dws->bus_num = pdev->id; > > @@ -383,7 +374,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) > > if (init_func) { > > ret = init_func(pdev, dwsmmio); > > if (ret) > > - goto out; > > + goto out_reset; > > } > > > > pm_runtime_enable(&pdev->dev); > > @@ -397,9 +388,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 +400,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); > > } > > > > -- > > 2.34.1 > > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel