From patchwork Sat Sep 7 03:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 104063 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 1smlts-0003o1-1y for patchwork@linuxtv.org; Sat, 07 Sep 2024 03:14:13 +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 9A2241C24D5B for ; Sat, 7 Sep 2024 03:14:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE39B15C136; Sat, 7 Sep 2024 03:10:52 +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 97E57157488; Sat, 7 Sep 2024 03:10:49 +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=1725678652; cv=none; b=VZfagMJ9MitAfdd66D3zuz1E5f8seFX6InU01cyOR+glaZnQlET2WdbjOZ/EbZ0S1PvBSQoKwmLDo6WPQ0zKG9B3wJ08XuApvjS/8vc8I6A8ykvBJRdHTgsfkYq9IbLYzOEmjhF97DkDGC1keAGZP3eyImZKYNBPR2UeDOL7xU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725678652; c=relaxed/simple; bh=QTU7fufNN1BaBlcJYY1qHswGUbgAx/DUxgQa8eGoits=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y4R74S3Usi7BlfYSr3/7gxCchPu0iWMY3SyToZALChEr29FNMZT+NhvOSQOWo4H06E3go4+gHTD3HwBKxP6BBxaBLfB3SXqd6kVr1wARh0Q9oTdjyzuzswRhtA8aUtDkDJZVGVmJVlBK2YGTCTCVxzKYQgnokEIpo07fNjzcS0w= 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.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4X0yjT4WHVz1xwt7; Sat, 7 Sep 2024 11:08:45 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 9151D1A016C; Sat, 7 Sep 2024 11:10:47 +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:10:46 +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:19:26 +0800 Message-ID: <20240907031926.3591353-11-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240907031926.3591353-1-lizetao1@huawei.com> References: <20240907031926.3591353-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: dggems702-chm.china.huawei.com (10.3.19.179) 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); }