Skip to contentSkip to conversation

drm/omap: dss: simplify omapdss_device_init_output

PATCH In review Andreas Kemnade 2 participants 4 messages Nov 17 – Nov 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/omap: dss: simplify omapdss_device_init_output

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.

---
 drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/omapdrm/dss/output.c +0 -10
index b5cef5093a883..cbb9b2f1a2133 100644
@@ -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)
Signature · 1 line
2.47.3
#1 lore raw
Quoted 34 lines · Andreas Kemnade

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.

---
 drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/omapdrm/dss/output.c +0 -6
index b5cef5093a883..cbb9b2f1a2133 100644
@@ -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;
-               }
-

drivers/gpu/drm/omapdrm/dss/output.c int omapdss_device_init_output(struct omap_dss_device *out, · line 41

Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/output.c +0 -4
                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.

Quoted 5 lines
drivers/gpu/drm/omapdrm/dss/output.c +0 -1
 void omapdss_device_cleanup_output(struct omap_dss_device *out)
--

2.47.3

#2 lore raw
Quoted 39 lines · On Thu, 19 Nov 2026 09:32:11 +0100 Albert Esteve <[email protected]> wrote:
Quoted 38 lines · Andreas Kemnade

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.

---
 drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/omapdrm/dss/output.c +0 -6
index b5cef5093a883..cbb9b2f1a2133 100644
@@ -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);
        }
 
Quoted 11 lines

drivers/gpu/drm/omapdrm/dss/output.c int omapdss_device_init_output(struct omap_dss_device *out, · line 41

Quoted 6 lines
drivers/gpu/drm/omapdrm/dss/output.c +0 -4
        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

Reviewed-by
#3 lore raw
Quoted 54 lines · Andreas Kemnade
Quoted 39 lines · On Thu, 19 Nov 2026 09:32:11 +0100 Albert Esteve <[email protected]> wrote:
Quoted 38 lines · Andreas Kemnade

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.

---
 drivers/gpu/drm/omapdrm/dss/output.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpu/drm/omapdrm/dss/output.c +0 -6
index b5cef5093a883..cbb9b2f1a2133 100644
@@ -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);
        }
 
Quoted 11 lines

drivers/gpu/drm/omapdrm/dss/output.c int omapdss_device_init_output(struct omap_dss_device *out, · line 41

Quoted 6 lines
drivers/gpu/drm/omapdrm/dss/output.c +0 -4
        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?

Quoted 1 line

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.

Thanks,
Albert.

Quoted 4 lines

Regards,
Andreas