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: 104047 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smliR-0003Ko-2n for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:24 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 101231F23C47 for ; Sat, 7 Sep 2024 03:02:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE1704D8C6; Sat, 7 Sep 2024 03:01:32 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A75903BBCC; Sat, 7 Sep 2024 03:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; cv=none; b=YDTsMZhDgxj+K/9IQ5ViI5oupH/i3AnvHT6YvV/hVfkzUAkwpVdhoGsyUuK4PXskYbKa/VsJotUL8QLE3uqGaOLhgNmT/lqLnzJOEKxhIf4E8rgBIx1VWBn17zsADJU1w1bHBQgT7oYM5MuPJ6BJ5xAFBQ0ykwBK9+Z+QhZuCms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; c=relaxed/simple; bh=9ndR7JYgXlK6gaL2DuxYVbZkag02HgoUfkhmww6ZP34=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P/N+CDi1YTsQK6KSYxx4KbE0OQ/figqjIN2NLISU00Rw2adYrWvhWrN9Gc1fmwKbfnWmR75prloPQFZLbqZNkIzv7WfEY0Bgs/keugTxU8EeJ89zdBDbTu72pwZw6JKGSKbljQo9M6S/vVRQ97hQ+bj8gNHfccYaZQWAC2kFpuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104051 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smlir-0003N5-2l for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:50 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7597F285D10 for ; Sat, 7 Sep 2024 03:02:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A7C71442F2; Sat, 7 Sep 2024 03:01:34 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5622381BA; Sat, 7 Sep 2024 03:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678093; cv=none; b=sgtkhLMid1DEaKUJ2hHrILo8QM0hNzBORf29rTnslAerF6DLD6H9B01HUh98bkSG2I3XJlv/2JVOpb8P03A/WuXpiACYny1bcWbcarVm+7tYricdPcW+9NlNyseRt7TVMzJvlWA8QOoMZWiXHbshzh2ci1554tNGt0YzXj8KmwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678093; c=relaxed/simple; bh=3DrBXBN4zHFdmZQPm97ddSdyM4eMMKuEHq8ZpIhhgb8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JPChYk7Wy935Ll3DJkPPl9HkujJPkpVkgs8QyZq3qQvfk/KtIzspH0I/QzSdoYn5C/R04Oh4gGZWwGYED3FwPH4+SAjE8otPCISlWiQ69ox2/Ho2V08naNBA9e0GnlZawg2NDOtOnPDdzM8dcI6PVMXLunBDv71W3v8FwFLp8gA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -7.3 (-------) X-LSpam-Report: No, score=-7.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104044 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smlhu-0003IQ-0Z for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:01:51 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 131701F23787 for ; Sat, 7 Sep 2024 03:01:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33E3939FC1; Sat, 7 Sep 2024 03:01:29 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37A1233991; Sat, 7 Sep 2024 03:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678088; cv=none; b=CSyTEdSIjj0m/lpI/Cu+Lfk9fnrfU7JOfh9qeZf/0jWb20+ivmu+ZjkwbuPsLIclT9wJXTxr+2Py4q4TpxFyn+LTUgPT3QcvYL8caRHUa1iRvW8/D/yN8FKJDwFfH0N+3kV5cEsCogoEkWE4cy0JG0xyZOmwJBy9iBkEJZtkdSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678088; c=relaxed/simple; bh=CJkyw4Pe6fR3XV4v8fZkKyySghrcwh8OHib7UMXEgUQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WGtdrLYO/KfH+DJhbsTMFTQXRkWpWeE1porlG1/BASA+CaYPWNkCLr8lSz3b3GxeEkAuqq1FO9LI3fhvHnwHNAwezAXRb9A0BvPQ3hkrLIztLOVzK0BfksERnbm2wMa/uWqqUVTgXE5fU8OEr0Q6iiElErPI7k2+GisZJV45yAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104045 Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smli1-0003Iz-2b for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:00 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 92C911C2186E for ; Sat, 7 Sep 2024 03:01:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAFC03E47B; Sat, 7 Sep 2024 03:01:30 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAF09381BA; Sat, 7 Sep 2024 03:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678090; cv=none; b=hnNepOnEnnAInxNXZ56EFMpi5LoHOeIXMuYRIZtRYIbCmWxij96KrjxXj07rR9KbA1rbgK1o+3r7+NRM7G9AvDZBhdf1idC4c7M7wwEn6HMb8e9TJsITneunjPEHfHKRzd70fZQ2bgNj5WQgzAPhsW0fS7pzfXgjhgpXpKwXjOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678090; c=relaxed/simple; bh=3b+7A5e6yMhko3erhk5rlZdd6Ltt1amgAMxhEwLvi74=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nTuozfULvY4D08JzZkrZgNo8o6ZxFsSeYyGvilBw40uL2tTmRR1kCeKhoEp0Nwn0Vs1FbXz/BYsWn3sFa2zP81rC5ICqp+yEeR4fPLn/6VNGOGj1VwrLUsHqHdxAX1jYTiPwvc1aYcWkh79ZidpKOsvPhmExKxTBw2vUP+So4d8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104053 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smljA-0003OE-1z for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:03:09 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 38C112867AF for ; Sat, 7 Sep 2024 03:03:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3793200CB; Sat, 7 Sep 2024 03:01:36 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6397F146D65; Sat, 7 Sep 2024 03:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678096; cv=none; b=rjb30KIHCxAmvbiWUk5dJtWRZ3/jARBGulfvok3q/RZt9jvoUDb8KMQxFKvRjKz5z2jMHvsREQJiAQvc35PsLE3txyvY/L4uKaOdcZZT++mG3doPflwOk37Bxfmv2Zg51gMd4Q/QXUWWJKLw/iiuTxUN4PNkHbaU8jQZcpLXL2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678096; c=relaxed/simple; bh=pgpSkhBHQe3kO4JzSy7/u8s/uy8jdKneq2h1Ysxr53I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qo80NGbSe9q3Gd3Jsw2EaOjgj2CiZO/Ml1/Ly/0MS+T8AWQYYZiDN3BDPWd24nHpsJa2yTrP3M+4BSAAjQLDUDpxXAU0wD8/ckdZg3rz33+wNolgdunrKzcgLhVy4Gdz6WrAFXKTBbRTmT3MZQFy47KMX9g49YM1kS+SV/3pNkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -7.3 (-------) X-LSpam-Report: No, score=-7.3 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104046 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smliE-0003Jz-1C for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:11 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 962321F237D1 for ; Sat, 7 Sep 2024 03:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 590434594D; Sat, 7 Sep 2024 03:01:32 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA3B733991; Sat, 7 Sep 2024 03:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; cv=none; b=LTLKheCVPFkz+zM50wkvvaOX6zeSbFVfNIWpBoLGa7ycWOrpuA3ybHHrWZVRzsmJqTE48tblKNmw1T6Tr+VFj+H7IyHebj2fpH3EgHidIgllIdLfw/y/luprSc4oxCoG73hbG7NCuV5mq8QjibJYKyXGlMDbJjEsXbs2f+uqL6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; c=relaxed/simple; bh=NTT6omI+1h722IadGdfo3Cu5+r9CNZ+yAF34IF8fqzU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i77sv+WgKTigSRtVy2SAYirwrYoWqvJzItBcxuPvkvZxlo/npxK+DbXGXa+iVe3xwcsFJD3vJWqWI2wIKf92TruqOATKxNoaXuwiURZOZ7yyLU6R9ND/rlKONz7xEJrBxev7l+z2XdcBlrpRFEBbkQi5xpwZ0iMRytZRTz+qfio= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104048 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smliV-0003L3-0D for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:28 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 303F71F23A9D for ; Sat, 7 Sep 2024 03:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AAD54F20C; Sat, 7 Sep 2024 03:01:33 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECC364084E; Sat, 7 Sep 2024 03:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; cv=none; b=haRz9bU8Vg3lP9WOJ9S22k8smPtrpf6hAZ4Fd/1wX2QA1q3OZnNkCa6YblfGGfDKgZgiB0pwggWN/QJ/yMPNXMx6hYUELNw+pBvEfvOcfm6bLG3xUFdfTnMdAnEH9VvpuABbDEZ/8/ZKyOqp1/xbN5TVIeHMCEB/s8Ql3NH8KNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678092; c=relaxed/simple; bh=7W1tcdm2zh5G5w60OHuhn10sbehAYbPyEfodQj/6jmU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TEYbstMJJ0gdn2xuon8HaaeAMMG7hpvYvoRoim7gLk7xqlDMpicHEvxuI7ZK/dNz9Y5KUJUValCJ+tRFnE6Y8u5pO05KgckSgMH/N1BACHTryoB/CRmTttc3lx5FcmroYW/16sh3925bn9YkY7V/JAN3iI/ziTbBgf1tNmhpVV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: 104049 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smlij-0003MB-2v for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:02:43 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D56F01F237DC for ; Sat, 7 Sep 2024 03:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9129131BAF; Sat, 7 Sep 2024 03:01:33 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 781BB43ADE; Sat, 7 Sep 2024 03:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678093; cv=none; b=KzISy0RrMA2PgCy1sK6XKsgUzKonx6/58/V7Qkdbn4vj9+5n0g7y9TQp88qXgN4hw5ZcOFemWbdZhVsaTGfRHdhqdwYhcQkHTDAXurMZw+v/7WEie/mApLTP+wGnmjKP9IYbpfcg34hgXuHoGS23wMnNXUflC2QN5aBtuTP7sPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678093; c=relaxed/simple; bh=3LkLjxpWEKDfGssDbCj1BcZ6R0Gz4xgvQlw3VPzlsf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YNPD6olx270Crf+ZtyByvbMEHCOzKcpBnwU8gTzn0ZVPYPlhfBH8B7HPtztgRTjI7cr+vSb9ls++/VThASXCF09yq7Aet2FzyIbJXWdGdAXImQM9Qq4f6CH+gSjpRdxMGQdF7nL/vuqZmwF+edzkGPECCvXUPe+XsMLLGSyJyHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: 104052 Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1smlj5-0003Nv-2Z for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:03:04 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C8EC31C226B4 for ; Sat, 7 Sep 2024 03:03:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C24F1BF2B; Sat, 7 Sep 2024 03:01:36 +0000 (UTC) X-Original-To: linux-media@vger.kernel.org Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 709F643ACB; Sat, 7 Sep 2024 03:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678096; cv=none; b=Mi8LVcKFi722pQZpYn6ljrXlIXh/px5siauO29etOpFyCMrz43ZGt8qUecf8BA9uVyF5BC6RC4XBoWPxhfRuKIDA+a4rVc9SjgHW2lxwEBytgWePA7cOITvWmu7Xvz3U/P0Pr+T+lIZdQ8w6cg1SMwFl5D+jzz/CFMJgVKyQbp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678096; c=relaxed/simple; bh=QTU7fufNN1BaBlcJYY1qHswGUbgAx/DUxgQa8eGoits=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aliEXJB4cB8L0EVUC8i1w8NPT4T1c+kt/MJCv4GFt5gvZxFpkTppNln/wNflwNZog/1t5sIh6d19O4QdQlE1V8hCkF7B+/WcmujxJnDjnlO8uQGof6jltuVIxdX33HPIuqwsayi8DlPrOEf9Zq05vpthSU9oS4mil9EPOsbTyUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemd500012.china.huawei.com (7.221.188.25) X-LSpam-Score: -5.0 (-----) X-LSpam-Report: No, score=-5.0 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DMARC_QUAR=1.198,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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); }