Commit 3f5e1e2f authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

media: hantro: streamline open, reuse error path

This adds a label to the error path to avoid calling
v4l2_m2m_ctx_init() and kfree(ctx) in two places each.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 4a0cad6d
...@@ -413,20 +413,18 @@ static int hantro_open(struct file *filp) ...@@ -413,20 +413,18 @@ static int hantro_open(struct file *filp)
if (func->id == MEDIA_ENT_F_PROC_VIDEO_ENCODER) { if (func->id == MEDIA_ENT_F_PROC_VIDEO_ENCODER) {
allowed_codecs = vpu->variant->codec & HANTRO_ENCODERS; allowed_codecs = vpu->variant->codec & HANTRO_ENCODERS;
ctx->buf_finish = hantro_enc_buf_finish; ctx->buf_finish = hantro_enc_buf_finish;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(vpu->m2m_dev, ctx,
queue_init);
} else if (func->id == MEDIA_ENT_F_PROC_VIDEO_DECODER) { } else if (func->id == MEDIA_ENT_F_PROC_VIDEO_DECODER) {
allowed_codecs = vpu->variant->codec & HANTRO_DECODERS; allowed_codecs = vpu->variant->codec & HANTRO_DECODERS;
ctx->buf_finish = hantro_dec_buf_finish; ctx->buf_finish = hantro_dec_buf_finish;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(vpu->m2m_dev, ctx,
queue_init);
} else { } else {
ctx->fh.m2m_ctx = ERR_PTR(-ENODEV); ret = -ENODEV;
goto err_ctx_free;
} }
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(vpu->m2m_dev, ctx, queue_init);
if (IS_ERR(ctx->fh.m2m_ctx)) { if (IS_ERR(ctx->fh.m2m_ctx)) {
ret = PTR_ERR(ctx->fh.m2m_ctx); ret = PTR_ERR(ctx->fh.m2m_ctx);
kfree(ctx); goto err_ctx_free;
return ret;
} }
v4l2_fh_init(&ctx->fh, vdev); v4l2_fh_init(&ctx->fh, vdev);
...@@ -447,6 +445,7 @@ static int hantro_open(struct file *filp) ...@@ -447,6 +445,7 @@ static int hantro_open(struct file *filp)
err_fh_free: err_fh_free:
v4l2_fh_del(&ctx->fh); v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh); v4l2_fh_exit(&ctx->fh);
err_ctx_free:
kfree(ctx); kfree(ctx);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment