[PATCH v2 41/41] drm: renesas: shmobile: remove now-redundant call to drm_connector_attach_encoder()

From: Luca Ceresoli

Date: Thu Apr 23 2026 - 08:06:24 EST


shmob_drm_connector_create() can init the connector in two ways, based on
the 'if (sdev->pdata)':

1. manually in shmob_drm_connector_create(), or
2. delegating to drm_bridge_connector_init()

Whichever branch is taken, drm_connector_attach_encoder() is called
immediately after to attach the connector to the encoder.

Now drm_bridge_connector_init() calls drm_connector_attach_encoder() on the
connector so it is not needed anymore in case 2 and should be removed, but
it is still needed in case 1. Move drm_connector_attach_encoder() from the
common path to inside shmob_drm_connector_create() in order to get back to
a single drm_connector_attach_encoder() in both cases.

Signed-off-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>

---

Changes in v2:
- rewrote completely, fixing potential ERR_PTR deref and ending up with
a cleaner patch
- also wrote more extensive commit message
---
.../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 5f460b38596c..815c770147ed 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -583,6 +583,13 @@ shmob_drm_connector_init(struct shmob_drm_device *sdev,

drm_connector_helper_add(connector, &connector_helper_funcs);

+ ret = drm_connector_attach_encoder(connector, encoder);
+ if (ret < 0) {
+ drm_connector_cleanup(connector);
+ kfree(scon);
+ return ERR_PTR(ret);
+ }
+
return connector;
}

@@ -594,7 +601,6 @@ int shmob_drm_connector_create(struct shmob_drm_device *sdev,
struct drm_encoder *encoder)
{
struct drm_connector *connector;
- int ret;

if (sdev->pdata)
connector = shmob_drm_connector_init(sdev, encoder);
@@ -606,17 +612,9 @@ int shmob_drm_connector_create(struct shmob_drm_device *sdev,
return PTR_ERR(connector);
}

- ret = drm_connector_attach_encoder(connector, encoder);
- if (ret < 0)
- goto error;
-
connector->dpms = DRM_MODE_DPMS_OFF;

sdev->connector = connector;

return 0;
-
-error:
- drm_connector_cleanup(connector);
- return ret;
}
--
2.53.0