Subject: [PATCH 11/37] drm/display: bridge-connector: return int from drm_bridge_connector_add_connector()

From: Luca Ceresoli <[email-masked]>
Date: Tue, 19 May 2026 12:37:28 +0200

This function returns a struct drm_bridge_connector * because this was the
case in the origin of its code. In current code it does not make sense: it
can only return either the same pointer it received as input or a negative
ERR_PTR.

This forces users to an unnecessarily complex error management code.

Clean up error management by just returning an int (0 or negative error).

Signed-off-by: Luca Ceresoli <[email-masked]>
---
 drivers/gpu/drm/display/drm_bridge_connector.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
index 6066ca0c5624..982bc64d8361 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -991,11 +991,9 @@ static int drm_bridge_connector_init_hdmi_audio_cec(struct drm_bridge_connector
  * @bridge_connector->drm and @bridge_connector->encoder fields are
  * assigned at least)
  *
- * Returns a pointer to @bridge_connector on success, or a negative error
- * pointer otherwise.
+ * Returns 0 on success or a negative error otherwise.
  */
-static struct drm_bridge_connector *
-drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector)
+static int drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector)
 {
 	struct drm_connector *connector;
 	struct i2c_adapter *ddc = NULL;
@@ -1012,7 +1010,7 @@ drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector
 					       &supported_formats, &max_bpc, &ddc,
 					       &panel_bridge, &support_hdcp);
 	if (ret)
-		return ERR_PTR(ret);
+		return ret;
 
 	if (bridge_connector->bridge_hdmi) {
 		if (!connector->ycbcr_420_allowed)
@@ -1041,18 +1039,18 @@ drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector
 					       supported_formats,
 					       max_bpc);
 		if (ret)
-			return ERR_PTR(ret);
+			return ret;
 	} else {
 		ret = drmm_connector_init(bridge_connector->drm, connector,
 					  &drm_bridge_connector_funcs,
 					  connector_type, ddc);
 		if (ret)
-			return ERR_PTR(ret);
+			return ret;
 	}
 
 	ret = drm_bridge_connector_init_hdmi_audio_cec(bridge_connector);
 	if (ret)
-		return ERR_PTR(ret);
+		return ret;
 
 	drm_connector_helper_add(connector, &drm_bridge_connector_helper_funcs);
 
@@ -1071,9 +1069,9 @@ drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector
 
 	ret = drm_connector_attach_encoder(connector, bridge_connector->encoder);
 	if (ret)
-		return ERR_PTR(ret);
+		return ret;
 
-	return bridge_connector;
+	return 0;
 }
 
 /**
@@ -1110,9 +1108,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm,
 	bridge_connector->drm = drm;
 	bridge_connector->encoder = encoder;
 
-	bridge_connector = drm_bridge_connector_add_connector(bridge_connector);
-	if (IS_ERR(bridge_connector))
-		return ERR_CAST(bridge_connector);
+	ret = drm_bridge_connector_add_connector(bridge_connector);
+	if (ret)
+		return ERR_PTR(ret);
 
 	return &bridge_connector->base;
 }

-- 
2.54.0