Skip to content

Commit 9545c91

Browse files
lucaceresoliFomys
authored andcommitted
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 <[email protected]> Acked-by: Dave Stevenson <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20250424-drm-bridge-convert-to-alloc-api-v2-27-8f91a404d86b@bootlin.com Signed-off-by: Louis Chauvet <[email protected]>
1 parent e11532b commit 9545c91

File tree

1 file changed

+5
-29
lines changed

1 file changed

+5
-29
lines changed

drivers/gpu/drm/vc4/vc4_dsi.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,6 @@ struct vc4_dsi {
552552
struct vc4_encoder encoder;
553553
struct mipi_dsi_host dsi_host;
554554

555-
struct kref kref;
556-
557555
struct platform_device *pdev;
558556

559557
struct drm_bridge *out_bridge;
@@ -1622,29 +1620,11 @@ static void vc4_dsi_dma_chan_release(void *ptr)
16221620
dsi->reg_dma_chan = NULL;
16231621
}
16241622

1625-
static void vc4_dsi_release(struct kref *kref)
1626-
{
1627-
struct vc4_dsi *dsi =
1628-
container_of(kref, struct vc4_dsi, kref);
1629-
1630-
kfree(dsi);
1631-
}
1632-
1633-
static void vc4_dsi_get(struct vc4_dsi *dsi)
1634-
{
1635-
kref_get(&dsi->kref);
1636-
}
1637-
1638-
static void vc4_dsi_put(struct vc4_dsi *dsi)
1639-
{
1640-
kref_put(&dsi->kref, &vc4_dsi_release);
1641-
}
1642-
16431623
static void vc4_dsi_release_action(struct drm_device *drm, void *ptr)
16441624
{
16451625
struct vc4_dsi *dsi = ptr;
16461626

1647-
vc4_dsi_put(dsi);
1627+
drm_bridge_put(&dsi->bridge);
16481628
}
16491629

16501630
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)
16551635
struct drm_encoder *encoder = &dsi->encoder.base;
16561636
int ret;
16571637

1658-
vc4_dsi_get(dsi);
1638+
drm_bridge_get(&dsi->bridge);
16591639

16601640
ret = drmm_add_action_or_reset(drm, vc4_dsi_release_action, dsi);
16611641
if (ret)
@@ -1810,15 +1790,12 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev)
18101790
struct device *dev = &pdev->dev;
18111791
struct vc4_dsi *dsi;
18121792

1813-
dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
1814-
if (!dsi)
1815-
return -ENOMEM;
1793+
dsi = devm_drm_bridge_alloc(&pdev->dev, struct vc4_dsi, bridge, &vc4_dsi_bridge_funcs);
1794+
if (IS_ERR(dsi))
1795+
return PTR_ERR(dsi);
18161796
dev_set_drvdata(dev, dsi);
18171797

1818-
kref_init(&dsi->kref);
1819-
18201798
dsi->pdev = pdev;
1821-
dsi->bridge.funcs = &vc4_dsi_bridge_funcs;
18221799
#ifdef CONFIG_OF
18231800
dsi->bridge.of_node = dev->of_node;
18241801
#endif
@@ -1836,7 +1813,6 @@ static void vc4_dsi_dev_remove(struct platform_device *pdev)
18361813
struct vc4_dsi *dsi = dev_get_drvdata(dev);
18371814

18381815
mipi_dsi_host_unregister(&dsi->dsi_host);
1839-
vc4_dsi_put(dsi);
18401816
}
18411817

18421818
struct platform_driver vc4_dsi_driver = {

0 commit comments

Comments
 (0)