mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
drm: rcar-du: Use drmm_encoder_alloc() to manage encoder
The encoder allocation was converted to a DRM managed resource at the
same time as the addition of a new helper drmm_encoder_alloc() which
simplifies the same process.
Convert the custom drm managed resource allocation of the encoder
with the helper to simplify the implementation, and prevent hitting a
WARN_ON() due to the handling the drm_encoder_init() call directly
without registering a .destroy() function op.
Fixes: f5f16725ed ("drm: rcar-du: Use DRM-managed allocation for encoders")
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
This commit is contained in:
committed by
Laurent Pinchart
parent
4042160c2e
commit
7a1adbd239
@@ -48,21 +48,12 @@ static unsigned int rcar_du_encoder_count_ports(struct device_node *node)
|
|||||||
static const struct drm_encoder_funcs rcar_du_encoder_funcs = {
|
static const struct drm_encoder_funcs rcar_du_encoder_funcs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void rcar_du_encoder_release(struct drm_device *dev, void *res)
|
|
||||||
{
|
|
||||||
struct rcar_du_encoder *renc = res;
|
|
||||||
|
|
||||||
drm_encoder_cleanup(&renc->base);
|
|
||||||
kfree(renc);
|
|
||||||
}
|
|
||||||
|
|
||||||
int rcar_du_encoder_init(struct rcar_du_device *rcdu,
|
int rcar_du_encoder_init(struct rcar_du_device *rcdu,
|
||||||
enum rcar_du_output output,
|
enum rcar_du_output output,
|
||||||
struct device_node *enc_node)
|
struct device_node *enc_node)
|
||||||
{
|
{
|
||||||
struct rcar_du_encoder *renc;
|
struct rcar_du_encoder *renc;
|
||||||
struct drm_bridge *bridge;
|
struct drm_bridge *bridge;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate the DRM bridge from the DT node. For the DPAD outputs, if the
|
* Locate the DRM bridge from the DT node. For the DPAD outputs, if the
|
||||||
@@ -101,26 +92,16 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
|
|||||||
return -ENOLINK;
|
return -ENOLINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
renc = kzalloc(sizeof(*renc), GFP_KERNEL);
|
|
||||||
if (renc == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
renc->output = output;
|
|
||||||
|
|
||||||
dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n",
|
dev_dbg(rcdu->dev, "initializing encoder %pOF for output %u\n",
|
||||||
enc_node, output);
|
enc_node, output);
|
||||||
|
|
||||||
ret = drm_encoder_init(&rcdu->ddev, &renc->base, &rcar_du_encoder_funcs,
|
renc = drmm_encoder_alloc(&rcdu->ddev, struct rcar_du_encoder, base,
|
||||||
DRM_MODE_ENCODER_NONE, NULL);
|
&rcar_du_encoder_funcs, DRM_MODE_ENCODER_NONE,
|
||||||
if (ret < 0) {
|
NULL);
|
||||||
kfree(renc);
|
if (!renc)
|
||||||
return ret;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
ret = drmm_add_action_or_reset(&rcdu->ddev, rcar_du_encoder_release,
|
renc->output = output;
|
||||||
renc);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach the bridge to the encoder. The bridge will create the
|
* Attach the bridge to the encoder. The bridge will create the
|
||||||
|
|||||||
Reference in New Issue
Block a user