drm/vc4: convert to devm_drm_bridge_alloc() API

This is the new API for allocating DRM bridges.

This driver already implements refcounting of the struct vc4_dsi, which
embeds struct drm_bridge. Now this is a duplicate of the refcounting
implemented by the DRM bridge core, so convert the vc4_dsi_get/put() calls
into drm_bridge_get/put() calls and get rid of the driver-specific
refcounting implementation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Acked-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250424-drm-bridge-convert-to-alloc-api-v2-27-8f91a404d86b@bootlin.com
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
This commit is contained in:
Luca Ceresoli 2025-04-24 20:59:34 +02:00 committed by Louis Chauvet
parent e11532be87
commit 9545c91ed7
No known key found for this signature in database
GPG Key ID: 20AD2EC65B102CE2

View File

@ -552,8 +552,6 @@ struct vc4_dsi {
struct vc4_encoder encoder;
struct mipi_dsi_host dsi_host;
struct kref kref;
struct platform_device *pdev;
struct drm_bridge *out_bridge;
@ -1622,29 +1620,11 @@ static void vc4_dsi_dma_chan_release(void *ptr)
dsi->reg_dma_chan = NULL;
}
static void vc4_dsi_release(struct kref *kref)
{
struct vc4_dsi *dsi =
container_of(kref, struct vc4_dsi, kref);
kfree(dsi);
}
static void vc4_dsi_get(struct vc4_dsi *dsi)
{
kref_get(&dsi->kref);
}
static void vc4_dsi_put(struct vc4_dsi *dsi)
{
kref_put(&dsi->kref, &vc4_dsi_release);
}
static void vc4_dsi_release_action(struct drm_device *drm, void *ptr)
{
struct vc4_dsi *dsi = ptr;
vc4_dsi_put(dsi);
drm_bridge_put(&dsi->bridge);
}
static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
@ -1655,7 +1635,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
struct drm_encoder *encoder = &dsi->encoder.base;
int ret;
vc4_dsi_get(dsi);
drm_bridge_get(&dsi->bridge);
ret = drmm_add_action_or_reset(drm, vc4_dsi_release_action, dsi);
if (ret)
@ -1810,15 +1790,12 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct vc4_dsi *dsi;
dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
if (!dsi)
return -ENOMEM;
dsi = devm_drm_bridge_alloc(&pdev->dev, struct vc4_dsi, bridge, &vc4_dsi_bridge_funcs);
if (IS_ERR(dsi))
return PTR_ERR(dsi);
dev_set_drvdata(dev, dsi);
kref_init(&dsi->kref);
dsi->pdev = pdev;
dsi->bridge.funcs = &vc4_dsi_bridge_funcs;
#ifdef CONFIG_OF
dsi->bridge.of_node = dev->of_node;
#endif
@ -1836,7 +1813,6 @@ static void vc4_dsi_dev_remove(struct platform_device *pdev)
struct vc4_dsi *dsi = dev_get_drvdata(dev);
mipi_dsi_host_unregister(&dsi->dsi_host);
vc4_dsi_put(dsi);
}
struct platform_driver vc4_dsi_driver = {