lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240822121749.19284-1-rongqianfeng@vivo.com>
Date: Thu, 22 Aug 2024 20:17:49 +0800
From: Rong Qianfeng <rongqianfeng@...o.com>
To: julian.calaby@...il.com,
	linux.amoon@...il.com,
	Stefan Agner <stefan@...er.ch>,
	Alison Wang <alison.wang@....com>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	David Airlie <airlied@...il.com>,
	Daniel Vetter <daniel@...ll.ch>,
	dri-devel@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org
Cc: opensource.kernel@...o.com,
	Rong Qianfeng <rongqianfeng@...o.com>
Subject: [PATCH v2] gpu: drm: Use devm_clk_get_enabled() helpers

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, use dev_err_probe consistently, and use its return value
to return the error code.

Signed-off-by: Rong Qianfeng <rongqianfeng@...o.com>
---
V1->V2 changes:
1. Drop the similar patch for sun6i_drc and sun8i_mixer as the patch may
have issues in sun6i_drc and sun8i_mixer. The specific problem is not
yet clear, but ChenYu has already encountered it.
2. use dev_err_probe for there is no more special handling needed here.

 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 26 +++++++----------------
 1 file changed, 8 insertions(+), 18 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..97bfba317854 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,10 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
 		return PTR_ERR(fsl_dev->regmap);
 	}
 
-	fsl_dev->clk = devm_clk_get(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;
-	}
+	fsl_dev->clk = devm_clk_get_enabled(dev, "dcu");
+	if (IS_ERR(fsl_dev->clk))
+		return dev_err_probe(dev, PTR_ERR(fsl_dev->clk),
+						     "failed to get dcu clock\n");
 
 	pix_clk_in = devm_clk_get(dev, "pix");
 	if (IS_ERR(pix_clk_in)) {
@@ -309,11 +303,9 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
 	fsl_dev->pix_clk = clk_register_divider(dev, pix_clk_name,
 			pix_clk_in_name, 0, base + DCU_DIV_RATIO,
 			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;
-	}
+	if (IS_ERR(fsl_dev->pix_clk))
+		return dev_err_probe(dev, PTR_ERR(fsl_dev->pix_clk),
+				      "failed to register pix clk\n");
 
 	fsl_dev->tcon = fsl_tcon_init(dev);
 
@@ -341,8 +333,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;
 }
 
@@ -352,7 +343,6 @@ static void fsl_dcu_drm_remove(struct platform_device *pdev)
 
 	drm_dev_unregister(fsl_dev->drm);
 	drm_dev_put(fsl_dev->drm);
-	clk_disable_unprepare(fsl_dev->clk);
 	clk_unregister(fsl_dev->pix_clk);
 }
 
-- 
2.39.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ