The ingenic driver allocates a structure holding both the DPI encoder
and the source bridge of its pipeline, and allocates it as a whole
through drmm_encoder_alloc(). The bridge is thus not known to
devm_drm_bridge_alloc(), which drm_bridge_attach() already warns
about.

The bridge private object also gets its name from the devm bridge
allocation, and drm_bridge_attach() will soon report a failure of
that initialization instead of ignoring it, so a bridge allocated any
other way would prevent the driver from probing.

Allocate the structure through devm_drm_bridge_alloc(), making the
bridge the primary object of the allocation, and initialise the
embedded encoder in place with drmm_encoder_init(). Both objects
stay in the same structure, so the container_of() conversions keep
working, and the bridge funcs assignment moves into the allocator
call.

Signed-off-by: Maxime Ripard <[email protected]>

---

To: Paul Cercueil <[email protected]>
Cc: Luca Ceresoli <[email protected]>
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 63198fd59498..8cad8dcfae60 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1304,18 +1304,25 @@ static int ingenic_drm_bind(struct device *dev, bool 
has_components)
                }
 
-               ib = drmm_encoder_alloc(drm, struct ingenic_drm_bridge, encoder,
-                                       NULL, DRM_MODE_ENCODER_DPI, NULL);
+               ib = devm_drm_bridge_alloc(dev, struct ingenic_drm_bridge,
+                                          bridge, &ingenic_drm_bridge_funcs);
                if (IS_ERR(ib)) {
                        ret = PTR_ERR(ib);
-                       dev_err(dev, "Failed to init encoder: %d\n", ret);
+                       dev_err(dev, "Failed to allocate bridge: %d\n", ret);
                        goto err_drvdata;
                }
 
                encoder = &ib->encoder;
+
+               ret = drmm_encoder_init(drm, encoder, NULL,
+                                       DRM_MODE_ENCODER_DPI, NULL);
+               if (ret) {
+                       dev_err(dev, "Failed to init encoder: %d\n", ret);
+                       goto err_drvdata;
+               }
+
                encoder->possible_crtcs = drm_crtc_mask(&priv->crtc);
 
                drm_encoder_helper_add(encoder, 
&ingenic_drm_encoder_helper_funcs);
 
-               ib->bridge.funcs = &ingenic_drm_bridge_funcs;
                ib->next_bridge = bridge;
 

-- 
2.55.0

Reply via email to