From patchwork Wed Aug 23 13:39: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: 13362504 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 D1FD9EE4993 for ; Wed, 23 Aug 2023 13:42: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=HD4IPJAxrHkbTkS67gnzWAYATo0soYmRIbLlAXuQ81s=; b=Ruh5hPKXf4K7Qx XeTPC6PnSsEamu0Cgmd9hPZkE7K3Z61GB1Rb8cWKWSMaqnAK1qKdbNQvNreGnM6TScm+0tpJQsdoT ep9/+y7UhoZ1I3/0/sSfedLUWA4Td7unHy1n+iYped7EAZzKQfJtkXU2Vsen2wF0ZuEXYumQMpFAN 8ay+yxnxj4ouMv61jANpflvazqe6BC3Te/gfYJCMCYfX9k45tUFKu/A5UzfUTk0X9BUwqHflcxVKl 9TW+OIoEcK/uabgkaTfbeXuCCor9rckgcVI4CtgzEQLZxB/QTTfCkOKhc3X4UbEMNjPNRYFutdHxM A04FYrTOd+gQQUlyK1bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7W-000jPr-20; Wed, 23 Aug 2023 13:42:02 +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 1qYo5h-000hOx-26; Wed, 23 Aug 2023 13:40:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6jq1m9tz16NyL; Wed, 23 Aug 2023 21:38:23 +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; Wed, 23 Aug 2023 21:39:51 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 01/25] spi: ar934x: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:14 +0800 Message-ID: <20230823133938.1359106-2-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_212639_015357C9 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13362496 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 5407DEE49A3 for ; Wed, 23 Aug 2023 13:40:50 +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=nDJTCFBs3+6pfvYzk5ZoEfu5D/UlMP9U8a8gaU6lzKE=; b=dlIWgXGlggqewl mkL6kEEG+gSRq2uKF5lBJ7eVr0iv5nX05Bzg5yRScjaE9bmOULIFPP021P8wxoc7WU7kt6DgnguLv vmLiFbsh/joWcpVEE0O2HkRy284xNEnY3i941T7jLIEnUOgElJVzN7mkplQJLMCWmEoT92H7dJZGm 947/JxnCQFSjoXHM8OYN7cpOePPUST4riP1FDkQ8+DQqbyvTlfvvQBQudLifAU+Q5lKDsOGognVCl S+6N1bZpFq6n4lzSX4K/uRBLRIXyj9oHV8v4DcOpjP57mYt27WwDNwT7Jh7GrTRTbFFw9g/EFPpY0 pLj7jsscQRP60CLwX/Nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo6H-000i4W-16; Wed, 23 Aug 2023 13:40:45 +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 1qYo5f-000hOl-2h; Wed, 23 Aug 2023 13:40:11 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6jq3yGBzrSbq; Wed, 23 Aug 2023 21:38:23 +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; Wed, 23 Aug 2023 21:39:52 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next v2 02/25] spi: armada-3700: Use helper function devm_clk_get_prepared() Date: Wed, 23 Aug 2023 21:39:15 +0800 Message-ID: <20230823133938.1359106-3-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_405257_FAA065BA X-CRM114-Status: GOOD ( 12.06 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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 Reviewed-by: Jonathan Cameron --- v1 -> v2: Drop the empty remove function a3700_spi_remove(). drivers/spi/spi-armada-3700.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index 0103ac0158c0..3c9ed412932f 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,40 +882,29 @@ 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: return ret; } -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 = { .driver = { .name = DRIVER_NAME, .of_match_table = of_match_ptr(a3700_spi_dt_ids), }, .probe = a3700_spi_probe, - .remove_new = a3700_spi_remove, }; module_platform_driver(a3700_spi_driver); From patchwork Wed Aug 23 13:39: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: 13362500 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 4B831EE49A3 for ; Wed, 23 Aug 2023 13:41: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=OX+SSOOhecx5X4ahuJESsQLyx1TtnNhAKxUBq3+jf08=; b=wEFpR4zgiK8ox3 8QWm60WcNZAmlxjcZGr0v+IReA/NL3PaTzWz9pXdDXBSby7uP7F6eH08czSJcuxd9/V5RHpYBDhZh KZ0raki3ylIXNA3bRJm399cYO4ZT4xnX07M086qBElChjCGYMYKEQ6yOgjJGl6LtgBSo7eAb0QoXf u5Vtbp6SuDPsDMMXL9eqRuCFMB03VnP1pDYitOOF6gSCgFhK+WMwJA51528j2cQJh3gso9Xz0nQyZ g7SuPGWxmhItheADzfBcMPINjSsDGsR5FDlMPohTFfbm3GGJEEWKOngKPW4N3aR2Ubm2zxxIlqovV fCiaNF2EWhPiNeGwTbPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo75-000iue-03; Wed, 23 Aug 2023 13:41:35 +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 1qYo5h-000hOw-25; Wed, 23 Aug 2023 13:40:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RW6h15S8RzLpCV; Wed, 23 Aug 2023 21:36: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; Wed, 23 Aug 2023 21:39:53 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 03/25] spi: aspeed: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:16 +0800 Message-ID: <20230823133938.1359106-4-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_205720_5E78E8C4 X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Reviewed-by: Chin-Ting Kuo Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362494 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 AC1D1EE49B0 for ; Wed, 23 Aug 2023 13:40:20 +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=hEiLyBZu00lG1ZpOzoJyzccPiYWKsQsvIrs60HUKP9c=; b=g299pWhKDn5VYM yA3jinzFQo7+3aviMW/jOgN4AHFaKF3npH+YNBnCy/BzR7nggOXgB3JMT/DNXj4LNQMqv7dJ/MsN+ vLtSs8rbqRObvwh1rF6gUfZKHliFvTkdZg1PCEMmjYo6OE819u0Dqmrqkp6OGCKdfHStqu6QlPYCB /ap9ICju7SQEZKsFGDfDtpsoGiX5diGPiakn2Nw29gRxO0Z1sy2IQJudqCieuCxZTOyBqD6K/tXIH 9c7CNou1qLzVVxhOZ/t73MAP+ES+12SYE8TEppsa2Tn+hMkBnM9iIaq4xvhNBk19p5pB2dlS8oDVS DHFatZpTkeKo53vkBUww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo5l-000hWE-1Y; Wed, 23 Aug 2023 13:40: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 1qYo5e-000hOr-3C; Wed, 23 Aug 2023 13:40:09 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gH4PXcztRv3; Wed, 23 Aug 2023 21:36:11 +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; Wed, 23 Aug 2023 21:39:54 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 04/25] spi: ath79: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:17 +0800 Message-ID: <20230823133938.1359106-5-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064007_309460_1ACA4880 X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362501 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 4ABB7EE4993 for ; Wed, 23 Aug 2023 13:41:48 +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=oLQFbtzMrOtJFFBzp064D3/nsWUM6mBKdzOg0EoIpeU=; b=ebc6RqeJzsgpKt vHFw4jaMGKUWSvqmFGzsdJKLI4Mfr90LhdBSz6OwX/jnb2MVhUyFwNYDEXgyq3/GohqX2sy7wqUPX bXNPh7zMm73l7XcLHLzXZolE0ACyqp4/wd80GZpwkTKJdIfSwMNcFC8EaW+0Biuyo0Fyrv2KiD7aQ +04vbGGrt8mC4HdOsCCn8UFH4tyqevfMv10KSpjYkDzGQAbVToqxYIZUYTdQoQTSxgixGy9En0RpA sw0yMUXPs78x6UEzmPyHhq7h/ELorC4rLg35BQo0Ah60sD+aYWQard778/ZEy8eR06UoJW9ra+xkx R/DNp6BwZ2k4CFOJkWeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7E-000j5m-0B; Wed, 23 Aug 2023 13:41:44 +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 1qYo5g-000hOt-1L; Wed, 23 Aug 2023 13:40:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gJ4xKSztRwy; Wed, 23 Aug 2023 21:36:12 +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; Wed, 23 Aug 2023 21:39:55 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 05/25] spi: spi-axi-spi-engine: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:18 +0800 Message-ID: <20230823133938.1359106-6-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_964213_9413E72B X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362506 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 06E66EE49B0 for ; Wed, 23 Aug 2023 13:42:18 +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=hKQOErseyGNHEmO5U1P6o1VOwiMzoc0NOo6Be4pBJtw=; b=WE5t5A28ynTn9/ OWRDL/uoljB+rWxSvpGoHb8uU0a/gxFcvyxK8tog7RbSc+KLta4KC++idOA8rvLYt5NkeLh0YE5ba cgCkRa7L9DvW0j0sGjTWSpVeQ5itPAtihyZh6Yov1XfcZInVBxu12KEaYxi9pT3/2qTb6OICetHdu vZt1px9hm5jlx9iPeNUis/ZKFtcFC0hoYEFzHdbWIZS3u1GK5F1oyxbLe68DWbKoeMAmQV3JShGK0 Tkj+Z1CeU4v4cMaE+pNxpSHGnI5cBrAH9mjfo/v0S4T754PrRgP6x4kroNbgH7gdpykHaxBGfAFcr BDQbuadGDNH+NjYHe2wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7f-000jcB-2U; Wed, 23 Aug 2023 13:42:11 +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 1qYo5h-000hP4-0b; Wed, 23 Aug 2023 13:40:16 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RW6h46w6SzLpCJ; Wed, 23 Aug 2023 21:36:52 +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; Wed, 23 Aug 2023 21:39:56 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 06/25] spi: bcm2835: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:19 +0800 Message-ID: <20230823133938.1359106-7-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_356662_CBFE0BDB X-CRM114-Status: GOOD ( 11.04 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362498 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 7C87CEE49B2 for ; Wed, 23 Aug 2023 13:41:02 +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=5ZQYFM8RVGJugQx8v3GqoggYWyIKdrUshxu9+8nxKcg=; b=AKwKZeLx9aELvt gdJZJCIGE6l5WRPdeyb2IA2tX4lWXVcmzPV57AKcXmOuJv88wRG7Wq8JjDHTPXsQaJO2YHdRFxBXu p7Pd/loGkMuUi1M/IsB6u49+WxL2l1xp8PjplfAhqyiUeRFGdZ7p2iKsE9XmJjoRpP9w6U+CMCUZc JraNsDDy8MI9cYjoFeqBgxs2rkF7GB8nI5dXl8l8fNkKkfJuXivlS66vOTOrMfvSPx8R9gfdW4t3f 4jatykCQBwk3JbcJ8UMwz4hmp2+jhmkonNJ6qGgQCsVpBZYCO1zr1zfVhoevIzouxly492em4kYxz ScRbWrBKdA0Il4iFDl3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo6S-000iGx-2Q; Wed, 23 Aug 2023 13:40:56 +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 1qYo5f-000hPV-2K; Wed, 23 Aug 2023 13:40:11 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6gX48BVzNmsj; Wed, 23 Aug 2023 21:36: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; Wed, 23 Aug 2023 21:39:58 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 07/25] spi: bcm2835aux: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:20 +0800 Message-ID: <20230823133938.1359106-8-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_293331_035D2ECA X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362507 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 C099CEE4993 for ; Wed, 23 Aug 2023 13:42: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=rO/xce5TAa6zhmcLVvYMzKicpf95uT77ar0//Qjw24k=; b=NPDqkgEKWe7kle NdqF0cH6FqLIoRm7psu9zdS0VxLvMIeyhZnxgevgkP+BA1pwO0zUX4WJu3iI40xpeSVlMfl3+vv3H b1Jc07MG/y6qu1fRASVXDB4nAHRakxtx00rLrYZ04+Yx3aJgYdMgjyKuIHr4QrT6iOwPFfd3XhKYZ qsPQezd+Iqt94lpsMqiOgpyYUhG2RCIPQDUQSjMQilex5jjBA4GTEBbfN8JHIyRiKb01MCHxQSeob bJM6uqtxbjDucpa2XV4FC6Iq5tZK36oECQ0CdPUJ3QP0BDHumWccja1EOqxGXqX8lNSmq++eHj3cI 1LIjl4ONesawq0jjfHAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo86-000k2b-0X; Wed, 23 Aug 2023 13:42:38 +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 1qYo5h-000hPF-23; Wed, 23 Aug 2023 13:40:15 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6jy5FlQz16NyT; Wed, 23 Aug 2023 21:38:30 +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; Wed, 23 Aug 2023 21:39:59 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 08/25] spi: spi-cadence: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:21 +0800 Message-ID: <20230823133938.1359106-9-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_203609_CD10582C X-CRM114-Status: UNSURE ( 9.14 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 12c940ba074a..1f2f8c717df6 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -581,31 +581,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); @@ -679,10 +667,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; @@ -703,8 +688,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 Wed Aug 23 13:39: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: 13362505 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 6BC73EE49B6 for ; Wed, 23 Aug 2023 13:42:13 +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=+9JbDmQVbRoaWvXiEtWX52oLjC40q+3DJ1SyvsY2wO4=; b=ZJ2miCEezXrabR k+vRjdiE9BuV1jGKDNxRyWwttXB+ZdMYQQ62/ZaTwoQ6oMQABxRPg+GIvA3UPRKaEGMRz19aGX8s6 +ZcLLdozoYycMoQPyL6dykPmtESB5ZmNKCn1qXSTGVlyf6E6+JpEqtqJf466RMjr3oz8vCzk72DE2 vwljZAADZQbLvwzEkVlmd3Y3zrvZTrpNcCLZWeIe/vZq0zaqXMCGHL9JrDulrjZQCxdX2OCfKVahj icpr17u0uzVOBoNaKLrVrImXdun7WzYcQeRz8RuL+U5li9ND63tny5+iOywIwz60hm22gHCDnwhPa gVK/OKhIa3hIXar9DlXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7b-000jWI-0Y; Wed, 23 Aug 2023 13:42: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 1qYo5h-000hQH-30; Wed, 23 Aug 2023 13:40:15 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gN70MPztS7L; Wed, 23 Aug 2023 21:36:16 +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; Wed, 23 Aug 2023 21:40:00 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 09/25] spi: spi-cavium-thunderx: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:22 +0800 Message-ID: <20230823133938.1359106-10-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_257213_A5C13A1C X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362495 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 29629EE49B6 for ; Wed, 23 Aug 2023 13:40:45 +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=jIKVyBZK4fh02TmvW5J3iTcNMYGYZc2zuA2E139kOKU=; b=pGVgzcMDYI4X/z QPDdLMWXc0uk8BMqvxQDUyIVkVqFMgHM05oLPfxD5GT9UIxRJuRbOrg0pZxwLGlnN0V9g7EKZ2Saj 5kvhFe67kzGOrmed3Q6Hvg+Sn04QpbcGw+nIZ4bSoOOtVBQPrDCvcO0ztPpw87eMyio5nLgFnQQtp Is+/1xFfhqm9ySINsH48Wm5ltteICK3qHGzcxJ0IN8Bpc2knTgL25QEpHZbrBVBglLHDTC0vEW8tA Kr8gBSl+CvQqWlxuHh61d02GNZGKIXmUUzI6Um2BTeYI4foooQGnIJDS2jsw6PQr5wMNokL9KtjHb Ltc47sJ0DIwZyjFm6x1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo6C-000hz1-1a; Wed, 23 Aug 2023 13:40:40 +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 1qYo5f-000hPf-2K; Wed, 23 Aug 2023 13:40:11 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6gb5mdGzNmwD; Wed, 23 Aug 2023 21:36: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; Wed, 23 Aug 2023 21:40:01 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 10/25] spi: davinci: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:23 +0800 Message-ID: <20230823133938.1359106-11-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_302290_74D70C58 X-CRM114-Status: GOOD ( 10.08 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362503 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 E826CEE49B2 for ; Wed, 23 Aug 2023 13:42:01 +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=Yqz8M4SLCZqL5jo6wvuMa1BILK+17oSy7damE+8fuW0=; b=rkX+thNoNy82Lv tqoEt5Kw3a4Yz21VKSLmikHm0QwefT7y42mm/inN7Dzx6HS7IqqPHklW+/wJD2FJZ/kQwEAMy/nzP tdn/i1otRQ3zrWPYmgrpEWOT2N6h/7d+nf1LHIPfz3KYTMJppDBQTQuG79R572Sj6t9UTmCuiNBrS zb9cHTYsaXZ+DXYAOXbk4jeQlXpkKYZ/P3+0PqwDFbYIs0z74wvdq/uliMjseG+307SMmzOkQqGnC 5V6Y6TLNNP5TbjhpVOg8US8Ch7EeHh7Ua0JL8a7n9tSGCA3I1QDGdv/bCUGMCWVHeu09ATn03HXZo De4yA33zxQB7cjU4lM+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7R-000jL0-2b; Wed, 23 Aug 2023 13:41:57 +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 1qYo5g-000hQC-2z; Wed, 23 Aug 2023 13:40:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6j72BqtzTmKC; Wed, 23 Aug 2023 21:37: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; Wed, 23 Aug 2023 21:40:02 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 11/25] spi: dw-bt1: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:24 +0800 Message-ID: <20230823133938.1359106-12-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_119792_925C3EA9 X-CRM114-Status: GOOD ( 10.37 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Acked-by: Serge Semin Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362499 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 2D996EE49A3 for ; Wed, 23 Aug 2023 13:41:05 +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/YrdPw2impGgn0okDRyhQGyHXrOmgHGnamUP7eMxeU=; b=ruERPzQpsQbBOm MWEd9WhxMKj0jwXvTb5kKFRxZD622yD6QhOAn+qQrvJe4BGj3MgFf1kCw5nHpuiqFf3+w77etWpNK DWNYMQ8QEdV6J3+Z9nSNC6j77eeafOXrUXvW0grDBkM/DiiGQjox1/XEy3Y74x17b1c0BCgw27x22 BoYQz1czPsFMRUXUkQ8MFMjvif0vXQs/+OdnLdfmMWB1MMCPRvvHJlanP70GWHIFmyHLOI80GBt4/ Ue/6bV3dSs2XVDGN+zyYgLBr3UgTPb3dFBsYYYWO+pzpvnZKqhpqkWn3sPIBK8no5cP5sVfU1fUOV oVXm9z2ERrUjd7trYH6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo6W-000iKc-0w; Wed, 23 Aug 2023 13:41:00 +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 1qYo5f-000hPi-2L; Wed, 23 Aug 2023 13:40:11 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6gd72g1zNn6Q; Wed, 23 Aug 2023 21:36:29 +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; Wed, 23 Aug 2023 21:40:03 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next v2 12/25] spi: dw-mmio: Use helper function devm_clk_get_*() Date: Wed, 23 Aug 2023 21:39:25 +0800 Message-ID: <20230823133938.1359106-13-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_286332_578732FE X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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 Acked-by: Serge Semin Reviewed-by: Jonathan Cameron --- v1 -> v2: Return directly instead of calling reset_control_deassert() before the reset control handler has been requested. And use the "out_reset" label instead of "out" before calling pm_runtime_enable(). drivers/spi/spi-dw-mmio.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 805264c9c65c..46801189a651 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -340,29 +340,20 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) if (dws->irq < 0) return dws->irq; /* -ENXIO */ - dwsmmio->clk = devm_clk_get(&pdev->dev, NULL); + dwsmmio->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dwsmmio->clk)) return PTR_ERR(dwsmmio->clk); - ret = clk_prepare_enable(dwsmmio->clk); - if (ret) - return ret; /* Optional clock needed to access the registers */ - dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); - if (IS_ERR(dwsmmio->pclk)) { - ret = PTR_ERR(dwsmmio->pclk); - goto out_clk; - } - ret = clk_prepare_enable(dwsmmio->pclk); - if (ret) - goto out_clk; + dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); + if (IS_ERR(dwsmmio->pclk)) + return PTR_ERR(dwsmmio->pclk); /* find an optional reset controller */ dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi"); - if (IS_ERR(dwsmmio->rstc)) { - ret = PTR_ERR(dwsmmio->rstc); - goto out_clk; - } + if (IS_ERR(dwsmmio->rstc)) + return PTR_ERR(dwsmmio->rstc); + reset_control_deassert(dwsmmio->rstc); dws->bus_num = pdev->id; @@ -383,7 +374,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) if (init_func) { ret = init_func(pdev, dwsmmio); if (ret) - goto out; + goto out_reset; } pm_runtime_enable(&pdev->dev); @@ -397,9 +388,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) out: pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(dwsmmio->pclk); -out_clk: - clk_disable_unprepare(dwsmmio->clk); +out_reset: reset_control_assert(dwsmmio->rstc); return ret; @@ -411,8 +400,6 @@ static void dw_spi_mmio_remove(struct platform_device *pdev) dw_spi_remove_host(&dwsmmio->dws); pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(dwsmmio->pclk); - clk_disable_unprepare(dwsmmio->clk); reset_control_assert(dwsmmio->rstc); } From patchwork Wed Aug 23 13:39: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: 13362497 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 F13FBEE4993 for ; Wed, 23 Aug 2023 13:40: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=XEpFHy2l4tvoSzXCvH4vYfEAWRZ7ZArQ7nV6pP3kwmQ=; b=M4Zeimo7qeeJnT K8uFVsA60Z/jRbMlFLTsNvPKLHoxU+oouLT7UQls/Uo+4VVNaXdGVnOQzHzar9LjtM8DKPK0pA8j/ 1asbu9kjRvZiLs/c6JfBs57Quo6v89z7aTcVa7dO5rWSFsjO8mmtsafb3nKgyZlkENOp9MmZIpMlZ tmmRHTwbv6FBFs8J/ZxWWeakNvKRlcDpEb/QXwNPEosS7wYrxxj1JNxq0/ISYaRMvjcb1RjDimXl+ zeGFLbr+Jpnrl/C8dJ7C66sns7QMDuflqwEdf0oZyePatZ4QunqZDxDomuGROg6/VsIyxNOe2lYvw cp3r/IFA8/RuKtLNTcbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo6P-000iCb-0W; Wed, 23 Aug 2023 13:40:53 +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 1qYo5g-000hQ3-1I; Wed, 23 Aug 2023 13:40:11 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RW6hD3Pr9zLpCj; Wed, 23 Aug 2023 21:37: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; Wed, 23 Aug 2023 21:40:04 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 13/25] spi: spi-fsl-dspi: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:26 +0800 Message-ID: <20230823133938.1359106-14-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064008_967596_C8735523 X-CRM114-Status: GOOD ( 10.34 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362502 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 9E2CDEE49B5 for ; Wed, 23 Aug 2023 13:41:49 +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=jy7lfaanEgtmeKCs6bDeTkczPH+4ft5DgosFOfsoC3o=; b=UcsyZ3xG62gOW5 B1G1/oQDGIF3IYjo+013PftHxY6o+mMk45qQQaNGnNET5gf+SLkvbSi+d+6AGwjafW1AATBAyuvc0 vadNP0zp5cSQUHCUkm5aQNUSGK0fry9Zt/AbvwJHPH9dHkfgIbzyELMexajOIbIIqFsn1efpuScbA ecNZcTdv0AyfY6L6QWCd0IoNJ8C9dpCvv0nNkMeFBG6I/aUS+Kml4hiMi4roUHDyoEdxMZpMLM/W4 yuYRw9Ov3G3Ov2JOuzemAalkbbHy2LW739HHylLeZODLvo+VGeYfJxMVcfjmJi5MhHFjYyoWi1Qx+ EsnOHZELLgvM+99xbcxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo7F-000j86-2z; Wed, 23 Aug 2023 13:41:45 +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 1qYo5h-000hQJ-1S; Wed, 23 Aug 2023 13:40:13 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6k51HDRz16NsJ; Wed, 23 Aug 2023 21:38:37 +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; Wed, 23 Aug 2023 21:40:05 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 14/25] spi: lantiq-ssc: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:27 +0800 Message-ID: <20230823133938.1359106-15-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064010_037689_29D2565D X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362509 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 79CDAEE4993 for ; Wed, 23 Aug 2023 13:42:47 +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=QJ7woef/EicnvP7h+RUN2PfICyf1ydoRfYYrWqURIQ4=; b=DBlR+g8BFkeB7k tci2JT4MPtb1U6hTLr6Cc3XwvKj1an3iDkGK4lHnmASj8MBDeOvQpqYQO7MFb52KuJNUwBkbmvne8 XlY3+hcY8yQj+BCJ8uUYGl+S+wP+2CsW9XyF6RVZuz8Cz603Zq1CNrR0B//HWra+jPXo/gaShmt5E AMTB3a/Dq12mtFG2vqqsm69hUvkJXVlY2DQ8zLkf2GEYmxffWZA+KxTk0Gx6SOYmnQHjzBq2vOvOd UwYHmYmNVsoEBejfxr0GhI21tbrQLPojWV43Gfyo/ibs3MbopsE5vCZLumCPYksy3dDCpEXcs3Nr7 BYa6YlLeE/fwRCMNbxoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo8B-000k7w-1V; Wed, 23 Aug 2023 13:42:43 +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 1qYo5i-000hRw-2C; Wed, 23 Aug 2023 13:40:16 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RW6hG4ZB9zLpCH; Wed, 23 Aug 2023 21:37:02 +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; Wed, 23 Aug 2023 21:40:06 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 15/25] spi: meson-spicc: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:28 +0800 Message-ID: <20230823133938.1359106-16-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064011_280573_2C28F504 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362508 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 5319CEE49B2 for ; Wed, 23 Aug 2023 13:42:46 +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=pFJvQayBHfeKaPn2dlbZTwur3Oo/nVf9w0Z0fwLg6HQ=; b=1clZJarpIIMtew A6vTZVNm9KzmsW0Ktfn4GbhtZkpA5KDVdDgZYhwZHYC5zlX9O1he54W/+rKIUiTpvLxVBl9ofeNsz aFt9zrbkEe+m38jO0R9dShQWMZq/YaW8ZTdSvBvPM1FZYr99tup3+ho+bblPxBpuTpG/2bAyXGp2B +CRm+HcdF6SB3gX4ZKbmuVaKj7MRUCqEdFGBOqDcWRfSJLBqRX+eubaN9sm1bS13oCWAqpMyRUdCI xFEhTzbA3KT1HYvt1ZGustl0+vxi/j3XXdXiHtW+baxyqmUStn3/2q77Lln0DBjksyD0HGWRMewor dC7mm7RbtAkym7I2vDGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo88-000k5A-2H; Wed, 23 Aug 2023 13:42:40 +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 1qYo5j-000hSS-2I; Wed, 23 Aug 2023 13:40:16 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gX3YYgztS8b; Wed, 23 Aug 2023 21:36: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; Wed, 23 Aug 2023 21:40:07 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 16/25] spi: spi-meson-spifc: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:29 +0800 Message-ID: <20230823133938.1359106-17-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064012_333110_8834DC4B X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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". Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362512 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 7FAB5EE49B2 for ; Wed, 23 Aug 2023 13:43:19 +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=ExTb8LJiKQWaCEJzEmiYykL+kRy60qNEMalTXD5nmcI=; b=DjEK5rB5FhtwJu hamAXVbMK8T7W3eexBurhI2ArH5ar482FF0YA1XzEmHs01ucZz2magMU7h00OH4QugiTttAlzo5Dh 4+IZH+L61pxv/cl8H727vLS3G5jMBHMf+YOuK3EERArXtuBvm/MAuRJhhqrLZVZmZHoJ1YuSxV299 NN+WShlRoTiyw9O/aUNPOJJZjzQpvmF/81WYMTDKc18KrJzu6WHpfFCejsLazRfqi/69ReJS3oR32 caeEcKtVdytSXF2l96NEokWe5zTAIv7CUP2mxSb4RRxPQKkhGhvDGqbIC6Jsp0FWgI/b1Pr9M+PZ+ fA9DMmnkrQjFoMXIVHSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo8e-000kUU-13; Wed, 23 Aug 2023 13:43:12 +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 1qYo5k-000hUL-2j; Wed, 23 Aug 2023 13:40:17 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6jF5Hc2zTm8S; Wed, 23 Aug 2023 21:37: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; Wed, 23 Aug 2023 21:40:08 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 17/25] spi: microchip-core-qspi: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:30 +0800 Message-ID: <20230823133938.1359106-18-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064015_367271_A7CF4EFA X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362510 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 48CA5EE49A3 for ; Wed, 23 Aug 2023 13:42:57 +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=D9ppPgeysy5ZXAn7nyuk8DqcLAj07XbGG4/AEpLGdzw=; b=oZfJnNtFApZxRx m8DZH0FgXt9cQaddemv2dI+UVNQpyNVkWysJSe8lXbTwEU669ib1R1RUYmU8fRIsN10GlYhMQEyEL 2QSIh3e/D0DHO+UuduHNh/NJ1F3bcpT78/yS40j4ZldWoNlaRMaIAPUtdlU6PNfpLZJRL2WnBSfaG zCCD1fPtfIVhSJuxLXb6tOUNTN2rpFfDlcUPFFSVNAQ/OSaKD3rezkEHQv/tM36rgBTbUqdK08NG+ fL09ACMRvRI4KcHUpLYP6LuCZ6imI4hF3gDaf9RASmcYugMoY9vRTwTz213Z5fikM+/Db2rFv5uDI bNhXYRXAkwY1Qq3+YAuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo8K-000kH5-2O; Wed, 23 Aug 2023 13:42:52 +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 1qYo5m-000hV3-0G; Wed, 23 Aug 2023 13:40:16 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6k8593RzrSKP; Wed, 23 Aug 2023 21:38: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; Wed, 23 Aug 2023 21:40:09 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 18/25] spi: microchip-core: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:31 +0800 Message-ID: <20230823133938.1359106-19-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064014_686023_3A0C6F8A X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362511 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 5D032EE49A3 for ; Wed, 23 Aug 2023 13:43: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=0hZqoB/tFuQATVsDVQRQZEmIQ4CBUO0H0k1t69YIDTs=; b=CxP+xmso6kbJdS N62+4WAI/b/SRVFtdmyM3olgLsPuU5UDX2N/rC89wYQl4Xa4ZUnBtKN+r0cRSVqIgSGgae7Ra207z cxYRlbQfATwpx0tPasmWiwF+m5nnRTOKGkj9oyZUajmCIY8VsRYftGqt+UQqg1i7cCWUtXpqMuRlk nDpNR90/hV7UEnZqWrIyDWwXy7mZFYgtZgEBXFF2ZQKUUYOFWGnfcD9QjqeC4TAg77quX4QLNfC0T BHzn8khtuNgxTRFfCM+pDABIcFWGXEUaWwuZaJcAdWK9c3+/W9ClcVJBIApCYYHhBnBJ1nNJhDxmq UcnVKFUS3sFzSkWJuVuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo8N-000kJv-0S; Wed, 23 Aug 2023 13:42:55 +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 1qYo5m-000hW9-2u; Wed, 23 Aug 2023 13:40:18 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6kB3rsyz16Nyl; Wed, 23 Aug 2023 21:38: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; Wed, 23 Aug 2023 21:40:10 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 19/25] spi: mtk-snfi: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:32 +0800 Message-ID: <20230823133938.1359106-20-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064015_481437_8EF8D677 X-CRM114-Status: GOOD ( 11.45 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao Reviewed-by: AngeloGioacchino Del Regno --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362513 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 F3CD5EE4993 for ; Wed, 23 Aug 2023 13:43: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=IOR5Shj/aBmybU4G0hO4gkxaCaN0zuATJJRus9wKPfU=; b=0zCCINR5qoUgsG /S4djqSdyIXzLvkXLAryqP6WNCafkr2AY4E2Mbf2vCZqWoJMOrlsHup6+kVv27FwxsXV2yuGpwZKB 03UlyMNLS7xoSTe5XBxJ69jFVK/q3h97cywdMYELBmYWtF7pGHPypJgLumOnBiXe7M0JpX4WtsHWi 6SLYaiBvSny9NzlwLURsrOF8omp/u59K6susiU2QoMMtZwdOj5oNng3B4tf4q73y3jn5H+7ErFIqr lZ/+FRsrEpG6fWeOK/kj4QVNj5ZsESWggiNWRca4P5SG9xVGXAcXbOwQbfJrD1R/y8Gu7y2Ki9pnD M0980DHlgF5GNgRyCtCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo8m-000ke9-1N; Wed, 23 Aug 2023 13:43:20 +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 1qYo5o-000hX4-01; Wed, 23 Aug 2023 13:40:18 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6kC4Q7nz16Nxc; Wed, 23 Aug 2023 21:38:43 +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; Wed, 23 Aug 2023 21:40:11 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 20/25] spi: npcm-fiu: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:33 +0800 Message-ID: <20230823133938.1359106-21-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064016_595484_97715849 X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 Wed Aug 23 13:39: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: 13362569 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 24DA9EE4993 for ; Wed, 23 Aug 2023 13:43:47 +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=qoLMDUoUEIr4jv3LYUMoR8719w3NngVLUbXpb3VPJd8=; b=2u7NksJKUcmGL9 GemvyA2ziYSPfRhoPhSTWZTaOZLdAHtvyV63JknWtS7ExvL8Zs+Q611lIj3ycffvGyZ321xqT8NuC 5KrI6X8eyMl8jrEI4j8ncqPP5j67bUMMFkIUmBwKQ9L2zyZfo9h4yB978n6yMoYyJf1kvKCcDLZcb t1j1vJaPDcCfnjOnteaCYlx4yU5/6QjAMcgS9jrcRhU6i510ysDNkS2cTUqy/E4Jzyrli4KWjmpf3 2F1GGUFczAv1HEK2cVR9pheiRNRdRINUi/bEMZ8ImfWiBX/vImNFKkZHmbXnVCAUbBuKfwfDoaW3K rYjyL6B41zLhWqHcD6Rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo97-000l6T-39; Wed, 23 Aug 2023 13:43:41 +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 1qYo5p-000hXh-2s; Wed, 23 Aug 2023 13:40:20 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gd6GSvztSCY; Wed, 23 Aug 2023 21:36:29 +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; Wed, 23 Aug 2023 21:40:13 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 21/25] spi: orion: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:34 +0800 Message-ID: <20230823133938.1359106-22-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064018_518180_AEBF9456 X-CRM114-Status: GOOD ( 10.74 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 1f10f5c8e34d..eee9ff4bfa5b 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_controller_put(host); 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_controller(host); pm_runtime_disable(&pdev->dev); From patchwork Wed Aug 23 13:39: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: 13362570 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 647DEEE4993 for ; Wed, 23 Aug 2023 13:43:52 +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=qsvo/4jI+Dtve1bycQmTfC2jqjwSTN2cwwMVlL0zul4=; b=5ElwSy2P6KEyOu HI/SwIX6f8yDNkMjvCTY5w3LT7eHVhi9y636KETODqe8n8GnsHxgpVzfr5qEzDapwQ0hQvHBpN2mJ fOIPeGpEftxTXWu8QA0x8AUJhYpx3OEI+VzybVpanGsL1DZyiTDcoC2EwQI2Iu8iZ7JQMWFJjL/4k hK+l5Ys/FcbPRLKhyP0FyylY9FQMBQtvCYga/dCnP15dZZTE//xFZdoVjsPFKqw+1Iwdnur2JEsfJ 7+yY9TL4LRZVQGg5HXkvphN8qbZJ8lCaObvONQZWxgHIShpESdqRfYZaeyD7BvjP/Hxxpr2bz7O5q I+c7VgaA9ApKAxTI5UxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo9D-000lBl-2d; Wed, 23 Aug 2023 13:43:47 +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 1qYo5q-000hZ8-0l; Wed, 23 Aug 2023 13:40:20 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RW6gf6j7LztSFf; Wed, 23 Aug 2023 21:36:30 +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; Wed, 23 Aug 2023 21:40:14 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 22/25] spi: pic32-sqi: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:35 +0800 Message-ID: <20230823133938.1359106-23-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064018_845196_447D8AB2 X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 883354d0ff52..3f1e5b27776b 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_host; } - 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_host; } - ret = clk_prepare_enable(sqi->sys_clk); - if (ret) { - dev_err(&pdev->dev, "sys clk enable failed\n"); - goto err_free_host; - } - - 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_host; - } - 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_host; } /* 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_host: spi_controller_put(host); 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 Wed Aug 23 13:39: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: 13362571 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 D55A8EE4993 for ; Wed, 23 Aug 2023 13:43: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=5ICg8TFsHFwNlLHRn6TPUKMXQwDtHOo63QyE5otTZB4=; b=B5uAoWXNqdQDaR OKmO2Wo4DeAcTKXfx4emc+YrcHCX/BXXvwiicbY6oYMuEvu8MDS8Bndeh3CjkG4hDrvAEfn0x8QBG RmZJI7ALR4ls8NY6nqqSyNEU48vC5gFjWJFsjrzi/xQJ8KjB9xSYvbjM6m/tFodf12t6S95Xd8oEd 99UxVjpyJk2jzV96u5UeSIS0MGFPkKUAQvsUDr6+sF++xEE23n83HJjsKTfbOXgiDa+Z0Tnr9l95c CUqRKE2y1TQMh5XdBl9sLAIqQnmGuW7JVcC++HrwNCbJtHKJUMdh42vvgoaSk7HjsvJSXkeQBJZcD oJPnWu9/219Lu78cIQNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo9I-000lH3-1A; Wed, 23 Aug 2023 13:43: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 1qYo5r-000ha8-0k; Wed, 23 Aug 2023 13:40:21 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6gs5KpLzNn3J; Wed, 23 Aug 2023 21:36: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; Wed, 23 Aug 2023 21:40:15 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 23/25] spi: pic32: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:36 +0800 Message-ID: <20230823133938.1359106-24-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064019_595888_B7557114 X-CRM114-Status: UNSURE ( 9.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 52b788dac10a..f55b38c577e4 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_host: spi_controller_put(host); 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 Wed Aug 23 13:39: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: 13362572 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 4309AEE49B2 for ; Wed, 23 Aug 2023 13:44: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=bQBE8+MkYCZEWLQhtfCm88q7AGwneToxvrjvuK/KanI=; b=vWeb6F0fhILuU4 KgDsvrs5JclZBKA747ztKoRLdyJjNMwZ5I6i4+efrX2783ii6J9hPhL7EWEoBqs1M4Eazvw1inX94 Zlvsva863Grv1aUqFdiIKIa8TtfMUNTDyy2Qd+FkJsarCkH0JcCVXyw+ZRX+J5U1Ka3WOVuJ7vW2F bgloufUFeAcJkrPxc+7vUD/NPpkaaV+d+7RrXepSJVrkCl9i8uLB2bq4fY6r2lqnnAccO4XCRelYN ahB1wPPTU7MJvUh9HLY+vghqcVICQZTQGedDxCYiq1FhhgrwQImk4CSrjOCxPxiMBpgFDvvByIUeg SWFhUhaqwAqn4GYhO99A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo9M-000lNZ-37; Wed, 23 Aug 2023 13:43:56 +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 1qYo5s-000hbN-37; Wed, 23 Aug 2023 13:40:23 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RW6kH6Qblz16Nym; Wed, 23 Aug 2023 21:38: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; Wed, 23 Aug 2023 21:40:16 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next v2 24/25] spi: spl022: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:37 +0800 Message-ID: <20230823133938.1359106-25-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064021_610334_BB124949 X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Linus Walleij Signed-off-by: Li Zetao Reviewed-by: Jonathan Cameron --- v1 -> v2: Delete the modification of odd formatting. drivers/spi/spi-pl022.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index bb347b6bb6f3..d1b6110b38fc 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); @@ -2240,8 +2234,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) 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: amba_release_regions(adev); @@ -2268,7 +2260,6 @@ pl022_remove(struct amba_device *adev) if (pl022->host_info->enable_dma) pl022_dma_remove(pl022); - clk_disable_unprepare(pl022->clk); amba_release_regions(adev); tasklet_disable(&pl022->pump_transfers); } From patchwork Wed Aug 23 13:39:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13362573 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 CB6ECEE4993 for ; Wed, 23 Aug 2023 13:44:02 +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=ZrrdFKE2UCS2fShfYjjLKoCEQJAN9HXdWiWPuy5DK+Q=; b=rr1Trnl/qSEb3s dVFjox1qMC/tp++hT/AuDQTnlZUfS2cm00D+hurZh+TD58A2Sqvwaua+3H95AgaY7Sw9gy8waA/6s XGrBxQJ9xPHs0B1mtIyW0TFrHaJh5rA6SVWISfCzx+s1Fm30nGMNwfQk+WjvuLfVCsvUV7T/KacLI T8s9yph10vPcbe1fW0LUBb1WoQsfwqFPreVT7gKKkuDhvVzy4B4aBRmJoZMxKuN6fb1K1ZNHHUY6F /a279BlpRpts2/9WVhD1K2i6nIjt3Bz3qLAT1N9s//GtWdgYKrz6Smyp26QRsqTSb8RhfiqjSbvX+ MQremYjh4fGU4h9Htpsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYo9P-000lRN-0o; Wed, 23 Aug 2023 13:43: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 1qYo5u-000hd6-2v; Wed, 23 Aug 2023 13:40:25 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RW6jQ27ZrzTmcD; Wed, 23 Aug 2023 21:38:02 +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; Wed, 23 Aug 2023 21:40:17 +0800 From: Li Zetao To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jonathan Cameron Subject: [PATCH -next v2 25/25] spi: rockchip: Use helper function devm_clk_get_enabled() Date: Wed, 23 Aug 2023 21:39:38 +0800 Message-ID: <20230823133938.1359106-26-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823133938.1359106-1-lizetao1@huawei.com> References: <20230822131237.1022815-1-lizetao1@huawei.com> <20230823133938.1359106-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_064023_498180_FC172E83 X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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. Reviewed-by: Jonathan Cameron Signed-off-by: Li Zetao --- v1 -> v2: None 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 5b010094dace..4b9669da2cf3 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);