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

From: Luca Ceresoli <[email-masked]>
Date: Tue, 19 May 2026 12:37:25 +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
anymore: it can only return either the same pointer it received as input or
a negative ERR_PTR.

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

No functional changes.

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

diff --git a/drivers/gpu/drm/display/drm_bridge_connector.c b/drivers/gpu/drm/display/drm_bridge_connector.c
index 97d9a4c6d166..d8a033ed8f41 100644
--- a/drivers/gpu/drm/display/drm_bridge_connector.c
+++ b/drivers/gpu/drm/display/drm_bridge_connector.c
@@ -772,14 +772,13 @@ static void drm_bridge_connector_put_bridges(struct drm_device *dev, void *data)
 	drm_bridge_put(bridge_connector->bridge_hdmi_cec);
 }
 
-static struct drm_bridge_connector *
-drm_bridge_connector_get_bridges(struct drm_bridge_connector *bridge_connector,
-				 int *connector_type,
-				 unsigned int *supported_formats,
-				 unsigned int *max_bpc,
-				 struct i2c_adapter **ddc,
-				 struct drm_bridge **panel_bridge,
-				 bool *support_hdcp)
+static int drm_bridge_connector_get_bridges(struct drm_bridge_connector *bridge_connector,
+					    int *connector_type,
+					    unsigned int *supported_formats,
+					    unsigned int *max_bpc,
+					    struct i2c_adapter **ddc,
+					    struct drm_bridge **panel_bridge,
+					    bool *support_hdcp)
 {
 	struct drm_connector *connector = &bridge_connector->base;
 
@@ -820,27 +819,27 @@ drm_bridge_connector_get_bridges(struct drm_bridge_connector *bridge_connector,
 		}
 		if (bridge->ops & DRM_BRIDGE_OP_HDMI) {
 			if (bridge_connector->bridge_hdmi)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 			if (!bridge->funcs->hdmi_write_avi_infoframe ||
 			    !bridge->funcs->hdmi_clear_avi_infoframe ||
 			    !bridge->funcs->hdmi_write_hdmi_infoframe ||
 			    !bridge->funcs->hdmi_clear_hdmi_infoframe)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			if (bridge->ops & DRM_BRIDGE_OP_HDMI_AUDIO &&
 			    (!bridge->funcs->hdmi_write_audio_infoframe ||
 			     !bridge->funcs->hdmi_clear_audio_infoframe))
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			if (bridge->ops & DRM_BRIDGE_OP_HDMI_HDR_DRM_INFOFRAME &&
 			    (!bridge->funcs->hdmi_write_hdr_drm_infoframe ||
 			     !bridge->funcs->hdmi_clear_hdr_drm_infoframe))
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			if (bridge->ops & DRM_BRIDGE_OP_HDMI_SPD_INFOFRAME &&
 			    (!bridge->funcs->hdmi_write_spd_infoframe ||
 			     !bridge->funcs->hdmi_clear_spd_infoframe))
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			bridge_connector->bridge_hdmi = drm_bridge_get(bridge);
 
@@ -852,57 +851,57 @@ drm_bridge_connector_get_bridges(struct drm_bridge_connector *bridge_connector,
 
 		if (bridge->ops & DRM_BRIDGE_OP_HDMI_AUDIO) {
 			if (bridge_connector->bridge_hdmi_audio)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			if (bridge_connector->bridge_dp_audio)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			if (!bridge->hdmi_audio_max_i2s_playback_channels &&
 			    !bridge->hdmi_audio_spdif_playback)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			if (!bridge->funcs->hdmi_audio_prepare ||
 			    !bridge->funcs->hdmi_audio_shutdown)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			bridge_connector->bridge_hdmi_audio = drm_bridge_get(bridge);
 		}
 
 		if (bridge->ops & DRM_BRIDGE_OP_DP_AUDIO) {
 			if (bridge_connector->bridge_dp_audio)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			if (bridge_connector->bridge_hdmi_audio)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			if (!bridge->hdmi_audio_max_i2s_playback_channels &&
 			    !bridge->hdmi_audio_spdif_playback)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			if (!bridge->funcs->dp_audio_prepare ||
 			    !bridge->funcs->dp_audio_shutdown)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 
 			bridge_connector->bridge_dp_audio = drm_bridge_get(bridge);
 		}
 
 		if (bridge->ops & DRM_BRIDGE_OP_HDMI_CEC_NOTIFIER) {
 			if (bridge_connector->bridge_hdmi_cec)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			bridge_connector->bridge_hdmi_cec = drm_bridge_get(bridge);
 		}
 
 		if (bridge->ops & DRM_BRIDGE_OP_HDMI_CEC_ADAPTER) {
 			if (bridge_connector->bridge_hdmi_cec)
-				return ERR_PTR(-EBUSY);
+				return -EBUSY;
 
 			bridge_connector->bridge_hdmi_cec = drm_bridge_get(bridge);
 
 			if (!bridge->funcs->hdmi_cec_enable ||
 			    !bridge->funcs->hdmi_cec_log_addr ||
 			    !bridge->funcs->hdmi_cec_transmit)
-				return ERR_PTR(-EINVAL);
+				return -EINVAL;
 		}
 
 		if (drm_bridge_is_last(bridge))
@@ -926,9 +925,9 @@ drm_bridge_connector_get_bridges(struct drm_bridge_connector *bridge_connector,
 	}
 
 	if (connector_type == DRM_MODE_CONNECTOR_Unknown)
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 
-	return bridge_connector;
+	return 0;
 }
 
 /**
@@ -956,11 +955,11 @@ drm_bridge_connector_add_connector(struct drm_bridge_connector *bridge_connector
 
 	connector = &bridge_connector->base;
 
-	bridge_connector = drm_bridge_connector_get_bridges(bridge_connector, &connector_type,
-							    &supported_formats, &max_bpc, &ddc,
-							    &panel_bridge, &support_hdcp);
-	if (IS_ERR(bridge_connector))
-		return bridge_connector;
+	ret = drm_bridge_connector_get_bridges(bridge_connector, &connector_type,
+					       &supported_formats, &max_bpc, &ddc,
+					       &panel_bridge, &support_hdcp);
+	if (ret)
+		return ERR_PTR(ret);
 
 	if (bridge_connector->bridge_hdmi) {
 		if (!connector->ycbcr_420_allowed)

-- 
2.54.0