From patchwork Tue Aug 22 13:12:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360706 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 408D1EE49AA for ; Tue, 22 Aug 2023 13:14:00 +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=i/rEjTvTyBFqNwYPtB5XF5HvhPv2KkHAg1zaw1utT6s=; b=wfdQGspYdffZu1 iqjLDicZUvZanbtoV6d0CwNrIVoxvx04aHBL/R8j4TH3qhP2TnYYgRBE79PHJTb0TPjUh/59Qh+vU 2XZIm4x/ZmwaRfVGHn4ZCNCWFNT+WVTLBV5zvKjQJdR5TcYncFDebXARkAwNyY4qYgG5bbEScATTN u8VCJY8WuPYrdJou5TxSWRo7fk6rhwsDLpOI64V+BkFQ+xr2/xSt8PgRpRgyLQxR9OCc0sEibqL/T M4ExJu/Q43m65r3UXAsL5Yh7Hhfw1vyQrxSgP6ufxsQ9H5QTOQWWHnP4vCYLYEGaQ1GnEIgMUwWSu hpKVjDSWzK7UpJwG+6uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCJ-00Fxvm-0k; Tue, 22 Aug 2023 13:13:27 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRBt-00FxVS-38; Tue, 22 Aug 2023 13:13:04 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RVV7G1xmtzLpF3; Tue, 22 Aug 2023 21:09:46 +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:12:49 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 01/25] spi: ar934x: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:13 +0800 Message-ID: <20230822131237.1022815-2-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_061302_472726_8AD8BCA6 X-CRM114-Status: GOOD ( 11.88 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-ar934x.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-ar934x.c b/drivers/spi/spi-ar934x.c index 58b98cea31d9..5ba988720851 100644 --- a/drivers/spi/spi-ar934x.c +++ b/drivers/spi/spi-ar934x.c @@ -168,27 +168,21 @@ static int ar934x_spi_probe(struct platform_device *pdev) struct ar934x_spi *sp; void __iomem *base; struct clk *clk; - int ret; base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); - clk = devm_clk_get(&pdev->dev, NULL); + clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(clk)) { dev_err(&pdev->dev, "failed to get clock\n"); return PTR_ERR(clk); } - ret = clk_prepare_enable(clk); - if (ret) - return ret; - ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*sp)); if (!ctlr) { dev_info(&pdev->dev, "failed to allocate spi controller\n"); - ret = -ENOMEM; - goto err_clk_disable; + return -ENOMEM; } /* disable flash mapping and expose spi controller registers */ @@ -212,25 +206,15 @@ static int ar934x_spi_probe(struct platform_device *pdev) sp->clk_freq = clk_get_rate(clk); sp->ctlr = ctlr; - ret = spi_register_controller(ctlr); - if (!ret) - return 0; - -err_clk_disable: - clk_disable_unprepare(clk); - return ret; + return spi_register_controller(ctlr); } static void ar934x_spi_remove(struct platform_device *pdev) { struct spi_controller *ctlr; - struct ar934x_spi *sp; ctlr = dev_get_drvdata(&pdev->dev); - sp = spi_controller_get_devdata(ctlr); - spi_unregister_controller(ctlr); - clk_disable_unprepare(sp->clk); } static struct platform_driver ar934x_spi_driver = { From patchwork Tue Aug 22 13:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360701 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 CDD4EEE49AE for ; Tue, 22 Aug 2023 13:13:35 +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=UH9lifyjrnXaL5xnxPT6j1DDoXOTbch5aIwFqU7IGb4=; b=zpYQyKHZt0XGPn IddnXawyhJ0soDsOdfa4+zgubLnPPhAUTPaPEVDBs6eZnWUmS/1RyLE5z3Mv/xcdx/ynxlAT6vZgt msmp9934ed3KYWHd+UOisJwoShyNqEHzBRXKL4abm6W/jyTHIo+CDefikzulvFVsp8cRCKADBceSf woGwS35c73MyekIRZQnKaeJju4EwgkiW4SbfNvP/kxLPXn+rTvDw8bm4tBgqGoOIORGiJARsqzuey weJHWE/N1erSdIY77GHFAk6g33r9Drkm5RAA6qHTJ9/JCuAQjctpDTMd7ewiRm5PTAqDFYaJDSpqc MxSqM9isLViD4IPqzycQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRBv-00FxY8-1e; Tue, 22 Aug 2023 13:13:03 +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 1qYRBs-00FxVX-0I; Tue, 22 Aug 2023 13:13:02 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV6j1lnzzNnMw; Tue, 22 Aug 2023 21:09:17 +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:12:50 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 02/25] spi: armada-3700: Use helper function devm_clk_get_prepared() Date: Tue, 22 Aug 2023 21:12:14 +0800 Message-ID: <20230822131237.1022815-3-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_061300_693220_10BC2325 X-CRM114-Status: GOOD ( 10.34 ) 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 Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), devm_clk_get() and clk_prepare() can now be replaced by devm_clk_get_prepared() when driver prepares the clocks for the whole lifetime of the device. Moreover, it is no longer necessary to unprepare the clocks explicitly. Signed-off-by: Li Zetao --- drivers/spi/spi-armada-3700.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index 0103ac0158c0..70113b9dab35 100644 --- a/drivers/spi/spi-armada-3700.c +++ b/drivers/spi/spi-armada-3700.c @@ -865,18 +865,12 @@ static int a3700_spi_probe(struct platform_device *pdev) init_completion(&spi->done); - spi->clk = devm_clk_get(dev, NULL); + spi->clk = devm_clk_get_prepared(dev, NULL); if (IS_ERR(spi->clk)) { dev_err(dev, "could not find clk: %ld\n", PTR_ERR(spi->clk)); goto error; } - ret = clk_prepare(spi->clk); - if (ret) { - dev_err(dev, "could not prepare clk: %d\n", ret); - goto error; - } - host->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ, clk_get_rate(spi->clk)); host->min_speed_hz = DIV_ROUND_UP(clk_get_rate(spi->clk), @@ -888,19 +882,17 @@ static int a3700_spi_probe(struct platform_device *pdev) dev_name(dev), host); if (ret) { dev_err(dev, "could not request IRQ: %d\n", ret); - goto error_clk; + goto error; } ret = devm_spi_register_controller(dev, host); if (ret) { dev_err(dev, "Failed to register host\n"); - goto error_clk; + goto error; } return 0; -error_clk: - clk_unprepare(spi->clk); error: spi_controller_put(host); out: @@ -909,10 +901,6 @@ static int a3700_spi_probe(struct platform_device *pdev) static void a3700_spi_remove(struct platform_device *pdev) { - struct spi_controller *host = platform_get_drvdata(pdev); - struct a3700_spi *spi = spi_controller_get_devdata(host); - - clk_unprepare(spi->clk); } static struct platform_driver a3700_spi_driver = { From patchwork Tue Aug 22 13:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360707 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 D6408EE49A3 for ; Tue, 22 Aug 2023 13:14:06 +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=JxZF0l+Ku7K6vIog+DiMQoQ1r4zh88tX1ilt2C5ytOQ=; b=2mjXHB0e0ke64t GuTC62AjbFf/OTa+RTRHcpS25tsgoyS8teVbHX9elwrHE6ffHXNOXt8ua7236JOhj8KjgBlD3mIMi 7RS/X/pvc92EpPKXVduMBDHRGJtYb5B9mhu+LqC8zWWYBEgcSILi40yOodR86tQTdh45FtKWEEXxb mzjicHBR7W6RJPsBsMCzT4H5AqwE7JliUf2L+vs+WZxKdOoUR9tpquoA3BpWDqMCaG2sNL8LXSNh0 /QeVAzpi/mdrx4d7DnLw4qWAONUo/Yn3mXxCfUSCQhbPG1vcHlD3hjaBjW3oRjLPSwVhD4jW2qgAr t5C6N5KQtkN6FGCqNTag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCH-00FxuC-2Z; Tue, 22 Aug 2023 13:13:25 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRBt-00FxVV-1t; Tue, 22 Aug 2023 13:13:03 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RVV9821pFz1L9G9; Tue, 22 Aug 2023 21:11:24 +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:12:51 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 03/25] spi: aspeed: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:15 +0800 Message-ID: <20230822131237.1022815-4-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_061302_106648_760B7913 X-CRM114-Status: GOOD ( 10.74 ) 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 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. Signed-off-by: Li Zetao Reviewed-by: Chin-Ting Kuo Reviewed-by: Cédric Le Goater --- drivers/spi/spi-aspeed-smc.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index 21b0fa646c7d..bbd417c55e7f 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -748,7 +748,7 @@ static int aspeed_spi_probe(struct platform_device *pdev) aspi->ahb_window_size = resource_size(res); aspi->ahb_base_phy = res->start; - aspi->clk = devm_clk_get(&pdev->dev, NULL); + aspi->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(aspi->clk)) { dev_err(dev, "missing clock\n"); return PTR_ERR(aspi->clk); @@ -760,12 +760,6 @@ static int aspeed_spi_probe(struct platform_device *pdev) return -EINVAL; } - ret = clk_prepare_enable(aspi->clk); - if (ret) { - dev_err(dev, "can not enable the clock\n"); - return ret; - } - /* IRQ is for DMA, which the driver doesn't support yet */ ctlr->mode_bits = SPI_RX_DUAL | SPI_TX_DUAL | data->mode_bits; @@ -777,14 +771,9 @@ static int aspeed_spi_probe(struct platform_device *pdev) ctlr->dev.of_node = dev->of_node; ret = devm_spi_register_controller(dev, ctlr); - if (ret) { + if (ret) dev_err(&pdev->dev, "spi_register_controller failed\n"); - goto disable_clk; - } - return 0; -disable_clk: - clk_disable_unprepare(aspi->clk); return ret; } @@ -793,7 +782,6 @@ static void aspeed_spi_remove(struct platform_device *pdev) struct aspeed_spi *aspi = platform_get_drvdata(pdev); aspeed_spi_enable(aspi, false); - clk_disable_unprepare(aspi->clk); } /* From patchwork Tue Aug 22 13:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360702 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 600FCEE49AE for ; Tue, 22 Aug 2023 13:13:44 +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=6+6p3o85LTzqIc5IAxGgWhjMrR6si2xFOn5j8riD0qc=; b=eu4Y6aFoIeW6ab iZReMNdBM8XK1e22zhFdo/9riXZlc0YyGvxhpAA7s/QrlpQTIfk8cM+J4BPk6XseKi1KBhtQZTEob IjDV+Vra1nJeG4YPHbefrhkx9LYxxbGsLU9FP1O2WgKliCVkSnWrIp9tyW0Z0Gu1O79IGb3SznKcH ajqhrzKtf3MCDTLXXxyXeF/8VSz5RzfM6rze/7Y3E00/HtXr8wJyc4qe2FWuyqc67kMTzbsOhdpsS EcJBNiV8pcgvo+wSGrZ92uWN2wnV5ryqnLCbfZ0khAKkNikhIf9frog9X/nvzrgAje6zGPj2kyZMU FE5StMQKe8jvi3MNFVmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRC5-00FxhA-0B; Tue, 22 Aug 2023 13:13:13 +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 1qYRBs-00FxVW-0c; Tue, 22 Aug 2023 13:13:02 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV984PwWzrSLc; Tue, 22 Aug 2023 21:11:24 +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:12:52 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 04/25] spi: ath79: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:16 +0800 Message-ID: <20230822131237.1022815-5-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_061300_516997_EF657940 X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-ath79.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 1b6d977d111c..c9f1d1e1dcf7 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -200,20 +200,16 @@ static int ath79_spi_probe(struct platform_device *pdev) goto err_put_host; } - sp->clk = devm_clk_get(&pdev->dev, "ahb"); + sp->clk = devm_clk_get_enabled(&pdev->dev, "ahb"); if (IS_ERR(sp->clk)) { ret = PTR_ERR(sp->clk); goto err_put_host; } - ret = clk_prepare_enable(sp->clk); - if (ret) - goto err_put_host; - rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ); if (!rate) { ret = -EINVAL; - goto err_clk_disable; + goto err_put_host; } sp->rrw_delay = ATH79_SPI_RRW_DELAY_FACTOR / rate; @@ -229,8 +225,6 @@ static int ath79_spi_probe(struct platform_device *pdev) err_disable: ath79_spi_disable(sp); -err_clk_disable: - clk_disable_unprepare(sp->clk); err_put_host: spi_controller_put(host); @@ -243,7 +237,6 @@ static void ath79_spi_remove(struct platform_device *pdev) spi_bitbang_stop(&sp->bitbang); ath79_spi_disable(sp); - clk_disable_unprepare(sp->clk); spi_controller_put(sp->bitbang.master); } From patchwork Tue Aug 22 13:12:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360712 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 7F161EE4993 for ; Tue, 22 Aug 2023 13:14:28 +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=qbkN/jpZO4q0FE/lfozNtYgnkAxX8a0BOTolQZv1PPg=; b=wLMAd0Y05q2rLO b2B2K4hL/PtOlwFDXRnIut+3w3GA+lN+Oj6Bc3yXZKNJpbxsvMJ7XlBZUvULUQkEl5qTefDWy9SDW Qqnht98RRrz/b/gkVdgH4FyUgP5brNXk6mUBZGKBihlo0oGwwwxo9nJ3xpsoRg4HhqBM7tTpc+DZR dZ71jKwaMsDioiY71scD8qflpvoKHyEDPxQl8qpP/z1qQQnqLb8VOZn03nzjvXvIrkKg9ILHVvbsM DAUmaBrCK+wH8utu8UKzO2Bml4vkT3CyfV+FxjI/vZZvAEAnNZu4LdsFwMcIBn1+mLDa2sdrlu3EW vfxOfezEn/v+QOO3RMLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCi-00FyRW-2s; Tue, 22 Aug 2023 13:13:52 +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 1qYRBv-00FxVa-0A; Tue, 22 Aug 2023 13:13:06 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8H6wtKzTm1P; Tue, 22 Aug 2023 21:10:39 +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:12:53 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 05/25] spi: spi-axi-spi-engine: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:17 +0800 Message-ID: <20230822131237.1022815-6-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_061303_595507_5580D929 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-axi-spi-engine.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c index 0258c9a72fdc..b96e55f59d1a 100644 --- a/drivers/spi/spi-axi-spi-engine.c +++ b/drivers/spi/spi-axi-spi-engine.c @@ -485,30 +485,22 @@ static int spi_engine_probe(struct platform_device *pdev) spin_lock_init(&spi_engine->lock); - spi_engine->clk = devm_clk_get(&pdev->dev, "s_axi_aclk"); + spi_engine->clk = devm_clk_get_enabled(&pdev->dev, "s_axi_aclk"); if (IS_ERR(spi_engine->clk)) { ret = PTR_ERR(spi_engine->clk); goto err_put_host; } - spi_engine->ref_clk = devm_clk_get(&pdev->dev, "spi_clk"); + spi_engine->ref_clk = devm_clk_get_enabled(&pdev->dev, "spi_clk"); if (IS_ERR(spi_engine->ref_clk)) { ret = PTR_ERR(spi_engine->ref_clk); goto err_put_host; } - ret = clk_prepare_enable(spi_engine->clk); - if (ret) - goto err_put_host; - - ret = clk_prepare_enable(spi_engine->ref_clk); - if (ret) - goto err_clk_disable; - spi_engine->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(spi_engine->base)) { ret = PTR_ERR(spi_engine->base); - goto err_ref_clk_disable; + goto err_put_host; } version = readl(spi_engine->base + SPI_ENGINE_REG_VERSION); @@ -518,7 +510,7 @@ static int spi_engine_probe(struct platform_device *pdev) SPI_ENGINE_VERSION_MINOR(version), SPI_ENGINE_VERSION_PATCH(version)); ret = -ENODEV; - goto err_ref_clk_disable; + goto err_put_host; } writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_RESET); @@ -527,7 +519,7 @@ static int spi_engine_probe(struct platform_device *pdev) ret = request_irq(irq, spi_engine_irq, 0, pdev->name, host); if (ret) - goto err_ref_clk_disable; + goto err_put_host; host->dev.of_node = pdev->dev.of_node; host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_3WIRE; @@ -545,10 +537,6 @@ static int spi_engine_probe(struct platform_device *pdev) return 0; err_free_irq: free_irq(irq, host); -err_ref_clk_disable: - clk_disable_unprepare(spi_engine->ref_clk); -err_clk_disable: - clk_disable_unprepare(spi_engine->clk); err_put_host: spi_controller_put(host); return ret; @@ -569,9 +557,6 @@ static void spi_engine_remove(struct platform_device *pdev) writel_relaxed(0xff, spi_engine->base + SPI_ENGINE_REG_INT_PENDING); writel_relaxed(0x00, spi_engine->base + SPI_ENGINE_REG_INT_ENABLE); writel_relaxed(0x01, spi_engine->base + SPI_ENGINE_REG_RESET); - - clk_disable_unprepare(spi_engine->ref_clk); - clk_disable_unprepare(spi_engine->clk); } static const struct of_device_id spi_engine_match_table[] = { From patchwork Tue Aug 22 13:12:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360703 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 7FD31EE49A4 for ; Tue, 22 Aug 2023 13:13:55 +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=sjUh6y2gc3fb4mCN7nrG5HcNRCpfXzoa9XzIAIgAt5o=; b=XmPHlwfhAifjpv DySvDT3nSCjVKQmw51ECHClre7biqjbJk9Jj7asV0NDGd12tsjdZHaPcubIr3e8HsnGydNa62CWVv 7odWRk+IQY+phwclpl8IYXVdr97cMoIqfT+d2RgMy1SCD/oFGq8np9hhyozZGOOEXp/Xueq0IYApe ihK7kLEN+tOT1fmrXY73pFY5ch3NJg+2eNjV4jM1z6WGBdVe04QYfk8gF3QUhzYwxYfZenBj1bqJk ntJDbmw2iKDftKu+ZRCwPPEQOi5CQ1usyffqcAMg/R60qzT/8NHGmmLzBwLQ4BMJgOYsn+XhjVgZ9 7L41nCDLjHhKIGLVWX9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCI-00Fxv1-1V; Tue, 22 Aug 2023 13:13:26 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRBt-00FxVb-1s; Tue, 22 Aug 2023 13:13:04 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RVV9C40tRz1L9MW; Tue, 22 Aug 2023 21:11:27 +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:12:54 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 06/25] spi: bcm2835: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:18 +0800 Message-ID: <20230822131237.1022815-7-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_061302_108215_B32A78DB X-CRM114-Status: GOOD ( 10.79 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-bcm2835.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e7bb2714678a..a457ad2f7db1 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -1352,7 +1352,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) if (IS_ERR(bs->regs)) return PTR_ERR(bs->regs); - bs->clk = devm_clk_get(&pdev->dev, NULL); + bs->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(bs->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(bs->clk), "could not get clk\n"); @@ -1363,14 +1363,11 @@ static int bcm2835_spi_probe(struct platform_device *pdev) if (bs->irq < 0) return bs->irq; - err = clk_prepare_enable(bs->clk); - if (err) - return err; bs->clk_hz = clk_get_rate(bs->clk); err = bcm2835_dma_init(ctlr, &pdev->dev, bs); if (err) - goto out_clk_disable; + return err; /* initialise the hardware with the default polarities */ bcm2835_wr(bs, BCM2835_SPI_CS, @@ -1396,8 +1393,6 @@ static int bcm2835_spi_probe(struct platform_device *pdev) out_dma_release: bcm2835_dma_release(ctlr, bs); -out_clk_disable: - clk_disable_unprepare(bs->clk); return err; } @@ -1415,8 +1410,6 @@ static void bcm2835_spi_remove(struct platform_device *pdev) /* Clear FIFOs, and disable the HW block */ bcm2835_wr(bs, BCM2835_SPI_CS, BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX); - - clk_disable_unprepare(bs->clk); } static const struct of_device_id bcm2835_spi_match[] = { From patchwork Tue Aug 22 13:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360711 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 A1AFEEE49A3 for ; Tue, 22 Aug 2023 13:14:24 +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=iU3v3ZyGlD5ShAL8zt+Er1iFLDU5YkE5DFrOem/CL5k=; b=mLxZTpHWc59i6K 33jb2qFw6O3QfiWygYUnyW24uBLFbQGEZDW7OKKbLzAfekgZB2SbksunMuF86DRWhMLWXvez6IhMP 2gTDbPy8JsBWxx5hWtXH4muc94eGevJG9S3cayuJXYIMZlg0QeqdQawtAx+3ZBRXId2ZrvB058DNL Z04xlI1dY9rV0bfILVe3rs5JTKtrFqdvJT9ziiBOnC6OGcvsoa0nu2FTk8ANbdiSocVKdUz0RRMGY H1QUZjB9EIGuEnRB4SR7VyKTwP9rrdwCb3xzqakI6JCwm9iMnakztPsvr4/L7tp+k9q/sgJFuYSwu qdNfqrX3wGq7Sj8Rc1Aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCg-00FyOE-1Z; Tue, 22 Aug 2023 13:13:50 +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 1qYRBu-00FxVc-0n; 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 4RVV6p4QMczNnL2; Tue, 22 Aug 2023 21:09:22 +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:12:55 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 07/25] spi: bcm2835aux: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:19 +0800 Message-ID: <20230822131237.1022815-8-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_061302_799045_B1DFCB4D X-CRM114-Status: GOOD ( 11.92 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-bcm2835aux.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c index 6d2a5d9f2498..06fe155a70c9 100644 --- a/drivers/spi/spi-bcm2835aux.c +++ b/drivers/spi/spi-bcm2835aux.c @@ -512,7 +512,7 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) if (IS_ERR(bs->regs)) return PTR_ERR(bs->regs); - bs->clk = devm_clk_get(&pdev->dev, NULL); + bs->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(bs->clk)) { err = PTR_ERR(bs->clk); dev_err(&pdev->dev, "could not get clk: %d\n", err); @@ -523,19 +523,11 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) if (bs->irq < 0) return bs->irq; - /* this also enables the HW block */ - err = clk_prepare_enable(bs->clk); - if (err) { - dev_err(&pdev->dev, "could not prepare clock: %d\n", err); - return err; - } - /* just checking if the clock returns a sane value */ clk_hz = clk_get_rate(bs->clk); if (!clk_hz) { dev_err(&pdev->dev, "clock returns 0 Hz\n"); - err = -ENODEV; - goto out_clk_disable; + return -ENODEV; } /* reset SPI-HW block */ @@ -547,22 +539,18 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) dev_name(&pdev->dev), host); if (err) { dev_err(&pdev->dev, "could not request IRQ: %d\n", err); - goto out_clk_disable; + return err; } err = spi_register_controller(host); if (err) { dev_err(&pdev->dev, "could not register SPI host: %d\n", err); - goto out_clk_disable; + return err; } bcm2835aux_debugfs_create(bs, dev_name(&pdev->dev)); return 0; - -out_clk_disable: - clk_disable_unprepare(bs->clk); - return err; } static void bcm2835aux_spi_remove(struct platform_device *pdev) @@ -575,9 +563,6 @@ static void bcm2835aux_spi_remove(struct platform_device *pdev) spi_unregister_controller(host); bcm2835aux_spi_reset_hw(bs); - - /* disable the HW block by releasing the clock */ - clk_disable_unprepare(bs->clk); } static const struct of_device_id bcm2835aux_spi_match[] = { From patchwork Tue Aug 22 13:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360705 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 D4AF5EE4993 for ; Tue, 22 Aug 2023 13:13:59 +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=5gvugA8+LIvU14A4nVS8jvz5K6eWLLN87VQyHFQ156E=; b=oE35SJjPxxuthr kTmYBbjKwm1w+UoKCPLRHER3XaOTKph5wUIzl9AoxX2GrvZj2IYN7bQHaTNYeGTG/fD/S50XvFFXK 9QPSBKg4U0WGlWmRjGg/csvu+cKsyqircoo6sOH732butCeiUg+6euBw/5m/ZkTDFKWhiWO8LuS6F pasG1hAkawlBdhIY2w26kvGBnkhMMV6k+NRifE2CxHT9rQ4AsynNARgn9zv/E7Fy+TlSPs/uBkTmG o7ivd1xOU9XI5IPvcuqOTUvTEbaK4l7sAj2d5SOWY/wMX37og23qJytj2qrc7wuliWC5rXZ1+8dNM JIIxDFfhmHGESb3DAE7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCG-00FxsI-0W; Tue, 22 Aug 2023 13:13:24 +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 1qYRBs-00FxVd-1P; Tue, 22 Aug 2023 13:13:03 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV9D6Z1TzrSP8; Tue, 22 Aug 2023 21:11:28 +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:12:56 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 08/25] spi: spi-cadence: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:20 +0800 Message-ID: <20230822131237.1022815-9-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_061300_968130_8540C9BB X-CRM114-Status: UNSURE ( 9.26 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-cadence.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 3c9813ad064b..174476bbdf54 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -576,31 +576,19 @@ static int cdns_spi_probe(struct platform_device *pdev) goto remove_ctlr; } - xspi->pclk = devm_clk_get(&pdev->dev, "pclk"); + xspi->pclk = devm_clk_get_enabled(&pdev->dev, "pclk"); if (IS_ERR(xspi->pclk)) { dev_err(&pdev->dev, "pclk clock not found.\n"); ret = PTR_ERR(xspi->pclk); goto remove_ctlr; } - ret = clk_prepare_enable(xspi->pclk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable APB clock.\n"); - goto remove_ctlr; - } - if (!spi_controller_is_target(ctlr)) { - xspi->ref_clk = devm_clk_get(&pdev->dev, "ref_clk"); + xspi->ref_clk = devm_clk_get_enabled(&pdev->dev, "ref_clk"); if (IS_ERR(xspi->ref_clk)) { dev_err(&pdev->dev, "ref_clk clock not found.\n"); ret = PTR_ERR(xspi->ref_clk); - goto clk_dis_apb; - } - - ret = clk_prepare_enable(xspi->ref_clk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable device clock.\n"); - goto clk_dis_apb; + goto remove_ctlr; } pm_runtime_use_autosuspend(&pdev->dev); @@ -674,10 +662,7 @@ static int cdns_spi_probe(struct platform_device *pdev) if (!spi_controller_is_target(ctlr)) { pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(xspi->ref_clk); } -clk_dis_apb: - clk_disable_unprepare(xspi->pclk); remove_ctlr: spi_controller_put(ctlr); return ret; @@ -698,8 +683,6 @@ static void cdns_spi_remove(struct platform_device *pdev) cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE); - clk_disable_unprepare(xspi->ref_clk); - clk_disable_unprepare(xspi->pclk); pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); From patchwork Tue Aug 22 13:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360704 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 96CFAEE49A4 for ; Tue, 22 Aug 2023 13:13:58 +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=ubUPeTp+dvFBipZjO5MKQ3xR6oxvw6rnvmVqcqqoP2M=; b=SUS95U/8BylU3e p87jIcZnc+wlNn+DS4ph10c0x0Y2fqMr5skQDH73bjOX2qBcikx8mY2G68sZWW2yj9FgApSadX35h ESnAiBDm5g9e4teSk9zhCmOY4Vg7ZsDqf64B2IOZH3BI0+IvDhB+KuEdJMsD60LmAldnhIb3LmAVv sn03YfIggNuJXsd1PkqDC58MCYU1LjL6q6A5IUr1tuUevDCE+jpWOlpsuQIIeePIrqncguViTi2Iz MlbTS1uZEUsAzRWds5K/s5+jk4W9oxyMIqsIi0QiKNZZm52de2PwqCEZa4YCZ8zYm0EreAFxgJZlN 15ZxxNCfk5+S9C6WpTFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCH-00FxtI-0L; Tue, 22 Aug 2023 13:13:25 +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 1qYRBt-00FxVf-1y; Tue, 22 Aug 2023 13:13:03 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV6g4mz2ztS5s; Tue, 22 Aug 2023 21:09:15 +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:12:57 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 09/25] spi: spi-cavium-thunderx: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:21 +0800 Message-ID: <20230822131237.1022815-10-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_061301_858805_4618316F X-CRM114-Status: UNSURE ( 8.95 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-cavium-thunderx.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/spi/spi-cavium-thunderx.c b/drivers/spi/spi-cavium-thunderx.c index f7c378a5f1bc..337aef12abcc 100644 --- a/drivers/spi/spi-cavium-thunderx.c +++ b/drivers/spi/spi-cavium-thunderx.c @@ -49,16 +49,12 @@ static int thunderx_spi_probe(struct pci_dev *pdev, p->regs.tx = 0x1010; p->regs.data = 0x1080; - p->clk = devm_clk_get(dev, NULL); + p->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(p->clk)) { ret = PTR_ERR(p->clk); goto error; } - ret = clk_prepare_enable(p->clk); - if (ret) - goto error; - p->sys_freq = clk_get_rate(p->clk); if (!p->sys_freq) p->sys_freq = SYS_FREQ_DEFAULT; @@ -82,7 +78,6 @@ static int thunderx_spi_probe(struct pci_dev *pdev, return 0; error: - clk_disable_unprepare(p->clk); pci_release_regions(pdev); spi_controller_put(host); return ret; @@ -97,7 +92,6 @@ static void thunderx_spi_remove(struct pci_dev *pdev) if (!p) return; - clk_disable_unprepare(p->clk); pci_release_regions(pdev); /* Put everything in a known state. */ writeq(0, p->register_base + OCTEON_SPI_CFG(p)); From patchwork Tue Aug 22 13:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360709 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 3BFBBEE49AE for ; Tue, 22 Aug 2023 13:14:21 +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=s0BsClnB2/6WHKW/qKqqKMtbLxp2HNWKFSfv6aeAoEU=; b=rdTlV/S4rb67EQ XwAmqh9xjOTc2wWnFzKcl2bF8cQJS8XF35SdEJxHlyg8Yw7LmNlJ4Y1DIaO65g+N5dNikrsj5CZkP dospsD5tKME+wiB/IwerDL1Dt9cp5Fpcyxdop+q7+SwBqKjj/rkhpHWLN9vIAe2jQP0qR2zGtkpvm CCGbq5SVH35+PWuoOwGBYd1pgdlv/OwA6Uukfa4gvLckKsa34lngrSQBgwe9FS9Wqtl+sS95wwnbR ar3xeBLlu/ZrDtI5AlgSOv04iDwkUXCVZtQrbCmL5UJPHbYfEYdT/oKN6z5vgaz3SQwa4JFO2YJIy Uv6xYWqqW3ttG+3fQlNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCe-00FyL0-06; Tue, 22 Aug 2023 13:13:48 +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 1qYRBu-00FxWF-2H; Tue, 22 Aug 2023 13:13:06 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV6s61w2zNnTg; Tue, 22 Aug 2023 21:09:25 +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:12:58 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 10/25] spi: davinci: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:22 +0800 Message-ID: <20230822131237.1022815-11-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_061303_790478_A3382E83 X-CRM114-Status: UNSURE ( 9.73 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-davinci.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index c457b550d3ad..5688be245c68 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -915,14 +915,11 @@ static int davinci_spi_probe(struct platform_device *pdev) dspi->bitbang.master = host; - dspi->clk = devm_clk_get(&pdev->dev, NULL); + dspi->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dspi->clk)) { ret = -ENODEV; goto free_host; } - ret = clk_prepare_enable(dspi->clk); - if (ret) - goto free_host; host->use_gpio_descriptors = true; host->dev.of_node = pdev->dev.of_node; @@ -947,7 +944,7 @@ static int davinci_spi_probe(struct platform_device *pdev) ret = davinci_spi_request_dma(dspi); if (ret == -EPROBE_DEFER) { - goto free_clk; + goto free_host; } else if (ret) { dev_info(&pdev->dev, "DMA is not supported (%d)\n", ret); dspi->dma_rx = NULL; @@ -991,8 +988,6 @@ static int davinci_spi_probe(struct platform_device *pdev) dma_release_channel(dspi->dma_rx); dma_release_channel(dspi->dma_tx); } -free_clk: - clk_disable_unprepare(dspi->clk); free_host: spi_controller_put(host); err: @@ -1018,8 +1013,6 @@ static void davinci_spi_remove(struct platform_device *pdev) spi_bitbang_stop(&dspi->bitbang); - clk_disable_unprepare(dspi->clk); - if (dspi->dma_rx) { dma_release_channel(dspi->dma_rx); dma_release_channel(dspi->dma_tx); From patchwork Tue Aug 22 13:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360725 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 9F9DFEE49AA for ; Tue, 22 Aug 2023 13:16:33 +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=Me8FtZpFEuQEs00s5/dkUeKCCVdFllw99yzHjDHUcVY=; b=AlkAz0W83ejHeI Fwca18gi3WWri2NkPZTjc4C3/Gb0l+XPFXvCAQjMS267OMQrccNRPYBSl5dzMum6rTrkDrCr7Q5ts sMz0IEGe0pXoLX8MdyAWN2gZlVHWhdhneNDeA0zs9RHKKv2WU53UQUAAz6MRTNa1ib96ovt3iUDoZ Z2p7vq/3HT3sbWnQisHT3NOvmhNiUEavZJ8QWc+IpudCmvxSNOXKXSXGBk37Wq91gVQxOqzeapDQ2 t3ZdTtLoVtYYNnP3z8KuRHwo/z5NvwO7I2Wfk5fcu26YuTr9AqvASwSCpRwycbhd9UfK+w1NJBaG4 QrOHhD+wUQsLS49xZ5PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREp-00G0rV-28; Tue, 22 Aug 2023 13:16:03 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCD-00Fxom-12; Tue, 22 Aug 2023 13:13:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=ATNWyflvOE9K73K3XYFGD2NMKqsZt+QmgiCjem3Lg7Y=; b=GmnwRFeYhAX0zYugajP+VG3qbe BMc5kBpoABNSpF9/o37y0PnIMRgOwwhfC3MB7Cu+KfiFByuoCZFF/9DINfUMMd5N92kGA66gMLU7e W8klSrNjlTjr8L7msTBS1eJg7z/FMZxMduvfqaqAgA49bTYJqyfHuQDlx+Kfx6s16uNaZYVo/QLW8 QfnSZHDF05fx+NZIsyQqz4nzopcqjbtBBOpliJQY1KDRCZyviJQACPhFEPr3lh874PmwMAJT3Jl2e wyQyYyaGoLTyHIE1fEudMVtfJPo0unq3xSyohTR7Nv/sS8v1V3LehINcV+7pAgQjnt5iAZNugB9ks ZWOXxh/w==; Received: from szxga08-in.huawei.com ([45.249.212.255]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRC8-002lCW-1F; Tue, 22 Aug 2023 13:13:19 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RVV9J6DNpz1L9Qn; Tue, 22 Aug 2023 21:11:32 +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:12:59 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 11/25] spi: dw-bt1: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:23 +0800 Message-ID: <20230822131237.1022815-12-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_141317_328521_509BFF7B X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao Acked-by: Serge Semin --- drivers/spi/spi-dw-bt1.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-dw-bt1.c b/drivers/spi/spi-dw-bt1.c index 5e1c01822967..5391bcac305c 100644 --- a/drivers/spi/spi-dw-bt1.c +++ b/drivers/spi/spi-dw-bt1.c @@ -269,43 +269,32 @@ static int dw_spi_bt1_probe(struct platform_device *pdev) dws->paddr = mem->start; - dwsbt1->clk = devm_clk_get(&pdev->dev, NULL); + dwsbt1->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dwsbt1->clk)) return PTR_ERR(dwsbt1->clk); - ret = clk_prepare_enable(dwsbt1->clk); - if (ret) - return ret; - dws->bus_num = pdev->id; dws->reg_io_width = 4; dws->max_freq = clk_get_rate(dwsbt1->clk); - if (!dws->max_freq) { - ret = -EINVAL; - goto err_disable_clk; - } + if (!dws->max_freq) + return -EINVAL; init_func = device_get_match_data(&pdev->dev); ret = init_func(pdev, dwsbt1); if (ret) - goto err_disable_clk; + return ret; pm_runtime_enable(&pdev->dev); ret = dw_spi_add_host(&pdev->dev, dws); if (ret) { pm_runtime_disable(&pdev->dev); - goto err_disable_clk; + return ret; } platform_set_drvdata(pdev, dwsbt1); return 0; - -err_disable_clk: - clk_disable_unprepare(dwsbt1->clk); - - return ret; } static void dw_spi_bt1_remove(struct platform_device *pdev) @@ -315,8 +304,6 @@ static void dw_spi_bt1_remove(struct platform_device *pdev) dw_spi_remove_host(&dwsbt1->dws); pm_runtime_disable(&pdev->dev); - - clk_disable_unprepare(dwsbt1->clk); } static const struct of_device_id dw_spi_bt1_of_match[] = { 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: 13360710 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 29A24EE4993 for ; Tue, 22 Aug 2023 13:14:21 +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=Ezi789YMLiVZE7hYSSJpmD2LYnEuDW+Cr2erSoTy15U=; b=tjPMHVZcqISNYX KESQM7x8Ullb8NV3Z8ek2QSSZl1p8+09qyBNQR6FPJ/VJKvI6kbQNXRadhZaJGvtBBJvr4dKw2wx4 6PrpZg3u1/l6+qey6091f7dv+idqtjoWHL3zfp9bP0piJmYVzZWT+RRvifIGTvRtMYnUXfLfsbgmd UnhZn67lSMTtSvUb4JiNfJD/xIj8+GbCiJ+iHvy/kKhD11BxavwZrcWkv28od7DMN57XAMSW851WR AwTNQpVE+39AzF9kQBGmydyYhTjPRRjBhuW2PxLiNHCn73yaa3xjEayE0n8lsFbQQsX6CiBKOLz7c 6uwGdRwAmJkrwjxVBcOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCf-00FyMQ-0r; Tue, 22 Aug 2023 13:13:49 +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-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 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); } From patchwork Tue Aug 22 13:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360713 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 8D356EE4993 for ; Tue, 22 Aug 2023 13:14:38 +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=azExZuHNMMogC41HapUFyguJeHiNRPG360Ox1axhMzs=; b=meQaVZU3Brce14 dUXXwoN/bVTK26F6CHJtYFja7ZdYQ0i7ePcuxslgfrTtx2CWUUllhz+2J8o1pW+IUXGKwstWEfJ12 FTgCCRSHYtpgXWymCX0wXlaIbPzuNU9YT2NNpFlBgo80VTaScWGXCEviHxXw2oqnk9bfL5cgJCEo/ K/PshJsDeQkN6G6ADz90XyMR5ScRYvgfv2DDwNdo2Cy7Bx9kQNoAgPWOWUg3l2KHqSZoo3C6gPvZ9 oAKri6TQhyaL+d7bnKLVVzgUjCQ0St+Jtrk9hewYZnhZ3YhaG+v5Pq6Z6xvqv5DQRBwfBSToyov3x RTQfJdkNdoYPIkjOlvpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRCx-00Fyhu-22; Tue, 22 Aug 2023 13:14:07 +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 1qYRBy-00FxZC-07; Tue, 22 Aug 2023 13:13:07 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV6l6x4PztS7V; Tue, 22 Aug 2023 21:09:19 +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:02 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 13/25] spi: spi-fsl-dspi: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:25 +0800 Message-ID: <20230822131237.1022815-14-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_061306_543966_A2412B9E X-CRM114-Status: GOOD ( 10.57 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-fsl-dspi.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 8318249f8a1f..c9eae046f66c 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -1372,19 +1372,16 @@ static int dspi_probe(struct platform_device *pdev) } } - dspi->clk = devm_clk_get(&pdev->dev, "dspi"); + dspi->clk = devm_clk_get_enabled(&pdev->dev, "dspi"); if (IS_ERR(dspi->clk)) { ret = PTR_ERR(dspi->clk); dev_err(&pdev->dev, "unable to get clock\n"); goto out_ctlr_put; } - ret = clk_prepare_enable(dspi->clk); - if (ret) - goto out_ctlr_put; ret = dspi_init(dspi); if (ret) - goto out_clk_put; + goto out_ctlr_put; dspi->irq = platform_get_irq(pdev, 0); if (dspi->irq <= 0) { @@ -1400,7 +1397,7 @@ static int dspi_probe(struct platform_device *pdev) IRQF_SHARED, pdev->name, dspi); if (ret < 0) { dev_err(&pdev->dev, "Unable to attach DSPI interrupt\n"); - goto out_clk_put; + goto out_ctlr_put; } poll_mode: @@ -1432,8 +1429,6 @@ static int dspi_probe(struct platform_device *pdev) out_free_irq: if (dspi->irq) free_irq(dspi->irq, dspi); -out_clk_put: - clk_disable_unprepare(dspi->clk); out_ctlr_put: spi_controller_put(ctlr); @@ -1458,7 +1453,6 @@ static void dspi_remove(struct platform_device *pdev) dspi_release_dma(dspi); if (dspi->irq) free_irq(dspi->irq, dspi); - clk_disable_unprepare(dspi->clk); } static void dspi_shutdown(struct platform_device *pdev) From patchwork Tue Aug 22 13:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360715 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 EB922EE49AC for ; Tue, 22 Aug 2023 13:15:32 +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=9MnA0etjfG68GN8uV4y8Bef9XAEpYztYazhwuVRaFBo=; b=Ybl7Q63kEXSEdP +GUFMTGlo0gaXezWNB2VLh9aHs8Iix4AE54+OiJm8U162OmQeXnycOmVo++mjSpKkTO9rObaBUim1 rCYxM4bsTFhdmFhMG8lzO6658m/G/+2GWe0XisMkvLpwWFUilBy1zwuWoh0PtqRi/mvCA6iPN7pD4 MJHRpZv9jDvkgTE6cfpzheaDdn1MtsRzcGaXvL4+OHBIUauqcVY968YAt2Fo/tvIkrM/GTTC6zB8b pcq5ez7PFRhkplJdJMhXyO1zHPRxxhSMMRjfukL3rGvetxDxudlIDkdH1Bv3JSz8Hm8WajO3ovWDB nmoMBPF5yP+bNa76gNRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRDm-00FzcE-1M; Tue, 22 Aug 2023 13:14:58 +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 1qYRC0-00Fxak-08; Tue, 22 Aug 2023 13:13:09 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8T4byTzTmMj; Tue, 22 Aug 2023 21:10:49 +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:03 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 14/25] spi: lantiq-ssc: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:26 +0800 Message-ID: <20230822131237.1022815-15-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_061308_352015_281D934B X-CRM114-Status: GOOD ( 10.28 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-lantiq-ssc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-lantiq-ssc.c b/drivers/spi/spi-lantiq-ssc.c index 938e9e577e4f..18a46569ba46 100644 --- a/drivers/spi/spi-lantiq-ssc.c +++ b/drivers/spi/spi-lantiq-ssc.c @@ -932,14 +932,11 @@ static int lantiq_ssc_probe(struct platform_device *pdev) if (err) goto err_host_put; - spi->spi_clk = devm_clk_get(dev, "gate"); + spi->spi_clk = devm_clk_get_enabled(dev, "gate"); if (IS_ERR(spi->spi_clk)) { err = PTR_ERR(spi->spi_clk); goto err_host_put; } - err = clk_prepare_enable(spi->spi_clk); - if (err) - goto err_host_put; /* * Use the old clk_get_fpi() function on Lantiq platform, till it @@ -952,7 +949,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev) #endif if (IS_ERR(spi->fpi_clk)) { err = PTR_ERR(spi->fpi_clk); - goto err_clk_disable; + goto err_host_put; } num_cs = 8; @@ -1010,8 +1007,6 @@ static int lantiq_ssc_probe(struct platform_device *pdev) destroy_workqueue(spi->wq); err_clk_put: clk_put(spi->fpi_clk); -err_clk_disable: - clk_disable_unprepare(spi->spi_clk); err_host_put: spi_controller_put(host); @@ -1029,7 +1024,6 @@ static void lantiq_ssc_remove(struct platform_device *pdev) hw_enter_config_mode(spi); destroy_workqueue(spi->wq); - clk_disable_unprepare(spi->spi_clk); clk_put(spi->fpi_clk); } From patchwork Tue Aug 22 13:12:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360714 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 10AA4EE49A3 for ; Tue, 22 Aug 2023 13:15:28 +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=qBLM9h8SxIJOWmSXmlKbwAMml+d15qLcLy+1HBd0DIw=; b=wFxbpZ4VeIJbdt iz3QC85xnsObxaMQCeuUXneAYFLxXGD9yFCqco0OAYTJRyCo7XctymydYdWyQAm0k2WqB+auoaDdZ MfbPZzEr4jH4IsmQ0QUZMpfDhAA+tJw06lXFSYOPuTFkx2C2rc7HC3MDit9ur+t5WqweVZkmykjMd YP+7qAIhhfHPqe46PPjFN7XJo3v1XfCM3YqHiMZFPX5tguutHc2xjJmYPEHRnxy2HCCemsfJ0x966 2Dvmcr9KpvIW9E8qtuWoD4xbMuf99ZHwgHrGl3DJmzPta+x0UC4I/GT14jfc/Wk0XRPmXr55jBbnn 3J6CGxEDQAQmkvabIBgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRDn-00Fzcy-0U; Tue, 22 Aug 2023 13:14:59 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRC0-00Fxar-0b; Tue, 22 Aug 2023 13:13:10 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RVV7Y2RhDzLpDk; Tue, 22 Aug 2023 21:10:01 +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:04 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 15/25] spi: meson-spicc: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:27 +0800 Message-ID: <20230822131237.1022815-16-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_061308_772699_44046106 X-CRM114-Status: UNSURE ( 9.60 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-meson-spicc.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c index 43d134f4b42b..1f2d26254e03 100644 --- a/drivers/spi/spi-meson-spicc.c +++ b/drivers/spi/spi-meson-spicc.c @@ -820,7 +820,7 @@ static int meson_spicc_probe(struct platform_device *pdev) goto out_master; } - spicc->core = devm_clk_get(&pdev->dev, "core"); + spicc->core = devm_clk_get_enabled(&pdev->dev, "core"); if (IS_ERR(spicc->core)) { dev_err(&pdev->dev, "core clock request failed\n"); ret = PTR_ERR(spicc->core); @@ -828,7 +828,7 @@ static int meson_spicc_probe(struct platform_device *pdev) } if (spicc->data->has_pclk) { - spicc->pclk = devm_clk_get(&pdev->dev, "pclk"); + spicc->pclk = devm_clk_get_enabled(&pdev->dev, "pclk"); if (IS_ERR(spicc->pclk)) { dev_err(&pdev->dev, "pclk clock request failed\n"); ret = PTR_ERR(spicc->pclk); @@ -836,22 +836,10 @@ static int meson_spicc_probe(struct platform_device *pdev) } } - ret = clk_prepare_enable(spicc->core); - if (ret) { - dev_err(&pdev->dev, "core clock enable failed\n"); - goto out_master; - } - - ret = clk_prepare_enable(spicc->pclk); - if (ret) { - dev_err(&pdev->dev, "pclk clock enable failed\n"); - goto out_core_clk; - } - spicc->pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(spicc->pinctrl)) { ret = PTR_ERR(spicc->pinctrl); - goto out_clk; + goto out_master; } device_reset_optional(&pdev->dev); @@ -878,31 +866,25 @@ static int meson_spicc_probe(struct platform_device *pdev) ret = meson_spicc_pow2_clk_init(spicc); if (ret) { dev_err(&pdev->dev, "pow2 clock registration failed\n"); - goto out_clk; + goto out_master; } if (spicc->data->has_enhance_clk_div) { ret = meson_spicc_enh_clk_init(spicc); if (ret) { dev_err(&pdev->dev, "clock registration failed\n"); - goto out_clk; + goto out_master; } } ret = devm_spi_register_master(&pdev->dev, master); if (ret) { dev_err(&pdev->dev, "spi master registration failed\n"); - goto out_clk; + goto out_master; } return 0; -out_clk: - clk_disable_unprepare(spicc->pclk); - -out_core_clk: - clk_disable_unprepare(spicc->core); - out_master: spi_master_put(master); @@ -916,9 +898,6 @@ static void meson_spicc_remove(struct platform_device *pdev) /* Disable SPI */ writel(0, spicc->base + SPICC_CONREG); - clk_disable_unprepare(spicc->core); - clk_disable_unprepare(spicc->pclk); - spi_master_put(spicc->master); } From patchwork Tue Aug 22 13:12:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360717 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 DA160EE4993 for ; Tue, 22 Aug 2023 13:15:34 +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=T9yjdwAJBXl58xigw27mRCrBtZaLHic8V4l53pWQ/ok=; b=ahRzyG+Y3bxcSV 96mrlaA5TVa/rulK/4wtVYaP87mqZRIUAkfbIXbuO04zOyk+ja2sfKXikMYUOXFF5KKLC0TAkIa12 14uEl0z04DgNXaQLwo7t8x+9Sq4hos14kaWfX7BD74vf4L2BPDiWFJIzIeL4n2tgUYyEDGIfK7S7X VbA7heMXjqW+LVNCVtXUs4a5xE0GGUA1iLrP6U5hcYJaUwoXCgn9MPyWSzP8dz1aVQa1Augxf1P9Y wAvuV//KTG6VvziiDX3Cg3fVQxtyVlWHeFg84upQFrP0jXt64Hqj7ar/Wcbcv7n9m98znLXswdr9P aY45FPTcOuEx9B23GvWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRDo-00Fzdp-00; Tue, 22 Aug 2023 13:15:00 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRC2-00Fxc0-2M; Tue, 22 Aug 2023 13:13:12 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RVV9Q1xf4z1L9Lx; Tue, 22 Aug 2023 21:11:38 +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:05 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 16/25] spi: spi-meson-spifc: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:28 +0800 Message-ID: <20230822131237.1022815-17-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_061311_260020_BD4BF812 X-CRM114-Status: GOOD ( 10.17 ) 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 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. Moreover, the lable "out_clk" no longer makes sense, rename it to "out_pm". Signed-off-by: Li Zetao --- drivers/spi/spi-meson-spifc.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c index 06626f406f68..d70a18885b49 100644 --- a/drivers/spi/spi-meson-spifc.c +++ b/drivers/spi/spi-meson-spifc.c @@ -312,19 +312,13 @@ static int meson_spifc_probe(struct platform_device *pdev) goto out_err; } - spifc->clk = devm_clk_get(spifc->dev, NULL); + spifc->clk = devm_clk_get_enabled(spifc->dev, NULL); if (IS_ERR(spifc->clk)) { dev_err(spifc->dev, "missing clock\n"); ret = PTR_ERR(spifc->clk); goto out_err; } - ret = clk_prepare_enable(spifc->clk); - if (ret) { - dev_err(spifc->dev, "can't prepare clock\n"); - goto out_err; - } - rate = clk_get_rate(spifc->clk); master->num_chipselect = 1; @@ -343,12 +337,11 @@ static int meson_spifc_probe(struct platform_device *pdev) ret = devm_spi_register_master(spifc->dev, master); if (ret) { dev_err(spifc->dev, "failed to register spi master\n"); - goto out_clk; + goto out_pm; } return 0; -out_clk: - clk_disable_unprepare(spifc->clk); +out_pm: pm_runtime_disable(spifc->dev); out_err: spi_master_put(master); @@ -357,11 +350,7 @@ static int meson_spifc_probe(struct platform_device *pdev) static void meson_spifc_remove(struct platform_device *pdev) { - struct spi_master *master = platform_get_drvdata(pdev); - struct meson_spifc *spifc = spi_master_get_devdata(master); - pm_runtime_get_sync(&pdev->dev); - clk_disable_unprepare(spifc->clk); pm_runtime_disable(&pdev->dev); } From patchwork Tue Aug 22 13:12:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360718 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 59AF2EE4993 for ; Tue, 22 Aug 2023 13:15:41 +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=Dwp5/ZKHWIiqm2BEHX6qJvRtlMhfKkKuHBtcfuanUr8=; b=2kbAArcNAt743u 1CMrhqYUgs0lD+Ofuz3WQFE++tk71jvdjvk3+JNAZlgiIygTfPoGD435/ikbajoAQeGH52Q5izOTN MDHsuN9ykKlqlSS+xs8pMPFm3KZpTIpTswtgc9CBMTUNKb/gOE2fEXykrQdGt+b5ZIa6+HGqOAEiN d11Ue+lWwMK/w0K9XpblgtQBRUU5NiipeyQdvYdX5O+q62uUcDwjoijGxHltwyK8XhQCgul9iQ39h 3MjtsFtidiI9f8Ke6cc8w/vD4MtQbfsLzn64OWT8CKAjPyUxJGHoA29zylTaPVVGt0H/VHPFu8onj VxTPoyqsyetXKxoK6rew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRDx-00Fzof-2M; Tue, 22 Aug 2023 13:15:09 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYRC3-00FxdR-0G; Tue, 22 Aug 2023 13:13:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RVV7b3XwRzLpDZ; Tue, 22 Aug 2023 21:10:03 +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:06 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 17/25] spi: microchip-core-qspi: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:29 +0800 Message-ID: <20230822131237.1022815-18-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_061311_635139_6A96BF9E X-CRM114-Status: GOOD ( 10.91 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-microchip-core-qspi.c | 29 +++++++-------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/spi/spi-microchip-core-qspi.c b/drivers/spi/spi-microchip-core-qspi.c index 4f76ddf97b10..396dfc0fa278 100644 --- a/drivers/spi/spi-microchip-core-qspi.c +++ b/drivers/spi/spi-microchip-core-qspi.c @@ -518,30 +518,23 @@ static int mchp_coreqspi_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(qspi->regs), "failed to map registers\n"); - qspi->clk = devm_clk_get(&pdev->dev, NULL); + qspi->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(qspi->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(qspi->clk), "could not get clock\n"); - ret = clk_prepare_enable(qspi->clk); - if (ret) - return dev_err_probe(&pdev->dev, ret, - "failed to enable clock\n"); - init_completion(&qspi->data_completion); mutex_init(&qspi->op_lock); qspi->irq = platform_get_irq(pdev, 0); - if (qspi->irq < 0) { - ret = qspi->irq; - goto out; - } + if (qspi->irq < 0) + return qspi->irq; ret = devm_request_irq(&pdev->dev, qspi->irq, mchp_coreqspi_isr, IRQF_SHARED, pdev->name, qspi); if (ret) { dev_err(&pdev->dev, "request_irq failed %d\n", ret); - goto out; + return ret; } ctlr->bits_per_word_mask = SPI_BPW_MASK(8); @@ -552,18 +545,11 @@ static int mchp_coreqspi_probe(struct platform_device *pdev) ctlr->dev.of_node = np; ret = devm_spi_register_controller(&pdev->dev, ctlr); - if (ret) { - dev_err_probe(&pdev->dev, ret, - "spi_register_controller failed\n"); - goto out; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, + "spi_register_controller failed\n"); return 0; - -out: - clk_disable_unprepare(qspi->clk); - - return ret; } static void mchp_coreqspi_remove(struct platform_device *pdev) @@ -574,7 +560,6 @@ static void mchp_coreqspi_remove(struct platform_device *pdev) mchp_coreqspi_disable_ints(qspi); control &= ~CONTROL_ENABLE; writel_relaxed(control, qspi->regs + REG_CONTROL); - clk_disable_unprepare(qspi->clk); } static const struct of_device_id mchp_coreqspi_of_match[] = { From patchwork Tue Aug 22 13:12:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360716 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 AF579EE49AF for ; Tue, 22 Aug 2023 13:15:33 +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=JjFXmBn3hdKYpvSdz3ZgwHsvU7TQGaoWhu+mGVX3rEI=; b=2CHxEer1zlCzNT RwXNC1g3j7zrgkxrTMxXBrkCoPfcMtpG4+Ep8fO0XsYfYyRstK1FPzzHU+JL+2iY4XYvM6ihWHc5k W2c3wZ2kM+jPwqFeixnkCQdlp7TwOufPew8QpgkHfPWLICLwf0VEd1j0cGMbdbFE1nnZOeTHN3JBc M5yElEIwgIPm1N3v7CZo3Qae/a3g5xQyR2xa+uDm8XpgODYAkSS3LzomhKVNqgK1G0w6hGwv8qF6/ rA67xtrxMGtcFVYaV5/hUQkHIQjRKEvFKtmevsWTBKt8DvuMxj4Y1baKeiRyU/YcRqmHIHBIO/WwH 5hqn4Kp9gLlRaHqIiNGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRDs-00Fzi2-0A; Tue, 22 Aug 2023 13:15:04 +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 1qYRC3-00FxeL-0q; Tue, 22 Aug 2023 13:13:12 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8Y6tVLzTlqq; Tue, 22 Aug 2023 21:10:53 +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:07 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 18/25] spi: microchip-core: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:30 +0800 Message-ID: <20230822131237.1022815-19-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_061311_572595_B68FC624 X-CRM114-Status: UNSURE ( 8.70 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-microchip-core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c index b451cd4860ec..becdcdc9e6d1 100644 --- a/drivers/spi/spi-microchip-core.c +++ b/drivers/spi/spi-microchip-core.c @@ -539,22 +539,16 @@ static int mchp_corespi_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, ret, "could not request irq\n"); - spi->clk = devm_clk_get(&pdev->dev, NULL); + spi->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(spi->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk), "could not get clk\n"); - ret = clk_prepare_enable(spi->clk); - if (ret) - return dev_err_probe(&pdev->dev, ret, - "failed to enable clock\n"); - mchp_corespi_init(master, spi); ret = devm_spi_register_master(&pdev->dev, master); if (ret) { mchp_corespi_disable(spi); - clk_disable_unprepare(spi->clk); return dev_err_probe(&pdev->dev, ret, "unable to register master for SPI controller\n"); } @@ -570,7 +564,6 @@ static void mchp_corespi_remove(struct platform_device *pdev) struct mchp_corespi *spi = spi_master_get_devdata(master); mchp_corespi_disable_ints(spi); - clk_disable_unprepare(spi->clk); mchp_corespi_disable(spi); } From patchwork Tue Aug 22 13:12:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360719 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 01D63EE49A4 for ; Tue, 22 Aug 2023 13:15:43 +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=lRqd/uLgEvOFbpD9BrhVTvVmRuuCm2UIwubIa9Pockc=; b=Hb5ZynsSYKp+kW rwktFsGVbQ+v3BkAmPejWbZnZjpVSaO74hU2MDEhuGkJDTUtuzBiz7TygdW1txTSxDUVHrDkDJZsg CcI1RMqayHmiGT4I4Vq29l8fnRK5EDbyfNd1PPL+RxJ58Efj91KRwldhNGXo4EKjt08+R9yLbp124 USIjydDk191bLQqTcdQ00YrqFmtm3iujfrq8w04mnB+WfBWu4F9rJlr4D2XnhF2ZNFMGUO7zByi1F DRwxBOk1OLa8LeENIyx2fU06a4PSRBzSpUie8CcbYrrv7z92KeFjOyY/3vUyGjoHeBo9FJWF2fTyV QeLrkwj1C5xV1kR3u2hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYRE0-00Fzr5-0J; Tue, 22 Aug 2023 13:15:12 +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 1qYRC4-00FxfF-12; Tue, 22 Aug 2023 13:13:14 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV9S5WmHzrSmC; Tue, 22 Aug 2023 21:11:40 +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:08 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 19/25] spi: mtk-snfi: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:31 +0800 Message-ID: <20230822131237.1022815-20-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_061312_929369_F5DDF5C8 X-CRM114-Status: GOOD ( 11.69 ) 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 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 two functions mtk_snand_enable_clk() and mtk_snand_disable_clk() no longer are used, drop them for clean code. Signed-off-by: Li Zetao --- drivers/spi/spi-mtk-snfi.c | 61 ++++++-------------------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c index 4433a8a9299f..8ad5a4764855 100644 --- a/drivers/spi/spi-mtk-snfi.c +++ b/drivers/spi/spi-mtk-snfi.c @@ -1332,42 +1332,6 @@ static const struct of_device_id mtk_snand_ids[] = { MODULE_DEVICE_TABLE(of, mtk_snand_ids); -static int mtk_snand_enable_clk(struct mtk_snand *ms) -{ - int ret; - - ret = clk_prepare_enable(ms->nfi_clk); - if (ret) { - dev_err(ms->dev, "unable to enable nfi clk\n"); - return ret; - } - ret = clk_prepare_enable(ms->pad_clk); - if (ret) { - dev_err(ms->dev, "unable to enable pad clk\n"); - goto err1; - } - ret = clk_prepare_enable(ms->nfi_hclk); - if (ret) { - dev_err(ms->dev, "unable to enable nfi hclk\n"); - goto err2; - } - - return 0; - -err2: - clk_disable_unprepare(ms->pad_clk); -err1: - clk_disable_unprepare(ms->nfi_clk); - return ret; -} - -static void mtk_snand_disable_clk(struct mtk_snand *ms) -{ - clk_disable_unprepare(ms->nfi_hclk); - clk_disable_unprepare(ms->pad_clk); - clk_disable_unprepare(ms->nfi_clk); -} - static int mtk_snand_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1406,49 +1370,45 @@ static int mtk_snand_probe(struct platform_device *pdev) ms->dev = &pdev->dev; - ms->nfi_clk = devm_clk_get(&pdev->dev, "nfi_clk"); + ms->nfi_clk = devm_clk_get_enabled(&pdev->dev, "nfi_clk"); if (IS_ERR(ms->nfi_clk)) { ret = PTR_ERR(ms->nfi_clk); dev_err(&pdev->dev, "unable to get nfi_clk, err = %d\n", ret); goto release_ecc; } - ms->pad_clk = devm_clk_get(&pdev->dev, "pad_clk"); + ms->pad_clk = devm_clk_get_enabled(&pdev->dev, "pad_clk"); if (IS_ERR(ms->pad_clk)) { ret = PTR_ERR(ms->pad_clk); dev_err(&pdev->dev, "unable to get pad_clk, err = %d\n", ret); goto release_ecc; } - ms->nfi_hclk = devm_clk_get_optional(&pdev->dev, "nfi_hclk"); + ms->nfi_hclk = devm_clk_get_optional_enabled(&pdev->dev, "nfi_hclk"); if (IS_ERR(ms->nfi_hclk)) { ret = PTR_ERR(ms->nfi_hclk); dev_err(&pdev->dev, "unable to get nfi_hclk, err = %d\n", ret); goto release_ecc; } - ret = mtk_snand_enable_clk(ms); - if (ret) - goto release_ecc; - init_completion(&ms->op_done); ms->irq = platform_get_irq(pdev, 0); if (ms->irq < 0) { ret = ms->irq; - goto disable_clk; + goto release_ecc; } ret = devm_request_irq(ms->dev, ms->irq, mtk_snand_irq, 0x0, "mtk-snand", ms); if (ret) { dev_err(ms->dev, "failed to request snfi irq\n"); - goto disable_clk; + goto release_ecc; } ret = dma_set_mask(ms->dev, DMA_BIT_MASK(32)); if (ret) { dev_err(ms->dev, "failed to set dma mask\n"); - goto disable_clk; + goto release_ecc; } // switch to SNFI mode @@ -1472,7 +1432,7 @@ static int mtk_snand_probe(struct platform_device *pdev) ret = mtk_snand_setup_pagefmt(ms, SZ_2K, SZ_64); if (ret) { dev_err(ms->dev, "failed to set initial page format\n"); - goto disable_clk; + goto release_ecc; } // setup ECC engine @@ -1484,7 +1444,7 @@ static int mtk_snand_probe(struct platform_device *pdev) ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng); if (ret) { dev_err(&pdev->dev, "failed to register ecc engine.\n"); - goto disable_clk; + goto release_ecc; } ctlr->num_chipselect = 1; @@ -1496,12 +1456,10 @@ static int mtk_snand_probe(struct platform_device *pdev) ret = spi_register_controller(ctlr); if (ret) { dev_err(&pdev->dev, "spi_register_controller failed.\n"); - goto disable_clk; + goto release_ecc; } return 0; -disable_clk: - mtk_snand_disable_clk(ms); release_ecc: mtk_ecc_release(ms->ecc); return ret; @@ -1513,7 +1471,6 @@ static void mtk_snand_remove(struct platform_device *pdev) struct mtk_snand *ms = spi_controller_get_devdata(ctlr); spi_unregister_controller(ctlr); - mtk_snand_disable_clk(ms); mtk_ecc_release(ms->ecc); kfree(ms->buf); } From patchwork Tue Aug 22 13:12:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360720 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 995ABEE49A4 for ; Tue, 22 Aug 2023 13:16:11 +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=Ha0yIvuT59A6FrW+4+x4QHVEXLR1rDoAHbdwgqd1GsY=; b=Noc62M0iXtEKki nrTFDiWFhqLIe4Uo/5FSqDMSMOSnBgLOYQ9YnbC6d23S80aO7I6PRUWhI48nMfjvHNVkTDHXv9CJr fe/bNL62HhegAwxHSoFYlOGaPPJgNjZiIAQbCBmrL11txqILNzi2AzDgcAn2CylB+wWevG4Wubz1B q4TbxjU7mle8qz4QxAnNz/ZO7TB2ukHYmoWey0TzrO7qH6GlPKjIk5IDimiIGqtGKyl1vBo1r+mG6 bccj1Su+d2rVpP7RMHQtPlUR0JMJFtH/hocxOIxRf0khl+Um6DrTSdJAB1OL1cjOiH6/yIUNZXskB eI/svpM2TVAJFIqUttZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREU-00G0U2-0k; Tue, 22 Aug 2023 13:15:42 +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 1qYRC5-00FxgX-1d; Tue, 22 Aug 2023 13:13:15 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV9T65q9zrSW6; Tue, 22 Aug 2023 21:11:41 +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:09 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 20/25] spi: npcm-fiu: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:32 +0800 Message-ID: <20230822131237.1022815-21-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_061314_099715_AA384586 X-CRM114-Status: GOOD ( 10.16 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-npcm-fiu.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-npcm-fiu.c b/drivers/spi/spi-npcm-fiu.c index 0ca21ff0e9cc..1a5277ff349f 100644 --- a/drivers/spi/spi-npcm-fiu.c +++ b/drivers/spi/spi-npcm-fiu.c @@ -699,7 +699,7 @@ static int npcm_fiu_probe(struct platform_device *pdev) struct spi_controller *ctrl; struct npcm_fiu_spi *fiu; void __iomem *regbase; - int id, ret; + int id; ctrl = devm_spi_alloc_host(dev, sizeof(*fiu)); if (!ctrl) @@ -737,7 +737,7 @@ static int npcm_fiu_probe(struct platform_device *pdev) fiu->res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory"); - fiu->clk = devm_clk_get(dev, NULL); + fiu->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(fiu->clk)) return PTR_ERR(fiu->clk); @@ -745,7 +745,6 @@ static int npcm_fiu_probe(struct platform_device *pdev) "nuvoton,spix-mode"); platform_set_drvdata(pdev, fiu); - clk_prepare_enable(fiu->clk); ctrl->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_DUAL | SPI_TX_QUAD; @@ -755,18 +754,11 @@ static int npcm_fiu_probe(struct platform_device *pdev) ctrl->num_chipselect = fiu->info->max_cs; ctrl->dev.of_node = dev->of_node; - ret = devm_spi_register_controller(dev, ctrl); - if (ret) - clk_disable_unprepare(fiu->clk); - - return ret; + return devm_spi_register_controller(dev, ctrl); } static void npcm_fiu_remove(struct platform_device *pdev) { - struct npcm_fiu_spi *fiu = platform_get_drvdata(pdev); - - clk_disable_unprepare(fiu->clk); } MODULE_DEVICE_TABLE(of, npcm_fiu_dt_ids); From patchwork Tue Aug 22 13:12:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360721 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 AC4B8EE49A3 for ; Tue, 22 Aug 2023 13:16:12 +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=8IsWKaFOhGWmfdLgckcNLcJQJ2URAMa9wzt0MRyMrdI=; b=Ag5JrJw2DYNOK9 gpxEjU1OAEKJ08pZQbkKBai5zqxBXK6hqH/FGYNsliY3NuIqfI9L4Xg31ErDnOv+Uv8hh2JHfaHip 31g2TlE87R4Kv/mKauj5hbmwgk5KV3X/M4ZPzH5ZTW8bOjNtucCRWm4Zhgz9h00oq83sIIcUG7Ksg KTpCOhoyFKfIPhglV7hth2D+sdeExbu3+bP4B6VpR16I/LxBZ7hXRzF98xwTMN+BylrfK4Tzpyw0W JCIIGYnQlXh+63srmH6XFfxbhDK8b7cTvhAm7VxAHKzfzAK574XpQUz7CRqnlLTrM69QHlZ7Bat+P CVe74QLdfvUE6AlXuB0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREV-00G0Vz-2D; Tue, 22 Aug 2023 13:15:43 +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 1qYRC6-00FxhJ-2I; Tue, 22 Aug 2023 13:13:16 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV9V6jD9zrSky; Tue, 22 Aug 2023 21:11:42 +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:10 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 21/25] spi: orion: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:33 +0800 Message-ID: <20230822131237.1022815-22-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_061315_019936_A3594144 X-CRM114-Status: GOOD ( 10.49 ) 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-orion.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index faf2764b91a8..d22bb67fee00 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -688,21 +688,17 @@ static int orion_spi_probe(struct platform_device *pdev) devdata = devdata ? devdata : &orion_spi_dev_data; spi->devdata = devdata; - spi->clk = devm_clk_get(&pdev->dev, NULL); + spi->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(spi->clk)) { status = PTR_ERR(spi->clk); goto out; } - status = clk_prepare_enable(spi->clk); - if (status) - goto out; - /* The following clock is only used by some SoCs */ spi->axi_clk = devm_clk_get(&pdev->dev, "axi"); if (PTR_ERR(spi->axi_clk) == -EPROBE_DEFER) { status = -EPROBE_DEFER; - goto out_rel_clk; + goto out; } if (!IS_ERR(spi->axi_clk)) clk_prepare_enable(spi->axi_clk); @@ -795,8 +791,6 @@ static int orion_spi_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); out_rel_axi_clk: clk_disable_unprepare(spi->axi_clk); -out_rel_clk: - clk_disable_unprepare(spi->clk); out: spi_master_put(master); return status; @@ -810,7 +804,6 @@ static void orion_spi_remove(struct platform_device *pdev) pm_runtime_get_sync(&pdev->dev); clk_disable_unprepare(spi->axi_clk); - clk_disable_unprepare(spi->clk); spi_unregister_master(master); pm_runtime_disable(&pdev->dev); From patchwork Tue Aug 22 13:12:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360722 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 32606EE49A4 for ; Tue, 22 Aug 2023 13:16: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: 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=IydG45ZcK2H2t0K2CmYmVAGlybT5iVs8H03PhWoeXC8=; b=4+TDEREHROIkMp SLsNtyU4gTKMOIkVP4sos9frJQxHTKlRXglJgaHz/TYtetWI0NXSq+YN5orlOQxgbth5uHAQrgjKz a4XDj+B6+LD472D4aWXGrw7lpAEBKrGmUA92c3XYXqrEfPcVy4GiNaWpUrfirjI2WIoktNnuyPdYC QJJ862cm1lGEp1bLsYC5JecnrlqzhMXCQJZGjwF04B5IPsWePEisl88A+s6Gw5qWGCGTtQWBDDMHL 2wjolttxl22qBkG8IpR9GQgvDGzI7EqiWv60mkkxSwfXQpaHPUzQuy3HrPDVXhNN7gtQnF/e+ex1d O38am69KMlx1wlUsWjkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREW-00G0Xq-37; Tue, 22 Aug 2023 13:15:44 +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 1qYRC7-00Fxi9-24; Tue, 22 Aug 2023 13:13:17 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV765Z8SzNnNM; Tue, 22 Aug 2023 21:09:38 +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:11 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 22/25] spi: pic32-sqi: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:34 +0800 Message-ID: <20230822131237.1022815-23-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_061316_132261_76371C5C X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-pic32-sqi.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/spi/spi-pic32-sqi.c b/drivers/spi/spi-pic32-sqi.c index 5cbebcf26a2a..d894b99e4104 100644 --- a/drivers/spi/spi-pic32-sqi.c +++ b/drivers/spi/spi-pic32-sqi.c @@ -593,33 +593,20 @@ static int pic32_sqi_probe(struct platform_device *pdev) } /* clocks */ - sqi->sys_clk = devm_clk_get(&pdev->dev, "reg_ck"); + sqi->sys_clk = devm_clk_get_enabled(&pdev->dev, "reg_ck"); if (IS_ERR(sqi->sys_clk)) { ret = PTR_ERR(sqi->sys_clk); dev_err(&pdev->dev, "no sys_clk ?\n"); goto err_free_master; } - sqi->base_clk = devm_clk_get(&pdev->dev, "spi_ck"); + sqi->base_clk = devm_clk_get_enabled(&pdev->dev, "spi_ck"); if (IS_ERR(sqi->base_clk)) { ret = PTR_ERR(sqi->base_clk); dev_err(&pdev->dev, "no base clk ?\n"); goto err_free_master; } - ret = clk_prepare_enable(sqi->sys_clk); - if (ret) { - dev_err(&pdev->dev, "sys clk enable failed\n"); - goto err_free_master; - } - - ret = clk_prepare_enable(sqi->base_clk); - if (ret) { - dev_err(&pdev->dev, "base clk enable failed\n"); - clk_disable_unprepare(sqi->sys_clk); - goto err_free_master; - } - init_completion(&sqi->xfer_done); /* initialize hardware */ @@ -629,7 +616,7 @@ static int pic32_sqi_probe(struct platform_device *pdev) ret = ring_desc_ring_alloc(sqi); if (ret) { dev_err(&pdev->dev, "ring alloc failed\n"); - goto err_disable_clk; + goto err_free_master; } /* install irq handlers */ @@ -669,10 +656,6 @@ static int pic32_sqi_probe(struct platform_device *pdev) err_free_ring: ring_desc_ring_free(sqi); -err_disable_clk: - clk_disable_unprepare(sqi->base_clk); - clk_disable_unprepare(sqi->sys_clk); - err_free_master: spi_master_put(master); return ret; @@ -685,10 +668,6 @@ static void pic32_sqi_remove(struct platform_device *pdev) /* release resources */ free_irq(sqi->irq, sqi); ring_desc_ring_free(sqi); - - /* disable clk */ - clk_disable_unprepare(sqi->base_clk); - clk_disable_unprepare(sqi->sys_clk); } static const struct of_device_id pic32_sqi_of_ids[] = { From patchwork Tue Aug 22 13:12:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360723 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 0AA47EE49A3 for ; Tue, 22 Aug 2023 13:16:29 +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=MemM5LBWLwbz/LDKaROci/iiyXrZBKTFPrN9G6Wr/mY=; b=V9Vb4r17Nloo4m 1CC+kP+N5bFUPKnq3g431gW8vCZwSG/OLekiDjt73ysj3vr/o+aWAGhuX4HC5zgG1PX4wTk3OQwv/ m+6fNMfKDH4cZBPb4vdqx/W+/uirGymFm1QkVJMm6ZFUGj0eNbUWtPboVGs7HIZ9gAG1tpnFYaX1x Mxo3CwrSvvQplzwfJVr/UP2RnxhdKbM85jGwT4SXEH+ZIWEqVfPNsfrec8LwiDpHxUKoM+NThU+1n 21ctmxCK38CkOLQRxgjsYq43lLUxHr7IS00KBdtW4IPjl6mfKwO/ZhSGhMbYmCKabk7uQqwM2Bxcs RWNn3YD5sV5cAz2987gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREc-00G0dD-1q; Tue, 22 Aug 2023 13:15:50 +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 1qYRC8-00Fxj0-1v; Tue, 22 Aug 2023 13:13:18 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8g2Vb5zTmTk; Tue, 22 Aug 2023 21:10:59 +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:12 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 23/25] spi: pic32: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:35 +0800 Message-ID: <20230822131237.1022815-24-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_061316_871973_994B51B0 X-CRM114-Status: UNSURE ( 8.95 ) X-CRM114-Notice: Please train this message. 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 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. Signed-off-by: Li Zetao --- drivers/spi/spi-pic32.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c index e9b4c9cb97fb..2b0680974cba 100644 --- a/drivers/spi/spi-pic32.c +++ b/drivers/spi/spi-pic32.c @@ -730,17 +730,13 @@ static int pic32_spi_hw_probe(struct platform_device *pdev, return pic32s->tx_irq; /* get clock */ - pic32s->clk = devm_clk_get(&pdev->dev, "mck0"); + pic32s->clk = devm_clk_get_enabled(&pdev->dev, "mck0"); if (IS_ERR(pic32s->clk)) { dev_err(&pdev->dev, "clk not found\n"); ret = PTR_ERR(pic32s->clk); goto err_unmap_mem; } - ret = clk_prepare_enable(pic32s->clk); - if (ret) - goto err_unmap_mem; - pic32_spi_hw_init(pic32s); return 0; @@ -837,7 +833,6 @@ static int pic32_spi_probe(struct platform_device *pdev) err_bailout: pic32_spi_dma_unprep(pic32s); - clk_disable_unprepare(pic32s->clk); err_master: spi_master_put(master); return ret; @@ -849,7 +844,6 @@ static void pic32_spi_remove(struct platform_device *pdev) pic32s = platform_get_drvdata(pdev); pic32_spi_disable(pic32s); - clk_disable_unprepare(pic32s->clk); pic32_spi_dma_unprep(pic32s); } From patchwork Tue Aug 22 13:12:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360724 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 63984EE49AC for ; Tue, 22 Aug 2023 13:16:34 +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=60FQ7OwnfCpg3+r9xaVlTc/W8wmzX7FNG/RLE6cJA1M=; b=3wRgOwANBFadNO Xounfua9vrSMciAmWy0Ul5glHBBmUW+U6IamhsCaUBwHkxGjA8vKYu7zt4n8a/eY2LjOQTYg4y/fU ec8gxNb7GOH42vEBZnFaa+nZgIw9zf80FgNNkn3T3zEzFJHfQSyGVfJReRxTRsDqCbMfKCvxrbMFc AcDaNXl60UOyAmIYxURJvrLuSH1SAFGltEmrlLOie2CycvlCMq8unFByWVzrz6JQjJL87PXsrd4sC WNgly8+LgaVX0xPCBXKG6tq3WpBt3DZWpQDy3h21YDSoSPvtQ+exHysUFkp/oBlAAtioA4pP9dixE mj2RFVU0exR3DNmZ0eRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREl-00G0lj-1y; Tue, 22 Aug 2023 13:15:59 +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 1qYRC9-00FxkD-2V; Tue, 22 Aug 2023 13:13:19 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RVV8h3386zTmLG; Tue, 22 Aug 2023 21:11:00 +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:13 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 24/25] spi: spl022: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:36 +0800 Message-ID: <20230822131237.1022815-25-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_061318_379706_1BB27493 X-CRM114-Status: UNSURE ( 8.39 ) X-CRM114-Notice: Please train this message. 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 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. Moreover, the label "err_no_clk_en" is no used, drop it for clean code. Signed-off-by: Li Zetao Reviewed-by: Linus Walleij --- drivers/spi/spi-pl022.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 1af75eff26b6..468a7fea9091 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2168,19 +2168,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) dev_info(&adev->dev, "mapped registers from %pa to %p\n", &adev->res.start, pl022->virtbase); - pl022->clk = devm_clk_get(&adev->dev, NULL); + pl022->clk = devm_clk_get_enabled(&adev->dev, NULL); if (IS_ERR(pl022->clk)) { status = PTR_ERR(pl022->clk); dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n"); goto err_no_clk; } - status = clk_prepare_enable(pl022->clk); - if (status) { - dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n"); - goto err_no_clk_en; - } - /* Initialize transfer pump */ tasklet_init(&pl022->pump_transfers, pump_transfers, (unsigned long)pl022); @@ -2236,16 +2230,14 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) return 0; - err_spi_register: +err_spi_register: if (platform_info->enable_dma) pl022_dma_remove(pl022); - err_no_irq: - clk_disable_unprepare(pl022->clk); - err_no_clk_en: - err_no_clk: - err_no_ioremap: +err_no_irq: +err_no_clk: +err_no_ioremap: amba_release_regions(adev); - err_no_ioregion: +err_no_ioregion: spi_master_put(master); return status; } @@ -2268,7 +2260,6 @@ pl022_remove(struct amba_device *adev) if (pl022->master_info->enable_dma) pl022_dma_remove(pl022); - clk_disable_unprepare(pl022->clk); amba_release_regions(adev); tasklet_disable(&pl022->pump_transfers); } From patchwork Tue Aug 22 13:12:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13360726 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 E5C20EE49A3 for ; Tue, 22 Aug 2023 13:16:39 +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=5o11iAPkNv+i68GsN63BVQsNb25D7Xx4pv2v2y9eZEg=; b=J8kz8iX/GrlceK iochj164cP5Zflc+MT4IkAoTkjRgLzcq8TJl3NSGQG1eh6ot+W1hD2qI+byB1ha7bK6B4/0ICEyWm QoYU1mQoz1cK5NhQjywNV1YSzTn/CxTi19DfFsy+doFDZldU41zOVUVKX/sLylEc3gb6tlMRjCLz6 Qoc16T35D7WQ/F/XoJMSNrOqBqqAkK61Qt64FakPKyAYEGJ3RGtPQ0ht7Y2OxZzun9AqBoo5D29VO QNzGriUrKgtz9rFJQoeFqxfCxS+BP9bfOyWIIswSCVL7W7GcDN9PMHpDaARg5nsEB9lHtjGnODlQV bY9GrbhFSClItq3i0fTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYREt-00G0v8-0D; Tue, 22 Aug 2023 13:16:07 +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 1qYRCA-00FxlB-2p; Tue, 22 Aug 2023 13:13:21 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RVV706V9xztSDs; Tue, 22 Aug 2023 21:09:32 +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:15 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Subject: [PATCH -next 25/25] spi: rockchip: Use helper function devm_clk_get_enabled() Date: Tue, 22 Aug 2023 21:12:37 +0800 Message-ID: <20230822131237.1022815-26-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_061319_430132_43099D50 X-CRM114-Status: GOOD ( 10.66 ) 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 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. Signed-off-by: Li Zetao Reviewed-by: Heiko Stuebner --- drivers/spi/spi-rockchip.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a37943847e81..cdbb86049d59 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -782,42 +782,30 @@ static int rockchip_spi_probe(struct platform_device *pdev) goto err_put_ctlr; } - rs->apb_pclk = devm_clk_get(&pdev->dev, "apb_pclk"); + rs->apb_pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); if (IS_ERR(rs->apb_pclk)) { dev_err(&pdev->dev, "Failed to get apb_pclk\n"); ret = PTR_ERR(rs->apb_pclk); goto err_put_ctlr; } - rs->spiclk = devm_clk_get(&pdev->dev, "spiclk"); + rs->spiclk = devm_clk_get_enabled(&pdev->dev, "spiclk"); if (IS_ERR(rs->spiclk)) { dev_err(&pdev->dev, "Failed to get spi_pclk\n"); ret = PTR_ERR(rs->spiclk); goto err_put_ctlr; } - ret = clk_prepare_enable(rs->apb_pclk); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to enable apb_pclk\n"); - goto err_put_ctlr; - } - - ret = clk_prepare_enable(rs->spiclk); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to enable spi_clk\n"); - goto err_disable_apbclk; - } - spi_enable_chip(rs, false); ret = platform_get_irq(pdev, 0); if (ret < 0) - goto err_disable_spiclk; + goto err_put_ctlr; ret = devm_request_threaded_irq(&pdev->dev, ret, rockchip_spi_isr, NULL, IRQF_ONESHOT, dev_name(&pdev->dev), ctlr); if (ret) - goto err_disable_spiclk; + goto err_put_ctlr; rs->dev = &pdev->dev; rs->freq = clk_get_rate(rs->spiclk); @@ -843,7 +831,7 @@ static int rockchip_spi_probe(struct platform_device *pdev) if (!rs->fifo_len) { dev_err(&pdev->dev, "Failed to get fifo length\n"); ret = -EINVAL; - goto err_disable_spiclk; + goto err_put_ctlr; } pm_runtime_set_autosuspend_delay(&pdev->dev, ROCKCHIP_AUTOSUSPEND_TIMEOUT); @@ -937,10 +925,6 @@ static int rockchip_spi_probe(struct platform_device *pdev) dma_release_channel(ctlr->dma_tx); err_disable_pm_runtime: pm_runtime_disable(&pdev->dev); -err_disable_spiclk: - clk_disable_unprepare(rs->spiclk); -err_disable_apbclk: - clk_disable_unprepare(rs->apb_pclk); err_put_ctlr: spi_controller_put(ctlr); @@ -950,13 +934,9 @@ static int rockchip_spi_probe(struct platform_device *pdev) static void rockchip_spi_remove(struct platform_device *pdev) { struct spi_controller *ctlr = spi_controller_get(platform_get_drvdata(pdev)); - struct rockchip_spi *rs = spi_controller_get_devdata(ctlr); pm_runtime_get_sync(&pdev->dev); - clk_disable_unprepare(rs->spiclk); - clk_disable_unprepare(rs->apb_pclk); - pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);