mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/omap: dss: simplify omapdss_device_init_output
@ 2026-11-17 18:40 Andreas Kemnade
  2026-11-19  8:32 ` Albert Esteve
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Kemnade @ 2026-11-17 18:40 UTC (permalink / raw)
  To: tomi.valkeinen, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, luca.ceresoli, andreas, louis.chauvet, aesteve,
	dri-devel, linux-kernel

During reviewing of a regression fix is that function, questionable
possibly unbalanced drm_bridge_put/get came to light. Sashiko
review pointed out that of_drm_get_bridge_by_endpoint() does not return
NULL, so the questionable code is simply unreachable and therefore does
at least not harm. Remove the dead code.

Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index b5cef5093a883..cbb9b2f1a2133 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -20,7 +20,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 			       struct drm_bridge *local_bridge)
 {
 	struct drm_bridge *bridge;
-	int ret;
 
 	bridge = of_drm_get_bridge_by_endpoint(out->dev->of_node, out->of_port, 0);
 	if (IS_ERR(bridge)) {
@@ -34,20 +33,11 @@ int omapdss_device_init_output(struct omap_dss_device *out,
 	out->bridge = bridge;
 
 	if (local_bridge) {
-		if (!out->bridge) {
-			ret = -EPROBE_DEFER;
-			goto error;
-		}
-
 		out->next_bridge = out->bridge;
 		out->bridge = drm_bridge_get(local_bridge);
 	}
 
 	return 0;
-
-error:
-	omapdss_device_cleanup_output(out);
-	return ret;
 }
 
 void omapdss_device_cleanup_output(struct omap_dss_device *out)
-- 
2.47.3


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

* Re: [PATCH] drm/omap: dss: simplify omapdss_device_init_output
  2026-11-17 18:40 [PATCH] drm/omap: dss: simplify omapdss_device_init_output Andreas Kemnade
@ 2026-11-19  8:32 ` Albert Esteve
  2026-11-19  9:17   ` Andreas Kemnade
  0 siblings, 1 reply; 4+ messages in thread
From: Albert Esteve @ 2026-11-19  8:32 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: tomi.valkeinen, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, luca.ceresoli, louis.chauvet, dri-devel, linux-kernel

On Tue, Nov 17, 2026 at 7:40 PM Andreas Kemnade <andreas@kemnade.info> wrote:
>
> During reviewing of a regression fix is that function, questionable
> possibly unbalanced drm_bridge_put/get came to light. Sashiko
> review pointed out that of_drm_get_bridge_by_endpoint() does not return
> NULL, so the questionable code is simply unreachable and therefore does
> at least not harm. Remove the dead code.
>
> Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
>  1 file changed, 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> index b5cef5093a883..cbb9b2f1a2133 100644
> --- a/drivers/gpu/drm/omapdrm/dss/output.c
> +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> @@ -20,7 +20,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
>                                struct drm_bridge *local_bridge)
>  {
>         struct drm_bridge *bridge;
> -       int ret;
>
>         bridge = of_drm_get_bridge_by_endpoint(out->dev->of_node, out->of_port, 0);
>         if (IS_ERR(bridge)) {
> @@ -34,20 +33,11 @@ int omapdss_device_init_output(struct omap_dss_device *out,
>         out->bridge = bridge;
>
>         if (local_bridge) {
> -               if (!out->bridge) {
> -                       ret = -EPROBE_DEFER;
> -                       goto error;
> -               }
> -
>                 out->next_bridge = out->bridge;
>                 out->bridge = drm_bridge_get(local_bridge);
>         }
>
>         return 0;
> -
> -error:
> -       omapdss_device_cleanup_output(out);
> -       return ret;
>  }

This looks correct, it is dead code. But removing it makes the return
value meaningless (every path returns 0), so it may make sense to make
omapdss_device_init_output() void?

I looked for the callers and there are only a handful. They can be
simplified to avoid checking the return value (the "r=...; if (r < 0)
{ cleanup; }" patterns is repeated in all of them).

BR,
Albert.

>
>  void omapdss_device_cleanup_output(struct omap_dss_device *out)
> --
> 2.47.3
>


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

* Re: [PATCH] drm/omap: dss: simplify omapdss_device_init_output
  2026-11-19  8:32 ` Albert Esteve
@ 2026-11-19  9:17   ` Andreas Kemnade
  2026-11-19  9:32     ` Albert Esteve
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Kemnade @ 2026-11-19  9:17 UTC (permalink / raw)
  To: Albert Esteve
  Cc: tomi.valkeinen, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, luca.ceresoli, louis.chauvet, dri-devel, linux-kernel

On Thu, 19 Nov 2026 09:32:11 +0100
Albert Esteve <aesteve@redhat.com> wrote:

> On Tue, Nov 17, 2026 at 7:40 PM Andreas Kemnade <andreas@kemnade.info> wrote:
> >
> > During reviewing of a regression fix is that function, questionable
> > possibly unbalanced drm_bridge_put/get came to light. Sashiko
> > review pointed out that of_drm_get_bridge_by_endpoint() does not return
> > NULL, so the questionable code is simply unreachable and therefore does
> > at least not harm. Remove the dead code.
> >
> > Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > ---
> >  drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
> >  1 file changed, 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> > index b5cef5093a883..cbb9b2f1a2133 100644
> > --- a/drivers/gpu/drm/omapdrm/dss/output.c
> > +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> > @@ -20,7 +20,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> >                                struct drm_bridge *local_bridge)
> >  {
> >         struct drm_bridge *bridge;
> > -       int ret;
> >
> >         bridge = of_drm_get_bridge_by_endpoint(out->dev->of_node, out->of_port, 0);
> >         if (IS_ERR(bridge)) {
> > @@ -34,20 +33,11 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> >         out->bridge = bridge;
> >
> >         if (local_bridge) {
> > -               if (!out->bridge) {
> > -                       ret = -EPROBE_DEFER;
> > -                       goto error;
> > -               }
> > -
> >                 out->next_bridge = out->bridge;
> >                 out->bridge = drm_bridge_get(local_bridge);
> >         }
> >
> >         return 0;
> > -
> > -error:
> > -       omapdss_device_cleanup_output(out);
> > -       return ret;
> >  }  
> 
> This looks correct, it is dead code. But removing it makes the return
> value meaningless (every path returns 0), so it may make sense to make
> omapdss_device_init_output() void?
> 
No, not every patch returns 0.

Regards,
Andreas

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

* Re: [PATCH] drm/omap: dss: simplify omapdss_device_init_output
  2026-11-19  9:17   ` Andreas Kemnade
@ 2026-11-19  9:32     ` Albert Esteve
  0 siblings, 0 replies; 4+ messages in thread
From: Albert Esteve @ 2026-11-19  9:32 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: tomi.valkeinen, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, luca.ceresoli, louis.chauvet, dri-devel, linux-kernel

On Thu, Nov 19, 2026 at 10:18 AM Andreas Kemnade <andreas@kemnade.info> wrote:
>
> On Thu, 19 Nov 2026 09:32:11 +0100
> Albert Esteve <aesteve@redhat.com> wrote:
>
> > On Tue, Nov 17, 2026 at 7:40 PM Andreas Kemnade <andreas@kemnade.info> wrote:
> > >
> > > During reviewing of a regression fix is that function, questionable
> > > possibly unbalanced drm_bridge_put/get came to light. Sashiko
> > > review pointed out that of_drm_get_bridge_by_endpoint() does not return
> > > NULL, so the questionable code is simply unreachable and therefore does
> > > at least not harm. Remove the dead code.
> > >
> > > Suggested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> > > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > > ---
> > >  drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
> > >  1 file changed, 10 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
> > > index b5cef5093a883..cbb9b2f1a2133 100644
> > > --- a/drivers/gpu/drm/omapdrm/dss/output.c
> > > +++ b/drivers/gpu/drm/omapdrm/dss/output.c
> > > @@ -20,7 +20,6 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> > >                                struct drm_bridge *local_bridge)
> > >  {
> > >         struct drm_bridge *bridge;
> > > -       int ret;
> > >
> > >         bridge = of_drm_get_bridge_by_endpoint(out->dev->of_node, out->of_port, 0);
> > >         if (IS_ERR(bridge)) {
> > > @@ -34,20 +33,11 @@ int omapdss_device_init_output(struct omap_dss_device *out,
> > >         out->bridge = bridge;
> > >
> > >         if (local_bridge) {
> > > -               if (!out->bridge) {
> > > -                       ret = -EPROBE_DEFER;
> > > -                       goto error;
> > > -               }
> > > -
> > >                 out->next_bridge = out->bridge;
> > >                 out->bridge = drm_bridge_get(local_bridge);
> > >         }
> > >
> > >         return 0;
> > > -
> > > -error:
> > > -       omapdss_device_cleanup_output(out);
> > > -       return ret;
> > >  }
> >
> > This looks correct, it is dead code. But removing it makes the return
> > value meaningless (every path returns 0), so it may make sense to make
> > omapdss_device_init_output() void?
> >
> No, not every patch returns 0.

Ah, I was looking at my local tree and I had missed your base differs
in the IS_ERR branch (which the patch context doesn't show). Scratch
the suggestion then.

Reviewed-by: Albert Esteve <aesteve@redhat.com>

Thanks,
Albert.

>
> Regards,
> Andreas
>


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

end of thread, other threads:[~2026-11-19  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 18:40 [PATCH] drm/omap: dss: simplify omapdss_device_init_output Andreas Kemnade
2026-11-19  8:32 ` Albert Esteve
2026-11-19  9:17   ` Andreas Kemnade
2026-11-19  9:32     ` Albert Esteve

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®