From patchwork Mon Aug 26 08:23:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Liu X-Patchwork-Id: 13777422 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 E0184C5321E for ; Mon, 26 Aug 2024 08:24:39 +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:References:In-Reply-To: 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: List-Owner; bh=1I7XV0k7ZcG2r7L54/eMYRoz9VTa/IHN3V6FYDeKWHg=; b=S5q9rd7EW5BWFn AqqLoTW6TBCAqlvHyuv1WY43wQgmLXxmwBGnUIEwTEhtCEOR8fZVAc3T0i03TLNFyu+9L1YmY8jCe x4AO0UD/4EPugCQR09ueT7nUKcVubJ5DahD48PQ3E2hc+uhn5hJWnmjYOcPvivDYy8VTOdPSgmUBV aXUI7a4YeLQH58Cn0ECAjbguoqF+AwBDfjJdesN8cm35viqDKaCEx288GfQRoctcY25kn7fRh3hEb azRJsNLVz38Gh143OPuQV4Z6iePW/aa9j7V2sa5Q4HqY6wwJK5d2mbn4+tGq30pkyqoXYtnjalyUA 2UWw0zQg5hNopzsgPIVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siV1g-00000006TQU-2O3r; Mon, 26 Aug 2024 08:24:36 +0000 Received: from mail-eastasiaazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c400::] helo=HK2PR02CU002.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siV1d-00000006TNx-1Rap for linux-riscv@lists.infradead.org; Mon, 26 Aug 2024 08:24:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RE0UzW+w3FUEKhdiUmjVFdFgAnL3F8PsvkKHDr+lE5yijMJpU8aygTjN3u+V2/pLRbj4SgEDe5kxbC4VqmnJnY5MunC5+r+PXbt2DePajMay1mQlaJ3tCFyliNPEgjY9OPQhstsa8kR/RpTRFNIVP9xkZbzE3iqPg6WvIuor5gkV0qDNoOuhw5y9my7JTnBmzFhtS/iJG3hknUqU8mpJXIlOyK/Yyd0LTbOOJn5UxS2Qpe1IfHgFymVzuhQbhdsAB1W1nQhFxSDG9hk8tO6EgS1k2pwJOB9PbAF5nZwNZyypFFO3PpRB/MVW7a2RJ882en/sLbJl1cwMDNYxXB8okw== 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=FCw5w8EU350n+BCInvshnTXKpjthG+654hsAT1zd3Z8=; b=zQ1PKjPMB6tV0kxhH3JjJAhA9thjRUPhlnl5l50j95BjV1jM8RuyqkD6NmRdFce6q3tyLIeiPtPIXarefap01q6X2HyyR5sgDZ0H7fUbF85nkdkIcQC57Dp4B/bSCljZPMf4NKDwU72UNsWMeFGjyxRezxrWmM0TGjrEj8I84iD08K/goYJvrlbfLzpv9YSlc9nDw/1Rsw/2lynAhfRIyH6DMlVAdhd5Z34ValYfx26B6tDwlxJPGlvFbBvZYjvfe/hbY5hyBMLZHHtl08Gz9Orv+v2aO9qEqcQsM1Q7bYW0uw0BH3SHmz46b9Zf323C1SN0A8bULjadp+TaCpnMXA== 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=FCw5w8EU350n+BCInvshnTXKpjthG+654hsAT1zd3Z8=; b=nD6YmoyFijfuZkULgtOtsH4sPVELMX8iVwxWrD7bC67nKhGys8dWaBHYW9Duh9aXAdPHKJ2o3VVWP5hdlAuA7iRsnrG87pSk74X0sDIkroUM1tmvQ1lXdDceWBCCmWMsMcXliJ82RVOeVTy77neA/ggvFAg25IYqb45jEc+2avjr0LDHKpthe+lf30nACV8rwN68JpX0HlZAAUt8Z4XG3hUsFzpjzq4fl2fJo+vV9aTb3lmVNZQ0YToxk8XalYTHVxIlag7AIcbyiszBVPc7Vxz6+CE2KpNCq5Z/FLN0cEv/RkJ77wF1p+VEUBo3G6S1BYJFcyGy/f346lz1kGq9Iw== 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 SEZPR06MB6665.apcprd06.prod.outlook.com (2603:1096:101:17c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Mon, 26 Aug 2024 08:24:25 +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 08:24:25 +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 v3 4/5] usb: mpfs: Use devm_clk_get_enabled() helpers Date: Mon, 26 Aug 2024 16:23:52 +0800 Message-Id: <20240826082353.2373-1-liulei.rjpt@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240826081900.2284-1-liulei.rjpt@vivo.com> References: <20240826081900.2284-1-liulei.rjpt@vivo.com> X-ClientProxiedBy: TYWP286CA0030.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::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_|SEZPR06MB6665:EE_ X-MS-Office365-Filtering-Correlation-Id: cdd17397-f1f8-4431-60f5-08dcc5a87ec8 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: AwzSxa2HqILEvdMAIe1CMFd+n3ovaci7fdOAn7tc8VJzcfaE13hZK6mI/T1XtDkxVWQT4NyWEv3tD5YlPBqb0wp/mgFxO73IBsPMIr2vG17Q/YUGSHZBqOp6EPmXEz5RawFuH68OsAOKUUm5Jl9OjT7x1MWoOa/e5lvMjkmCsJya7OmU6Mm3gpF5jmM5R++/8N1Hirjyj42QdcP8IDo6VYnDoZFNOA6KoR4/f9dl35t45wPFofpnS4vEM8gNUh37PqXRlby6qdM6yaV4fNAZqDWijVQ65RYcDtibdEMK1/TKgNmrJvv17/obUD7S1RFWl8IGlOdQMPGPcLaEVeLlFnwp89neo2PETTuGtqwQ5x3lh2dJq6s0Qk90m7CXQgHQx6huHpA9M+YlIaNI6IBItx5ybWvpbYRS/DSMeKEmiDZ1Z/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PR06MB5624.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: GbN+OrBG56hYG17bin0Wo0Xv/C9bnyYbvBtxs1IBY1jrY/7SMl2sHslKidpbag/bvnv0v2h/vLbRqkWhR9v563nGTzSPbpsluhdp1kHJN2C3S9xMe8OeHqk+aY29B638R1RqNlkbJaR1n/AX3uLbV0+4K8t+p6vA3bceK8Q8lXVV8FBgfErkFVAYUoab2XUPhoCDZqZZR79GxAaAjBDJFTAASQvps/twSuD87q6yxTEu0xZ/5SpXqmhWGCb2yYCoYfSBcL20yCz/kWskbruIsOFoRXxfs6baQXBwYWmmDCnGraZ6Dr5nVDYWpBhDMDOhKvP77mod9fMd2WmrVHLcnGZUKIErFSrjgmFDHqnuYskZGQTDvN92bL4j+njw0d4S9KKgshQrmMytBgW1CnvFZyHl24tX0ivFCflV3Cn5G67WhQuTxR+FmUVmqWCzq2jDxy2W/M9eX1mccIIv74XrkIy5PEGkwqFugpDnOuYBcDeQadTcr5Bi1XP6Cr5EysVjUZx/cNtTRuz6LvGh2KiL1DEG0GPuVfrRbux/7SZIsxq/OH1J6Pl00XxhbsQLcJ59GhfhzVpYiQVH0oPQSThzOHEnxEbJ6YdwFScObb8eGnUwGCKIDo+/Kc16APzjwTIG0j20sVCWU+Bwo0jk6kvG50JX8WEfifkrHB3mgjUq4yieC1dcbKrygB9XMApCi7GT36PfE/GYq+l5lx1MlOj8CozsaJ71pWPCCo72o1wAQbEfC/OhRAQCQdWRfzN4av8Oyy/25iVp3Y7git8JP6YrrsxNGiAaGd922KRY9i7RB/UG6bmkEuwGQ4cjp1bzceykUZZbOS6g375OyBl2HJ2V59hGnK2rO2bRY2r6f/DWHTboM+ZNfAh8ek3ozCllQU02CPgtApL99drzV+Ov9R+B+N3kOK3/0MChKtK87OwG3Ksp/hfW13AuLp5dewyaw6XS3LcCmH8Kt9Vq6J7Miaze2TRKFIblbJ8LzGumZy8+ZYrlSNVbzP1guqH/HxDCGYmTcBLlvJJ8lVFwNos/HSqqbew+w2ngUrWnDb1LQUuMphatLa+g6Hpq9Cl4G1gRhyEh5t6hLxPK8+VBZZiq8Pq4vd/+9yFospiZcsryIfQtbLtLy1aPbe7/BFH7ZAT1BBR0tSgj1/e5iPH200EPIe1ei/tYRXDAsab+dRXIj+HQE0bm2h0f2lz7dmo8ij6LVrN6YznvUAXVgVzMai1XulOr85jXW/CkCdBQOxt9VI6PB/itI2zeYcFMDRFq4Gl/i90B3N17UEb75+4PiObsRa17tCLI7ohiZYbHqSrUBYzK2ClXInLSmAk3M4n6GndFdegaFYmS9LWk5yTEtSiLASGSo/qcI/NPOcV7D9ftJeEXwV5olPbjSiMsYp1/UQntBzmeUitH1MIKgekgZeCYp6GvlSWnWFTCJXdcxgS1HukGijVwXD7kzAFbq+A9/ySI4ilIXmZUNX8/ACWaFRpekp0r0LGadO/rltiU2EVoCboSQAgKL8KL3maQOtX+VqW1fFjetq/PQguI1AU16yq7lBJX7BJPLwTm2d0cxYPpf+POmBzwm0GNtDUK+Fopo/Duh6vt X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdd17397-f1f8-4431-60f5-08dcc5a87ec8 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5624.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 08:24:25.4239 (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: gR7IY8h0nRJzHAXgACAO9NLfQqnoyeMFhIsXUl0y31ns1XM0QynmGvx1BC6UX2zcD3EI/gplZ3+PPwkMS7WbnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6665 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_012433_411242_E6FF759D X-CRM114-Status: GOOD ( 11.95 ) 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(). --- v2 -> v3 Fix the email thread. --- 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); }