From patchwork Mon Aug 26 02:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu Bo X-Patchwork-Id: 13776951 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 44EB4C5321E for ; Mon, 26 Aug 2024 01:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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:In-Reply-To:References:List-Owner; bh=YZ9m2rc+I2JzJkVMOhTPvVfDbwm3w0VS6fYoAUeUA+o=; b=2OJAi8t35d0UQTf0shRGfph9dD 2QZQy4J6t1qOnC0ztqUqJ2ZruT2yL0Cd2zsvI8NsakYECtjMFm16mHSTByoBGnyzSICrQSHK/xUu1 eu108bZ/44yYmLqIkNCh+p8yNIEVlec/zJ4aoa9p8VhWXs9krY2XKMsZVm/l4VhZFj7P0ksEniUey QwIuMlJGjpVPsGsnrl468IsN0XU0ebG21aaPBX7k4mIApdrzQcia5auwJCXQHfjTo2ORdkbWlI4BK brS0iNZYEigBZaQ+jaPtn9wAkSCDGt1HcnN4A/1XSB62OSnxr2QyLRSS01ttpbQ1ZcQqC8moNYG5r cbkErpog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siOom-00000005T9R-2XTM; Mon, 26 Aug 2024 01:46:52 +0000 Received: from mail-tyzapc01on2061f.outbound.protection.outlook.com ([2a01:111:f403:2011::61f] helo=APC01-TYZ-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siOo0-00000005T37-3GkO for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 01:46:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IKPoE9tfY9A/EevhCGxp5EeEWObColAUZJN9RfiejbRlkNE6tZoJSw4aaZRhp1sBcUps3ReEKfYwxiRIiRuRzPpfYW4fsQo4VytI73AEhBxcb0Qixmhij24o6ZRxGX0HS8Fq+RkgKtmgEGuD8FNQZI0qN2AfMb4rYBIBYb0w7b8ui4CgyiO5X88dxfvIKKhTth/A3xI8I8v41k9RMagL9dg4xE4kCn2HoNbVJUpF6BVq7r32UmUgkc5x5B8sdcgj8DCHAIDEPGkshah6yGRd84UFWJNv6LkxCd8qlp5DH4ioCSB9NZsL050xj3AbkVLyJG2Np/TJvQjVHn4e5+Up7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YZ9m2rc+I2JzJkVMOhTPvVfDbwm3w0VS6fYoAUeUA+o=; b=Gc5zwFALozKFTL1SkhW4w00d4gZzvMr3+UmDPsz+wRwNJZvCQvk6uGkrspGnrfGnVEOzEPsFISpbmVKtw0MnfHoPQ4mhP9M0onhZOnZfjHpgW//2/2MzaMNM3SoikM6XaRhKK7pkN2kY7d6jxrbFutkwf/jTVH8sY6D6uuFIFhsQ2FDIAAML32juXGHb9xPcgPdeqeli3ogqX4OaPwIbRl1Ls0fkiJLPSLB/tcubiSxL8ceru/SzkRQS6OpR7vlgatKWGYynQOMSV0h/2/cn1olfwVvBGM581CyXMRLOihV+exk0ANy5StOn7t2Wx4Lj5CRTSP+j8FWaBtQesxsYJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YZ9m2rc+I2JzJkVMOhTPvVfDbwm3w0VS6fYoAUeUA+o=; b=AENTItZ9YOepGskTb925l7dznjZymhDTtEAoq5aiHQvJAu0YhmpnxkMEV1JMIsiSqrITl4cvp2wESUagnI1QtpFLY2EkKxXARYXVfhkPcctjYGJoHkhdbViMANAj7SYfIZ4QzN8/3GKAXBHlG4wK454skn6ok9xjETuFmFeKcxU74QKtuTyLyFYAK9PK8RRL8TitrDG7+NGQX3br0nH9o86Bw5eKaVq2nJFDpHg2AMjBRW0VNaNHtxCJC3drR5O3M/88ST4nX1PVpvlgJ0UFBPbvZkhJ4STpwAmZR/IXwrCuCYLxy/UFqWRsXwlYOhBsCNWl7pzVJT85iNHuSq6wIA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) by JH0PR06MB6478.apcprd06.prod.outlook.com (2603:1096:990:38::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Mon, 26 Aug 2024 01:45:45 +0000 Received: from PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5]) by PSAPR06MB4486.apcprd06.prod.outlook.com ([fe80::43cb:1332:afef:81e5%6]) with mapi id 15.20.7875.019; Mon, 26 Aug 2024 01:45:44 +0000 From: Wu Bo To: linux-kernel@vger.kernel.org Cc: Thomas Petazzoni , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Wu Bo , Wu Bo Subject: [PATCH v2] PCI: armada8k: change to use devm_clk_get_enabled() helpers Date: Sun, 25 Aug 2024 20:00:38 -0600 Message-Id: <20240826020038.2205146-1-bo.wu@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SG2PR01CA0177.apcprd01.prod.exchangelabs.com (2603:1096:4:28::33) To PSAPR06MB4486.apcprd06.prod.outlook.com (2603:1096:301:89::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAPR06MB4486:EE_|JH0PR06MB6478:EE_ X-MS-Office365-Filtering-Correlation-Id: e630cc8a-3719-4c97-1e5f-08dcc570cc8e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: 6axgs7dTyyjiTsKwHPaz28Mg70Nf05pVL5EdyvE+uFH35KlMS6rR+iROqbwnQHwQmaXfUf0JMmzRZImW40Fpx6GlbCqVMH29qy6AHBxAbwrojdltobaLj9umkd/pMqLYi6t2TRK2d90ajCBYEc3VRmWGEgOpXiLKz7HX+IGJ1cZZ9yCkDIgZJXqJ7fLKTohOWO9eQ+v82o7qz4mhANVlt4tD+zlKuH/IxseiRWClGn70/mrEdgukvB3w7CLTFY6cS13SM3uuhk5CYwaBawHUos2+BmhD4MV5c3mC8y//XxWxbJfz12w7GFtMFd2b9s/uzivRzBJ2whqpWZElG6hlow78Po10p3Ly1ARU2Rtbz7jXRHD2dShtRJrMQyoWqU/k18oBCzFTQA+jrzTvCmmhD5tX7Ulq2icHxCu+7gqmeKuDYjeql0jthXKku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.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ytbU/EaMfL334+Az87DcdZLxy1HFk78hPGxxZJ6uj+0hbjGMBZg3sY1L6r2mAxlwiVREeNrEzeDIZjc2ZlAWLF0MJMaxOnvcjp4iCfVNcJna6UVKTGnoLlhE2AW6kTetq2w6Er9hKJVPEFlNtDgDhOKMk4SvpmFzkKS4WaTgfIjGsyiyNFxGeCeTcsBqayXL0qzEIoLEXua42AbhDKXOLCgP7YCEzaIDeRNNfw89i1YtMobEeRUvZD/MFgZRsdunWeQMzGj/pfBKVZvpQ0VHoXEfwLETRq0zw3gTPCe23Zju5Y0M5jyvJRXaNWOeE3Hp9/TnYIR+axETeOAi7z+wjNgHysmEcK/S5cwNIbjx7Iz2p/NgdxGw+7xcsZxC968jLo89AgSo4nJVuRacsU/WG4S4tpTQSX1yDnwYC1YkNBLPSiRk82nTTJXRmcZfrYhMwxSo+S5j42clBKthJtQ+f+z+VR5I69x5aFIzJe5p9YhRaCGyyGliQKGDqAGw/gcOVMAn91H1gEgFnHvjxyVTLNAW2bMGkcQwqSNPyOyWcoVvmOfQJII+2u0Yka1OrvfG8bodb+nogJHJ5yHKra+ffD5kBcpXvzkq0IleBIHeBdhOMzv9EsnokCSC0oxnnjmSbwj7aPr5vrGXETEyl1A4JGDX/ci6cdtyLb503pVOiNWAz15mnzw1Wmqyl4fKF6o9e/PLk0mwHUHm1LC2KGHvj/h8cK35+CYwJ94mp8qjSqUs+hn6xoOa2is5vgf7MbqPs+tXd31eJEfwDLWjj11el7seMMluxmLczk7gPggNGbtGKfZTb3RQhbNLMr7dAnn8dGe/1Hmq5zKMFWy1IKcFVlf9nazxPL8kRl+0gY4W68eEWQf+S87f7bJ/wAjEyrOcy35S+ZafF6s0zqFiyCqDz14qsRdmDp5x4cw6h3PeJ9ENjX4KKd8dX6swP0HmULqzvqej+Ioexp7AJ0SxBwYgyp+jv5tkJGH8y/uSlZOPm3FcDLfsPCVP+6ImWb8AY/Em2hwewQn3HIkOYt1va4gHL4JAaz854O84YTlcE62vhlvT42rHGa81U3Qwx2KNzfABNOOP+8hypiMGKOGUu26pW3lfxu/e0PwAsxThSqaUi7NuR5i0zWJRdgC2WFg9BnH+TmzA6lPH4GDffBFVyTyE/lnZNpKiPzHyAdQRkSqO+MxIpfG7lQMNAV3DJTzk+deho5ljc2OoTuOzR2P/YV0FysC8j19wwrP52nTJk+PcgCYznOe1qOZgVU8Re4aMSxTiihlgB6ppj+T0h9zHpvY8+yo5bEXNI9xSWu68IkbjYCJzkluVq+7U+pkj0oqcWFaN+vyZLVCk7DttQCmp8AaZW61snlf0CU+ih25pNOQX+eQgzpOdO5KcT1X11GbcvsNbmEHsgpbhVKbSIUtzQqjRg/jvLPE2Ew2oL9L9ao3c3KPP2tgVFMRhZgJjpbktZ7Wzpr1L6JdJBnavC1eQILZK5dygkJBVFtHRBTclnnV0knni/5h002l2qcxT/PNzrW5rZxWGIuGt8TJ73qMjfAPBla/ugc0zjCXFBEyDw8ELhDGSDIfZdL8BBeuEw3xZDhOv X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e630cc8a-3719-4c97-1e5f-08dcc570cc8e X-MS-Exchange-CrossTenant-AuthSource: PSAPR06MB4486.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 01:45:44.0669 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hjzc4aPy5tAgg/jVYKRU99nZakcyQGCcVEz+iYwZ14Esd9RVuFNWPNt8Kln3atxpZuhumOBJN/0kJCCw74nkQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: JH0PR06MB6478 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_184604_831600_CD1DFCC9 X-CRM114-Status: GOOD ( 11.44 ) 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() to make the code cleaner and avoid calling clk_disable_unprepare() Signed-off-by: Wu Bo --- v2: use dev_err_probe() to handle error return drivers/pci/controller/dwc/pcie-armada8k.c | 36 ++++++++-------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-armada8k.c b/drivers/pci/controller/dwc/pcie-armada8k.c index b5c599ccaacf..9708a6fde545 100644 --- a/drivers/pci/controller/dwc/pcie-armada8k.c +++ b/drivers/pci/controller/dwc/pcie-armada8k.c @@ -284,23 +284,17 @@ static int armada8k_pcie_probe(struct platform_device *pdev) pcie->pci = pci; - pcie->clk = devm_clk_get(dev, NULL); + pcie->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(pcie->clk)) - return PTR_ERR(pcie->clk); - - ret = clk_prepare_enable(pcie->clk); - if (ret) - return ret; - - pcie->clk_reg = devm_clk_get(dev, "reg"); - if (pcie->clk_reg == ERR_PTR(-EPROBE_DEFER)) { - ret = -EPROBE_DEFER; - goto fail; - } - if (!IS_ERR(pcie->clk_reg)) { - ret = clk_prepare_enable(pcie->clk_reg); - if (ret) - goto fail_clkreg; + return dev_err_probe(dev, PTR_ERR(pcie->clk), + "could not enable clk\n"); + + pcie->clk_reg = devm_clk_get_enabled(dev, "reg"); + if (IS_ERR(pcie->clk_reg)) { + ret = dev_err_probe(dev, -EPROBE_DEFER, + "could not enable reg clk\n"); + if (ret == -EPROBE_DEFER) + return ret; } /* Get the dw-pcie unit configuration/control registers base. */ @@ -308,12 +302,12 @@ static int armada8k_pcie_probe(struct platform_device *pdev) pci->dbi_base = devm_pci_remap_cfg_resource(dev, base); if (IS_ERR(pci->dbi_base)) { ret = PTR_ERR(pci->dbi_base); - goto fail_clkreg; + goto out; } ret = armada8k_pcie_setup_phys(pcie); if (ret) - goto fail_clkreg; + goto out; platform_set_drvdata(pdev, pcie); @@ -325,11 +319,7 @@ static int armada8k_pcie_probe(struct platform_device *pdev) disable_phy: armada8k_pcie_disable_phys(pcie); -fail_clkreg: - clk_disable_unprepare(pcie->clk_reg); -fail: - clk_disable_unprepare(pcie->clk); - +out: return ret; }