From patchwork Sat Sep 7 03:10:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13794973 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 DEF49E6FE47 for ; Sat, 7 Sep 2024 03:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=jMbVVReWvkNIKhbh8fiJVJaZWXhI4NXu9tg089fSlWE=; b=y2s5GAGuavL8mvO+xMfGlFXYrq XnLCnMeVf3axgMo7cM/rON5nDcQ6wtdXQoC6b7D9LHfvjkDbl4iS8gAMmwKhjTvrVg6P/7zPEqDoO KWB2A+WSiNZ7E7eQjy0CE9Lcr2UZbCi+qeEzFMK6RqcGnVGNpyWlSZKnF+qA3XzEJmwoFo5/Tnty7 WAHpqs80VXcVjRjYRK6UEndBeR4dEBMoG2Ig9OAVyhIh8GPsjuQA5SS7oCuVaz8HvX4DDuxTIfNM0 wPAMtz4prFEoRc+94p1LJR6JFc8UX87BF1wkdDjaW8rd4qrPFYsmcJAiU9CPstmG0d44NJxjenAnX XobxxMJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smljc-0000000EA8M-2Dvz; Sat, 07 Sep 2024 03:03:36 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhY-0000000E9UF-2hKR; Sat, 07 Sep 2024 03:01:30 +0000 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4X0yXT3KPFz1S9f6; Sat, 7 Sep 2024 11:00:57 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id CB8E91400CF; Sat, 7 Sep 2024 11:01:21 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:20 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH -next v2 2/2] media: siano: remove redundant null pointer checks in cec_devnode_init() Date: Sat, 7 Sep 2024 11:10:00 +0800 Message-ID: <20240907031009.3591057-3-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200128_966591_A729D703 X-CRM114-Status: UNSURE ( 7.80 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the debugfs_create_dir() never returns a null pointer, checking the return value for a null pointer is redundant, Remove this check since debugfs_create_file can handle IS_ERR pointers. Signed-off-by: Li Zetao --- v1 -> v2: Remove this check since debugfs_create_file can handle IS_ERR pointers. v1: https://lore.kernel.org/all/20240903143607.2004802-2-lizetao1@huawei.com/ drivers/media/common/siano/smsdvb-debugfs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c index 73990e469df9..9db38ae4ecee 100644 --- a/drivers/media/common/siano/smsdvb-debugfs.c +++ b/drivers/media/common/siano/smsdvb-debugfs.c @@ -411,10 +411,6 @@ void smsdvb_debugfs_register(void) * subsystem. */ d = debugfs_create_dir("smsdvb", usb_debug_root); - if (IS_ERR_OR_NULL(d)) { - pr_err("Couldn't create sysfs node for smsdvb\n"); - return; - } smsdvb_debugfs_usb_root = d; } From patchwork Sat Sep 7 03:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13795015 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 5EC0FE6FE47 for ; Sat, 7 Sep 2024 03:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=BgJ+00DQTKDQl4wrOCrY9mJxPDhI27OdDP87JdPpWAY=; b=D9/32kJQ0WRkvk5fGCIVE6W8TN C7KY+/MHarUUjGbinyXG7dslgz+Lmuj2WsEySsYdpajaKuDFQ67S3hWkXPg8Qf87s5gjAj3ba/A4f XjIQQVvjcASDGoi59x2rA8S9iQ7dlRdn/w503RARV190JX3HhQYs3hfgX8fj8wPXm9zftg6VnHPY/ FctJ/8bQ6gmituiVRC3yRA4/Xk2bLrieEUVK0wR2bwLZus9IQe0ViRwgkKWDtx0zvEMTgf1B9mFID PrxMhtFGGJ/DN0xm/qsFBOMQao6NwlQZzpOsy+LD0HUQw7TMfvO7mBv8RHP90cjEZZaUwVQSzbxX3 usU7tG1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlnT-0000000EAhK-1dIQ; Sat, 07 Sep 2024 03:07:35 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhY-0000000E9UD-3TdP; Sat, 07 Sep 2024 03:01:31 +0000 Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4X0yXB5KYYzyRRW; Sat, 7 Sep 2024 11:00:42 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id B4300180064; Sat, 7 Sep 2024 11:01:23 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:22 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 03/10] net: ethernet: arc: Convert using devm_clk_get_enabled() in emac_probe() Date: Sat, 7 Sep 2024 11:10:02 +0800 Message-ID: <20240907031009.3591057-5-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200129_426769_AD53B0EA X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the out_clk_disable_unprepare label, and the original error process can changed to the out_dispose_mapping error path. Signed-off-by: Li Zetao --- drivers/net/ethernet/arc/emac_rockchip.c | 34 +++++------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c index 493d6356c8ca..22b3ebe059d9 100644 --- a/drivers/net/ethernet/arc/emac_rockchip.c +++ b/drivers/net/ethernet/arc/emac_rockchip.c @@ -144,7 +144,7 @@ static int emac_rockchip_probe(struct platform_device *pdev) goto out_netdev; } - priv->refclk = devm_clk_get(dev, "macref"); + priv->refclk = devm_clk_get_enabled(dev, "macref"); if (IS_ERR(priv->refclk)) { dev_err(dev, "failed to retrieve reference clock (%ld)\n", PTR_ERR(priv->refclk)); @@ -152,18 +152,12 @@ static int emac_rockchip_probe(struct platform_device *pdev) goto out_netdev; } - err = clk_prepare_enable(priv->refclk); - if (err) { - dev_err(dev, "failed to enable reference clock (%d)\n", err); - goto out_netdev; - } - /* Optional regulator for PHY */ priv->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(priv->regulator)) { if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) { err = -EPROBE_DEFER; - goto out_clk_disable; + goto out_netdev; } dev_err(dev, "no regulator found\n"); priv->regulator = NULL; @@ -173,7 +167,7 @@ static int emac_rockchip_probe(struct platform_device *pdev) err = regulator_enable(priv->regulator); if (err) { dev_err(dev, "failed to enable phy-supply (%d)\n", err); - goto out_clk_disable; + goto out_netdev; } } @@ -200,7 +194,7 @@ static int emac_rockchip_probe(struct platform_device *pdev) } if (priv->soc_data->need_div_macclk) { - priv->macclk = devm_clk_get(dev, "macclk"); + priv->macclk = devm_clk_get_enabled(dev, "macclk"); if (IS_ERR(priv->macclk)) { dev_err(dev, "failed to retrieve mac clock (%ld)\n", PTR_ERR(priv->macclk)); @@ -208,37 +202,26 @@ static int emac_rockchip_probe(struct platform_device *pdev) goto out_regulator_disable; } - err = clk_prepare_enable(priv->macclk); - if (err) { - dev_err(dev, "failed to enable mac clock (%d)\n", err); - goto out_regulator_disable; - } - /* RMII TX/RX needs always a rate of 25MHz */ err = clk_set_rate(priv->macclk, 25000000); if (err) { dev_err(dev, "failed to change mac clock rate (%d)\n", err); - goto out_clk_disable_macclk; + goto out_regulator_disable; } } err = arc_emac_probe(ndev, interface); if (err) { dev_err(dev, "failed to probe arc emac (%d)\n", err); - goto out_clk_disable_macclk; + goto out_regulator_disable; } return 0; -out_clk_disable_macclk: - if (priv->soc_data->need_div_macclk) - clk_disable_unprepare(priv->macclk); out_regulator_disable: if (priv->regulator) regulator_disable(priv->regulator); -out_clk_disable: - clk_disable_unprepare(priv->refclk); out_netdev: free_netdev(ndev); return err; @@ -251,14 +234,9 @@ static void emac_rockchip_remove(struct platform_device *pdev) arc_emac_remove(ndev); - clk_disable_unprepare(priv->refclk); - if (priv->regulator) regulator_disable(priv->regulator); - if (priv->soc_data->need_div_macclk) - clk_disable_unprepare(priv->macclk); - free_netdev(ndev); } From patchwork Sat Sep 7 03:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13794975 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 17CCFCE7B04 for ; Sat, 7 Sep 2024 03:05: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=gLCUNemtqspOuOgn5wRRmSmyL2hFZstbzm/Kt9cBEq4=; b=jFAZoFE7QrE/VjldqdXNA+xvTZ E6OZvYOhOKNQMu9vC7IX2WguicEDFHC9HK47RvMG3dLV6oOO60jEToEbgZmiI/8MUHT0jn2nZ4mpn EaDqkvU/H7/ovcmMQ8k9ey85X/1WBDwdEie9Hv26Lq/EkAeWmAujZ+5anQeaxkgjJ3OFaiSHy9aUN VuHc1DKZTwVm2xaFQOmdbiLyuawmxHe4HzcYsFpJjuELqfp2/B9fTTeoarZGxES36p57yjOW/ipbe Bi6+b0T1PWP6m6KPlaoHPt9eHmKG+E2lLEX26G/mgfbykh3RWx8rzMj0rOEiLKrPbQmL4+2HLUDKP is1E6NNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smllY-0000000EAS5-3fUA; Sat, 07 Sep 2024 03:05:36 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhY-0000000E9UE-3TeX; Sat, 07 Sep 2024 03:01:31 +0000 Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4X0yVf5Dq0z1xwtx; Sat, 7 Sep 2024 10:59:22 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id A8586180041; Sat, 7 Sep 2024 11:01:24 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:23 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 04/10] net: ethernet: ethoc: Convert using devm_clk_get_enabled() in ethoc_probe() Date: Sat, 7 Sep 2024 11:10:03 +0800 Message-ID: <20240907031009.3591057-6-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200129_442914_F383B032 X-CRM114-Status: GOOD ( 11.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the free2 label, and the meaning of the free3 label is not clear, Changing it to free_mdiobus will make it more understandable. Signed-off-by: Li Zetao --- drivers/net/ethernet/ethoc.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index ad41c9019018..1a56e20cb679 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -1172,13 +1172,10 @@ static int ethoc_probe(struct platform_device *pdev) /* Allow the platform setup code to adjust MII management bus clock. */ if (!eth_clkfreq) { - struct clk *clk = devm_clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); - if (!IS_ERR(clk)) { - priv->clk = clk; - clk_prepare_enable(clk); - eth_clkfreq = clk_get_rate(clk); - } + if (!IS_ERR(priv->clk)) + eth_clkfreq = clk_get_rate(priv->clk); } if (eth_clkfreq) { u32 clkdiv = MIIMODER_CLKDIV(eth_clkfreq / 2500000 + 1); @@ -1195,7 +1192,7 @@ static int ethoc_probe(struct platform_device *pdev) priv->mdio = mdiobus_alloc(); if (!priv->mdio) { ret = -ENOMEM; - goto free2; + goto free; } priv->mdio->name = "ethoc-mdio"; @@ -1208,7 +1205,7 @@ static int ethoc_probe(struct platform_device *pdev) ret = mdiobus_register(priv->mdio); if (ret) { dev_err(&netdev->dev, "failed to register MDIO bus\n"); - goto free3; + goto free_mdiobus; } ret = ethoc_mdio_probe(netdev); @@ -1240,10 +1237,8 @@ static int ethoc_probe(struct platform_device *pdev) netif_napi_del(&priv->napi); error: mdiobus_unregister(priv->mdio); -free3: +free_mdiobus: mdiobus_free(priv->mdio); -free2: - clk_disable_unprepare(priv->clk); free: free_netdev(netdev); out: @@ -1267,7 +1262,6 @@ static void ethoc_remove(struct platform_device *pdev) mdiobus_unregister(priv->mdio); mdiobus_free(priv->mdio); } - clk_disable_unprepare(priv->clk); unregister_netdev(netdev); free_netdev(netdev); } From patchwork Sat Sep 7 03:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13794976 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 9C26ACE7B04 for ; Sat, 7 Sep 2024 03:06: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=chw1h0Z5cY5M1kg2inNHKDwbByIqj9vajfRkywaok4g=; b=DJIc5UP5GpVK7ETHYIwCwmu0pT JN15F6p9agI7RuGCxp36Ba5w9Q2/ZpoY+v+ZgZcsmFbqvpGr93Fp8PP9u0n+L6452Im7738QmT4EF q3niQjm7OEp5b1MDebwD1WBFIgze7LYK1xqmx5m6IagqRP0RX+yR5AoWbhkshXVKuRwoWQNLnPJEL BZcb2qYYkRuWa+dVnbWKzRbHxJdT/tVo8QnAk7ynaoC/+b7bTdiG+gIF9YeZX9vS7TMPVmb7t5R2V LH+GyFDA22dZrz0rHK2VFNtfUG+tPlpm5rqlMJDNxbJU2K3ZyMyxiwcHDQA34sTF+/DnnmUTcs9xQ InswuXFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlmW-0000000EAZi-0eVC; Sat, 07 Sep 2024 03:06:36 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhY-0000000E9UL-2oaQ; Sat, 07 Sep 2024 03:01:31 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X0yXZ0L87z1j83Y; Sat, 7 Sep 2024 11:01:02 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 9D7401A0188; Sat, 7 Sep 2024 11:01:25 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:24 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 05/10] net: ftgmac100: Convert using devm_clk_get_enabled() in ftgmac100_setup_clk() Date: Sat, 7 Sep 2024 11:10:04 +0800 Message-ID: <20240907031009.3591057-7-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200129_383945_973A9506 X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the cleanup_clk label, and the original error process can return directly. It turns out that checking the return value of clk_prepare_enable is a bit counter-intuitive. Here use PTR_ERR_OR_ZERO to make it more intuitive. Signed-off-by: Li Zetao --- v1 -> v2: Optimize return value checking and add commit information for easy understanding v1: https://lore.kernel.org/all/20240831021334.1907921-6-lizetao1@huawei.com/ drivers/net/ethernet/faraday/ftgmac100.c | 26 +++++------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index f3cc14cc757d..f2911507d7b8 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1767,13 +1767,10 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv) struct clk *clk; int rc; - clk = devm_clk_get(priv->dev, NULL /* MACCLK */); + clk = devm_clk_get_enabled(priv->dev, NULL /* MACCLK */); if (IS_ERR(clk)) return PTR_ERR(clk); priv->clk = clk; - rc = clk_prepare_enable(priv->clk); - if (rc) - return rc; /* Aspeed specifies a 100MHz clock is required for up to * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz @@ -1782,21 +1779,14 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv) rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ : FTGMAC_100MHZ); if (rc) - goto cleanup_clk; + return rc; /* RCLK is for RMII, typically used for NCSI. Optional because it's not * necessary if it's the AST2400 MAC, or the MAC is configured for * RGMII, or the controller is not an ASPEED-based controller. */ - priv->rclk = devm_clk_get_optional(priv->dev, "RCLK"); - rc = clk_prepare_enable(priv->rclk); - if (!rc) - return 0; - -cleanup_clk: - clk_disable_unprepare(priv->clk); - - return rc; + priv->rclk = devm_clk_get_optional_enabled(priv->dev, "RCLK"); + return PTR_ERR_OR_ZERO(priv->rclk); } static bool ftgmac100_has_child_node(struct device_node *np, const char *name) @@ -2020,16 +2010,13 @@ static int ftgmac100_probe(struct platform_device *pdev) err = register_netdev(netdev); if (err) { dev_err(&pdev->dev, "Failed to register netdev\n"); - goto err_register_netdev; + goto err_phy_connect; } netdev_info(netdev, "irq %d, mapped at %p\n", netdev->irq, priv->base); return 0; -err_register_netdev: - clk_disable_unprepare(priv->rclk); - clk_disable_unprepare(priv->clk); err_phy_connect: ftgmac100_phy_disconnect(netdev); err_ncsi_dev: @@ -2058,9 +2045,6 @@ static void ftgmac100_remove(struct platform_device *pdev) ncsi_unregister_dev(priv->ndev); unregister_netdev(netdev); - clk_disable_unprepare(priv->rclk); - clk_disable_unprepare(priv->clk); - /* There's a small chance the reset task will have been re-queued, * during stop, make sure it's gone before we free the structure. */ From patchwork Sat Sep 7 03:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13794974 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 DB652E6FE47 for ; Sat, 7 Sep 2024 03:04: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=DVD1QGiP9d91g9aUVaXMNZylZwGqP+iL2ICi7KEknBA=; b=xBkw8ECPbbgUhpqi9Oos0U+8Wj kHyvIURlRPyrXf/z/yhiqhq+ZKEsYWwHTNzOPrJ0TjNQDtCH/PRvwGhRMamU3NsI4e5jUpInqwYgR gIAcdN8bKmGt6+xgq1Db5B3hHBCw4N4issAzqTWimJIYhINMgDrQywJjLBcHn7p/i+Xil83dyI/Jn icmBg+UrWwl3I+QamtDDv0oKeZeBDIhX7P2jWwWHh+XbsjUtTp9JYWWBb9cdqQ3P8MhB3vu89owZU 7272m4yjdBpgBF7mPNe0mP1Qk0D1nxswzT5S+RnqRi1qC0SeC3UMcnz3NAjVAnIhel77MtIJjO68r 6qsO8Xug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlkb-0000000EAJr-3cwb; Sat, 07 Sep 2024 03:04:37 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhY-0000000E9Uf-2mgu; Sat, 07 Sep 2024 03:01:30 +0000 Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4X0yXZ1PbNz1S9r3; Sat, 7 Sep 2024 11:01:02 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 894471400CF; Sat, 7 Sep 2024 11:01:26 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:25 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 06/10] net: ethernet: hisilicon: Convert using devm_clk_get_enabled() in hisi_femac_drv_probe() Date: Sat, 7 Sep 2024 11:10:05 +0800 Message-ID: <20240907031009.3591057-8-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200129_243509_49F7CEB0 X-CRM114-Status: GOOD ( 10.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the out_disable_clk label, and the original error process can change to the out_free_netdev error path. Signed-off-by: Li Zetao --- drivers/net/ethernet/hisilicon/hisi_femac.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hisi_femac.c b/drivers/net/ethernet/hisilicon/hisi_femac.c index 2406263c9dd3..ffb6f4751d8b 100644 --- a/drivers/net/ethernet/hisilicon/hisi_femac.c +++ b/drivers/net/ethernet/hisilicon/hisi_femac.c @@ -797,23 +797,17 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) goto out_free_netdev; } - priv->clk = devm_clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "failed to get clk\n"); ret = -ENODEV; goto out_free_netdev; } - ret = clk_prepare_enable(priv->clk); - if (ret) { - dev_err(dev, "failed to enable clk %d\n", ret); - goto out_free_netdev; - } - priv->mac_rst = devm_reset_control_get(dev, "mac"); if (IS_ERR(priv->mac_rst)) { ret = PTR_ERR(priv->mac_rst); - goto out_disable_clk; + goto out_free_netdev; } hisi_femac_core_reset(priv); @@ -826,7 +820,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) priv->phy_reset_delays, DELAYS_NUM); if (ret) - goto out_disable_clk; + goto out_free_netdev; hisi_femac_phy_reset(priv); } @@ -834,7 +828,7 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) if (!phy) { dev_err(dev, "connect to PHY failed!\n"); ret = -ENODEV; - goto out_disable_clk; + goto out_free_netdev; } phy_attached_print(phy, "phy_id=0x%.8lx, phy_mode=%s\n", @@ -885,8 +879,6 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) out_disconnect_phy: netif_napi_del(&priv->napi); phy_disconnect(phy); -out_disable_clk: - clk_disable_unprepare(priv->clk); out_free_netdev: free_netdev(ndev); @@ -902,7 +894,6 @@ static void hisi_femac_drv_remove(struct platform_device *pdev) unregister_netdev(ndev); phy_disconnect(ndev->phydev); - clk_disable_unprepare(priv->clk); free_netdev(ndev); } From patchwork Sat Sep 7 03:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13795018 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 A7FCECE7B04 for ; Sat, 7 Sep 2024 03:10: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=41L1nEW/samYfOdu0jKmZpFpOmHOMMf27yFSYrqi2Ng=; b=AOjdwLGWlhOykGG9e6sMaeZN0d wuuLPRhyfRAsv4hZLFFo+nem1D0+rlqXN3wqTwNUW3u8GJLvH5Ju5kefvQlE8xRbUki16nrJpQi1B +CgzAQLXbdSaGvfZ3rCt5jz/h3j1ZYETB/gf0tm9ZdcNzOfUO7bFBc0tLaxbjupFNPp3YDmX6t2ns Qeq/o8/r8xqlzwrfd8Vcz7p7OK3HDv+pWQCXv2hs0vg6ll25E9D1igOg9VhxcYSkX8fxN4vleFm4k db9RL3YLczuXTQpPezyu98gqjoROgNAjJD1xmYLRL8kZ6aQZM8yoQahpKM1F0cCGWJNjfBmmQwwY4 gR6BbHRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlqK-0000000EBAi-1SA0; Sat, 07 Sep 2024 03:10:32 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlha-0000000E9Uy-2hIt; Sat, 07 Sep 2024 03:01:34 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4X0yVp5msjzpVXD; Sat, 7 Sep 2024 10:59:30 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 7BCF51800CF; Sat, 7 Sep 2024 11:01:27 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:26 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 07/10] net: lantiq_xrx200: Convert using devm_clk_get_enabled() in xrx200_probe() Date: Sat, 7 Sep 2024 11:10:06 +0800 Message-ID: <20240907031009.3591057-9-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200131_372803_B29A2B24 X-CRM114-Status: GOOD ( 12.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the err_unprepare_clk label, and the original error process can change to the err_uninit_dma error path. Some comments have also been adjusted. Signed-off-by: Li Zetao --- drivers/net/ethernet/lantiq_xrx200.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c index 07904a528f21..976748551643 100644 --- a/drivers/net/ethernet/lantiq_xrx200.c +++ b/drivers/net/ethernet/lantiq_xrx200.c @@ -589,8 +589,8 @@ static int xrx200_probe(struct platform_device *pdev) if (priv->chan_tx.dma.irq < 0) return -ENOENT; - /* get the clock */ - priv->clk = devm_clk_get(dev, NULL); + /* get the clock and enable clock gate */ + priv->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "failed to get clock\n"); return PTR_ERR(priv->clk); @@ -605,11 +605,6 @@ static int xrx200_probe(struct platform_device *pdev) if (err) return err; - /* enable clock gate */ - err = clk_prepare_enable(priv->clk); - if (err) - goto err_uninit_dma; - /* set IPG to 12 */ xrx200_pmac_mask(priv, PMAC_RX_IPG_MASK, 0xb, PMAC_RX_IPG); @@ -628,13 +623,10 @@ static int xrx200_probe(struct platform_device *pdev) err = register_netdev(net_dev); if (err) - goto err_unprepare_clk; + goto err_uninit_dma; return 0; -err_unprepare_clk: - clk_disable_unprepare(priv->clk); - err_uninit_dma: xrx200_hw_cleanup(priv); @@ -654,9 +646,6 @@ static void xrx200_remove(struct platform_device *pdev) /* remove the actual device */ unregister_netdev(net_dev); - /* release the clock */ - clk_disable_unprepare(priv->clk); - /* shut down hardware */ xrx200_hw_cleanup(priv); } From patchwork Sat Sep 7 03:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13795023 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 6645DCE7B04 for ; Sat, 7 Sep 2024 03:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=cmGotvtWFqpQIAqiBA37J7LsIK40iYkuPNMb0jGlqb0=; b=DwsTTu8hUCiafPSMlNKKKajUGB 3FICF6a3+0M3W2+FUF+PbJXZjlUHtpUy8RxulvduW3Srl3+e0xo1Tm26S2lA8LhN14II+tPEpfy+V VrP5OZqIHA6J+3VfayrFEHhTooKzpmIrZ1HgT+cU/STUKLi0myxaUmrWTaiAmhQdMVdMkIMbxQDEX Q1nvb0aW7SkcX91ThzP8kBZ/kj4eWAGxQmbuukWFT6QQoqy1B9IC38VwMVdvKYcZXCJDMMrs+51aq FIitBzVmNYgK3/UTIL3yTE5iICeQI/cY7y3tAfTedj2uGa/LscEfAOjY3fBLhpfcGg8cur290so3i GAnFAZVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlsR-0000000EC01-2pc2; Sat, 07 Sep 2024 03:12:43 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhe-0000000E9VX-0H7o; Sat, 07 Sep 2024 03:01:37 +0000 Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4X0yT20Tvrz1HJL8; Sat, 7 Sep 2024 10:57:58 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 75D881400D3; Sat, 7 Sep 2024 11:01:28 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:27 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 08/10] net: stmmac: dwmac-dwc-qos-eth: Convert using devm_clk_get_enabled() in dwc_qos_probe() Date: Sat, 7 Sep 2024 11:10:07 +0800 Message-ID: <20240907031009.3591057-10-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200134_834604_EACDF064 X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the disable label, and the original error process can return directly. The tegra_eqos_probe() also has similar modifications. Signed-off-by: Li Zetao --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 98 ++++--------------- 1 file changed, 17 insertions(+), 81 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index ec924c6c76c6..d6e9a93771f4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -123,49 +123,24 @@ static int dwc_qos_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat, struct stmmac_resources *stmmac_res) { - int err; - - plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); + plat_dat->stmmac_clk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); if (IS_ERR(plat_dat->stmmac_clk)) { dev_err(&pdev->dev, "apb_pclk clock not found.\n"); return PTR_ERR(plat_dat->stmmac_clk); } - err = clk_prepare_enable(plat_dat->stmmac_clk); - if (err < 0) { - dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", - err); - return err; - } - - plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); + plat_dat->pclk = devm_clk_get_enabled(&pdev->dev, "phy_ref_clk"); if (IS_ERR(plat_dat->pclk)) { dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); - err = PTR_ERR(plat_dat->pclk); - goto disable; - } - - err = clk_prepare_enable(plat_dat->pclk); - if (err < 0) { - dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", - err); - goto disable; + return PTR_ERR(plat_dat->pclk); } return 0; - -disable: - clk_disable_unprepare(plat_dat->stmmac_clk); - return err; } static void dwc_qos_remove(struct platform_device *pdev) { - struct net_device *ndev = platform_get_drvdata(pdev); - struct stmmac_priv *priv = netdev_priv(ndev); - clk_disable_unprepare(priv->plat->pclk); - clk_disable_unprepare(priv->plat->stmmac_clk); } #define SDMEMCOMPPADCTRL 0x8800 @@ -283,53 +258,27 @@ static int tegra_eqos_probe(struct platform_device *pdev, if (!is_of_node(dev->fwnode)) goto bypass_clk_reset_gpio; - eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus"); - if (IS_ERR(eqos->clk_master)) { - err = PTR_ERR(eqos->clk_master); - goto error; - } + eqos->clk_master = devm_clk_get_enabled(&pdev->dev, "master_bus"); + if (IS_ERR(eqos->clk_master)) + return PTR_ERR(eqos->clk_master); - err = clk_prepare_enable(eqos->clk_master); - if (err < 0) - goto error; - - eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus"); - if (IS_ERR(eqos->clk_slave)) { - err = PTR_ERR(eqos->clk_slave); - goto disable_master; - } + eqos->clk_slave = devm_clk_get_enabled(&pdev->dev, "slave_bus"); + if (IS_ERR(eqos->clk_slave)) + return PTR_ERR(eqos->clk_slave); data->stmmac_clk = eqos->clk_slave; - err = clk_prepare_enable(eqos->clk_slave); - if (err < 0) - goto disable_master; - - eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); - if (IS_ERR(eqos->clk_rx)) { - err = PTR_ERR(eqos->clk_rx); - goto disable_slave; - } - - err = clk_prepare_enable(eqos->clk_rx); - if (err < 0) - goto disable_slave; + eqos->clk_rx = devm_clk_get_enabled(&pdev->dev, "rx"); + if (IS_ERR(eqos->clk_rx)) + return PTR_ERR(eqos->clk_rx); - eqos->clk_tx = devm_clk_get(&pdev->dev, "tx"); - if (IS_ERR(eqos->clk_tx)) { - err = PTR_ERR(eqos->clk_tx); - goto disable_rx; - } - - err = clk_prepare_enable(eqos->clk_tx); - if (err < 0) - goto disable_rx; + eqos->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); + if (IS_ERR(eqos->clk_tx)) + return PTR_ERR(eqos->clk_tx); eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); - if (IS_ERR(eqos->reset)) { - err = PTR_ERR(eqos->reset); - goto disable_tx; - } + if (IS_ERR(eqos->reset)) + return PTR_ERR(eqos->reset); usleep_range(2000, 4000); gpiod_set_value(eqos->reset, 0); @@ -370,15 +319,6 @@ static int tegra_eqos_probe(struct platform_device *pdev, reset_control_assert(eqos->rst); reset_phy: gpiod_set_value(eqos->reset, 1); -disable_tx: - clk_disable_unprepare(eqos->clk_tx); -disable_rx: - clk_disable_unprepare(eqos->clk_rx); -disable_slave: - clk_disable_unprepare(eqos->clk_slave); -disable_master: - clk_disable_unprepare(eqos->clk_master); -error: return err; } @@ -388,10 +328,6 @@ static void tegra_eqos_remove(struct platform_device *pdev) reset_control_assert(eqos->rst); gpiod_set_value(eqos->reset, 1); - clk_disable_unprepare(eqos->clk_tx); - clk_disable_unprepare(eqos->clk_rx); - clk_disable_unprepare(eqos->clk_slave); - clk_disable_unprepare(eqos->clk_master); } struct dwc_eth_dwmac_data { From patchwork Sat Sep 7 03:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13795022 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 2CA97E6FE47 for ; Sat, 7 Sep 2024 03:11: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=dI9QzobGUL5/hC9sGQjYFpUWs9CLmQQUNH1MsjThy/k=; b=XXKdHp3G0MiXP4U7XKJJcmEro+ RDSZza+m+trJgfYTNrUOiqhusZJaZ+AxPthKVSeGSWr637hiHHiKm8nYk2O8wpbne6kaCgiGI5srf y7uiQJpy1uacb3YFo8XpPkyPByGMpw6QmdUGQOtLF5uFQYwYJV0U7yRJDYy3pD7lMd95Gf4/MLRs9 W5CorhUVTA2Q7EGhKwp+6Z6K2Ed5Hs+Yzln+snzww1hr/m8sbDZ65KS6ZImSQpOCqh0nv6gWDYkdq kAI5kDtFwpHacaKkcpu/2VzuUjE47/Hx3808slwXhHFkMASnRVJz0BL/pc03CSmV5ksRj52X3FhNW +8XOMPOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlrS-0000000EBfl-25wF; Sat, 07 Sep 2024 03:11:42 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhc-0000000E9XB-04o5; Sat, 07 Sep 2024 03:01:36 +0000 Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4X0yY400BHz69LM; Sat, 7 Sep 2024 11:01:27 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 6B0421800F2; Sat, 7 Sep 2024 11:01:29 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:28 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 09/10] net: ethernet: sunplus: Convert using devm_clk_get_enabled() in spl2sw_probe() Date: Sat, 7 Sep 2024 11:10:08 +0800 Message-ID: <20240907031009.3591057-11-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200132_728603_155CB15C X-CRM114-Status: GOOD ( 14.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_enabled() instead of devm_clk_get() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path, drop the out_clk_disable label, and the original error process can return directly. Some comments have also been adjusted. After this modification , it is no longer necessary to use clk, so delete the clk member of the spl2sw_common structure. Signed-off-by: Li Zetao --- v1 -> v2: Delete the clk member of the spl2sw_common structure v1: https://lore.kernel.org/all/20240831021334.1907921-10-lizetao1@huawei.com/ drivers/net/ethernet/sunplus/spl2sw_define.h | 1 - drivers/net/ethernet/sunplus/spl2sw_driver.c | 25 +++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/sunplus/spl2sw_define.h b/drivers/net/ethernet/sunplus/spl2sw_define.h index acc6c1228ebc..6318eccc6c4e 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_define.h +++ b/drivers/net/ethernet/sunplus/spl2sw_define.h @@ -224,7 +224,6 @@ struct spl2sw_common { struct platform_device *pdev; struct reset_control *rstc; - struct clk *clk; void *desc_base; dma_addr_t desc_dma; diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c index 391a1bc7f446..887da05bc204 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c @@ -327,6 +327,7 @@ static int spl2sw_probe(struct platform_device *pdev) struct net_device *ndev; struct spl2sw_mac *mac; u8 mac_addr[ETH_ALEN]; + struct clk *clk; int irq, i, ret; if (platform_get_drvdata(pdev)) @@ -355,12 +356,12 @@ static int spl2sw_probe(struct platform_device *pdev) return ret; irq = ret; - /* Get clock controller. */ - comm->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(comm->clk)) { - dev_err_probe(&pdev->dev, PTR_ERR(comm->clk), + /* Get and enable clock controller. */ + clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(clk)) { + dev_err_probe(&pdev->dev, PTR_ERR(clk), "Failed to retrieve clock controller!\n"); - return PTR_ERR(comm->clk); + return PTR_ERR(clk); } /* Get reset controller. */ @@ -371,10 +372,6 @@ static int spl2sw_probe(struct platform_device *pdev) return PTR_ERR(comm->rstc); } - /* Enable clock. */ - ret = clk_prepare_enable(comm->clk); - if (ret) - return ret; udelay(1); /* Reset MAC */ @@ -388,7 +385,7 @@ static int spl2sw_probe(struct platform_device *pdev) dev_name(&pdev->dev), comm); if (ret) { dev_err(&pdev->dev, "Failed to request irq #%d!\n", irq); - goto out_clk_disable; + return ret; } /* Initialize TX and RX descriptors. */ @@ -396,7 +393,7 @@ static int spl2sw_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "Fail to initialize mac descriptors!\n"); spl2sw_descs_free(comm); - goto out_clk_disable; + return ret; } /* Initialize MAC. */ @@ -406,7 +403,7 @@ static int spl2sw_probe(struct platform_device *pdev) ret = spl2sw_mdio_init(comm); if (ret) { dev_err(&pdev->dev, "Failed to initialize mdio bus!\n"); - goto out_clk_disable; + return ret; } /* Get child node ethernet-ports. */ @@ -506,8 +503,6 @@ static int spl2sw_probe(struct platform_device *pdev) out_free_mdio: spl2sw_mdio_remove(comm); -out_clk_disable: - clk_disable_unprepare(comm->clk); return ret; } @@ -536,8 +531,6 @@ static void spl2sw_remove(struct platform_device *pdev) netif_napi_del(&comm->tx_napi); spl2sw_mdio_remove(comm); - - clk_disable_unprepare(comm->clk); } static const struct of_device_id spl2sw_of_match[] = { From patchwork Sat Sep 7 03:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13795024 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 E46F9E6FE47 for ; Sat, 7 Sep 2024 03:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding: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=muHz4FCDmjeJpvVMb39ECSG7bzB+txFc5J0PoCAJOuI=; b=Od/vLIOjPORT+feE5prINeH2Hu F2NZoBrwx81LZQ3WvkFta7F/nhl58zQPCus1GZAEC+uo+5EmH6j+N5l9/RTerbTdWFkEfHImsZRcP uM/NuxtW7oWRE48drDQrbZZVTyfS0ZDl2ZQIj/aPTZ2wlINlRR6K7YF+YQYL8GlmgRrVW/LethqND FxqgkjTUXXPIfR8/evwOE4QL+3PMD64NREEWc+GhilrW6qOx8qi2UHYqp4tdVRztwaZaRT61XS5gk pGAnDOvV7pshKcY7uFDuGrR/mt6yZ0O4fnbL3nTG0W5KanZefCK1l1oxQA07PTObsK1BDQscMKKyl b7+suoow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smltR-0000000ECNt-3qvu; Sat, 07 Sep 2024 03:13:45 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smlhe-0000000E9Xb-2PsQ; Sat, 07 Sep 2024 03:01:38 +0000 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X0yRL2ZlSz20nY1; Sat, 7 Sep 2024 10:56:30 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 5BFA91A0188; Sat, 7 Sep 2024 11:01:30 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Sat, 7 Sep 2024 11:01:29 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH net-next v2 10/10] net: xilinx: axienet: Convert using devm_clk_get_optional_enabled() in axienet_probe() Date: Sat, 7 Sep 2024 11:10:09 +0800 Message-ID: <20240907031009.3591057-12-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031009.3591057-1-lizetao1@huawei.com> References: <20240907031009.3591057-1-lizetao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_200135_282026_1B93BE70 X-CRM114-Status: GOOD ( 10.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_clk_get_optional_enabled() instead of devm_clk_get_optional() + clk_prepare_enable(), which can make the clk consistent with the device life cycle and reduce the risk of unreleased clk resources. Since the device framework has automatically released the clk resource, there is no need to execute clk_disable_unprepare(clk) on the error path. Reviewed-by: Radhey Shyam Pandey Signed-off-by: Li Zetao --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 374dff70ef0d..87c5dcec2325 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -2592,22 +2592,17 @@ static int axienet_probe(struct platform_device *pdev) seqcount_mutex_init(&lp->hw_stats_seqcount, &lp->stats_lock); INIT_DEFERRABLE_WORK(&lp->stats_work, axienet_refresh_stats); - lp->axi_clk = devm_clk_get_optional(&pdev->dev, "s_axi_lite_clk"); - if (!lp->axi_clk) { + lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev, "s_axi_lite_clk"); + if (!lp->axi_clk) /* For backward compatibility, if named AXI clock is not present, * treat the first clock specified as the AXI clock. */ - lp->axi_clk = devm_clk_get_optional(&pdev->dev, NULL); - } + lp->axi_clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); + if (IS_ERR(lp->axi_clk)) { ret = PTR_ERR(lp->axi_clk); goto free_netdev; } - ret = clk_prepare_enable(lp->axi_clk); - if (ret) { - dev_err(&pdev->dev, "Unable to enable AXI clock: %d\n", ret); - goto free_netdev; - } lp->misc_clks[0].id = "axis_clk"; lp->misc_clks[1].id = "ref_clk"; @@ -2923,7 +2918,6 @@ static int axienet_probe(struct platform_device *pdev) axienet_mdio_teardown(lp); cleanup_clk: clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks); - clk_disable_unprepare(lp->axi_clk); free_netdev: free_netdev(ndev); @@ -2947,7 +2941,6 @@ static void axienet_remove(struct platform_device *pdev) axienet_mdio_teardown(lp); clk_bulk_disable_unprepare(XAE_NUM_MISC_CLOCKS, lp->misc_clks); - clk_disable_unprepare(lp->axi_clk); free_netdev(ndev); }