mirror of
https://github.com/torvalds/linux.git
synced 2026-09-29 12:24:02 +02:00
drm/rockchip: dw_hdmi: Use drmres helpers for encoder resources
Change to use drmres helpers drmm_kzalloc() to allocate driver data and drmm_encoder_init() to initialize the encoder. With use of drmres the manual encoder cleanup in failure path and unbind is also removed. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Tested-by: Heiko Stuebner <heiko@sntech.de> #rk3328 Signed-off-by: Heiko Stuebner <heiko@sntech.de> Link: https://patch.msgid.link/20260518193748.2482823-4-jonas@kwiboo.se
This commit is contained in:
parent
9cefcd0e83
commit
3de723684b
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <drm/bridge/dw_hdmi.h>
|
||||
#include <drm/drm_edid.h>
|
||||
#include <drm/drm_managed.h>
|
||||
#include <drm/drm_of.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
#include <drm/drm_simple_kms_helper.h>
|
||||
|
|
@ -552,13 +553,14 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
|
|||
if (!drv_data)
|
||||
return -ENODEV;
|
||||
|
||||
hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
|
||||
hdmi = drmm_kzalloc(drm, sizeof(*hdmi), GFP_KERNEL);
|
||||
if (!hdmi)
|
||||
return -ENOMEM;
|
||||
|
||||
plat_data = devm_kmemdup(dev, drv_data, sizeof(*drv_data), GFP_KERNEL);
|
||||
plat_data = drmm_kzalloc(drm, sizeof(*drv_data), GFP_KERNEL);
|
||||
if (!plat_data)
|
||||
return -ENOMEM;
|
||||
memcpy(plat_data, drv_data, sizeof(*drv_data));
|
||||
|
||||
hdmi->dev = dev;
|
||||
hdmi->plat_data = plat_data;
|
||||
|
|
@ -610,28 +612,20 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
|
|||
FIELD_PREP_WM16(RK3568_HDMI_SCLIN_MSK, 1));
|
||||
}
|
||||
|
||||
ret = drmm_encoder_init(drm, encoder, NULL, DRM_MODE_ENCODER_TMDS, NULL);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to init encoder\n");
|
||||
|
||||
drm_encoder_helper_add(encoder, &dw_hdmi_rockchip_encoder_helper_funcs);
|
||||
drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_TMDS);
|
||||
|
||||
platform_set_drvdata(pdev, hdmi);
|
||||
|
||||
hdmi->hdmi = dw_hdmi_bind(pdev, encoder, plat_data);
|
||||
|
||||
/*
|
||||
* If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(),
|
||||
* which would have called the encoder cleanup. Do it manually.
|
||||
*/
|
||||
if (IS_ERR(hdmi->hdmi)) {
|
||||
ret = PTR_ERR(hdmi->hdmi);
|
||||
goto err_bind;
|
||||
}
|
||||
if (IS_ERR(hdmi->hdmi))
|
||||
return dev_err_probe(dev, PTR_ERR(hdmi->hdmi),
|
||||
"failed to probe dw-hdmi bridge\n");
|
||||
|
||||
return 0;
|
||||
|
||||
err_bind:
|
||||
drm_encoder_cleanup(encoder);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
|
||||
|
|
@ -640,7 +634,6 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
|
|||
struct rockchip_hdmi *hdmi = dev_get_drvdata(dev);
|
||||
|
||||
dw_hdmi_unbind(hdmi->hdmi);
|
||||
drm_encoder_cleanup(&hdmi->encoder.encoder);
|
||||
}
|
||||
|
||||
static const struct component_ops dw_hdmi_rockchip_ops = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user