]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/rockchip: dw_hdmi_qp: Switch to drmm_encoder_init()
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Mon, 9 Mar 2026 22:44:34 +0000 (00:44 +0200)
committerHeiko Stuebner <heiko@sntech.de>
Thu, 26 Mar 2026 19:30:44 +0000 (20:30 +0100)
Simplify encoder initialization and cleanup by making use of
drmm_encoder_init(), which takes care of registering
drm_encoder_cleanup() with drmm_add_action().

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20260310-drm-rk-fixes-v2-6-645ecfb43f49@collabora.com
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c

index 1a09bcc96c3ece255df8bdfad2bf909adbcc69ab..c78db7f8ab6c766fd11ce4dc743b66439160e5f1 100644 (file)
@@ -21,6 +21,7 @@
 #include <drm/bridge/dw_hdmi_qp.h>
 #include <drm/display/drm_hdmi_helper.h>
 #include <drm/drm_bridge_connector.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_of.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
@@ -477,7 +478,7 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
        if (!pdev->dev.of_node)
                return -ENODEV;
 
-       hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+       hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
        if (!hdmi)
                return -ENOMEM;
 
@@ -586,16 +587,16 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
                return ret;
 
        drm_encoder_helper_add(encoder, &dw_hdmi_qp_rockchip_encoder_helper_funcs);
-       drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
+       ret = drmm_encoder_init(drm, encoder, NULL, DRM_MODE_ENCODER_TMDS, NULL);
+       if (ret)
+               return dev_err_probe(hdmi->dev, ret, "Failed to init encoder");
 
        platform_set_drvdata(pdev, hdmi);
 
        hdmi->hdmi = dw_hdmi_qp_bind(pdev, encoder, &plat_data);
-       if (IS_ERR(hdmi->hdmi)) {
-               drm_encoder_cleanup(encoder);
+       if (IS_ERR(hdmi->hdmi))
                return dev_err_probe(hdmi->dev, PTR_ERR(hdmi->hdmi),
                                     "Failed to bind dw-hdmi-qp");
-       }
 
        connector = drm_bridge_connector_init(drm, encoder);
        if (IS_ERR(connector))
@@ -612,8 +613,6 @@ static void dw_hdmi_qp_rockchip_unbind(struct device *dev,
        struct rockchip_hdmi_qp *hdmi = dev_get_drvdata(dev);
 
        cancel_delayed_work_sync(&hdmi->hpd_work);
-
-       drm_encoder_cleanup(&hdmi->encoder.encoder);
 }
 
 static const struct component_ops dw_hdmi_qp_rockchip_ops = {