From patchwork Mon Aug 26 07:06:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Liu X-Patchwork-Id: 13777398 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 107D2C54733 for ; Mon, 26 Aug 2024 08:15:27 +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=f51i7ikpQVQEc3QWCdhMBhS6hMUm/719P036cM+6P1c=; b=X6qAHGId/1jwQj XJBqinuctQZG6VIyBAG42F/cK/BW4QDm7WaD7R8fHiISjhtJLKELd3q/QVH1dgJkktQy3xZfV0ug4 VbXfwE3vS0PD9kohhmtSZa8kViKCq6Qgh1mSIxkWY3GJcl2ubZy6z/ibGRZeiV/FgYsxC7dnOs/qu t+X65skkIJXWcS33docM4zsidS5prSqH2hDvtn5E0bVgT0Kv10rTAxa3M1xHubOnF4z2rQn+Jy76v jQTlZwoeG0WkT642Mnx4vPX5Bh2TmvH5WygnEAQ+dyWPe9JkxNVPd162Bes7srPYm3BjtwC0FlwPr RH+TVazPsvHlXZ0IDq6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siUsk-00000006R27-1EFU; Mon, 26 Aug 2024 08:15:22 +0000 Received: from mail-sgaapc01on20628.outbound.protection.outlook.com ([2a01:111:f400:feab::628] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siTot-00000006COk-3UYi for linux-riscv@lists.infradead.org; Mon, 26 Aug 2024 07:07:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CF9MW4sE6Zu27BdONibj+oxAdnhBdp8G/SCmQ/R9VLHP5jC0l/DZAn1zM0nnnMMUHZTq8ni41yBnMSd21i5oTB/QcJ8RerZ+M5lRhG87AbjnhJkgSTkI13S0aTfdBEmFxyJuh4a1UY2h4r3CpQJSgLaJjgxbaBB3/kEXSlGKKdsNAFJ+CD2gLdbDoD9q/r+R4VQtL8BIrNKij03RKx7kBUWlYsVoxXKiF8SZ0FDfejRbtQUZRB4lJ/uFxFgk9BSD+ZOPF1NUeLQaqPpcZwZM7+Eplo9D04xghgM7Zjy4DGIka2FsET2Qb/UOZ3MyLE9PpEmOVdKpSchuPYL5BJQo3w== 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=CorwTMLuhosCwzF7YuR3ptqxDHpdpZfCA3AlN1a2eZo=; b=Wah2otBdhC3qS+51smeLjl/Kd0Vp2TPnfM5rUMBjs6uzHvLtMJbbgrVlDe7415vNX/tXAL9dbZ9KHgChlLN2mwZWgfU23MCw8mtXE4Aj/e08rGHfZ4v7dRxrgpOQprZuqGiK6PkS0NpKvzJRYCjDN1ZJotfczutGPIFzkRlKabz+cTjLQEtH0bg46cNd5d6kYBgNz/uKZXP3cD15mzFzUbL5yT1uKhA82sDX+zyq9NVgZEg6Wpx9n/ci6uKHLdaHW8MmPR67Mcpse2Lp7Chx0GKvVBNC2uyUaVHdz5QB0yjkMKB6WkY/3RXqN2WHMdC8c8D0lQqmRv1SQZArRpxSiw== 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=CorwTMLuhosCwzF7YuR3ptqxDHpdpZfCA3AlN1a2eZo=; b=UHT17zFbaptAN5IZ5X6dzCB3CcsWrIwL3Zi60YWFg0xhfmOqhM4z4lNlZ0wMY7ugJunmAzbnH+XBhqJKnguqHa22pEUpOFkRWByKFLjSL6reLQxzj+K8XIyN4PXerxccCmBSUiH9vIRv0QMoxKydWOUPFoH4UF9HR4cWUyZ6Oi9sakGK6ul93rD19U5yVMqGAZka6q1qALyo24ufsaeJ7V158rU4RTqvRjA5Ss0hI/E0cgxk2GVSvfhCQH3kguL1VQIvkbXu0gJ/Pk02k/J5dyualgM0p13rAL7YYHn6qtEhseHSZpGApEVSBiQywNongz7y2P576vT30Rb6vGdoTw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5624.apcprd06.prod.outlook.com (2603:1096:101:c8::14) by TY0PR06MB5847.apcprd06.prod.outlook.com (2603:1096:400:276::6) 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 07:07:11 +0000 Received: from SEZPR06MB5624.apcprd06.prod.outlook.com ([fe80::e837:10e3:818e:bdfd]) by SEZPR06MB5624.apcprd06.prod.outlook.com ([fe80::e837:10e3:818e:bdfd%5]) with mapi id 15.20.7897.021; Mon, 26 Aug 2024 07:07:10 +0000 From: Lei Liu To: Conor Dooley , Daire McNamara , Bin Liu , Greg Kroah-Hartman , linux-riscv@lists.infradead.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Lei Liu Subject: [PATCH v2 4/5] usb: mpfs: Use devm_clk_get_enabled() helpers Date: Mon, 26 Aug 2024 15:06:57 +0800 Message-Id: <20240826070658.1933-1-liulei.rjpt@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR01CA0016.apcprd01.prod.exchangelabs.com (2603:1096:4:191::20) To SEZPR06MB5624.apcprd06.prod.outlook.com (2603:1096:101:c8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5624:EE_|TY0PR06MB5847:EE_ X-MS-Office365-Filtering-Correlation-Id: cc379384-2897-4692-3a4d-08dcc59db448 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: v+KFbqy+PXK4q1Yrb7mcBK+VWNidlhUpYnDLFJW27dI8UMYLZLWlctRt+T8XAYDbNrj3U8kg3WzoO8A5bNi/w9/GuV0TLv1ODptwEh+rCAa/hXuvyEeVYpB7KPCjvDQG/WDKxna19zDiFJGtl7mVfPl6UW8rE8z+SE6dGwwZ9lhzzGmhXGzHRTduoes8gkX2PqT9vyKMVgmZmgMTVmerCJ3Vr86rmLVqj2TcBYHJn1UbopALl+ruQByvQauco2lGF2kU/akXaH3IKWsP1ko/iJ+k5ay/D8n74POtGw3uEK8e3Kdf+y4E+PJxdFVJZqynsKnGDX9Pj3O3LpT75Nm+/OwM95u3keYgaoHaQbWECaTPAkiijd3g9McJrNW89WWOugx5CAZf6Xq0YKSKD+84/9eW9BHxVRTCpszA/jqYHfqjkir7BBnhlvyPetFmSiR+FlJVeVPhcO2kP1oMNcBjgrz1SS5sqOGPoEyK9ZZnbsdEfz/uYFoj+D1WdoRU6JinIBP2+ZotJaBf5U3OjE3Tjl/A/hq9wOMLiXLssTC1Eep1Q53mI2XrV+VN1WE0UKLDyWt73sJJeezdQGVUKE3JRH75FNFVgaIFXvcl3F4VGYBs1Ns9xRjM7LgSgirbCYoJZ3OTnk90tqnYHIDguxJ3kkttvDNl7Bpq4fggDVn2NW5x1DezJja2cZTv7Xf9luPk6So8S9PBqzvkoOlwcd/8cB73sp0QJ3rxqDKi4j6Y0+GduRyGfVe4aMseosdNF74zaVL/M4j+VscC7DFCSD1ylyvyhfv5e08yzpNFp1QH3wost1XojDRSab2//T3APlTOtplQASFTjL0ZfWLRMfCp0WNOtPgGu+A3+XZNXprOquLrBDrhm0QnPF+vtN1rdbFIzL3n2oZKS7pdJQOMZCf322365Mx4YGKZNEz21I0ESTU6plJzoCxb2AsIrI/J3vhcTMZs7GM4Xal5eu8n2SLLEuJlZxlTUIh9hMDFYPipPGerJqN3zVDs//6xTUZrIHwbjCxSKYUWy84qy2O4iWogYGnN1o6gj1/a5/9zToteZYiCvRCg5zxTvPcX0WT7EALYhRhKhiy9POIJFiVl/f8XlOlqqifLwZpNvC6c1zrqCuB+5GLqURQaitCktBrz4skE0T+RWk4tPHhhcds9P2JzA7WJC2g3FZGDzYn5sgO/bQQx6tGOyl+jCCDyZBwyfX0y0KZV4+J55B1EVADPnyeW7VfC43hq/LGNxpgG5tACYIy2kyENne1IUrUMm5uN4bEIop0gx7kvQ0oxZPAVXX/XfFlLCJEpbldBICDKSdK6pw1X5iNvqgroVGvbcewjDvLWJOh/4L0GAXvaXGmZDhuqHFjtYjwGS4WTNZuJAGrSOEQQVCqZyNE4s/H44QiwSwKvaieDJVY+1FiR0ybvQHWTlw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5624.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350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OTT4d6FyDtEkEBjhAjpYhMbOEGffzq8cUM8KkwNvDJF/JuMtvwnKQBwhhbb7tIL0L8CNtszST4fMS5Z4kfnEvklFd+jVkjcrt0nJPqD3eQJmlAuVluvMMSgNWD2TRYulZNLkUdgSD5lp7It/rrGWvZfoGjlvMQshHuNN5IbjcUb5XhFySBc854CjPnBL76tFIvA0CoTq78kieayr1IiF7YR4IUg9Qc3msLV65iLtjJGuI2ihD81+6UCu3RJtEHUwIXkpPt4jnaqxCpMGcJ2t8sVFbAtNKukb5AgHBEBYT5dtiyTp6etK8FHrgT0fIPedozp3XQPKoN7pDN0sXIy1ZBLH1LzX4pNih4Ecld2BlhDb7CHw11Y9+sdN9Ao+kn3me7bId+KhWLa23fQSqO8IILt5rdeSnrc3NKB9l0wsrGbveU/LiP9P04LDTZX1R7ib+n/YriWd3iE0+lkyXH4O2WvNWUC8KoOyn80qwtUIrMmA9fphXYosKWuyKVGNilqCpe90/VKZTFnTmmkVzqTePPWuXqFAxvCQ0YHYAVOXtE9NxLddOSzIxX66LSuGKwDb1zI6uPeuiNhRo2Qqf8ER9dy X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc379384-2897-4692-3a4d-08dcc59db448 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5624.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 07:07:10.7316 (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: VpW4ZYRKgv9BycsRFPDIb2BTbyvhRA3F87qbebMo/zFgKXZJAR942TdVMKNyBJES+vOPJHjltaZz5vuY6aSPew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5847 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_000719_898150_F9E8F939 X-CRM114-Status: GOOD ( 11.43 ) 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 calls to clk_disable_unprepare(). --- v1 -> v2 Incorrect usage of devm_clk_get_enable() should be corrected to devm_clk_get_enabled(). Signed-off-by: Lei Liu --- drivers/usb/musb/mpfs.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c index 29c7e5cdb230..ce6ad65c5fd0 100644 --- a/drivers/usb/musb/mpfs.c +++ b/drivers/usb/musb/mpfs.c @@ -159,19 +159,13 @@ static int mpfs_probe(struct platform_device *pdev) return -ENOMEM; } - clk = devm_clk_get(&pdev->dev, NULL); + clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(clk)) { dev_err(&pdev->dev, "failed to get clock\n"); ret = PTR_ERR(clk); goto err_phy_release; } - ret = clk_prepare_enable(clk); - if (ret) { - dev_err(&pdev->dev, "failed to enable clock\n"); - goto err_phy_release; - } - musb_pdev->dev.parent = dev; musb_pdev->dev.coherent_dma_mask = DMA_BIT_MASK(39); musb_pdev->dev.dma_mask = &musb_pdev->dev.coherent_dma_mask; @@ -184,7 +178,7 @@ static int mpfs_probe(struct platform_device *pdev) pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { ret = -ENOMEM; - goto err_clk_disable; + goto err_phy_release; } pdata->config = &mpfs_musb_hdrc_config; @@ -203,7 +197,7 @@ static int mpfs_probe(struct platform_device *pdev) dev_err(dev, "failed to register usb-phy %ld\n", PTR_ERR(glue->phy)); ret = PTR_ERR(glue->phy); - goto err_clk_disable; + goto err_phy_release; } platform_set_drvdata(pdev, glue); @@ -211,27 +205,24 @@ static int mpfs_probe(struct platform_device *pdev) ret = platform_device_add_resources(musb_pdev, pdev->resource, pdev->num_resources); if (ret) { dev_err(dev, "failed to add resources\n"); - goto err_clk_disable; + goto err_phy_release; } ret = platform_device_add_data(musb_pdev, pdata, sizeof(*pdata)); if (ret) { dev_err(dev, "failed to add platform_data\n"); - goto err_clk_disable; + goto err_phy_release; } ret = platform_device_add(musb_pdev); if (ret) { dev_err(dev, "failed to register musb device\n"); - goto err_clk_disable; + goto err_phy_release; } dev_info(&pdev->dev, "Registered MPFS MUSB driver\n"); return 0; -err_clk_disable: - clk_disable_unprepare(clk); - err_phy_release: usb_phy_generic_unregister(glue->phy); platform_device_put(musb_pdev); @@ -242,7 +233,6 @@ static void mpfs_remove(struct platform_device *pdev) { struct mpfs_glue *glue = platform_get_drvdata(pdev); - clk_disable_unprepare(glue->clk); platform_device_unregister(glue->musb); usb_phy_generic_unregister(pdev); }