Skip to content

Commit 3257bd1

Browse files
lucaceresolipH5
authored andcommitted
drm/imx: parallel-display: convert to devm_drm_bridge_alloc() API
This is the new API for allocating DRM bridges. This conversion was missed during the initial conversion of all bridges to the new API. Thus all kernels with commit 94d50c1 ("drm/bridge: get/put the bridge reference in drm_bridge_attach/detach()") and using this driver now warn due to drm_bridge_attach() incrementing the refcount, which is not initialized without using devm_drm_bridge_alloc() for allocation. To make the conversion simple and straightforward without messing up with the drmm_simple_encoder_alloc(), move the struct drm_bridge from struct imx_parallel_display_encoder to struct imx_parallel_display. Also remove the 'struct imx_parallel_display *pd' from struct imx_parallel_display_encoder, not needed anymore. Fixes: 94d50c1 ("drm/bridge: get/put the bridge reference in drm_bridge_attach/detach()") Reported-by: Ernest Van Hoecke <[email protected]> Closes: https://lore.kernel.org/all/hlf4wdopapxnh4rekl5s3kvoi6egaga3lrjfbx6r223ar3txri@3ik53xw5idyh/ Signed-off-by: Luca Ceresoli <[email protected]> Reviewed-by: Louis Chauvet <[email protected]> Tested-by: Ernest Van Hoecke <[email protected]> Link: https://patch.msgid.link/20251014-drm-bridge-alloc-imx-ipuv3-v1-1-a1bb1dcbff50@bootlin.com Signed-off-by: Philipp Zabel <[email protected]>
1 parent d8eb00b commit 3257bd1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/gpu/drm/imx/ipuv3/parallel-display.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@
2525

2626
struct imx_parallel_display_encoder {
2727
struct drm_encoder encoder;
28-
struct drm_bridge bridge;
29-
struct imx_parallel_display *pd;
3028
};
3129

3230
struct imx_parallel_display {
3331
struct device *dev;
3432
u32 bus_format;
3533
struct drm_bridge *next_bridge;
34+
struct drm_bridge bridge;
3635
};
3736

3837
static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b)
3938
{
40-
return container_of(b, struct imx_parallel_display_encoder, bridge)->pd;
39+
return container_of(b, struct imx_parallel_display, bridge);
4140
}
4241

4342
static const u32 imx_pd_bus_fmts[] = {
@@ -195,15 +194,13 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
195194
if (IS_ERR(imxpd_encoder))
196195
return PTR_ERR(imxpd_encoder);
197196

198-
imxpd_encoder->pd = imxpd;
199197
encoder = &imxpd_encoder->encoder;
200-
bridge = &imxpd_encoder->bridge;
198+
bridge = &imxpd->bridge;
201199

202200
ret = imx_drm_encoder_parse_of(drm, encoder, imxpd->dev->of_node);
203201
if (ret)
204202
return ret;
205203

206-
bridge->funcs = &imx_pd_bridge_funcs;
207204
drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
208205

209206
connector = drm_bridge_connector_init(drm, encoder);
@@ -228,9 +225,10 @@ static int imx_pd_probe(struct platform_device *pdev)
228225
u32 bus_format = 0;
229226
const char *fmt;
230227

231-
imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL);
232-
if (!imxpd)
233-
return -ENOMEM;
228+
imxpd = devm_drm_bridge_alloc(dev, struct imx_parallel_display, bridge,
229+
&imx_pd_bridge_funcs);
230+
if (IS_ERR(imxpd))
231+
return PTR_ERR(imxpd);
234232

235233
/* port@1 is the output port */
236234
imxpd->next_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);

0 commit comments

Comments
 (0)