From patchwork Tue Aug 20 12:58: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: 13770183 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 B39F0C531DC for ; Tue, 20 Aug 2024 14:11:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0168B10E7E5; Tue, 20 Aug 2024 14:11:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=vivo.com header.i=@vivo.com header.b="MGQWZ7OX"; dkim-atps=neutral Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010001.outbound.protection.outlook.com [52.101.128.1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1190910E1EE for ; Tue, 20 Aug 2024 12:59:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vg+G/gj4E7SxAnjT4mncKaGA6JgDoD8V8z1sBa0pn8ugFcLPsjcCtoQQg46utkOpnYEsY+xVL3ZOvWOAVisDiE6t1mdHdYbI/beKQWlQd9hr3POtUWR/4VeJhUIQO1Rrh+2sBz5jokVbOweXVdHsPRiEDN+TTyUAluv5PUMtktAf0JCHgokVE7/OSkPwFfMcroBl5PH8MVltW6VY21YTgk1ClOkjFYqC11EGVB0FntYR+Zo5F19W1dX6L7qdRNdRU2yvDA6WiwZaSh4nBsXmIZSwSSHe1jL5uYM7t2pU4xcbKNS5RgeVp5tZCMWoYepXEEgPDSZldTwXotkcD6HkKQ== 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=XRLw71wB4Ai1sE4Q8xSOt5qTsHe0+n8B+sr7C3Mo2R4=; b=d1Ov/uDVURApGqhYfFDVUHV78AqXhG4V09DxTiIuiPS/5MaVIjBQcw2eDGWWO7Qr4dC8/fr9a/RNZEpAJwVGAj9rqjT3GJ4RQTApMTJaDPFZZvnuhDQfqrrEC85mKQqwt25cmURG9r7d1buMN9gE6Tj4y1MSnf8UshHlGD97O93D1gKXop6oovv84C48lQ0NIYUfqAJk8Qa8MtXEDiDDDGp7iKeaPbjgpwOqTj5SxPqszVtk3Yms5EPGeMv9enScZ2u3Qm8mIZkM+jmbAyOXbfmPeE6SNVz/I/O2ewifQa/4LH8ZU7ee8iQvluoMjinD45VckK+q7U4Yp26kGI85yg== 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=XRLw71wB4Ai1sE4Q8xSOt5qTsHe0+n8B+sr7C3Mo2R4=; b=MGQWZ7OXYYMLRHJa5+cmAKqGjCM/vpucaAgTDRzrd+psb9e8PQaJ9Uo4K99z4cwbnm1bNh6I+PO/FuCynWowCQtV97inM5ksfSgpZaKK1FWDkaHQroj4ScB/aAsrSRK3sj8zyFj1EKLL6JLPtK9rcB3uzsw4nhQRVa3sqt0RcGftQkrqrwXngyEIDx/Pwn/DpiYo/vk26ZenJ0D953NwtAXQU8GFsX4lFT/MfuoDAq9MIDJuorFAqOPpvGFylWFq52ZQEN18dL4Rey2KCm9nmBvwZPMS2j6phDe0NKQxNnxzlnNVePr0TiVMX/2kZ6Irano7zRllvIQgG3m/aijUIg== 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 OSQPR06MB7156.apcprd06.prod.outlook.com (2603:1096:604:293::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Tue, 20 Aug 2024 12:59:10 +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.7875.019; Tue, 20 Aug 2024 12:59:10 +0000 From: Rong Qianfeng To: Stefan Agner , Alison Wang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Cc: opensource.kernel@vivo.com, Rong Qianfeng Subject: [PATCH] gpu: drm: Use devm_clk_get_enabled() helpers Date: Tue, 20 Aug 2024 20:58:40 +0800 Message-Id: <20240820125840.9032-1-rongqianfeng@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: TYCP301CA0029.JPNP301.PROD.OUTLOOK.COM (2603:1096:400:381::15) To SI2PR06MB5140.apcprd06.prod.outlook.com (2603:1096:4:1af::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SI2PR06MB5140:EE_|OSQPR06MB7156:EE_ X-MS-Office365-Filtering-Correlation-Id: 2cd29964-a1fb-4564-4d13-08dcc117e221 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|7416014|376014|1800799024|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: cgOvvh88lGT4lSXy2QV5CxNUOABb6kPXPWGe8uGP/K6lGLYPGszoC5Wj4HNtqerxS4Ae7tw5ya4Lh7Z78KtIgDIUGXb1pENDSXnV2rMUe7lt0GLsGu2IxHwfonK6T+mAapdC+JqQYUaGdXyST/83JN7PwXSk6+fcOmCys7v/+RVmAPZVG4LtCnya8YE1geIGrCixx3tNtC+PT/CumHga89blEEfPvAzai1FMafx92VdrGeNr0Zm0PHhrxFOQFkBjSqghoG/+QWEpty/9O+AyjnoMGzoppBZ5hzkNtpPyY5kudR9BTp1+i27Ra9U1UryzQZQpjecPYwRPQWZDc5UjEWBZff+fZmlNkdDr8FYVAkyRBv63vquWkhxaF9HqsmVXMAqRZwZSU/8ZtkyIq2dHEla6iUTMePzoVMXekeTIhUQwanrsCrsHh2CzSxcoEEh7/RAvDlv5HTHmDo5lpXu2kPQ/stadFDF7Um35uuzFA7txsl5O8ljzenvkrzN+rz5W6/2xtxUfCaemfuNANVaVzxJwheM2Ngm0znz5ki1oypRO/RMAKR/zy6XvytO+RbmbR+2HbilqEFSblYt7DLrjmUSOhRizRxcn/uXpwYiBjUZaGbr3j6s1MlcHTY9V5JKQ52D2ObJQwNzg90DrzzAquhoT1jB+Wnn28dvWsYxTYwscjgBzUnSKI69CZMuXShKYCRf030nvmqpW/xFYZyzuRSKb9ROzD2BQ3iFY58Y3ND4lYpoCc4n0JTsIlBilnJFtpuJGe73a1/FsBe8/jlAFyaatsQne3A98xVjt9/ORlAz8aMJ6KcW/Gl375Tqajz7ctj4J9QdstaiW1FlFWM3XSWJ5pbjpaIXpxwhRE9sn7twj7UwrTadE6GptHmx6fD01eufkxmccLWvCMZ9uMA8XH6flEEliSu4u5Lhrk1rVKuEvurspxoa7lEPW5ytB/WVz+uFwKbBBUelcnGh4nSuD9Vnrh3qZ6GzhxVuHDuQs2qhpCuKf8RKJlCr+IzFXCWVERMQc3mjv1Xy0ckjpDduJ71+vSbDVAleOVIRRT5jD8DBs+vClhyGWDDBVKFX7DQ+lL1T3mOVhM8iTWSZC2sOBzE6HfwSHKQsn9Y6xgmLoE3dOp4slljoKVpFctgS7JkBBVP2ObZhKt0YWaxcJxRin73bqyxVy1cJjVvXnyxmulBquA8fAsBxjR5fiv29qf5jTBm/rw6EX8JBWi9kxiokC9RyrXqXnkCgIYYaRjIeSHN3SiYWvgcYJ+pSz1yVU8+6F8T8U+eCInvmv1MGGQ/TLSNpUCiCNOvmMZoPrDpGEp5Wyq6+uTB1ePbP/U56CLS/NPzO5RZynixmFI9+n45PFfznF/1zEeB6KbnVwR2v+dbvmq0XLkxbtzyh09UtSDresq9kL1ueN/uP8bnRvZwD8I7zAHxq6f7ddblmXTWEFmxQ= 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)(7416014)(376014)(1800799024)(52116014)(921020)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lfhV+Ow0gyzViy0TjvqsBh4YqZ1bwXeE6G35QVHpu6RzRD0Gyk3zPPBPQyDPCTree/RVRGROqHLj0gc3ehhYbyJn7GDxkqIegxlkp4g9M6WGTVkV8RMJZHH+YeAWhusruUNGWE1xAAwyNiTftHleN02mT4QcD++H9Xo7BVUPMKscU9nRviRzk+a29DkijDZ3JArBoe7DivYas9Y8MKWLBNkk9fPy+gJJgWgXUlB3wgez8DJ4dTCgGIK3/6GRG+dEBU/LuT1FM9MA20n6FRMcAQ8Zj723RhGFTvujrIiVu85xMulfZuFNel5fNpo33bIVlXSVuQkknJRglDb29U3Yb6u6CH4rqSY/jquMSKBPSRx1xCgYJjZxNpk9rIo+kFeuA5Va01fjpYVOTAi3X5Prkvr5WTQu7Tdra5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XP0cPewXAfqDr6H6uCOhj9g+j2GeBZYIGuqexK5uuQ2hykP58QO4MbSYGxCSLs5wNk8K9uX3ldBnTiRTsB64TsGUUSXGjcc9qxU X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cd29964-a1fb-4564-4d13-08dcc117e221 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB5140.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2024 12:59:10.3658 (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: W9EjIzLY3tAe72vreMAlE7Vrkz3JjEyWzf7raeS5Wc1/Do4QsEHN1PrjZLd2cGjOnx1apVXO/ab8l5OXHx9Wgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSQPR06MB7156 X-Mailman-Approved-At: Tue, 20 Aug 2024 14:11:49 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Replace devm_clk_get() and clk_prepare_enable() with devm_clk_get_enabled() that also disables and unprepares it on driver detach. Signed-off-by: Rong Qianfeng --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 13 +++---------- drivers/gpu/drm/sun4i/sun6i_drc.c | 15 ++++----------- drivers/gpu/drm/sun4i/sun8i_mixer.c | 13 +++---------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index ab6c0c6cd0e2..057dceaf079e 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -284,16 +284,11 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) return PTR_ERR(fsl_dev->regmap); } - fsl_dev->clk = devm_clk_get(dev, "dcu"); + fsl_dev->clk = devm_clk_get_enabled(dev, "dcu"); if (IS_ERR(fsl_dev->clk)) { dev_err(dev, "failed to get dcu clock\n"); return PTR_ERR(fsl_dev->clk); } - ret = clk_prepare_enable(fsl_dev->clk); - if (ret < 0) { - dev_err(dev, "failed to enable dcu clk\n"); - return ret; - } pix_clk_in = devm_clk_get(dev, "pix"); if (IS_ERR(pix_clk_in)) { @@ -311,8 +306,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) div_ratio_shift, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL); if (IS_ERR(fsl_dev->pix_clk)) { dev_err(dev, "failed to register pix clk\n"); - ret = PTR_ERR(fsl_dev->pix_clk); - goto disable_clk; + return PTR_ERR(fsl_dev->pix_clk); } fsl_dev->tcon = fsl_tcon_init(dev); @@ -341,8 +335,7 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev) drm_dev_put(drm); unregister_pix_clk: clk_unregister(fsl_dev->pix_clk); -disable_clk: - clk_disable_unprepare(fsl_dev->clk); + return ret; } diff --git a/drivers/gpu/drm/sun4i/sun6i_drc.c b/drivers/gpu/drm/sun4i/sun6i_drc.c index 0d342f43fa93..f263ad282828 100644 --- a/drivers/gpu/drm/sun4i/sun6i_drc.c +++ b/drivers/gpu/drm/sun4i/sun6i_drc.c @@ -42,33 +42,28 @@ static int sun6i_drc_bind(struct device *dev, struct device *master, return ret; } - drc->bus_clk = devm_clk_get(dev, "ahb"); + drc->bus_clk = devm_clk_get_enabled(dev, "ahb"); if (IS_ERR(drc->bus_clk)) { dev_err(dev, "Couldn't get our bus clock\n"); ret = PTR_ERR(drc->bus_clk); goto err_assert_reset; } - clk_prepare_enable(drc->bus_clk); - drc->mod_clk = devm_clk_get(dev, "mod"); + drc->mod_clk = devm_clk_get_enabled(dev, "mod"); if (IS_ERR(drc->mod_clk)) { dev_err(dev, "Couldn't get our mod clock\n"); ret = PTR_ERR(drc->mod_clk); - goto err_disable_bus_clk; + goto err_assert_reset; } ret = clk_set_rate_exclusive(drc->mod_clk, 300000000); if (ret) { dev_err(dev, "Couldn't set the module clock frequency\n"); - goto err_disable_bus_clk; + goto err_assert_reset; } - clk_prepare_enable(drc->mod_clk); - return 0; -err_disable_bus_clk: - clk_disable_unprepare(drc->bus_clk); err_assert_reset: reset_control_assert(drc->reset); return ret; @@ -80,8 +75,6 @@ static void sun6i_drc_unbind(struct device *dev, struct device *master, struct sun6i_drc *drc = dev_get_drvdata(dev); clk_rate_exclusive_put(drc->mod_clk); - clk_disable_unprepare(drc->mod_clk); - clk_disable_unprepare(drc->bus_clk); reset_control_assert(drc->reset); } diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index bd0fe2c6624e..ebf00676a76d 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -507,19 +507,18 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, return ret; } - mixer->bus_clk = devm_clk_get(dev, "bus"); + mixer->bus_clk = devm_clk_get_enabled(dev, "bus"); if (IS_ERR(mixer->bus_clk)) { dev_err(dev, "Couldn't get the mixer bus clock\n"); ret = PTR_ERR(mixer->bus_clk); goto err_assert_reset; } - clk_prepare_enable(mixer->bus_clk); - mixer->mod_clk = devm_clk_get(dev, "mod"); + mixer->mod_clk = devm_clk_get_enabled(dev, "mod"); if (IS_ERR(mixer->mod_clk)) { dev_err(dev, "Couldn't get the mixer module clock\n"); ret = PTR_ERR(mixer->mod_clk); - goto err_disable_bus_clk; + goto err_assert_reset; } /* @@ -530,8 +529,6 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, if (mixer->cfg->mod_rate) clk_set_rate(mixer->mod_clk, mixer->cfg->mod_rate); - clk_prepare_enable(mixer->mod_clk); - list_add_tail(&mixer->engine.list, &drv->engine_list); base = sun8i_blender_base(mixer); @@ -592,8 +589,6 @@ static int sun8i_mixer_bind(struct device *dev, struct device *master, return 0; -err_disable_bus_clk: - clk_disable_unprepare(mixer->bus_clk); err_assert_reset: reset_control_assert(mixer->reset); return ret; @@ -606,8 +601,6 @@ static void sun8i_mixer_unbind(struct device *dev, struct device *master, list_del(&mixer->engine.list); - clk_disable_unprepare(mixer->mod_clk); - clk_disable_unprepare(mixer->bus_clk); reset_control_assert(mixer->reset); }