From: Andy Yan <andy.yan@rock-chips.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
quentin.schulz@cherry.de,
Heiko Stuebner <heiko.stuebner@cherry.de>
Subject: Re: [PATCH v2 1/2] drm/rockchip: lvds: move pclk preparation in with clk_get
Date: Tue, 4 Mar 2025 09:29:33 +0800 [thread overview]
Message-ID: <23e1ecc4-3386-426a-aa54-4d4c082cbf8a@rock-chips.com> (raw)
In-Reply-To: <20250301173547.710245-2-heiko@sntech.de>
Hi Heiko,
On 3/2/25 01:35, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@cherry.de>
>
> 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 <quentin.schulz@cherry.de>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
Reviewed-by: Andy Yan <andy.yan@rock-chips.com>
> ---
> drivers/gpu/drm/rockchip/rockchip_lvds.c | 19 +++----------------
> 1 file changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> index 385cf6881504..ecfae8d5da89 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -448,15 +448,13 @@ struct drm_encoder_helper_funcs px30_lvds_encoder_helper_funcs = {
> static int rk3288_lvds_probe(struct platform_device *pdev,
> struct rockchip_lvds *lvds)
> {
> - int ret;
> -
> lvds->regs = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(lvds->regs))
> return PTR_ERR(lvds->regs);
>
> - lvds->pclk = devm_clk_get(lvds->dev, "pclk_lvds");
> + lvds->pclk = devm_clk_get_prepared(lvds->dev, "pclk_lvds");
> if (IS_ERR(lvds->pclk)) {
> - DRM_DEV_ERROR(lvds->dev, "could not get pclk_lvds\n");
> + DRM_DEV_ERROR(lvds->dev, "could not get or prepare pclk_lvds\n");
> return PTR_ERR(lvds->pclk);
> }
>
> @@ -480,12 +478,6 @@ static int rk3288_lvds_probe(struct platform_device *pdev,
> }
> }
>
> - ret = clk_prepare(lvds->pclk);
> - if (ret < 0) {
> - DRM_DEV_ERROR(lvds->dev, "failed to prepare pclk_lvds\n");
> - return ret;
> - }
> -
> return 0;
> }
>
> @@ -728,20 +720,15 @@ static int rockchip_lvds_probe(struct platform_device *pdev)
> dev_set_drvdata(dev, lvds);
>
> ret = component_add(&pdev->dev, &rockchip_lvds_component_ops);
> - if (ret < 0) {
> + if (ret < 0)
> DRM_DEV_ERROR(dev, "failed to add component\n");
> - clk_unprepare(lvds->pclk);
> - }
>
> return ret;
> }
>
> static void rockchip_lvds_remove(struct platform_device *pdev)
> {
> - struct rockchip_lvds *lvds = platform_get_drvdata(pdev);
> -
> component_del(&pdev->dev, &rockchip_lvds_component_ops);
> - clk_unprepare(lvds->pclk);
> }
>
> struct platform_driver rockchip_lvds_driver = {
next prev parent reply other threads:[~2025-03-04 1:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-01 17:35 [PATCH v2 0/2] drm/rockchip: lvds: probe logging improvements Heiko Stuebner
2025-03-01 17:35 ` [PATCH v2 1/2] drm/rockchip: lvds: move pclk preparation in with clk_get Heiko Stuebner
2025-03-04 1:29 ` Andy Yan [this message]
2025-03-01 17:35 ` [PATCH v2 2/2] drm/rockchip: lvds: Hide scary error messages on probe deferral Heiko Stuebner
2025-03-04 1:31 ` Andy Yan
2025-03-04 11:46 ` Quentin Schulz
2025-03-04 12:38 ` Heiko Stübner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23e1ecc4-3386-426a-aa54-4d4c082cbf8a@rock-chips.com \
--to=andy.yan@rock-chips.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko.stuebner@cherry.de \
--cc=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=quentin.schulz@cherry.de \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®