From patchwork Thu Aug 22 02:52:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13772515 X-Patchwork-Delegate: geert@linux-m68k.org Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010040.outbound.protection.outlook.com [52.101.128.40]) (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 84A341CF9A; Thu, 22 Aug 2024 02:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724295239; cv=fail; b=XqUVlqQd/37IhG4wj2FWlwse42ZKyrMUG4sHFXXc82HWBM6gGlnbegMT2cy8kTrOtmqmOq/8kkVxJlUZazNEq20Mkl7rp4YAZP2Qc8dZajRxQiU2b+D3LbBxB7ddndKL1/KVx92AJLzsNZ2HhntFfKgLasTgQGPG2yB/3g8/x8w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724295239; c=relaxed/simple; bh=eukMocBaSIj04YTmeXwq8lRSfiOCc8qfJMNZuwFrtyE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VZhb61VffRKhzVk9qWYGvt2HJKoI9VNMebUfG7joFaXI74uflO9kq+QCwN2rxftiSNuFE82XiV5HfaBaD5K6Gu/11ZofcvIsHuQLjVtHjxMsNnBmPqcycpJ8aLEU1Kfi1hBdDVewUrMuDkFFiDjWhyHNBCkzGYj4gLLVB9HS5n8= 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=FksC+jML; arc=fail smtp.client-ip=52.101.128.40 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="FksC+jML" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QKkQ4kpq/g8ssrVjINonp/V5Cw7WGUkE6+xfRK6rtgTIkbNFBpDEdBYluCL6f2eJiNr83Zt1tcf0DdXVUdI6A+iR728NpSMKx692ENkHNuAzVKuI5mg6JhMUMiQ+jKY5NihaAVoUqF5fxUPsTyolwxRLvL+gBwyjF9Lpsq+BjLyDXqzbI0W4y+Ut3GzC88u4PnlnCCO/Lr/jVtGt4aoswltzb2Bc6P7ic68334Ya8Mf+DU25QnsZ3dfLpdvJXNF2sKlEqL5HAjm4Q2lsV753Z7yWeLnJ8nn8ussd7rDSCjMrWdU4yZhatiYzLQuC1ptTxw+lEHP7o4Go4ryQGK4Y1A== 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=vOrDO9UbLr3Jvx96zifJRWw8lfqqYFrFS2p+2C0sGoE=; b=l5TkxGz3e6XCBPHqwPOMKj7Szyva25gqEZd3IR2N5BCCsQW5tIiZEp9clDXlFGJOZmPUMK37rhpyP5x5oqyJHAftg2PUnT1Bn0vK+ctuSNjdh6bqC+yl3NmR7GoxSM0ja0bu9gS/oZElCEN8nTgA35uQX25xepTAwNPrumrwweHhaX9IOucHy9OTKq0UqSpSjn8sdtW7LzV9TRmG1DrU31wXasT94n0qi+CQhLOFr0wsPGQ9I+gj4PbHnef18dK0PCJKjdMSZBqpKY91rEMD2vP91B7t748ptkFiCdP7aD4lPcs+Jwhs8LWOWM6tD+Og33bqn9HdYfQaUuDixje98A== 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=vOrDO9UbLr3Jvx96zifJRWw8lfqqYFrFS2p+2C0sGoE=; b=FksC+jMLUMZtWMPGHeGRjVhgeS36pttq+yr8KhSOfKKteBxoUUlIkatE6xBfHanRFL1vWkCmnl8VSJ9lLHhJFTmqhk8rtkc35/gp8Q2lqUIWfZRTtI75XpMyxtEPKud3CQvBsEjMLXJeke0J4lgOkrar8TnSMELqA4HWIvhJ0J1iOLRdpjjF3b2+MApo225WfVavr0i/w8pbCyipHUnOITqP/0FowXQrBablos7wUbnOHK8dLzAFeI0qWQoEs2Mp0HVput1SVhSUFn2HXN8WmpMSLEQD48SSsXfNGL2vHRCk4EyUmF/5GWeLgkHD8iQtSxetLoHp3cIJWC4mMEg8aw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) by SEZPR06MB6485.apcprd06.prod.outlook.com (2603:1096:101:17e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 02:53:54 +0000 Received: from SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666]) by SI2PR06MB5140.apcprd06.prod.outlook.com ([fe80::468a:88be:bec:666%6]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 02:53:54 +0000 From: Rong Qianfeng To: Wolfram Sang , Andi Shyti , Paul Cercueil , linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Cc: opensource.kernel@vivo.com, Rong Qianfeng Subject: [PATCH 1/2] i2c: emev2: Use devm_clk_get_enabled() helpers Date: Thu, 22 Aug 2024 10:52:57 +0800 Message-Id: <20240822025258.53263-2-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240822025258.53263-1-rongqianfeng@vivo.com> References: <20240822025258.53263-1-rongqianfeng@vivo.com> X-ClientProxiedBy: TYCP286CA0280.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c9::8) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|SEZPR06MB6485:EE_ X-MS-Office365-Filtering-Correlation-Id: b757c25b-8002-461e-7ba5-08dcc25596f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: IM3l0xXHuQ6Ic+sGg7GwuaMfzXLLsC5YMq44Z7l7I5r8OrbZBoKdUM+2Md77wuzf44FqioT1LGfZ9aI13u0Iky6k6Ryq5b3nY8X/Kn/0ect8dqPPW5hy/DI2msrA9F5mTqkoZe4S7tiIWDPTEtHa7ZNNBBimCjAkshSS1mC41tSl+WDyFR2M5+E4tBdqcZScQ1vx2xXuxrD6WwGBuQrv5tkFpB3ujIfCUuULbGHrKP7kcKOwz9cCfB8o+3HqpnhyrP0y8l1WBkWwCLgzLk0P/MMlT8xhL4yfoZ+Z4pLRTJLosQAJGOLniCyZyJDe2EknOvYX6AKUq23ab9pcZdXMneB9QTLsLJWTUsi1arDpxqxYUu2qpZ8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255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB5140.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EetOEPUuJ+Odg9/wjT9Qh/u7Nz2KG39AF2k7LDFav/0oXorBBfZMkAgEm3F+0sn3uRH8oh2gidPAZtIoRBfqPCCxL9SWKuMZcybD+6NSP/1wPePAWgkdFnAW8xxqF+P/8xq9HAS7IpDZKTdea7QmSK+0md09o8PhS6EVQs9z0/90odWWhhQw6steEo3lu7NZaSE0D3bfVUAQSc47f460Vv8MwziATYZTLBb9KJKj9SkZqLdNInhYoCI37y+lAUztaxX6wEAIFGgSZkeSUipU2LO8NNvSmg+nZmXcE2TRRMkX0zWci8jnsOYCtNdH9EsUaXzoHwLK4Mtppvdt9DYu0BDv9DOoOOIxWzfz13z48IQPJOPOyHFpkjNa7fwrHkpouFoIoKcKbKxmV54XkNWKlOKzb4N09276lyiiOkoColiTj+kxQexo/MvwyKJX7LKp1zbmXdAgT6+AIGEZISyYaVGFJ/yvQirNtT5up/noFP/BI8dlay+ycxDnb5UOFoSBS2HqSlRTZzdjb/xlnLJwfX3DtJJO4vC+bA3iEEwKETb7eFHHFiqu08PqMjJCINQqHB2xRJmyH/ij6QY0LufNPYM1J7wMsfYY8hD26x8TLRpKqiGecWkj1UANOJMZixHkIBWUR/WIAYbe5ONdRgZMfCFwgc1IeRkr8iSdEQRRHsdIWrfLR9j4RY6bshJMz0eSqcTLZ6Wf7KLWlTuzAn+rVsYJyCdghRXlf865kIfB9s/hPypg5XqXztfLbRfz373/OA03+q+AT1D/A4ewSh1JaoTijpp0dWvBDIGV2dLmVPP3zuYAcOPoUBJqZmtUCvPOVPm0Z8xSCabNUadgIKaoVGupCaKRu5DVvVuXxM63KHax1XtVvwVxsqUrKfTMvNTI1O+LeyTBBV77ZXsnnojr71Z/CVgrxRhrbTzn280oR0P6/OjE0Q+jjbaRtWpfWN2keciDSRVz04wEXeMIXmFkkqLwYzmNCG+IIHK5MaHY1wuL2tg6+qwHNkbfMqoa68JSAsRLpbWQISFLmDUPULKQTNm5h6AkmBlbwi8+kutTDxXZBG3KO5uEDwVMNcF9JJIbYrAHZLYbgRTJY2/pSkqDwCn7HxBZdTfTUT/9samzwD3tfceOvIe6Nkg2HJNig3ny91PdTtl8TUDJl/pj5B/4LO6WTQ6/agE8wXiPh7otugZl4P/b5xqbH/15noxaoH8rHitHW5Oppc+xkLCS6mjeNq5yE9W9LjwyFAGeyMX76CcdqHr4/TeuFu92fNULyAsPIyt3WwBMAHzUcRJYqbkpbBQYMHb8GKCN71fbHL4KnrqYUx80/N64BWcJZUT1D0Bl/hPWBWnXBFxNjtUPNXqHhswJA5A5VrlDNFiX60HzFhcXtD1GNO7fMP2e8MzprLL4aNNaS+HQDDkcLeARGfF95YJxX6VT9GlpEAWMxYVxSGIP0IBoU0NDwvUXrCZacmTxdigtRQYM/bfBEo9wxYp4Ehz+KHirHPm07A1lVd+avvjfg10XyEgM2cCD4cPlRPhMLpGOeYTfjsIx9hxtncqTKD+Zu8T9NB1WBydaPntUcqoWtPydqTcGNAGu5awK60Ec X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b757c25b-8002-461e-7ba5-08dcc25596f1 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 02:53:54.2559 (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: zI2r/GBvV0dmxZC8r0pC0Y/FaIK6sfq7j2McpqnHs7lnEqRclowG3rUQw7okKH/0fVuctxc/OJplKkM6BqrMvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6485 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(). While at it, remove the goto label "err_clk:", and use its return value to return the error code. Signed-off-by: Rong Qianfeng --- drivers/i2c/busses/i2c-emev2.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-emev2.c b/drivers/i2c/busses/i2c-emev2.c index 557409410445..20efe0b0cb85 100644 --- a/drivers/i2c/busses/i2c-emev2.c +++ b/drivers/i2c/busses/i2c-emev2.c @@ -373,14 +373,10 @@ static int em_i2c_probe(struct platform_device *pdev) strscpy(priv->adap.name, "EMEV2 I2C", sizeof(priv->adap.name)); - priv->sclk = devm_clk_get(&pdev->dev, "sclk"); + priv->sclk = devm_clk_get_enabled(&pdev->dev, "sclk"); if (IS_ERR(priv->sclk)) return PTR_ERR(priv->sclk); - ret = clk_prepare_enable(priv->sclk); - if (ret) - return ret; - priv->adap.timeout = msecs_to_jiffies(100); priv->adap.retries = 5; priv->adap.dev.parent = &pdev->dev; @@ -397,26 +393,22 @@ static int em_i2c_probe(struct platform_device *pdev) ret = platform_get_irq(pdev, 0); if (ret < 0) - goto err_clk; + return ret; priv->irq = ret; ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0, "em_i2c", priv); if (ret) - goto err_clk; + return ret; ret = i2c_add_adapter(&priv->adap); if (ret) - goto err_clk; + return ret; dev_info(&pdev->dev, "Added i2c controller %d, irq %d\n", priv->adap.nr, priv->irq); return 0; - -err_clk: - clk_disable_unprepare(priv->sclk); - return ret; } static void em_i2c_remove(struct platform_device *dev) @@ -424,7 +416,6 @@ static void em_i2c_remove(struct platform_device *dev) struct em_i2c_device *priv = platform_get_drvdata(dev); i2c_del_adapter(&priv->adap); - clk_disable_unprepare(priv->sclk); } static const struct of_device_id em_i2c_ids[] = {