summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2022-07-11 20:38:59 +0300
committerMaxime Ripard <maxime@cerno.tech>2022-07-13 11:46:08 +0300
commite126d318002639c979f23764f5d496a78e9bd85e (patch)
tree8245afae6685b1aeeeaa656cc0f41a656c4fc0c7
parent77932adf2a2c9625da8bc8885b626690ee500601 (diff)
downloadlinux-e126d318002639c979f23764f5d496a78e9bd85e.tar.xz
drm/vc4: dpi: Switch to DRM-managed encoder initialization
The current code will call drm_encoder_cleanup() when the device is unbound. However, by then, there might still be some references held to that encoder, including by the userspace that might still have the DRM device open. Let's switch to a DRM-managed initialization to clean up after ourselves only once the DRM device has been last closed. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220711173939.1132294-30-maxime@cerno.tech
-rw-r--r--drivers/gpu/drm/vc4/vc4_dpi.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c
index c4ea99f85e5b..ceb14aea6c05 100644
--- a/drivers/gpu/drm/vc4/vc4_dpi.c
+++ b/drivers/gpu/drm/vc4/vc4_dpi.c
@@ -316,35 +316,28 @@ static int vc4_dpi_bind(struct device *dev, struct device *master, void *data)
if (ret)
return ret;
- drm_simple_encoder_init(drm, &dpi->encoder.base, DRM_MODE_ENCODER_DPI);
+ ret = drmm_encoder_init(drm, &dpi->encoder.base,
+ NULL,
+ DRM_MODE_ENCODER_DPI,
+ NULL);
+ if (ret)
+ return ret;
+
drm_encoder_helper_add(&dpi->encoder.base, &vc4_dpi_encoder_helper_funcs);
ret = vc4_dpi_init_bridge(dpi);
if (ret)
- goto err_destroy_encoder;
+ return ret;
dev_set_drvdata(dev, dpi);
vc4_debugfs_add_regset32(drm, "dpi_regs", &dpi->regset);
return 0;
-
-err_destroy_encoder:
- drm_encoder_cleanup(&dpi->encoder.base);
- return ret;
-}
-
-static void vc4_dpi_unbind(struct device *dev, struct device *master,
- void *data)
-{
- struct vc4_dpi *dpi = dev_get_drvdata(dev);
-
- drm_encoder_cleanup(&dpi->encoder.base);
}
static const struct component_ops vc4_dpi_ops = {
.bind = vc4_dpi_bind,
- .unbind = vc4_dpi_unbind,
};
static int vc4_dpi_dev_probe(struct platform_device *pdev)