Skip to content

Commit d4f5efb

Browse files
Heiko Stuebnermmind
authored andcommitted
drm/rockchip: lvds: move pclk preparation in with clk_get
The LVDS block needs a separate pclk only on some socs, so currently requests and prepares it in the soc-specific probe function, but common code is required to unprepare it in the error path or on driver remove. While this works because clk_unprepare just does nothing if clk is NULL, this mismatch of who is responsible still is not very nice. The clock-framework already has a helper for clk-get-and-prepare even with devres support in devm_clk_get_prepared(). This will get and prepare the clock and also unprepare it on driver removal, saving the driver from having to handle it "manually". Reviewed-by: Quentin Schulz <[email protected]> Reviewed-by: Andy Yan <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d05386a commit d4f5efb

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

drivers/gpu/drm/rockchip/rockchip_lvds.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,13 @@ struct drm_encoder_helper_funcs px30_lvds_encoder_helper_funcs = {
448448
static int rk3288_lvds_probe(struct platform_device *pdev,
449449
struct rockchip_lvds *lvds)
450450
{
451-
int ret;
452-
453451
lvds->regs = devm_platform_ioremap_resource(pdev, 0);
454452
if (IS_ERR(lvds->regs))
455453
return PTR_ERR(lvds->regs);
456454

457-
lvds->pclk = devm_clk_get(lvds->dev, "pclk_lvds");
455+
lvds->pclk = devm_clk_get_prepared(lvds->dev, "pclk_lvds");
458456
if (IS_ERR(lvds->pclk)) {
459-
DRM_DEV_ERROR(lvds->dev, "could not get pclk_lvds\n");
457+
DRM_DEV_ERROR(lvds->dev, "could not get or prepare pclk_lvds\n");
460458
return PTR_ERR(lvds->pclk);
461459
}
462460

@@ -480,12 +478,6 @@ static int rk3288_lvds_probe(struct platform_device *pdev,
480478
}
481479
}
482480

483-
ret = clk_prepare(lvds->pclk);
484-
if (ret < 0) {
485-
DRM_DEV_ERROR(lvds->dev, "failed to prepare pclk_lvds\n");
486-
return ret;
487-
}
488-
489481
return 0;
490482
}
491483

@@ -728,20 +720,15 @@ static int rockchip_lvds_probe(struct platform_device *pdev)
728720
dev_set_drvdata(dev, lvds);
729721

730722
ret = component_add(&pdev->dev, &rockchip_lvds_component_ops);
731-
if (ret < 0) {
723+
if (ret < 0)
732724
DRM_DEV_ERROR(dev, "failed to add component\n");
733-
clk_unprepare(lvds->pclk);
734-
}
735725

736726
return ret;
737727
}
738728

739729
static void rockchip_lvds_remove(struct platform_device *pdev)
740730
{
741-
struct rockchip_lvds *lvds = platform_get_drvdata(pdev);
742-
743731
component_del(&pdev->dev, &rockchip_lvds_component_ops);
744-
clk_unprepare(lvds->pclk);
745732
}
746733

747734
struct platform_driver rockchip_lvds_driver = {

0 commit comments

Comments
 (0)