From patchwork Thu Aug 17 02:44:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355916 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 B7E35C2FC0F for ; Thu, 17 Aug 2023 02:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PZ83UDXPRpc0axqtEFf+ESYnCGDZPcqz7kDBqAnZzd8=; b=rQQtjBJUCqcqLf xP9BHUlNKh+jfM4XO+2O+/4q0RobZID9vWsTjzxxu88LPWE4+26zDh49ihkn9T3AUDe0oWheZbB+s MGWpFf3kRHKgmWQAiDXBZ/Qs3Avp1fHQS/0twRerHMQ+SUbWMm13AR1qxtpW08BC/K1BsGTa3BA0v Dg4QKqfhasfZ+M3J25UoJteMMURMGVuYopF+TFarf7DRV/kkVU7ocrw+YmCkKjKdfKwNojZoXPpyC +/Dy9IKZZr4brPWlCNEiFADSTRBRli7FOBbSjVhB9OXNQvuLukmfiN84VqiSy0jh1Oh1h8828X5o5 Vf9xxsjd+LZKX2zcslGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1G-005N8i-2d; Thu, 17 Aug 2023 02:45:54 +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 1qWT10-005Mxm-0I; Thu, 17 Aug 2023 02:45:40 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RR8Td4ChWzrSX8; Thu, 17 Aug 2023 10:44:05 +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; Thu, 17 Aug 2023 10:45:26 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 01/11] mtd: spear_smi: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:44:59 +0800 Message-ID: <20230817024509.3951629-2-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194538_369329_E3CDEBD5 X-CRM114-Status: GOOD ( 10.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/devices/spear_smi.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index 93bca5225116..0a35e5236ae5 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c @@ -993,21 +993,17 @@ static int spear_smi_probe(struct platform_device *pdev) dev->num_flashes = MAX_NUM_FLASH_CHIP; } - dev->clk = devm_clk_get(&pdev->dev, NULL); + dev->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(dev->clk)) { ret = PTR_ERR(dev->clk); goto err; } - ret = clk_prepare_enable(dev->clk); - if (ret) - goto err; - ret = devm_request_irq(&pdev->dev, irq, spear_smi_int_handler, 0, pdev->name, dev); if (ret) { dev_err(&dev->pdev->dev, "SMI IRQ allocation failed\n"); - goto err_irq; + goto err; } mutex_init(&dev->lock); @@ -1020,14 +1016,11 @@ static int spear_smi_probe(struct platform_device *pdev) ret = spear_smi_setup_banks(pdev, i, pdata->np[i]); if (ret) { dev_err(&dev->pdev->dev, "bank setup failed\n"); - goto err_irq; + goto err; } } return 0; - -err_irq: - clk_disable_unprepare(dev->clk); err: return ret; } @@ -1056,8 +1049,6 @@ static int spear_smi_remove(struct platform_device *pdev) WARN_ON(mtd_device_unregister(&flash->mtd)); } - clk_disable_unprepare(dev->clk); - return 0; } From patchwork Thu Aug 17 02:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355914 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 6F13FC2FC14 for ; Thu, 17 Aug 2023 02:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iaso+oJPmw6po4KWLTehjn7YMiudblccErw8VpiIr1Y=; b=gAu/kIpkr8vDdv kC+ZJ0bUwWZhAf6qzz8pXpC3qm+M+tG4dWKa+oz+36cL5bpOIaPv4FVh0GUabzamPyOIfE+5Zdewd 0ZTH9maMaklbhYKeZCSdWx+Obv1y0XF+B9x84anEES643VDE7UL9iROFhrcoiN2ugBD8cYJJE3ueA w84cBuiXM+qBn7u5yctRNZwdoj0KPGCNoAkV76C1xXUdDWOKN4CFMbaY7msg5SZBI29QDOelG5jEq SDYr137o5S+sDk2V7hRcDeMoE2stTq4OmtAzihsn9E93QNPX8Q9pm4typKWhwnVZmQxdwEYzvwO4v q5LQrRu1Ls0uUDmq2nIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT13-005N2n-2w; Thu, 17 Aug 2023 02:45:41 +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 1qWT0z-005Mxn-0i; Thu, 17 Aug 2023 02:45:38 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RR8Sp01SMzVkS3; Thu, 17 Aug 2023 10:43:21 +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; Thu, 17 Aug 2023 10:45:27 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 02/11] mtd: rawnand: arasan: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:00 +0800 Message-ID: <20230817024509.3951629-3-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194537_698281_8C491B6A X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/arasan-nand-controller.c | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/mtd/nand/raw/arasan-nand-controller.c b/drivers/mtd/nand/raw/arasan-nand-controller.c index 906eef70cb6d..4621ec549cc7 100644 --- a/drivers/mtd/nand/raw/arasan-nand-controller.c +++ b/drivers/mtd/nand/raw/arasan-nand-controller.c @@ -1440,45 +1440,29 @@ static int anfc_probe(struct platform_device *pdev) anfc_reset(nfc); - nfc->controller_clk = devm_clk_get(&pdev->dev, "controller"); + nfc->controller_clk = devm_clk_get_enabled(&pdev->dev, "controller"); if (IS_ERR(nfc->controller_clk)) return PTR_ERR(nfc->controller_clk); - nfc->bus_clk = devm_clk_get(&pdev->dev, "bus"); + nfc->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus"); if (IS_ERR(nfc->bus_clk)) return PTR_ERR(nfc->bus_clk); - ret = clk_prepare_enable(nfc->controller_clk); - if (ret) - return ret; - - ret = clk_prepare_enable(nfc->bus_clk); - if (ret) - goto disable_controller_clk; - ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); if (ret) - goto disable_bus_clk; + return ret; ret = anfc_parse_cs(nfc); if (ret) - goto disable_bus_clk; + return ret; ret = anfc_chips_init(nfc); if (ret) - goto disable_bus_clk; + return ret; platform_set_drvdata(pdev, nfc); return 0; - -disable_bus_clk: - clk_disable_unprepare(nfc->bus_clk); - -disable_controller_clk: - clk_disable_unprepare(nfc->controller_clk); - - return ret; } static void anfc_remove(struct platform_device *pdev) @@ -1486,9 +1470,6 @@ static void anfc_remove(struct platform_device *pdev) struct arasan_nfc *nfc = platform_get_drvdata(pdev); anfc_chips_cleanup(nfc); - - clk_disable_unprepare(nfc->bus_clk); - clk_disable_unprepare(nfc->controller_clk); } static const struct of_device_id anfc_ids[] = { From patchwork Thu Aug 17 02:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355913 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 7296FC2FC15 for ; Thu, 17 Aug 2023 02:46: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EDm1DXQAX9nMaBrVDyEFghTzUPReie6QxdNhyAYi2YA=; b=PfVhjjOA9JZILW naufi5Jy0+S/LWcEx1JSgcWve98aUaBWRsAvrrb0Vr/syQZF9PNQbQCl68Kxb47x1XneRvVEWNYQU yW5SHmvTOtVdS6tL+MalTombbe76HgA+cPb2OIDtVlzd+E3rby7hr+Fs4GLZr2vFLKBxn4/B2ulUZ uL4QRReMABJVkeQ27OMPgWsD4linJFLHOpFhEndcZ8Gcnt0+5Jypjht2JznNPzXvEQXKNmbLdV6Pa N3ecfW/+Atw74ZX6YLap5lb7fvBAhs0n4UozxIY4BejJ84HTFYG+PqxTT0khmjXStorQb7MLkfUJ7 kiTekC4FOljVZZomWLoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT12-005N1W-30; Thu, 17 Aug 2023 02:45: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 1qWT0y-005Mxq-2Z; Thu, 17 Aug 2023 02:45:38 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RR8Sq0XFRzVkPQ; Thu, 17 Aug 2023 10:43: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; Thu, 17 Aug 2023 10:45:28 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 03/11] mtd: rawnand: fsmc: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:01 +0800 Message-ID: <20230817024509.3951629-4-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194537_057939_4C3CA3B6 X-CRM114-Status: GOOD ( 11.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/fsmc_nand.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c index 7b4742420dfc..ab1b9a5c93e9 100644 --- a/drivers/mtd/nand/raw/fsmc_nand.c +++ b/drivers/mtd/nand/raw/fsmc_nand.c @@ -1066,16 +1066,12 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) host->regs_va = base + FSMC_NOR_REG_SIZE + (host->bank * FSMC_NAND_BANK_SZ); - host->clk = devm_clk_get(&pdev->dev, NULL); + host->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(host->clk)) { dev_err(&pdev->dev, "failed to fetch block clock\n"); return PTR_ERR(host->clk); } - ret = clk_prepare_enable(host->clk); - if (ret) - return ret; - /* * This device ID is actually a common AMBA ID as used on the * AMBA PrimeCell bus. However it is not a PrimeCell. @@ -1157,7 +1153,6 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) dma_release_channel(host->read_dma_chan); disable_clk: fsmc_nand_disable(host); - clk_disable_unprepare(host->clk); return ret; } @@ -1182,7 +1177,6 @@ static void fsmc_nand_remove(struct platform_device *pdev) dma_release_channel(host->write_dma_chan); dma_release_channel(host->read_dma_chan); } - clk_disable_unprepare(host->clk); } } From patchwork Thu Aug 17 02:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355917 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 18030C05052 for ; Thu, 17 Aug 2023 02:46: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M86iMSNGxUfPtjNrOxfTM2xBxXAxFfxJd5O6vjHwcoo=; b=TR+D6ZM5yjldFf sjzfffD9Wk2YOUeT6Ht68YFajuG9n2BDykDEUpQ5kzI26y69JEwCiT1Zhgeq6KYL3xIGlrJkoHag1 KBGHS9cIN4tzFSLuwOcsPzlv62mBhf7gIwR4NG5Km3XIPTQMp5h68HGOgt2VD6mZz7QUv/pLs35P/ 5ecJOlPs+jsLhBNuU9JOZ3ypBVDU2Ik9iioTCGUBWZ3XxWREGHlh/Wptb1EqFIr7nakr8AVbGPF6A W4qNjnS7/y+WXgRD8wSEDf/D4iTob2Teo3Rheg+dQA5rp36OgaOJ7Si48QCo637nDLEeQ9G3SHpPi ASg8Sr740yU/XB/fxP2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1H-005N9d-2o; Thu, 17 Aug 2023 02:45:55 +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 1qWT10-005Mxu-1b; Thu, 17 Aug 2023 02:45:40 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RR8Rr56nPzFqjm; Thu, 17 Aug 2023 10:42:32 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 17 Aug 2023 10:45:29 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 04/11] mtd: rawnand: intel: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:02 +0800 Message-ID: <20230817024509.3951629-5-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194539_015082_714F4B4C X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/intel-nand-controller.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c index a9909eb08124..cb5d88f42297 100644 --- a/drivers/mtd/nand/raw/intel-nand-controller.c +++ b/drivers/mtd/nand/raw/intel-nand-controller.c @@ -626,16 +626,10 @@ static int ebu_nand_probe(struct platform_device *pdev) goto err_of_node_put; } - ebu_host->clk = devm_clk_get(dev, NULL); + ebu_host->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(ebu_host->clk)) { ret = dev_err_probe(dev, PTR_ERR(ebu_host->clk), - "failed to get clock\n"); - goto err_of_node_put; - } - - ret = clk_prepare_enable(ebu_host->clk); - if (ret) { - dev_err(dev, "failed to enable clock: %d\n", ret); + "failed to get and enable clock\n"); goto err_of_node_put; } @@ -643,7 +637,7 @@ static int ebu_nand_probe(struct platform_device *pdev) if (IS_ERR(ebu_host->dma_tx)) { ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx), "failed to request DMA tx chan!.\n"); - goto err_disable_unprepare_clk; + goto err_of_node_put; } ebu_host->dma_rx = dma_request_chan(dev, "rx"); @@ -698,8 +692,6 @@ static int ebu_nand_probe(struct platform_device *pdev) nand_cleanup(&ebu_host->chip); err_cleanup_dma: ebu_dma_cleanup(ebu_host); -err_disable_unprepare_clk: - clk_disable_unprepare(ebu_host->clk); err_of_node_put: of_node_put(chip_np); @@ -716,7 +708,6 @@ static void ebu_nand_remove(struct platform_device *pdev) nand_cleanup(&ebu_host->chip); ebu_nand_disable(&ebu_host->chip); ebu_dma_cleanup(ebu_host); - clk_disable_unprepare(ebu_host->clk); } static const struct of_device_id ebu_nand_match[] = { From patchwork Thu Aug 17 02:45:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355919 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 4415EC05052 for ; Thu, 17 Aug 2023 02:46:25 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4/yuLO77B1nIT3Cz/OQyEzOVIa9SJ2XC7svo3LBiWlQ=; b=R4wym8LEV/RngZ A/WazcVPiJB3lR3C24dYY6HkHDedehRhYvAwRGm3AJrs7ZH8loIfSOvR7TCiZFEEExL7mwxoHVGLU OhaQediRMSDYLjA9oPSyocIMbUKtzoLdziCd87Nd51PVGsEa7H1a+e04xxxlt2A2I2GKFxf0JUyJc 6R5cVaD6ryiViGjW98oKwxOgJatGPaQ9+zZJ1on+UENz9rr5pxZrfsL1dBUOyUAxABfhpb/wQjGQ6 4UUcXFnFHJJFmtuCoKHPNPh5ufhbp+1eQw0txPjCcKCntK14FlPZ0nP6wpABe5uUQixWJQUxHxqbN QA/d/sxVKIL6oGM+wEdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1G-005N8C-0m; Thu, 17 Aug 2023 02:45:54 +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 1qWT0z-005MyE-2t; Thu, 17 Aug 2023 02:45:40 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RR8Tk182HzrSX7; Thu, 17 Aug 2023 10:44:10 +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; Thu, 17 Aug 2023 10:45:30 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 05/11] mtd: rawnand: lpc32xx_slc: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:03 +0800 Message-ID: <20230817024509.3951629-6-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194538_370576_4A110B80 X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/lpc32xx_slc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c index 2201264d3c37..1c5fa855b9f2 100644 --- a/drivers/mtd/nand/raw/lpc32xx_slc.c +++ b/drivers/mtd/nand/raw/lpc32xx_slc.c @@ -871,15 +871,12 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) mtd->dev.parent = &pdev->dev; /* Get NAND clock */ - host->clk = devm_clk_get(&pdev->dev, NULL); + host->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(host->clk)) { dev_err(&pdev->dev, "Clock failure\n"); res = -ENOENT; goto enable_wp; } - res = clk_prepare_enable(host->clk); - if (res) - goto enable_wp; /* Set NAND IO addresses and command/ready functions */ chip->legacy.IO_ADDR_R = SLC_DATA(host->io_base); @@ -907,13 +904,13 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) GFP_KERNEL); if (host->data_buf == NULL) { res = -ENOMEM; - goto unprepare_clk; + goto enable_wp; } res = lpc32xx_nand_dma_setup(host); if (res) { res = -EIO; - goto unprepare_clk; + goto enable_wp; } /* Find NAND device */ @@ -934,8 +931,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) nand_cleanup(chip); release_dma: dma_release_channel(host->dma_chan); -unprepare_clk: - clk_disable_unprepare(host->clk); enable_wp: lpc32xx_wp_enable(host); @@ -962,7 +957,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev) tmp &= ~SLCCFG_CE_LOW; writel(tmp, SLC_CTRL(host->io_base)); - clk_disable_unprepare(host->clk); lpc32xx_wp_enable(host); } From patchwork Thu Aug 17 02:45:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355918 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 AF874C2FC0F for ; Thu, 17 Aug 2023 02:46:23 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JvYHGKQdctX+Cd2SO2pRl6P40bjDVlmpspo8mU/82/Y=; b=3PyEEru8RKy+kh 5MC43E15YEolMNeSza5WEhzxQIR3s+hlaJ0uA1DbS8cVFLI1ntsHoD9dhk5blmZ6XTlPiRYy4HdVD c+vvtZacawyzqCe1wmUhTkyGMf2MwQi/R+baAOQmawRGeFkwR6S8jr9v3Sr62Y1t6UTyMrZe4rtEK zf/F80qaAqoyYvs8ald3PiYE5wD4z7jhZBzke7gELyGAyXh4batjZp+trAe1W1Cy8nLqlJK61yxew WdLM4NtGHROvLIOkPMML+aaPr1D+wPK2/k1E5LlCPFqA7yZ2vvKO/yjtpdYghZMMqG8EwzJQ0bbHw Qf0hSg1TFM6EiB0uSOdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1H-005N99-18; Thu, 17 Aug 2023 02:45:55 +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 1qWT10-005MyX-0I; Thu, 17 Aug 2023 02:45:40 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RR8St45rwzVkSF; Thu, 17 Aug 2023 10:43:26 +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; Thu, 17 Aug 2023 10:45:31 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 06/11] mtd: rawnand: mpc5121: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:04 +0800 Message-ID: <20230817024509.3951629-7-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194538_368017_128E82AF X-CRM114-Status: GOOD ( 10.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/mpc5121_nfc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/mpc5121_nfc.c b/drivers/mtd/nand/raw/mpc5121_nfc.c index 6e8e790f84e7..215610f808f1 100644 --- a/drivers/mtd/nand/raw/mpc5121_nfc.c +++ b/drivers/mtd/nand/raw/mpc5121_nfc.c @@ -595,8 +595,6 @@ static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) struct nand_chip *chip = mtd_to_nand(mtd); struct mpc5121_nfc_prv *prv = nand_get_controller_data(chip); - clk_disable_unprepare(prv->clk); - if (prv->csreg) iounmap(prv->csreg); } @@ -717,17 +715,12 @@ static int mpc5121_nfc_probe(struct platform_device *op) } /* Enable NFC clock */ - clk = devm_clk_get(dev, "ipg"); + clk = devm_clk_get_enabled(dev, "ipg"); if (IS_ERR(clk)) { - dev_err(dev, "Unable to acquire NFC clock!\n"); + dev_err(dev, "Unable to acquire and enable NFC clock!\n"); retval = PTR_ERR(clk); goto error; } - retval = clk_prepare_enable(clk); - if (retval) { - dev_err(dev, "Unable to enable NFC clock!\n"); - goto error; - } prv->clk = clk; /* Reset NAND Flash controller */ From patchwork Thu Aug 17 02:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355920 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 511B5C2FC0F for ; Thu, 17 Aug 2023 02:46:51 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vQXdKmZHWHBPVCqtUAf3ANG3elC4zm7HWusui4V/SYo=; b=cDfcKiKK5aY/35 G7oj3jpcnkqA+pwpu9bpf1FtB0MB63dwfaurEyUiF9l810DQWnwOPipqCJv6YXIEGEBiOcrXIhtrS ObDNbsUF3T3pLcsLkfH34SOv4yZAJv6rJD0rrOrLOLb74Zu1pLfK9Q7F9b4k0xMBciY+pKgWAUniF 2W+IGtcgVEoI+gTTRUSAswxpdDXKdm+otH0guJNHmIsG0grxT1QbJaQcilNeCu54jC7I2sLYB+We2 hCjsdIhutev96zE45fG9nnf107HisTQbmQz+pyLZf9Q24v1i1CS+4LWD4V8is7q29rc1H+JJe2EWv +oFhHPwJQl+QhK4sr5zA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1l-005NXv-2t; Thu, 17 Aug 2023 02:46:25 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWT12-005Mz6-1o; Thu, 17 Aug 2023 02:45:42 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RR8Tm1WZ0zrSXH; Thu, 17 Aug 2023 10:44: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; Thu, 17 Aug 2023 10:45:33 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 07/11] mtd: rawnand: mtk: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:05 +0800 Message-ID: <20230817024509.3951629-8-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194541_014890_2F4A3D8E X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. The mtk_nfc_enable_clk() is a helper function that enables the "clk->nfi_clk" and "clk->pad_clk", it can be combined into devm_clk_get_enabled(). Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/mtk_nand.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c index b6eb8cb6b5e9..0d185e650aaf 100644 --- a/drivers/mtd/nand/raw/mtk_nand.c +++ b/drivers/mtd/nand/raw/mtk_nand.c @@ -1545,40 +1545,36 @@ static int mtk_nfc_probe(struct platform_device *pdev) goto release_ecc; } - nfc->clk.nfi_clk = devm_clk_get(dev, "nfi_clk"); + nfc->clk.nfi_clk = devm_clk_get_enabled(dev, "nfi_clk"); if (IS_ERR(nfc->clk.nfi_clk)) { dev_err(dev, "no clk\n"); ret = PTR_ERR(nfc->clk.nfi_clk); goto release_ecc; } - nfc->clk.pad_clk = devm_clk_get(dev, "pad_clk"); + nfc->clk.pad_clk = devm_clk_get_enabled(dev, "pad_clk"); if (IS_ERR(nfc->clk.pad_clk)) { dev_err(dev, "no pad clk\n"); ret = PTR_ERR(nfc->clk.pad_clk); goto release_ecc; } - ret = mtk_nfc_enable_clk(dev, &nfc->clk); - if (ret) - goto release_ecc; - irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = -EINVAL; - goto clk_disable; + goto release_ecc; } ret = devm_request_irq(dev, irq, mtk_nfc_irq, 0x0, "mtk-nand", nfc); if (ret) { dev_err(dev, "failed to request nfi irq\n"); - goto clk_disable; + goto release_ecc; } ret = dma_set_mask(dev, DMA_BIT_MASK(32)); if (ret) { dev_err(dev, "failed to set dma mask\n"); - goto clk_disable; + goto release_ecc; } platform_set_drvdata(pdev, nfc); @@ -1586,14 +1582,11 @@ static int mtk_nfc_probe(struct platform_device *pdev) ret = mtk_nfc_nand_chips_init(dev, nfc); if (ret) { dev_err(dev, "failed to init nand chips\n"); - goto clk_disable; + goto release_ecc; } return 0; -clk_disable: - mtk_nfc_disable_clk(&nfc->clk); - release_ecc: mtk_ecc_release(nfc->ecc); @@ -1618,7 +1611,6 @@ static void mtk_nfc_remove(struct platform_device *pdev) } mtk_ecc_release(nfc->ecc); - mtk_nfc_disable_clk(&nfc->clk); } #ifdef CONFIG_PM_SLEEP From patchwork Thu Aug 17 02:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355924 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 1D08EC2FC14 for ; Thu, 17 Aug 2023 02:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FIhwwNr7aVdeAlphQ2sJTsbdz5vPT6PSIjrfFZqqKVk=; b=M+9TBEC1XD95Wj B9Uh2Xi+5TiqFibxhsd1wWxJ/FD4jgHFuUDnFSChP2hYv2+ayGeSeNBvD51LwmUJs4AOIcNCVAb4e Su7p4f/U0fiJYQgu0wo7R5Tb+DBpMgv9DEU4d0YS9xwL3pw34It+L4k8TI/2hPqnYfC/ic4AbMIYE ggVrrIHdEgP0gogE2qxrHkZpDMw889+x9vL8JNKgoCkx73urxbF23jTA3/FhsJ31R9RZ0mhoinglT JAu3Wq1hR/XkqbLJA13BnbHwrCpplalwfwHXHh958k/94oSm47t2eGe4SQXLl1MQo3q39lGfqxavQ +SmNmUQT3Jlqvp4CdQ7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT2A-005Nvx-2t; Thu, 17 Aug 2023 02:46:50 +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 1qWT11-005Mzr-2J; Thu, 17 Aug 2023 02:45:41 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RR8R957c5ztRwX; Thu, 17 Aug 2023 10:41:57 +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; Thu, 17 Aug 2023 10:45:34 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 08/11] mtd: rawnand: stm32_fmc2: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:06 +0800 Message-ID: <20230817024509.3951629-9-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194540_286131_D34A7DF1 X-CRM114-Status: GOOD ( 11.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c b/drivers/mtd/nand/raw/stm32_fmc2_nand.c index 2f9e43f64dd7..88811139aaf5 100644 --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c @@ -1951,21 +1951,17 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev) init_completion(&nfc->complete); - nfc->clk = devm_clk_get(nfc->cdev, NULL); - if (IS_ERR(nfc->clk)) + nfc->clk = devm_clk_get_enabled(nfc->cdev, NULL); + if (IS_ERR(nfc->clk)) { + dev_err(dev, "can not get and enable the clock\n"); return PTR_ERR(nfc->clk); - - ret = clk_prepare_enable(nfc->clk); - if (ret) { - dev_err(dev, "can not enable the clock\n"); - return ret; } rstc = devm_reset_control_get(dev, NULL); if (IS_ERR(rstc)) { ret = PTR_ERR(rstc); if (ret == -EPROBE_DEFER) - goto err_clk_disable; + return ret; } else { reset_control_assert(rstc); reset_control_deassert(rstc); @@ -2018,9 +2014,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev) sg_free_table(&nfc->dma_data_sg); sg_free_table(&nfc->dma_ecc_sg); -err_clk_disable: - clk_disable_unprepare(nfc->clk); - return ret; } @@ -2045,8 +2038,6 @@ static void stm32_fmc2_nfc_remove(struct platform_device *pdev) sg_free_table(&nfc->dma_data_sg); sg_free_table(&nfc->dma_ecc_sg); - clk_disable_unprepare(nfc->clk); - stm32_fmc2_nfc_wp_enable(nand); } From patchwork Thu Aug 17 02:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355922 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 D97E5C2FC0F for ; Thu, 17 Aug 2023 02:47:07 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xZgnQzlIixPzueIyOcOcAztjeglMpburnbtqaGpt27A=; b=mGYpNo7FtuyeiW DQmnyg2aytRQ58wupX8eB/EtyaSEEGda/nrXL4xQWbGYkFgNrXXsAZzvCeno8kbIHk1Ri67V/Bgp5 nTEVdvLguOUPF+D6WgXVqmuA96UwG/Ai2uaFRUAWGejRi/GyInSxUIlLT8/2Z+coaFy3Br0lq8JNq gAYdcZY/7LF9MrVMmwWUiDMdulyZCcTVfyHsCIpY+A255MKQyUxI/JWyotcFeT+ohwsYGKFweKmGV Uxv6SgpzBHUaNPFk59iUrTXgXW1CS+lWHuznYCtBDRxf9ISg4jZPNLVexaF9NBh9oqESZXfrdoKk/ oLL4cLQeY5WVv5Y8IktQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT20-005NmD-0C; Thu, 17 Aug 2023 02:46:40 +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 1qWT14-005Mzp-1I; Thu, 17 Aug 2023 02:45:44 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RR8Tq4PPFz1GDc3; Thu, 17 Aug 2023 10:44:15 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 17 Aug 2023 10:45:35 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 09/11] mtd: rawnand: sunxi: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:07 +0800 Message-ID: <20230817024509.3951629-10-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194542_869961_23F6E6FD X-CRM114-Status: GOOD ( 11.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/sunxi_nand.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 64c09eae951d..9abf38049d35 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -2094,37 +2094,26 @@ static int sunxi_nfc_probe(struct platform_device *pdev) if (irq < 0) return irq; - nfc->ahb_clk = devm_clk_get(dev, "ahb"); + nfc->ahb_clk = devm_clk_get_enabled(dev, "ahb"); if (IS_ERR(nfc->ahb_clk)) { dev_err(dev, "failed to retrieve ahb clk\n"); return PTR_ERR(nfc->ahb_clk); } - ret = clk_prepare_enable(nfc->ahb_clk); - if (ret) - return ret; - - nfc->mod_clk = devm_clk_get(dev, "mod"); + nfc->mod_clk = devm_clk_get_enabled(dev, "mod"); if (IS_ERR(nfc->mod_clk)) { dev_err(dev, "failed to retrieve mod clk\n"); - ret = PTR_ERR(nfc->mod_clk); - goto out_ahb_clk_unprepare; + return PTR_ERR(nfc->mod_clk); } - ret = clk_prepare_enable(nfc->mod_clk); - if (ret) - goto out_ahb_clk_unprepare; - nfc->reset = devm_reset_control_get_optional_exclusive(dev, "ahb"); - if (IS_ERR(nfc->reset)) { - ret = PTR_ERR(nfc->reset); - goto out_mod_clk_unprepare; - } + if (IS_ERR(nfc->reset)) + return PTR_ERR(nfc->reset); ret = reset_control_deassert(nfc->reset); if (ret) { dev_err(dev, "reset err %d\n", ret); - goto out_mod_clk_unprepare; + return ret; } nfc->caps = of_device_get_match_data(&pdev->dev); @@ -2163,10 +2152,6 @@ static int sunxi_nfc_probe(struct platform_device *pdev) dma_release_channel(nfc->dmac); out_ahb_reset_reassert: reset_control_assert(nfc->reset); -out_mod_clk_unprepare: - clk_disable_unprepare(nfc->mod_clk); -out_ahb_clk_unprepare: - clk_disable_unprepare(nfc->ahb_clk); return ret; } @@ -2181,8 +2166,6 @@ static void sunxi_nfc_remove(struct platform_device *pdev) if (nfc->dmac) dma_release_channel(nfc->dmac); - clk_disable_unprepare(nfc->mod_clk); - clk_disable_unprepare(nfc->ahb_clk); } static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = { From patchwork Thu Aug 17 02:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355923 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 9E7A6C05052 for ; Thu, 17 Aug 2023 02:47:15 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LngrbGp6lilR+ReRbKQpMahvJKfTutK5WOgs6ACkLTg=; b=DJP6hL+nPFR0sg tHMa3LL2dGDdKiIkoW8OaF8M7Y8y5S9vaX1rmXKKiuh3SaxD/GPBOueeeJ8MGoKahdhwNhdBqME57 4MG7BlPLh/HnaBzJO56/6/LhcwOkJMA3q4+cDXBZdMPD8UeOUFlXO6Tm4LDVl9BwFdOCKBeEN+sqE M00tr3YqhxGMrVfSe4ujdb4HWLWlzq1Julp9KjOcLnkcpviszxqw2gxsvdEA+vIItQho99CTsjEtB b28RZZTAYjBfxdct4vo05KGA3m1EC1ua5VgNwhKEGZ1LMogm33vCcy3EWApAokL+oZPDvCCww7Zeb VNzJzJNyp0dJ+ylqFyTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT2C-005NxA-0j; Thu, 17 Aug 2023 02:46:52 +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 1qWT12-005N0v-12; Thu, 17 Aug 2023 02:45:42 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RR8Rz442wzFqjg; Thu, 17 Aug 2023 10:42:39 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 17 Aug 2023 10:45:36 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 10/11] mtd: rawnand: vf610_nfc: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:08 +0800 Message-ID: <20230817024509.3951629-11-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194540_807432_BB0AA0D5 X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao --- drivers/mtd/nand/raw/vf610_nfc.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index dcdf33dbaef2..1ce9d5c2b1f7 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -834,21 +834,15 @@ static int vf610_nfc_probe(struct platform_device *pdev) if (IS_ERR(nfc->regs)) return PTR_ERR(nfc->regs); - nfc->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(nfc->clk)) + nfc->clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(nfc->clk)) { + dev_err(nfc->dev, "Unable to get and enable clock!\n"); return PTR_ERR(nfc->clk); - - err = clk_prepare_enable(nfc->clk); - if (err) { - dev_err(nfc->dev, "Unable to enable clock!\n"); - return err; } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); - if (!of_id) { - err = -ENODEV; - goto err_disable_clk; - } + if (!of_id) + return -ENODEV; nfc->variant = (enum vf610_nfc_variant)of_id->data; @@ -858,9 +852,8 @@ static int vf610_nfc_probe(struct platform_device *pdev) if (nand_get_flash_node(chip)) { dev_err(nfc->dev, "Only one NAND chip supported!\n"); - err = -EINVAL; of_node_put(child); - goto err_disable_clk; + return -EINVAL; } nand_set_flash_node(chip, child); @@ -869,8 +862,7 @@ static int vf610_nfc_probe(struct platform_device *pdev) if (!nand_get_flash_node(chip)) { dev_err(nfc->dev, "NAND chip sub-node missing!\n"); - err = -ENODEV; - goto err_disable_clk; + return -ENODEV; } chip->options |= NAND_NO_SUBPAGE_WRITE; @@ -880,7 +872,7 @@ static int vf610_nfc_probe(struct platform_device *pdev) err = devm_request_irq(nfc->dev, irq, vf610_nfc_irq, 0, DRV_NAME, nfc); if (err) { dev_err(nfc->dev, "Error requesting IRQ!\n"); - goto err_disable_clk; + return err; } vf610_nfc_preinit_controller(nfc); @@ -892,7 +884,7 @@ static int vf610_nfc_probe(struct platform_device *pdev) /* Scan the NAND chip */ err = nand_scan(chip, 1); if (err) - goto err_disable_clk; + return err; platform_set_drvdata(pdev, nfc); @@ -904,8 +896,6 @@ static int vf610_nfc_probe(struct platform_device *pdev) err_cleanup_nand: nand_cleanup(chip); -err_disable_clk: - clk_disable_unprepare(nfc->clk); return err; } @@ -918,7 +908,6 @@ static void vf610_nfc_remove(struct platform_device *pdev) ret = mtd_device_unregister(nand_to_mtd(chip)); WARN_ON(ret); nand_cleanup(chip); - clk_disable_unprepare(nfc->clk); } #ifdef CONFIG_PM_SLEEP From patchwork Thu Aug 17 02:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13355921 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 272CCC05052 for ; Thu, 17 Aug 2023 02:46: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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jPIYrft1/P3FRCv+ZAGTZov2RB2Yjf8+m4h3L4H3j8M=; b=F8ytkToqDMPOBt W6QSSK62S9lZvopLUr/yYYMNX9Q154K2D0hVseRUsh2uX9zqAVy0c4gj7AqcVW+uO/vYZO63nvFYT C19hmY3sZTRpcscHtWi+pmk7+frNiNdZ9W51vA1124qmB/F76qXv3tkY59Ukx11dhD4DZyqxTekUa pINPT14kC4hasjk52qTRx4vO5spmm5gfEuuu4PWYYyONAR8kohD/5mDXHbe+iHoi90EuG7Az3DWNG 62rOMMuQDXV00l4oxWWfciuuFr80l9oPj6y+62zkc8aI44QUYy2mLocEAkjzN8I3QvR45fYpxLsSB 82mqY0gXEJF7abcMgNQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWT1q-005Nd7-2w; Thu, 17 Aug 2023 02:46:30 +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 1qWT13-005N1D-17; Thu, 17 Aug 2023 02:45:43 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RR8RL6pvVzNn0V; Thu, 17 Aug 2023 10:42:06 +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; Thu, 17 Aug 2023 10:45:37 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , Subject: [PATCH -next 11/11] mtd: spi-nor: Use helper function devm_clk_get_enabled() Date: Thu, 17 Aug 2023 10:45:09 +0800 Message-ID: <20230817024509.3951629-12-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817024509.3951629-1-lizetao1@huawei.com> References: <20230817024509.3951629-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-20230816_194541_820368_B452318F X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, paul@crapouillou.net, dmitry.torokhov@gmail.com, philmd@linaro.org, geert+renesas@glider.be, martin.blumenstingl@googlemail.com, yangyingliang@huawei.com, lizetao1@huawei.com, christophe.leroy@csgroup.eu, linux-sunxi@lists.linux.dev, rogerq@kernel.org, linux-mtd@lists.infradead.org, u.kleine-koenig@pengutronix.de, christophe.kerello@foss.st.com, linux-mediatek@lists.infradead.org, jinpu.wang@ionos.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, heiko@sntech.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After the commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), it can replace the pair of functions, devm_clk_get() and clk_prepare_enable() with a single helper function devm_clk_get_enabled(). Moreover, the driver will keeps a clock prepared (or enabled) during the whole lifetime of the driver, it is unnecessary to unprepare and disable clock explicitly when remove driver or in the error handling path. Signed-off-by: Li Zetao Reviewed-by: Miquel Raynal --- drivers/mtd/spi-nor/controllers/nxp-spifi.c | 33 ++++----------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/spi-nor/controllers/nxp-spifi.c b/drivers/mtd/spi-nor/controllers/nxp-spifi.c index 337e83bf3362..5d8f47ab146f 100644 --- a/drivers/mtd/spi-nor/controllers/nxp-spifi.c +++ b/drivers/mtd/spi-nor/controllers/nxp-spifi.c @@ -394,30 +394,18 @@ static int nxp_spifi_probe(struct platform_device *pdev) if (IS_ERR(spifi->flash_base)) return PTR_ERR(spifi->flash_base); - spifi->clk_spifi = devm_clk_get(&pdev->dev, "spifi"); + spifi->clk_spifi = devm_clk_get_enabled(&pdev->dev, "spifi"); if (IS_ERR(spifi->clk_spifi)) { - dev_err(&pdev->dev, "spifi clock not found\n"); + dev_err(&pdev->dev, "spifi clock not found or unable to enable\n"); return PTR_ERR(spifi->clk_spifi); } - spifi->clk_reg = devm_clk_get(&pdev->dev, "reg"); + spifi->clk_reg = devm_clk_get_enabled(&pdev->dev, "reg"); if (IS_ERR(spifi->clk_reg)) { - dev_err(&pdev->dev, "reg clock not found\n"); + dev_err(&pdev->dev, "reg clock not found or unable to enable\n"); return PTR_ERR(spifi->clk_reg); } - ret = clk_prepare_enable(spifi->clk_reg); - if (ret) { - dev_err(&pdev->dev, "unable to enable reg clock\n"); - return ret; - } - - ret = clk_prepare_enable(spifi->clk_spifi); - if (ret) { - dev_err(&pdev->dev, "unable to enable spifi clock\n"); - goto dis_clk_reg; - } - spifi->dev = &pdev->dev; platform_set_drvdata(pdev, spifi); @@ -430,24 +418,17 @@ static int nxp_spifi_probe(struct platform_device *pdev) flash_np = of_get_next_available_child(pdev->dev.of_node, NULL); if (!flash_np) { dev_err(&pdev->dev, "no SPI flash device to configure\n"); - ret = -ENODEV; - goto dis_clks; + return -ENODEV; } ret = nxp_spifi_setup_flash(spifi, flash_np); of_node_put(flash_np); if (ret) { dev_err(&pdev->dev, "unable to setup flash chip\n"); - goto dis_clks; + return ret; } return 0; - -dis_clks: - clk_disable_unprepare(spifi->clk_spifi); -dis_clk_reg: - clk_disable_unprepare(spifi->clk_reg); - return ret; } static int nxp_spifi_remove(struct platform_device *pdev) @@ -455,8 +436,6 @@ static int nxp_spifi_remove(struct platform_device *pdev) struct nxp_spifi *spifi = platform_get_drvdata(pdev); mtd_device_unregister(&spifi->nor.mtd); - clk_disable_unprepare(spifi->clk_spifi); - clk_disable_unprepare(spifi->clk_reg); return 0; }