From patchwork Thu Aug 29 06:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Jianzheng X-Patchwork-Id: 13782647 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 5D66CC7EE2C for ; Thu, 29 Aug 2024 06:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=DNudSC1TxzQoqMLhvgjXPQGriWabnYHQvurKRQtI8H8=; b=WutJiZ1FQO19/4 aewf4FPkWDTy42wQlijlbkyyKZPnkg5B7ICwwTTREQV0Dek9VdasvLVCcyO1J3VSXPwUplkKsYDNr M2QiqLi9ZAxr6UJ9xg2EqyvHOltsiPhAeLHnMH1+U/1HcuWnbKb/SMCY45fur/q3rhOzSOAnpdZNx OaBRezAoKOxicBYdlpu4eGTSP8UTCQs7+lbOahfU1e4Re2lzIC3n8mH+Dp8jHgyl0JmKzYBSr5+to 6unFSHAMA4rH56qXfwQnxHeT+vh6vw32fZMlOOb8RCja3XeM5IbxGV7pKLJSM3r41sHNNNsHd+rGo kSk2v8tUjBjrNhSARHow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjYze-00000000qiF-18wt; Thu, 29 Aug 2024 06:50:54 +0000 Received: from mail-sgaapc01on20629.outbound.protection.outlook.com ([2a01:111:f400:feab::629] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjYyl-00000000qRZ-16h4 for linux-riscv@lists.infradead.org; Thu, 29 Aug 2024 06:50:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Px6ArrXrS0xViRr8xBI3A58wRHQFE5pHLINCUE8m++UDvEx7KIzQ+lVNVoNek9xGN33KDrQNEXyhRpkdm7vG8KHjxep3rsPtJxnixHFrncUvB24fLwK1mD2BmbFDNQz/SL+bQ2Qjoe7zS6QVO++LfGWEr54scKmb7SC+mpiUBAZK+rs2AmxoIPF+cyVbR9V6KXIFje2IikiQ3zAbkWICULuY19nK/MlTjaup8l7E4/5XObr0+BzPBdvwhAUXVSDLbzWcHh3FPwIMhP+JoaaYPVjc39jSrY7biDdvCw7uvgB1LXArtN582SqzMJBKCX8J5gP0rIe6WZBAYwJV1Fkjew== 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=7ERW67835KJU82Kiry6wBE9lAwUEgX1142JZ2NSdtbE=; b=DnPsEFDut7MffD93l25/3Bn8Z3XjaBiHVQjSubrm7ec/NPpWA/cjRRl8v2dgRkwUX39pahc99klVuw7H23ay0V6DrAiSZ+uWNIi9DbWqmg0lnov/XNZZi8YI+FJdvSNdwjWkW580Xy6HYVVQU9n2fuawPh8Gd5yH4ZpueKkW2HHsmqptDqvKugqu3FZoGDB3KEJMGsg7RKedsIPMP6RS7XDcrYoZ07POqpLXb8lYsyPUTBf1moDC9S9zWHVOw6uWyld/pk34N68mMlGUxg0JKCjnt0IJ/LZHxvpl56YERlxYyKqUotD59eoHTuR9nqwNOQiY4/5Go0Ad3u28A8D8VQ== 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=7ERW67835KJU82Kiry6wBE9lAwUEgX1142JZ2NSdtbE=; b=TLyovVo0ZMTewBlsJ4Lh8T7opJ9xbj7eweVQkE/aaWIHvkOAZjyjxfWS2GRH6+nVP9T2PA9kE5wotK0H5CRjA/8kiEm6aJrsnuI+I5gdOOENn1y1jkUR3N+0+qxZLNjbXXwVcoSKyoadiy5NX2MCDqXHHLFs/nTgw3qkiq6fKQNAtgDFvHyKFMfdOUlWERMO8yBQxeWLmtIVJBBCKOfL1iQPdpPUgBtzO65RKFZfnmrrs/D50g1pa4DgiLic+CRqexBKb8/mzJ0F2swzj46509re+isEOunsRLPXAOORmtrZ5Ba26sDx0Q7Rofth5tXqxfL9Tv127MZ8h9slo0TMyA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from KL1PR0601MB4211.apcprd06.prod.outlook.com (2603:1096:820:23::14) by SEYPR06MB6822.apcprd06.prod.outlook.com (2603:1096:101:1b0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25; Thu, 29 Aug 2024 06:49:53 +0000 Received: from KL1PR0601MB4211.apcprd06.prod.outlook.com ([fe80::29e8:8083:a2b3:bd1a]) by KL1PR0601MB4211.apcprd06.prod.outlook.com ([fe80::29e8:8083:a2b3:bd1a%4]) with mapi id 15.20.7897.027; Thu, 29 Aug 2024 06:49:53 +0000 From: Wang Jianzheng To: Damien Le Moal , Linus Walleij , linux-riscv@lists.infradead.org (open list:CANAAN/KENDRYTE K210 SOC FPIOA DRIVER), linux-gpio@vger.kernel.org (open list:CANAAN/KENDRYTE K210 SOC FPIOA DRIVER), linux-kernel@vger.kernel.org (open list) Cc: opensource.kernel@vivo.com, wangjianzheng@vivo.com Subject: [PATCH 4/5] pinctrl: k210: Use devm_clk_get_enabled() helpers Date: Thu, 29 Aug 2024 14:49:38 +0800 Message-Id: <20240829064938.20114-1-wangjianzheng@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYCP286CA0310.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:38b::7) To KL1PR0601MB4211.apcprd06.prod.outlook.com (2603:1096:820:23::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB4211:EE_|SEYPR06MB6822:EE_ X-MS-Office365-Filtering-Correlation-Id: aeb346c0-f52e-4f7c-ab51-08dcc7f6c91d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: h4y7tzYiSVtysS00k+r8cKh5ZHqDRZlAlOAqiYgYa2sbQwlgpe6Qp2/tMY7na4hgtYlvo0DONCjxe61+aZj0gb7sumkWn7rDbYvuYVCqEDaLNigtBNkxw3OBRIOITL/LrjnwdjsJAebsqybzu/xtuAKEoo1VHE8BfhJZMychxaHqg59m4ZeuQm7zm7dk9JLyGWApkWBV+k0n9NglYt9nr2aTctu/R0x8pqrEiff233BE78uhBT/iDzi4X7pqZE8W6MzCJk35ElIWqCqc0u9l1kZOsoogdW11wZaix12+6K75Tk/mGY746KN6qrlVyIK8yDropw0sLHBAbEbg2AYYvlHj0hVz9ZMV0eudL+Q6JOknwEXFkrpUafAM+MaBSsFrbsezyl1Q7Gcjld1jwSt93c+C5323wJWcbFEe5bdC95KPZ0+DA8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4211.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6j9YJUGdlom/69klZPow2FuqvdOCG+RROvjQTR5P596xGomcJNJkDszptr+z3Ks2twCZY61mSK28yb49KbAAHsEyaBNMnkOxp8e2I0CZMgnf98DlrjXJKhJ+/GGGXKfxi0bW2jsvgO8GHTN/6dszyUREDl18q2Jk/5aV6lJjJrbefakLdx1qPTvFt+05UkDrerlzFDp4J1t6hs48kltdPcJBzesE9E47hizOtSlfVpNyjs8SJCbsYTJXiChLWKqTQ1d4NOu6eAQxJYXTAWmCQP4ypIFCQskFU0Q7f6dQCY9xTyUVzW9I0lCLvnROCeo/2JEhIITsBxYQXkIMKS3966AFpYWVhBHvFT+kf3LBjOh/87Y8UIZax4Mxs7H+fYptjvncNNUD0tRIpZ37jufeJZU+2mDSdsc6no7TraZsb+a1n+7Fd8berMv6Dvd6QtzFsamsxTOLVbSS0Osqszg8fT80Z15mWY2pcpgnW7SQ6HqUDxRKmZFcnVLDERruWAz5/TcFZGGW5qtNJZw/PWeHQcfDKeK3cnkpy7my+J/nD0b1Y3UFcMjqe7W/u/440NhCX2PNAv93JeB0R2E6LwcY2dqg3TbBp/tWhy944EXH3KKykL31Cms1Htt6HC2Ag3Mwlnd3FmqsnR/C7gpkZPXRg3hG+zayoM68Ti/+qb7U3cm/5crXBiw7MHGpTxdxVi23w4FKwNg0bAgnckg9N+7qsuJugT26AJSYcJXqPs7YNIQc5ozN9a9UDFXQxcoBLPoqHuH5E7EeLGq4BPRJ9s3te5Bi7iikBOxLl0moN7XbpvyIKdLuVEekLqvx069F/Yu6soum9+TYY0eqorbCY8CWntgCTXMhIl7C3KYB2kPjDn27fP77djjsW/Bn9/wXeqz/OHjk9jVdn4mL9Btyen1pfpFgyylpd9TujvlwbvmKdE/9MRRoEkFxDRqg+pTp1AHTlFniJGIsT9QNVQQ2Hc1z78EPCNP/QYILCaxLL75wUgBy9zOQhIGGksb0ASKPS4sk/I878zj1N1ezCgTZtrSsW4AZ6ywdjzcBWGfX5eSBJ+m4kkqkm3yzvEa1pTV4DJfcYkwGBrJIaVPixveQUwHbOUhKAx0fHY1Mjz1yTCR2wqUqw5H8FyudAKlJc8oaQygM/fIhc2bToUmFjRS+Z46hYiZGY3gtEyi/1bsdyXhEF8TASYMrDr6oWArp2l2K6QpXUMev39Zf7HSCOy57NMvg3g2tb5zeBfUcMQQftcZCOGTtRyyo+RAQPNATYi1Cz3u5vJfiS72pEytgxeI76FkzoVFagTtNZ0nOkbwgxPObvnASrgM800U+yxFn4UlONQzUit3xVFAmAAAD9r6bRH0JmWwUJ823rL6WXi9EmAYgXbziXp80buYmwZiIP7KrdwvbPeQbl7sLngrI922fuk+Z+KbqWD6DZH8vlq3njBsDNI2XI8o9OPYiM1ByO+Q+LOBBa062cPJDIGQRFMNckSYdBQ9TYHg6bOTTiLiDpbbhywWNewpnXhAnOh/3taouUVJmqbvfZ/XuN/5hlNF0ev50O0bvx/DINx5dEGQc98CE3cG/vUviuAlmS1QM1bhJoMnu X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: aeb346c0-f52e-4f7c-ab51-08dcc7f6c91d X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4211.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2024 06:49:53.1315 (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: gYNaXTFOuGb9rTOzww2H0qAjirbKru9o6NiCc+67Mi5GBafa3fcnIAs9mcTxJbT4nT/R/afKcq23TqjL6y6E4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6822 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240828_234959_330630_3BBF0D94 X-CRM114-Status: GOOD ( 11.47 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). Signed-off-by: Wang Jianzheng Reviewed-by: Damien Le Moal --- drivers/pinctrl/pinctrl-k210.c | 35 ++++++++-------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c index a898e40451fe..0f6b55fec31d 100644 --- a/drivers/pinctrl/pinctrl-k210.c +++ b/drivers/pinctrl/pinctrl-k210.c @@ -925,7 +925,6 @@ static int k210_fpioa_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct k210_fpioa_data *pdata; - int ret; dev_info(dev, "K210 FPIOA pin controller\n"); @@ -940,46 +939,28 @@ static int k210_fpioa_probe(struct platform_device *pdev) if (IS_ERR(pdata->fpioa)) return PTR_ERR(pdata->fpioa); - pdata->clk = devm_clk_get(dev, "ref"); + pdata->clk = devm_clk_get_enabled(dev, "ref"); if (IS_ERR(pdata->clk)) return PTR_ERR(pdata->clk); - ret = clk_prepare_enable(pdata->clk); - if (ret) - return ret; - - pdata->pclk = devm_clk_get_optional(dev, "pclk"); - if (!IS_ERR(pdata->pclk)) { - ret = clk_prepare_enable(pdata->pclk); - if (ret) - goto disable_clk; - } + pdata->pclk = devm_clk_get_optional_enabled(dev, "pclk"); + if (IS_ERR(pdata->pclk)) + return PTR_ERR(pdata->pclk); pdata->sysctl_map = syscon_regmap_lookup_by_phandle_args(np, "canaan,k210-sysctl-power", 1, &pdata->power_offset); - if (IS_ERR(pdata->sysctl_map)) { - ret = PTR_ERR(pdata->sysctl_map); - goto disable_pclk; - } + if (IS_ERR(pdata->sysctl_map)) + return PTR_ERR(pdata->sysctl_map); k210_fpioa_init_ties(pdata); pdata->pctl = pinctrl_register(&k210_pinctrl_desc, dev, (void *)pdata); - if (IS_ERR(pdata->pctl)) { - ret = PTR_ERR(pdata->pctl); - goto disable_pclk; - } + if (IS_ERR(pdata->pctl)) + return PTR_ERR(pdata->pctl); return 0; - -disable_pclk: - clk_disable_unprepare(pdata->pclk); -disable_clk: - clk_disable_unprepare(pdata->clk); - - return ret; } static const struct of_device_id k210_fpioa_dt_ids[] = {