All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/mxsfb: improve clk handling for axi clk
@ 2020-07-20 15:32 Uwe Kleine-König
  2023-01-10  9:26 ` Javier Martinez Canillas
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2020-07-20 15:32 UTC (permalink / raw)
  To: Marek Vasut, Stefan Agner, David Airlie, Daniel Vetter
  Cc: Pengutronix Kernel Team, Shawn Guo, NXP Linux Team, dri-devel

Ignoring errors from devm_clk_get() is wrong. To handle not all platforms
having an axi clk use devm_clk_get_optional() instead and do proper error
handling.

Also the clk API handles NULL as a dummy clk (which is also returned by
devm_clk_get_optional() if there is no clk) so there is no need to check
for NULL before calling clk_prepare_enable() or its counter part.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index fb972dd4f642..6e185ba74b4b 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -77,14 +77,12 @@ drm_pipe_to_mxsfb_drm_private(struct drm_simple_display_pipe *pipe)
 
 void mxsfb_enable_axi_clk(struct mxsfb_drm_private *mxsfb)
 {
-	if (mxsfb->clk_axi)
-		clk_prepare_enable(mxsfb->clk_axi);
+	clk_prepare_enable(mxsfb->clk_axi);
 }
 
 void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb)
 {
-	if (mxsfb->clk_axi)
-		clk_disable_unprepare(mxsfb->clk_axi);
+	clk_disable_unprepare(mxsfb->clk_axi);
 }
 
 static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = {
@@ -214,9 +212,9 @@ static int mxsfb_load(struct drm_device *drm)
 	if (IS_ERR(mxsfb->clk))
 		return PTR_ERR(mxsfb->clk);
 
-	mxsfb->clk_axi = devm_clk_get(drm->dev, "axi");
+	mxsfb->clk_axi = devm_clk_get_optional(drm->dev, "axi");
 	if (IS_ERR(mxsfb->clk_axi))
-		mxsfb->clk_axi = NULL;
+		return PTR_ERR(mxsfb->clk_axi);
 
 	mxsfb->clk_disp_axi = devm_clk_get(drm->dev, "disp_axi");
 	if (IS_ERR(mxsfb->clk_disp_axi))
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mxsfb: improve clk handling for axi clk
  2020-07-20 15:32 [PATCH] drm/mxsfb: improve clk handling for axi clk Uwe Kleine-König
@ 2023-01-10  9:26 ` Javier Martinez Canillas
  2023-01-10 10:06   ` Javier Martinez Canillas
  0 siblings, 1 reply; 4+ messages in thread
From: Javier Martinez Canillas @ 2023-01-10  9:26 UTC (permalink / raw)
  To: Uwe Kleine-König, Marek Vasut, Stefan Agner, David Airlie,
	Daniel Vetter
  Cc: dri-devel, Shawn Guo, NXP Linux Team, Pengutronix Kernel Team

Hello Uwe,

On 7/20/20 17:32, Uwe Kleine-König wrote:
> Ignoring errors from devm_clk_get() is wrong. To handle not all platforms
> having an axi clk use devm_clk_get_optional() instead and do proper error
> handling.
> 
> Also the clk API handles NULL as a dummy clk (which is also returned by
> devm_clk_get_optional() if there is no clk) so there is no need to check
> for NULL before calling clk_prepare_enable() or its counter part.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Patch looks good to me.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mxsfb: improve clk handling for axi clk
  2023-01-10  9:26 ` Javier Martinez Canillas
@ 2023-01-10 10:06   ` Javier Martinez Canillas
  2023-01-10 10:33     ` Marek Vasut
  0 siblings, 1 reply; 4+ messages in thread
From: Javier Martinez Canillas @ 2023-01-10 10:06 UTC (permalink / raw)
  To: Uwe Kleine-König, Marek Vasut, Stefan Agner, David Airlie,
	Daniel Vetter
  Cc: dri-devel, Shawn Guo, NXP Linux Team, Pengutronix Kernel Team

On 1/10/23 10:26, Javier Martinez Canillas wrote:
> Hello Uwe,
> 
> On 7/20/20 17:32, Uwe Kleine-König wrote:
>> Ignoring errors from devm_clk_get() is wrong. To handle not all platforms
>> having an axi clk use devm_clk_get_optional() instead and do proper error
>> handling.
>>
>> Also the clk API handles NULL as a dummy clk (which is also returned by
>> devm_clk_get_optional() if there is no clk) so there is no need to check
>> for NULL before calling clk_prepare_enable() or its counter part.
>>
>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> Patch looks good to me.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>

I've pushed this to drm-misc (dri-misc-next) now. Thanks!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/mxsfb: improve clk handling for axi clk
  2023-01-10 10:06   ` Javier Martinez Canillas
@ 2023-01-10 10:33     ` Marek Vasut
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2023-01-10 10:33 UTC (permalink / raw)
  To: Javier Martinez Canillas, Uwe Kleine-König, Stefan Agner,
	David Airlie, Daniel Vetter
  Cc: dri-devel, Shawn Guo, NXP Linux Team, Pengutronix Kernel Team

On 1/10/23 11:06, Javier Martinez Canillas wrote:
> On 1/10/23 10:26, Javier Martinez Canillas wrote:
>> Hello Uwe,
>>
>> On 7/20/20 17:32, Uwe Kleine-König wrote:
>>> Ignoring errors from devm_clk_get() is wrong. To handle not all platforms
>>> having an axi clk use devm_clk_get_optional() instead and do proper error
>>> handling.
>>>
>>> Also the clk API handles NULL as a dummy clk (which is also returned by
>>> devm_clk_get_optional() if there is no clk) so there is no need to check
>>> for NULL before calling clk_prepare_enable() or its counter part.
>>>
>>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>
>> Patch looks good to me.
>>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>>
> 
> I've pushed this to drm-misc (dri-misc-next) now. Thanks!

Thanks, I admit, I missed the patch, sorry.

It does indeed look correct.

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-10 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 15:32 [PATCH] drm/mxsfb: improve clk handling for axi clk Uwe Kleine-König
2023-01-10  9:26 ` Javier Martinez Canillas
2023-01-10 10:06   ` Javier Martinez Canillas
2023-01-10 10:33     ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.