From patchwork Tue Aug 27 09:57:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13779158 X-Patchwork-Delegate: kuba@kernel.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2082.outbound.protection.outlook.com [40.107.255.82]) (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 68E8219DF9E; Tue, 27 Aug 2024 09:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724751745; cv=fail; b=oVYmysc/sTyl0WOwEJHFBqWIKa3bcbyitNUU+aEycnGoQKpsRcbnsoZaHQtkup916VOSFXkeqLV5PwglG1/Hug/LL5WLu8W/3EVFvxL7VESZwLklZycOfZ7UrhqSZh3NsS6vwV/ZsfZfT5B7gemvZR98JKZlzt4HE0XKYhOQx/c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724751745; c=relaxed/simple; bh=+yl3wY+Y3//QW1QVJNi8d8JWyl/OXne4Vv48283jx+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=c0JleW27V338D57ijGq45h5/DOZI0C4yFqo0/7d47WHcvIJKnLDwpHYNUVKUEEsphvXn7AlZXpgPFJkIGk8l3rN0N/j4syg5qnHHpAL59NUS6Bt0+qpNHzovpLp/WUm6mdRrnIXvhYjPC7X6u+8WflmribH8R6jL0h3rb9XpL60= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=NBEb07pm; arc=fail smtp.client-ip=40.107.255.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="NBEb07pm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nPcg01vbY0EicVUsndhEU5/eDSdjsMqv887laLnFLeoeXeX0OVD+umnCDICxf6UeneCTvaMT0re59PPQaDc7AO3uOM1uKycIocYff70q7Xc3zJ1BBkRrBDM+dMSuNfnpfCovO71FzVhu2nQvGzOC2PWcxGUR6B+dmmGYZ7x5pB4e5wdJkfMcTH/EkYiXR67IDt4FLyAuMvLb/E3Zr/1n9X4MyQ+SX5zSu0jJlcLLvZUVj5lyUgqYk0RXlvP0bqQGueNJNdAt7unTlke62MDotC7OQxelicxMN2CN5w331g/btn09WE4aaGnT7DWZ2ghBP5x1SO9EM03OlK4sJSe/Cg== 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=DX76DWkqLyJ4WRX+FaO0CYX54Hi+W6eU3EBLAexE2KU=; b=dyaqzSuXNTWTSjrH4n4i3BMZLps3Al+G/f1doJ6rqxIvEhf5Ay2nn40NH5LqsfnN4HyGJW20v1akv0RPcq0M0VKcjh6+h8sGo+BnEeHU7AZM1flPN0CTcUZoc2px7IrJII5taXDsqkXChx3RyF85RhTAqNoK6xDReWM+WBTHZwjdB8LMxM5pbp1czphKZ17kQKM7bYcTZATdyMP+SNJRoaR5bhZVguZD3KI+GLXDCEA415I2Q1VzapwhtE4zrsq6KFTJM09BYA/n9xeYo2CcQi8vOdchart97hkJijsnBVp1nx84z00vzo+A357BB8rzct2fObiXgBW+eO0cZrpfRw== 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=DX76DWkqLyJ4WRX+FaO0CYX54Hi+W6eU3EBLAexE2KU=; b=NBEb07pmSt6/8gdur7ZbISsG956M/v7fMBjS6xbGKOQba3zhhmR3T/Xv0nbCLXnSrcMlCk1Od1rIpm7XnZSbavFGbMFYvKtnmwUAinhNOtkjfQxzq1SU5+TjKcgKYTKCgoaW9kRI+sBSCAGWDiyO65qk6P5ikGxt0oXCBq+tQsgbV798bD1WzP0ooBF76F02dsx4FgL/18Tl8XUhg7Cr1B4fes7jZD8WfB+jtL2gGUoriOE0cIgeYUVn+LeQQ//cya4r0ZT05tNIUUx32mLyXyO1k1WjH1OLpG/zm3l/Eh3qZms8mG1Q32ekk1ZGt9XAghBT4lDlCNyEt6DZF86nqA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB5734.apcprd06.prod.outlook.com (2603:1096:400:281::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Tue, 27 Aug 2024 09:42:20 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::8c74:6703:81f7:9535]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::8c74:6703:81f7:9535%7]) with mapi id 15.20.7897.021; Tue, 27 Aug 2024 09:42:20 +0000 From: Yangtao Li To: clement.leger@bootlin.com, andrew@lunn.ch, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ulli.kroll@googlemail.com, linus.walleij@linaro.org, marcin.s.wojtas@gmail.com, linux@armlinux.org.uk, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, hkallweit1@gmail.com, u.kleine-koenig@pengutronix.de, jacob.e.keller@intel.com, justinstitt@google.com, sd@queasysnail.net, horms@kernel.org Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Yangtao Li , Maxime Chevallier , Serge Semin Subject: [net-next v3 2/9] net: stmmac: platform: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Date: Tue, 27 Aug 2024 03:57:05 -0600 Message-Id: <20240827095712.2672820-3-frank.li@vivo.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240827095712.2672820-1-frank.li@vivo.com> References: <20240827095712.2672820-1-frank.li@vivo.com> X-ClientProxiedBy: SI2PR02CA0053.apcprd02.prod.outlook.com (2603:1096:4:196::16) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB5734:EE_ X-MS-Office365-Filtering-Correlation-Id: 333c5851-47d1-4d17-37b7-08dcc67c8be4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: vfZlq+TkNOd+mMyduRZPeZ6kCTDGeA6NXxjqhb/+I0HzWj5wkiTV6rsyUoF2IBEQcKRieySIUUSyTiGrJ1Tc9K/UNdRt7C6qP2k/0QSHwC/C5024kD9H103qp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RULifj0XajAUaapHoD6ATcOrm8yW7hc4bUBsMWVEpwbKZZXyf2bFXZGb6afkCdG+gXn3boNkmt8gqxB+6pTLyiFxUCMcIgfzIjML+W/05F3Mx/KRh5c/8zxLUiCbdZZ7kwFwqUMRVpRTcx7UDT2eLMlyF/p51FfVwGHlvxoqnfXKg7O4zNkPYpDHdwEknYPaFSpbhSrHhgk1JmLn9vpOmQgiA1L22DPousW98sXsbRFV2/LiVNZ2FVhiftE+o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Pe2vHVmnplCW/RQVxiQD7jrvKS+WrOU8uzppf7TsS9hly/owsR15tPlKpevrYlsP5YiLHhgAmiWl5HwKjm/yLqtkny6gyDxFU2iocX+KoDF3uc/Qjs7ri2IOy586Wox1XytMeQz1XgTTFCbCtyhgQ+8eRWfHAb3CbfUebjXYA2A2gN31tbJ/H2kf54kANGMrZkyjAKLLfcizIjWjraPWGJGDI0nvCrKS6dqWAQOM2w2zBmeSUG51j54+ET8pQjlTv3r9sdorQXV7gZhLTO9RgkcIjVMBs19ffq4YciPUkNKGictzGW+hPNM/ytKn/z4Rys2YTSwiUV78wDjuEHw5nddri5lSuILa2wbFl90ifXmVYip/acHhN8r0qgnxpUG0m07T3gSK96oZd9BOWWbxRHNPs/IxcXOOZcmo2lYaX1xhpzrDwa+8DtA6rjHKCoFTcSyGqCcYAXRXr7GWB+lqB2LQhcHiGbaHYT4gUd75TB1eiA/SrEihpUMu5qLEx+6IQWfx1xeQvmEYCcddfggTWyUvP/cfe8FTemMaAobq0YrXfBcbaIwaznRWO9S5A1KbYMNKjjaMStCfeOCJU7Zt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MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 09:42:20.6693 (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: NjZZmpvdq6/fwTEvuo316YGq8y0EOFZ1BP/GItu2aUaL/9Yy036sTSD49HL7YtTHgOOCKWUCsUtyQJa+0e38CA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5734 X-Patchwork-Delegate: kuba@kernel.org Use devm_clk_get_enabled() and devm_clk_get_optional_enabled() to simplify code. Signed-off-by: Yangtao Li Reviewed-by: Maxime Chevallier Suggested-by: Serge Semin Reviewed-by: Serge Semin --- v2: -remove unused 'ret' -fix incompatible-pointer-types .../ethernet/stmicro/stmmac/stmmac_platform.c | 35 +++++-------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index ad868e8d195d..4365afabf3c4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -415,8 +415,6 @@ static int stmmac_of_get_mac_mode(struct device_node *np) static void stmmac_remove_config_dt(struct platform_device *pdev, struct plat_stmmacenet_data *plat) { - clk_disable_unprepare(plat->stmmac_clk); - clk_disable_unprepare(plat->pclk); of_node_put(plat->phy_node); of_node_put(plat->mdio_node); } @@ -436,7 +434,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) struct plat_stmmacenet_data *plat; struct stmmac_dma_cfg *dma_cfg; int phy_mode; - void *ret; int rc; plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); @@ -615,21 +612,16 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) /* clock setup */ if (!of_device_is_compatible(np, "snps,dwc-qos-ethernet-4.10")) { - plat->stmmac_clk = devm_clk_get(&pdev->dev, - STMMAC_RESOURCE_NAME); + plat->stmmac_clk = devm_clk_get_enabled(&pdev->dev, STMMAC_RESOURCE_NAME); if (IS_ERR(plat->stmmac_clk)) { dev_warn(&pdev->dev, "Cannot get CSR clock\n"); plat->stmmac_clk = NULL; } - clk_prepare_enable(plat->stmmac_clk); } - plat->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); - if (IS_ERR(plat->pclk)) { - ret = plat->pclk; - goto error_pclk_get; - } - clk_prepare_enable(plat->pclk); + plat->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk"); + if (IS_ERR(plat->pclk)) + return ERR_CAST(plat->pclk); /* Fall-back to main clock in case of no PTP ref is passed */ plat->clk_ptp_ref = devm_clk_get(&pdev->dev, "ptp_ref"); @@ -644,26 +636,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, STMMAC_RESOURCE_NAME); - if (IS_ERR(plat->stmmac_rst)) { - ret = plat->stmmac_rst; - goto error_hw_init; - } + if (IS_ERR(plat->stmmac_rst)) + return ERR_CAST(plat->stmmac_rst); plat->stmmac_ahb_rst = devm_reset_control_get_optional_shared( &pdev->dev, "ahb"); - if (IS_ERR(plat->stmmac_ahb_rst)) { - ret = plat->stmmac_ahb_rst; - goto error_hw_init; - } + if (IS_ERR(plat->stmmac_ahb_rst)) + return ERR_CAST(plat->stmmac_ahb_rst); return plat; - -error_hw_init: - clk_disable_unprepare(plat->pclk); -error_pclk_get: - clk_disable_unprepare(plat->stmmac_clk); - - return ret; } static void devm_stmmac_remove_config_dt(void *data)