From patchwork Tue Aug 27 03:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13778803 Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010041.outbound.protection.outlook.com [52.101.128.41]) (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 1EDE71B978; Tue, 27 Aug 2024 03:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730544; cv=fail; b=MlMZusfFf9MYbOJBg5K4QkTmxMeW3FG5khOkKV5zSQuMNXEGvYzBELMYnRvDVl5RwYFM2788gRqScvSHipTsC7T7g8DVHRKkSlCLR1dwPxPCyWGGMQ1HRgq4RdtEa5phv5U3M92gYUxzN4mZu5AANtbkCfFIaqU96Yt86nH+mm0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730544; c=relaxed/simple; bh=cF0AJa6LTRobnLH9L+nH+1pTx+DG8UDf0O0syA4Ja/Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=dQk+mI4coA316ESV7kS2VG+AZ8NRpxouEmQmM/0VlS6F335SdbO8++xR1DJdRtSRKt7NYfu7OzC+NmQfu+T84UKxA2Ni5tnbjPRx65nD3Q4teUwiNAYwLZAmxKvJNlhblEJfSTnOadsxng43T4Vk6zQnRj9sQEUTYRd+G/k4q84= 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=YDzvKnEe; arc=fail smtp.client-ip=52.101.128.41 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="YDzvKnEe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ynIIEi6P+t8P8d6vLk5Xngu3rEvqCIPrtg7WSGYINQYeqOV0yCzxQy7CoR8zhIqTl7yaQh/BvyJCKTGT5Skw0I4Je/yTt2MAoISu+0o9/4KNTHGM9NqgNlHc4e0F4O1lSWcFU54tewiBS5tOB+98BIaDuhLWmdlIZS9qQVSXtOnVYm9Aw1ZtQY1N7cImxX9q6qLxsKrzYm/KsLBmKlosfqkEmcymN/VeKoqXuum7MflJLMypcLJ2oSmLV9O9QMKqU9O2HbkSlKcQrG60tAOx2W0C+BpeXoaoaYCOf9q29mq10oOLWQT/YNBvSB12KgiO9YjYKEQNjcON1YyN5xIeeA== 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=BNJCGszWoHFq0L51NYpvZNK97qulYTh8Q7SAAhMmavE=; b=u8DKmBBrd+Ig/nfbP0Ch5TlWDClYCyy7Cu8Wmqo0fu5AOnQYsdDGqc9X42t5FJwWQxGpgYD0MhRH0WIVJ+Zt9xIrbBhU4NLoWN4AMBH+St2Iv+cMPTHW+R8s1ewEyxTCTPGsna08VT9eCYX57p8V0WdQURBSNpJgG1cWtslbbHUYV8GqFMoLanFLCZ+X7z6u4zYQs6UFth/R3d0PoCZsA4bgszD7IcHdRh83SD80/C6bn+VAoBitSAbeyJ4LSCY6HGTxdTkEwJvZ90dEKWoV8D0JmIH6OjpdbLBgjgX4h0kH9wJ3Xuh5dfD+iFQAVfPZfDrd+zw8s2NxE6AHl5A/xg== 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=BNJCGszWoHFq0L51NYpvZNK97qulYTh8Q7SAAhMmavE=; b=YDzvKnEe2/Ed4GMNe5DtkMJpk6r7s5wmcJS+ylJT0Ef4WBfAHPY/WsFgLvAoBUfLOX81m8dTZPNR7cdt1h+TKWXYagz6XRqHVDAOW+CI2meDHRnNBj1lANlqeRPdGj0pQ0mpzaAFNUI1lWfh/KdbWZ+JlvOJMm3toeVHzUV2f4De0qn5osEGTTms9GvGflgY2lxzm0R99fY+F/QeoucymFsYdE8laZak2Fh8KPGGIXSW0X1cfPTnwJdgBfBqTFa1bGgvdd27lNHjTFsibHXjZsWiHMqVzbAFkzmC0CcnknaWu5kRiJWCGvybGsC1+vD8pgGIPFkObf99KFv9P3VZ7A== 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 SEZPR06MB6531.apcprd06.prod.outlook.com (2603:1096:101:184::14) 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 03:48:59 +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.021; Tue, 27 Aug 2024 03:48:59 +0000 From: Rong Qianfeng To: andriy.shevchenko@intel.com, biju.das.jz@bp.renesas.com, 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 v4 1/3] i2c: emev2: Use devm_clk_get_enabled() helpers Date: Tue, 27 Aug 2024 11:48:39 +0800 Message-Id: <20240827034841.4121-2-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240827034841.4121-1-rongqianfeng@vivo.com> References: <20240827034841.4121-1-rongqianfeng@vivo.com> X-ClientProxiedBy: TYCPR01CA0131.jpnprd01.prod.outlook.com (2603:1096:400:26d::19) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|SEZPR06MB6531:EE_ X-MS-Office365-Filtering-Correlation-Id: 36b518fc-5721-40f8-63e1-08dcc64b2f10 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: grr+XaneuMzA0Sr5YS2aU8Mqy4Fjw7bjirzfTFmcxIdH+1yrLaTL5SUpBXlroMPWptWIWtO84G4tnvR0tIKeW6RZBy0oA0653pTWHxUajv0vp2O9oF7fK/ZglMpOsGVyURk4ZOWuWRaQ/pDcvrKBWC49Ybwx0Hmklag1e5NMoFQEytelVldyuD5H8lM9Rjc2fFzk5nVPsUh2AMHoAKGVEcY+PZQh3vxxotO4WCN17bY4CUBhnSjXOxJ1DucsGpe5RMWUK1hfzB0lubBdgJNHb3AAOXSM9fIG29hfNfNqDEHqzfitGGBAyE4vEgwxAgfRDNihdegSwiWctlBKtAfg6OXtvAbc05YAnalaXF7ND2l5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Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB5140.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: UEmCQz1T+tOqSTobYuubtp1AL8/o/aRoiPoPxdBg58GZQEGbESvH07Yp+1iHSrw3qz+XNqerAwV48L/1fEFuo76HHPYaAVVDXKfIOZHKxEb5C2iyXxkMlQ42SUVu9WI2ARFi246qUiOgKCbqdbepFxDT03FdY9AIQd0fHpGbmLMgyplfcamknPraOxIxrJafiU9k5R6LgjAm4CFchAOi9nmSg8BWruGaraLdi3+n0Jqku/EcxawBx0T6AGivCCdPjPonVl5/Kf2yiFjNKehfWhE8Q8jWax3/jX0p0IULcAOVVRd1Nxz1qTkkcPJBC+5W/Svgvafm37j6UnzwY/TB/KdCXbD/8Zm6gdbTHfQnDQ1o4qZL60cZTmI59Hk/PlzyDeTaB6qrgDBo2jcgoB/1G6cseNftHdijNcfaUNIt5BsHyoejcxStewhbefuE5vK7DX6my6LPhq9PKeCy3xya6n3e7DnT2Yg8ou/gBZnnqnFIVGSjckFJmJxKqFnrD0jW/suE/IKjHLQCl5K0Gx/wBD3r3fIEL0ZKqB7P/1l9etdoFLOryVlogzgBO+OLVY6OacN+uK+n8+OuURYSV10uJrWKzlfPv0O53gWR6fGQoo/5VVo5xuSMxA+4Sv1UxZNYxUfkBcghwmy9o8alyO7QqmVZsZdjrJXsldYsgzSu7+KtPXGgJzF0fXb2yx6AXMeMD81eZi8If31c6zSCEDGdJ62bzmxsn3D3CknZgogC6bim3ns2Xuf11lwSuKrfLa7nAPl8UeY50h8A2yN38r+Ym4uRRPPPT/w3qZDnwau3xNtD3TGqainkz5KZff29sTVUX5AdV9LcglGmJTzdYoZz68aEPCAZXSMpe2jJEIa449VFioVHtJp1Ih0K7guFRUtRMiw2RxFOngrG2fG2gOX6NO018QYEErGxqFkuXz7PsL/Sb5sLs6R3CALyjMFLMOz5zEFZ+uWxQfczOvr62sBpagInDABKd+jYIwo8Wmrf30j1SIGoODA1Sy3IYsYPP5zIMm4sRUdD3hZRMR1+ah9/Rnp7WXzyGCkwF5Zy9PjYfs/r5TI6XtzSNZs2Soun3a/njIgvTdMElBBCY+g7tEc4pLCs0vczEx+Vv7N5BgzHsma42F+1emOrVqm5jX4rxzpLTLY1fCebrGkn1lpIvnS1nHaEkkTwL+blYyPLW35P++IdNDaaQ9XI179JuRbnv3dvLbjgWuDx8QVzyZTM8reX44/APE6YyYGBpRNFi4t4Rk8BE79/4QqBQEZrqdkvYLKkQx1+79558JWIFh8dHvSdXMYBY7zAQEJ+d8lIdVrnZ0KeuM6JmnyH4rjLaOEO201CUjXhZVpEX5VSj2fiuhlPQRPNSIrytOmZFtpnKQUCkHSbpZE2VsjKzGjFnrPP+/hiViXBGfuXBnL/79tXkTiFNEI6r5zWCHTl+JnuPIKzFwyCSdANkTw7VhufH84FSrEYaXYfzLWdcwB00IIfQsnHPYDAogVF+ftU2UTaPL5z6rZq2Krm+GrNGRTcXE8vTG3up62JDy9GlsS87AzH2QmQp822OuWxjd/ZF5LFwHU9rt0+EamX3M6BuGdXI0mrbGwJ X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36b518fc-5721-40f8-63e1-08dcc64b2f10 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 03:48:59.6178 (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: Ajz1StS/GIbEEdOsZ4ze4Se91+4QvysDADlZ+Anfagcl8zvXmMmuysNVeWktPyKoh7f1lns0c4XdW/eeM+4DbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6531 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, no need to save clk pointer, drop sclk from struct em_i2c_device. Signed-off-by: Rong Qianfeng Reviewed-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang --- drivers/i2c/busses/i2c-emev2.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-emev2.c b/drivers/i2c/busses/i2c-emev2.c index 557409410445..d08be3f3cede 100644 --- a/drivers/i2c/busses/i2c-emev2.c +++ b/drivers/i2c/busses/i2c-emev2.c @@ -67,7 +67,6 @@ struct em_i2c_device { void __iomem *base; struct i2c_adapter adap; struct completion msg_done; - struct clk *sclk; struct i2c_client *slave; int irq; }; @@ -361,6 +360,7 @@ static const struct i2c_algorithm em_i2c_algo = { static int em_i2c_probe(struct platform_device *pdev) { struct em_i2c_device *priv; + struct clk *sclk; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); @@ -373,13 +373,9 @@ 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"); - if (IS_ERR(priv->sclk)) - return PTR_ERR(priv->sclk); - - ret = clk_prepare_enable(priv->sclk); - if (ret) - return ret; + sclk = devm_clk_get_enabled(&pdev->dev, "sclk"); + if (IS_ERR(sclk)) + return PTR_ERR(sclk); priv->adap.timeout = msecs_to_jiffies(100); priv->adap.retries = 5; @@ -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[] = { From patchwork Tue Aug 27 03:48:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13778804 Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010015.outbound.protection.outlook.com [52.101.128.15]) (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 A679257CAC; Tue, 27 Aug 2024 03:49:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730548; cv=fail; b=mnJZsDFIJertqMlm1QWqieuomWkpira4irfpD8YOei2WtkFVZoGRxa8MeefVv3H65JHkKZOpqzmJZ0h16WJkTGrpOIGUpGYFsgJQAudsyP6nwuQG5gWwvVpalQidldHhejJ+gtEqCTfJl1SouLfnMV3ZjHm8fAxB7d7IoUuKbak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730548; c=relaxed/simple; bh=NqHJNC6wnB7+4GZP9jq/byOKxN3JJ9f9FElFA94FvBg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=S/mv9e8N6LrAnNAfRAd7MhSFJluUQWRzhDk/2Sa9SNOhG19BEfrZp+nLSz+gfF1JRY7mxPXPONqxhgjLAQgSZu5UHFKh/rhl7bg93inlJfWrYOoME0wEpYapzby0CI6UHXMeWrTk1xmuKmBqXjhKp+V4TUp9zAY/A3QEu+zxTEU= 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=iTpcc11m; arc=fail smtp.client-ip=52.101.128.15 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="iTpcc11m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Co3vkHbit0yMd5tQPWJinspgDT1ISSKCPTgOwpEV419oa5ZJZrxZaE3QJo9LyWCv5aiLSCauYhtIpprWSP7J8J7LSwHtTIPE9Hn8JiyBihLeWg5prGDtu7sIanPfd155co3IkCIO6c+/6nzcSkqJsDCUDE/qQaNljvGAnzhpGxW0SneVOV2mY/k//HhBLE2O/CHRie9kiRfm72qwScht8ZphU5c/fPfFDwTKm8jIJlo5nONbW/MUkYnifdHxkQXqdz3S7fQAKR45C8f7pwDeRhvPRuHZ2K5FliXS2+3SHUDbbHJXHkvIeNe3XAfTymn0GNz4MgMuiBbXOKyqUv3NHA== 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=B2wsPYT2IZRii9Och4mlfhJpBSQygjtpkDFM2UKw5v8=; b=gJVxuHBOsq2Ocr/K/OFbpfvcs428g05fB4EoURNh3SNjVcjDWtTIe/5N+KIQbkFq+3Uq8/z0Jo0BebivB6YJc5rTg1HXIo7UraO222UiOkNRYFrHRou4uMSX4q/KvA6fE3txEaUbr+kHE+Tjns9V3BpIwTq3AUGvxMwrPpxjxATtHj96/34O8FqhmGONPxEoO41QqrPf5kNeFhrKSId819VVsCXo7tVIGfsrHC1KdK18wa4dAUr1F5rrlc9AhiqDWwurBVKsxXH9nKb3PB3qmAQxxxwSP/rJFLaw9KiaY/S/k7vMpzrlBmYX5KAqLPTJ7WL77yK3mgXO87Szy7zECQ== 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=B2wsPYT2IZRii9Och4mlfhJpBSQygjtpkDFM2UKw5v8=; b=iTpcc11mOPy1xcHehJx1M9NyUSQcrjzPA8gUgOrXVG7pzEWE6nPpl6nnrYOXImYQeq26U9ejnHK8tAg+ma6eWBnQ6EdBkps1idd1LXjyM3vblRvWHrZCXvo1YON3JmbSTjXRSHM0+/LXP9NraqB+/lZNOymPX2HhkkOxeHrJqffPl4bqroeUJ9gqXt/XUVQpnRKbRQbr9aY7/RrGCDHWpKteWKUd6jXYmT9YRpU3UFTov9fLXywGz98z//TshaS6nv/ActkjVyL9CauGMkIkAbU5LOUoU+vRwfBibUwaxZv9v3EC5QD2Q/8F6sO7oaTmR2afals0DvUykNGtwZt+Ww== 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 SEZPR06MB6531.apcprd06.prod.outlook.com (2603:1096:101:184::14) 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 03:49:03 +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.021; Tue, 27 Aug 2024 03:49:03 +0000 From: Rong Qianfeng To: andriy.shevchenko@intel.com, biju.das.jz@bp.renesas.com, 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 v4 2/3] i2c: jz4780: Use devm_clk_get_enabled() helpers Date: Tue, 27 Aug 2024 11:48:40 +0800 Message-Id: <20240827034841.4121-3-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240827034841.4121-1-rongqianfeng@vivo.com> References: <20240827034841.4121-1-rongqianfeng@vivo.com> X-ClientProxiedBy: TYCPR01CA0131.jpnprd01.prod.outlook.com (2603:1096:400:26d::19) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|SEZPR06MB6531:EE_ X-MS-Office365-Filtering-Correlation-Id: 261908ad-49a5-4ddc-778e-08dcc64b315c 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: 9sLHas63k2HoAN9YC7wcwH2+G5fGzxJnX/7GF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0KHVVKbcy3ivwl0DojSu0pTvNHVYoHM5a5cAXtNTTOPedyUhLyPrg2L2DXLEEFT1gaVYNRKoTIS0gZ7v83B7NBcQO5proFpIXcx8vsbA937ycBqIYZlZVtYU3L/RaVt3pms98x2fmXi+MC631plvePHVjdwkmJHZS9cOdHzEMxas4NoO4W1vQxnF9jnqMk3plFVJSYMOapYJlkKxdmKLtxEcL4qe0inED5i/Np3UGBC+oSZZEpC998ffOz4jH5pmWQNqYN8nwPcksubVnh0ThiMOxic57x6qpoymMowwv9dLsW2//3w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB5140.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: CiRglgMbnbUCYuD3xXGEV5XX5a/uCjPxyy67HhirJnka0uDP13odzZgy8vECpfCkpuqgXqoHnQzSvZYzeHXJhk+ljHYlfAC8RVmnBlcSz+/9E+s+Vc3unb0eLWbnCqRcw8g74k+821kOKjj73Fuio0APQOS/aJoXFFh/P0eFIDsSEwFwvjzM3kS+ht0wCksuke8mCxklOAELR8uAfvJ1X0/JU6cXBjScAsIFsdQPsns83DIFPDzAhvuoUigGs4ghqo8664DcYSuumCM+bwp69uZBmPSAQf5eSvDbEARUU1ZyOeVrvwXmJB3vyUqAe9/4nj/Bm8a6E77iOyJLvgd/oj7bpUmvRJMfNw0zg2/L0R1286pUtVJ/rrYPUJi8/SQQK/UTg2hHm0L8VMT9F6qUBbtJtwYa9PQlabCTaHn0qzrHTcdHDFfRIw6GL39MKO9u/v+Yt7XiXYGWbEaGE/3p6sHW+vREsXFG0dRxUaiPwxk18sppo6Kxq8W27NaAzyX+ekHX6i29Uivo77LpDloJgyzZNbQqA6k/YqLtdFqgqGWk6VS+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-Exchange-CrossTenant-Network-Message-Id: 261908ad-49a5-4ddc-778e-08dcc64b315c X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 03:49:03.5279 (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: goFvqpxq7YlqGG1n23iYhjtWvfTIak9NGHGytxj2V4yKthHOxpeXbROMIsc/tJRDR9+LvYq7//LQQXk4TlWY0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6531 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, no more special handling needed here, remove the goto label "err:". Signed-off-by: Rong Qianfeng Acked-by: Paul Cercueil --- drivers/i2c/busses/i2c-jz4780.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c index 4aafdfab6305..92cc5b091137 100644 --- a/drivers/i2c/busses/i2c-jz4780.c +++ b/drivers/i2c/busses/i2c-jz4780.c @@ -792,26 +792,22 @@ static int jz4780_i2c_probe(struct platform_device *pdev) platform_set_drvdata(pdev, i2c); - i2c->clk = devm_clk_get(&pdev->dev, NULL); + i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(i2c->clk)) return PTR_ERR(i2c->clk); - ret = clk_prepare_enable(i2c->clk); - if (ret) - return ret; - ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", &clk_freq); if (ret) { dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); - goto err; + return ret; } i2c->speed = clk_freq / 1000; if (i2c->speed == 0) { ret = -EINVAL; dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); - goto err; + return ret; } jz4780_i2c_set_speed(i2c); @@ -827,29 +823,25 @@ static int jz4780_i2c_probe(struct platform_device *pdev) ret = platform_get_irq(pdev, 0); if (ret < 0) - goto err; + return ret; i2c->irq = ret; + ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, dev_name(&pdev->dev), i2c); if (ret) - goto err; + return ret; ret = i2c_add_adapter(&i2c->adap); if (ret < 0) - goto err; + return ret; return 0; - -err: - clk_disable_unprepare(i2c->clk); - return ret; } static void jz4780_i2c_remove(struct platform_device *pdev) { struct jz4780_i2c *i2c = platform_get_drvdata(pdev); - clk_disable_unprepare(i2c->clk); i2c_del_adapter(&i2c->adap); } From patchwork Tue Aug 27 03:48:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Qianfeng X-Patchwork-Id: 13778805 Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010061.outbound.protection.outlook.com [52.101.128.61]) (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 5274C823DF; Tue, 27 Aug 2024 03:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730554; cv=fail; b=mQ+4e9+kw4ZCWbzGShTBSHFAm1kS39Whqo8Js96ui09VYz4F9SnTzGaVCUEWl28dWbE+P4vB6umkdQ/pqVsS72tPeVhjgCPcYwOYjKUsek6B0N+7l8wnEUOs5QnLXoJvFrIqsIBY6yMT1HWiWw/SGm9nAL/GJLLG6TqXOEBwGF4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724730554; c=relaxed/simple; bh=LQwv8w26gHCXUOZIiNPEtg7mleZIu0UpGDzzZqQlinw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IE8bv/tP9GC9a5RW9FIGa64ZTN83CotydJ7gAjmDl1viru9wLRhVpFvl/u/J3jzwFMqBB5tPLhhGLvmYrHmni+IbzpZ7BV17O3Zm36XOItIh11qXzvcgAr8fPQzR8Cbk7HZed6o5fipi3GhfVAqHK8oRKfzQvhuTmobNO+ePK68= 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=Kp0mwIGL; arc=fail smtp.client-ip=52.101.128.61 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="Kp0mwIGL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J+QOjqhYHNE3LvCzfVKnb1rxx/Fla8Dm1MOlbDZcogq600gc7vtBuc0TYL/8oJM+yGcJ/7RKolKwRnoviDKQ/AHGSkhd9n23qmNsXs4/vC1q92mimLLcRZni1tpoh2ZaorYBiHGBg90C+n43CxIGV7VPoTb/pHpTh15frpNzlmsCv3uTSPli+PIfgjSEUjPZ5QTQyYIekW9agCQC+p5uArdyXzNEieLPNoNeCL3+jeW9kIb746wNbE2wMh7DDsj6xVM50bKvVDGJbC1kInATZn1rlNtlWoBQsylxscWNGRKWXXwugSzExkN+qsNe6yC7bmHSrES1GqwjZMGL94lqlQ== 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=PoWQwT3qKzI1rJ+Y673H/hRZaFJDhObg/J9+MUYW6XE=; b=EOYWUde+NcAouXz9LsRgydu+nKZceK4ie2iSoPlhJTd3HNPO7T13zHdHIIYF+vmEQ/rGBIntc8erUGQQE84p+o99thIH44f/Qgc8+0HoJc3kRGv/l+3VKWETC8oAKMU/fOdaXwz2C1ztqjh73lgvBd5eq9aSgNu1vsn+5JoGdrzwxw6UyDZcefTD28YHpYjSJx7Uy0bhkZumMOMGk9xiNeIarx+O+gk4g4UZHr+7RfzAh8b/JFCgHhAzu/tMVrAySOnaWXbqwqhaW9gtXS84g6PBJ6b1Vq/TfoLJUON+tUZUiQBoYDjNySngf/XLIIIygKpdm9x0CLJFaj8SkDgv4Q== 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=PoWQwT3qKzI1rJ+Y673H/hRZaFJDhObg/J9+MUYW6XE=; b=Kp0mwIGL74obaVx8QztUw6UhYOVE7Mn/L5fWhE9StzyDqe810Jz1NQjZb03Ck21DEl/LoRJwgq+EcyK4BabCHh1sKDilG56qoeKxpzj1zAWkqF2QRhZ604uYW89gOPiBsw6t99lbxw6+Fc2hQXpUZNw/P7Yc7dZgNaxCwmxwscweuFZu7e157Bwb3z+nnxWfEeAIE8P/qeEYBL0fGt4n+ZHPpEgZ1HTiKKWLEbwZ011hyXEVPqmdM0/WvTzMlM4uaAlE0z7lVRfMcvOpDzf3FhkBlTHM8tTCWil2VEEPNAhRuYdrM9Ff3gAeAXRLNnzbPDjo8vzMqzF5jeQNJEUxRQ== 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 SEZPR06MB6531.apcprd06.prod.outlook.com (2603:1096:101:184::14) 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 03:49:07 +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.021; Tue, 27 Aug 2024 03:49:07 +0000 From: Rong Qianfeng To: andriy.shevchenko@intel.com, biju.das.jz@bp.renesas.com, 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 v4 3/3] i2c: jz4780: Use dev_err_probe() Date: Tue, 27 Aug 2024 11:48:41 +0800 Message-Id: <20240827034841.4121-4-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20240827034841.4121-1-rongqianfeng@vivo.com> References: <20240827034841.4121-1-rongqianfeng@vivo.com> X-ClientProxiedBy: TYCPR01CA0131.jpnprd01.prod.outlook.com (2603:1096:400:26d::19) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|SEZPR06MB6531:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c4936dd-41dd-4907-8779-08dcc64b33d2 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: crC9lWIw4MzMnKffu4Nt/aOx7ByI8wM6ZEffsObmXd72a1A0mx6QjtAIOxFhtd8qb4qamIM8mRbu3rXyAqyCrK/dDWErYon+Uj6PVzi6o5SH4rnHPf0ZifTeJi0G88CzHf2J40zsQ6Cl1hjJcy9nbp7LaEtKuhRXiJ2TVhsa17W37R3WJJ8x8l3OwNB5+2zgUx4DXVasxQA+CGb62MZ3OSPTslbFPl2FzvBnlHjJy1qcUi3DhvkrmJof2U+U+uXcV69tkzgXzfSv0wL5th0qAEpJTOc5ZtmVRhHrOlQ0ErbaCQM6Kv8CFh3wyrIpcj4maSu79JD65NDy/SafZZnJDQCimW7z54m5zQ5PnvjhBm0PQf6il1SnMUurCDE5aA8FfR4jB3LUag0Fw7wcIYts9AhPBK7zXqqQz80CmUd869HDf8P7DCJ3/e5GiDYQWusfVks0Ab1BnI4+CymODvxWlDX2NwZWMEugyZquKSTB4c+TPKnnKaAR8JwfaIskqVPBE3VMb1ZYkN6nsleLMyRemyz9eDo8a2enBtIoq2D8LZhFc7OJJaR2tO5J9wzytlpCcip7vytkRMY4yVP9WWdpTLdMngyqoTwXvOjoP3SdoT7P3unKciwiJ9mH/q7U4COD4Gr+TeKRikhelzwhVd2jjx87iwyQPcMpEr8Zj95kVXkg6QYQ4XeAahN7lrHJFBdoE6FmtGVyc59BdgFrySQpWJRPB945shzFxb4l6WWU9UUbgeOU7cs86T+hB6XFi5LqIW6XkrIrcNrydxh5PnzczSk3vcvtvR6Ahu3fvXm2dDlQSI3QbhaJiKm5OrhttldIqxWwxOUwWTjR4o0M5u4G/b7BlG6VRefFawFWYiwFeQQi9/pu0bpwzhrvVVVc504HaNCylvKbiDrDwNfWgGot/pFc0is56CnGFsWfnNKoi9TM4c3nwSYUhGRc38Q24OLh99M8EtR8krXNUgRKj/kI96m3Pgn0PBZyREdK4Yp0tOZ7x8lhZRcWF1xgewKRADUfzGx43x04XzWVNyhSkmzb0DLndlJ0pz8jwSYEmkrb/ZA91jhR0NmECCzO910kgAdyikdyiklVWT2We/ql8yT7PKTUg54JCczZtsOTDaMnMFKdVvr37CoeEECVbYayVuf4MXgSqecEzrtvBJO1bURXiRsNwhPY+pEzTnOk3Y5B7a3h1oQ3WDQj7mq8BtTM40FP0WPRjx8VAJgFC1gGthghJagn4z7/YmkseRyH1pggap8pXD/F800c0B/lrWZYtpx/kgJohLQ+LoC8CR4ys4rf5NNRG86r0cthNEsPSh/K4IJTfOc4zAYIs5w8ocXxIGo4phlefeL5aJZ9bjYZeaOYlQji0sXqH9UnVsg5O5Ea22Dg9MZOGcQ0p3qZMqMS62OEusRw93V4vXvz1KYWVB0w1Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB5140.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: schs4vM61dEmtsKI7/Vrf3b8sVjvA5XDmcjtHPF7vJZBJMWixLMj9ZDPj0QNahyl3tlFohpLTqiae5slyKmTYMpqdhwcntPxV7XzUUOCfCV7M2ftDPUK9nGttlcbtlBdu534OFtBBcHG6mVjmEQif/nO/ISunJ2GpiRw3Vw4g1jar78driIMjAuL3AaRlB8ql5s4czb1bpd60Zg8U+8QqTlfrfakW0dbXoufeK9y1kPt3neeIFvk494TiYiKJRcj6R/Lz0agWM5py3CgCvpmJ8GPj8HHTTkBRgUORsDcAwgWZ5/NB1y08KoLQ89V89yrvOTjag4/j2JxOD7d21Bx8joO6WicOMvm7OpazDdzE9WZO4lgIS0cREjHaCOrwYIUk4HcL0iyTNWoQQQiwfUqT+h50CgOv9HLxI6QHkviubSItBGS50p/XRepgOLOAyR0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yI9JBYQKCKPzOKPdMLWSYHdWYi8nnZPj5ZPAjsZhVIk X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c4936dd-41dd-4907-8779-08dcc64b33d2 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2024 03:49:07.5787 (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: zYODWBbYlQLVrXu+64S0GNBHj9d2x8JsEbmrW12JXfje0oIF69si+UADK7nJYCCmQmYgD1AoQ3tGG/tk8OBhVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6531 No more special handling needed here, so use dev_err_probe() to simplify the code. While at it, use struct dev *dev to replace &pdev->dev to further simplify the code. Use the macro definition HZ_PER_KHZ to replace the 1000. Signed-off-by: Rong Qianfeng --- drivers/i2c/busses/i2c-jz4780.c | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c index 92cc5b091137..72823a0f39c2 100644 --- a/drivers/i2c/busses/i2c-jz4780.c +++ b/drivers/i2c/busses/i2c-jz4780.c @@ -23,6 +23,7 @@ #include #include #include +#include #define JZ4780_I2C_CTRL 0x00 #define JZ4780_I2C_TAR 0x04 @@ -764,14 +765,15 @@ static int jz4780_i2c_probe(struct platform_device *pdev) unsigned int clk_freq = 0; unsigned short tmp; struct jz4780_i2c *i2c; + struct device *dev = &pdev->dev; - i2c = devm_kzalloc(&pdev->dev, sizeof(struct jz4780_i2c), GFP_KERNEL); + i2c = devm_kzalloc(dev, sizeof(struct jz4780_i2c), GFP_KERNEL); if (!i2c) return -ENOMEM; - i2c->cdata = device_get_match_data(&pdev->dev); + i2c->cdata = device_get_match_data(dev); if (!i2c->cdata) { - dev_err(&pdev->dev, "Error: No device match found\n"); + dev_err(dev, "Error: No device match found\n"); return -ENODEV; } @@ -779,8 +781,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev) i2c->adap.algo = &jz4780_i2c_algorithm; i2c->adap.algo_data = i2c; i2c->adap.retries = 5; - i2c->adap.dev.parent = &pdev->dev; - i2c->adap.dev.of_node = pdev->dev.of_node; + i2c->adap.dev.parent = dev; + i2c->adap.dev.of_node = dev->of_node; sprintf(i2c->adap.name, "%s", pdev->name); init_completion(&i2c->trans_waitq); @@ -792,26 +794,24 @@ static int jz4780_i2c_probe(struct platform_device *pdev) platform_set_drvdata(pdev, i2c); - i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL); + i2c->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(i2c->clk)) return PTR_ERR(i2c->clk); - ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", + ret = of_property_read_u32(dev->of_node, "clock-frequency", &clk_freq); - if (ret) { - dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, + "clock-frequency not specified in DT\n"); + + i2c->speed = clk_freq / HZ_PER_KHZ; + if (i2c->speed == 0) + return dev_err_probe(dev, -EINVAL, + "clock-frequency minimum is HZ_PER_KHZ\n"); - i2c->speed = clk_freq / 1000; - if (i2c->speed == 0) { - ret = -EINVAL; - dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); - return ret; - } jz4780_i2c_set_speed(i2c); - dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); + dev_info(dev, "Bus frequency is %d KHz\n", i2c->speed); if (i2c->cdata->version < ID_X1000) { tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); @@ -826,8 +826,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev) return ret; i2c->irq = ret; - ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, - dev_name(&pdev->dev), i2c); + ret = devm_request_irq(dev, i2c->irq, jz4780_i2c_irq, 0, + dev_name(dev), i2c); if (ret) return ret;