public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/sti: hdmi: remove bridge when component_add fails
@ 2026-04-10 19:41 Osama Abdelkader
  2026-04-14  7:24 ` Luca Ceresoli
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Abdelkader @ 2026-04-10 19:41 UTC (permalink / raw)
  To: luca.ceresoli, Alain Volmat, Raphael Gallais-Pou,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel
  Cc: Osama Abdelkader

when component_add fails in sti_hdmi_probe remove the drm bridge
and put i2c adapter before return

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
 drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index f8222e60b1e0..839c80a7d954 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -1460,8 +1460,13 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, hdmi);
 
 	drm_bridge_add(&hdmi->bridge);
-	return component_add(&pdev->dev, &sti_hdmi_ops);
+	ret = component_add(&pdev->dev, &sti_hdmi_ops);
+	if (ret)
+		goto remove_bridge;
+	return 0;
 
+ remove_bridge:
+	drm_bridge_remove(&hdmi->bridge);
  release_adapter:
 	i2c_put_adapter(hdmi->ddc_adapt);
 
-- 
2.43.0


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

* Re: [PATCH] drm/sti: hdmi: remove bridge when component_add fails
  2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
@ 2026-04-14  7:24 ` Luca Ceresoli
  0 siblings, 0 replies; 2+ messages in thread
From: Luca Ceresoli @ 2026-04-14  7:24 UTC (permalink / raw)
  To: Osama Abdelkader, Alain Volmat, Raphael Gallais-Pou,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel

Hello,

On Fri Apr 10, 2026 at 9:41 PM CEST, Osama Abdelkader wrote:
> when component_add fails in sti_hdmi_probe remove the drm bridge
> and put i2c adapter before return
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
>  drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
> index f8222e60b1e0..839c80a7d954 100644
> --- a/drivers/gpu/drm/sti/sti_hdmi.c
> +++ b/drivers/gpu/drm/sti/sti_hdmi.c
> @@ -1460,8 +1460,13 @@ static int sti_hdmi_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, hdmi);
>
>  	drm_bridge_add(&hdmi->bridge);
> -	return component_add(&pdev->dev, &sti_hdmi_ops);
> +	ret = component_add(&pdev->dev, &sti_hdmi_ops);
> +	if (ret)
> +		goto remove_bridge;
> +	return 0;
>
> + remove_bridge:
> +	drm_bridge_remove(&hdmi->bridge);
>   release_adapter:
>  	i2c_put_adapter(hdmi->ddc_adapt);

This function has an insane amount of sections like:

  if (IS_ERR(...)) {
      DRM_ERROR(...);
      ret = PTR_ERR(...);
      goto release_adapter;
  }

I guess all these can be dramatically simplified by using a devm
action. of_get_i2c_adapter_by_node() has no devm_ version but you can add a
release action using devm_add_action_or_reset(). This would allow to
simplify all the error management if()s and avoid any gotos.

On top of that you can just switch to devm_drm_bridge_add().

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2026-04-14  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 19:41 [PATCH] drm/sti: hdmi: remove bridge when component_add fails Osama Abdelkader
2026-04-14  7:24 ` Luca Ceresoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox