Commit b8081154 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab
Browse files

media: mtk-vcodec: don't check return val of mtk_venc_get_q_data



The function mtk_venc_get_q_data always returns a reference
so there is no need to check if the return value is null.
In addition move the q_data initialization to the declaration

Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent ba0b00e7
Loading
Loading
Loading
Loading
+7 −32
Original line number Diff line number Diff line
@@ -400,7 +400,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
	const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
	struct vb2_queue *vq;
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
	int i, ret;
	const struct mtk_video_fmt *fmt;

@@ -415,12 +415,6 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
		return -EBUSY;
	}

	q_data = mtk_venc_get_q_data(ctx, f->type);
	if (!q_data) {
		mtk_v4l2_err("fail to get q data");
		return -EINVAL;
	}

	fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
	if (!fmt) {
		fmt = &ctx->dev->venc_pdata->capture_formats[0];
@@ -461,7 +455,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
	const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
	struct vb2_queue *vq;
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
	int ret, i;
	const struct mtk_video_fmt *fmt;

@@ -476,12 +470,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
		return -EBUSY;
	}

	q_data = mtk_venc_get_q_data(ctx, f->type);
	if (!q_data) {
		mtk_v4l2_err("fail to get q data");
		return -EINVAL;
	}

	fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
	if (!fmt) {
		fmt = &ctx->dev->venc_pdata->output_formats[0];
@@ -521,14 +509,13 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv,
	struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
	struct vb2_queue *vq;
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
	int i;

	vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
	if (!vq)
		return -EINVAL;

	q_data = mtk_venc_get_q_data(ctx, f->type);

	pix->width = q_data->coded_width;
	pix->height = q_data->coded_height;
@@ -597,15 +584,11 @@ static int vidioc_venc_g_selection(struct file *file, void *priv,
				     struct v4l2_selection *s)
{
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);

	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
		return -EINVAL;

	q_data = mtk_venc_get_q_data(ctx, s->type);
	if (!q_data)
		return -EINVAL;

	switch (s->target) {
	case V4L2_SEL_TGT_CROP_DEFAULT:
	case V4L2_SEL_TGT_CROP_BOUNDS:
@@ -631,15 +614,11 @@ static int vidioc_venc_s_selection(struct file *file, void *priv,
				     struct v4l2_selection *s)
{
	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);

	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
		return -EINVAL;

	q_data = mtk_venc_get_q_data(ctx, s->type);
	if (!q_data)
		return -EINVAL;

	switch (s->target) {
	case V4L2_SEL_TGT_CROP:
		/* Only support crop from (0,0) */
@@ -806,11 +785,9 @@ static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
				   struct device *alloc_devs[])
{
	struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vq);
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, vq->type);
	unsigned int i;

	q_data = mtk_venc_get_q_data(ctx, vq->type);

	if (q_data == NULL)
		return -EINVAL;

@@ -830,11 +807,9 @@ static int vb2ops_venc_queue_setup(struct vb2_queue *vq,
static int vb2ops_venc_buf_prepare(struct vb2_buffer *vb)
{
	struct mtk_vcodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
	struct mtk_q_data *q_data;
	struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, vb->vb2_queue->type);
	int i;

	q_data = mtk_venc_get_q_data(ctx, vb->vb2_queue->type);

	for (i = 0; i < q_data->fmt->num_planes; i++) {
		if (vb2_plane_size(vb, i) < q_data->sizeimage[i]) {
			mtk_v4l2_err("data will not fit into plane %d (%lu < %d)",