From: Alexandre Courbot <acourbot@chromium.org> To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Cc: "Linux Media Mailing List" <linux-media@vger.kernel.org>, kernel@collabora.com, "Andrew-CT Chen" <andrew-ct.chen@mediatek.com>, courbot@chromium.org, "Dafna Hirschfeld" <dafna3@gmail.com>, eizan@chromium.org, houlong.wei@mediatek.com, "Hsin-Yi Wang" <hsinyi@chromium.org>, "Hans Verkuil" <hverkuil@xs4all.nl>, "Irui Wang" <irui.wang@mediatek.com>, LKML <linux-kernel@vger.kernel.org>, "moderated list:ARM/Mediatek SoC support" <linux-mediatek@lists.infradead.org>, "Maoguang Meng (孟毛广)" <maoguang.meng@mediatek.com>, "Matthias Brugger" <matthias.bgg@gmail.com>, "Mauro Carvalho Chehab" <mchehab@kernel.org>, minghsiu.tsai@mediatek.com, "Tomasz Figa" <tfiga@chromium.org>, "Tiffany Lin" <tiffany.lin@mediatek.com> Subject: Re: [PATCH v2 6/7] media: mtk-vcodec: don't check return val of mtk_venc_get_q_data Date: Mon, 27 Dec 2021 16:06:25 +0900 [thread overview] Message-ID: <CAPBb6MXqwWDhCVrdvdUZ3U6P8-CJXo22mkQ_wrQ3_LLGacOvvg@mail.gmail.com> (raw) In-Reply-To: <20211117130635.11633-7-dafna.hirschfeld@collabora.com> On Wed, Nov 17, 2021 at 10:07 PM Dafna Hirschfeld <dafna.hirschfeld@collabora.com> wrote: > > 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: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> > --- > .../platform/mtk-vcodec/mtk_vcodec_enc.c | 39 ++++--------------- > 1 file changed, 7 insertions(+), 32 deletions(-) > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > index be28f2401839..5caaeb4773ca 100644 > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > @@ -399,7 +399,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; > > @@ -414,12 +414,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]; > @@ -460,7 +454,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; > > @@ -475,12 +469,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]; > @@ -520,14 +508,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; > @@ -596,15 +583,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: > @@ -630,15 +613,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) */ > @@ -805,11 +784,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; > > @@ -829,11 +806,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)", > -- > 2.17.1 >
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Courbot <acourbot@chromium.org> To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Cc: "Linux Media Mailing List" <linux-media@vger.kernel.org>, kernel@collabora.com, "Andrew-CT Chen" <andrew-ct.chen@mediatek.com>, courbot@chromium.org, "Dafna Hirschfeld" <dafna3@gmail.com>, eizan@chromium.org, houlong.wei@mediatek.com, "Hsin-Yi Wang" <hsinyi@chromium.org>, "Hans Verkuil" <hverkuil@xs4all.nl>, "Irui Wang" <irui.wang@mediatek.com>, LKML <linux-kernel@vger.kernel.org>, "moderated list:ARM/Mediatek SoC support" <linux-mediatek@lists.infradead.org>, "Maoguang Meng (孟毛广)" <maoguang.meng@mediatek.com>, "Matthias Brugger" <matthias.bgg@gmail.com>, "Mauro Carvalho Chehab" <mchehab@kernel.org>, minghsiu.tsai@mediatek.com, "Tomasz Figa" <tfiga@chromium.org>, "Tiffany Lin" <tiffany.lin@mediatek.com> Subject: Re: [PATCH v2 6/7] media: mtk-vcodec: don't check return val of mtk_venc_get_q_data Date: Mon, 27 Dec 2021 16:06:25 +0900 [thread overview] Message-ID: <CAPBb6MXqwWDhCVrdvdUZ3U6P8-CJXo22mkQ_wrQ3_LLGacOvvg@mail.gmail.com> (raw) In-Reply-To: <20211117130635.11633-7-dafna.hirschfeld@collabora.com> On Wed, Nov 17, 2021 at 10:07 PM Dafna Hirschfeld <dafna.hirschfeld@collabora.com> wrote: > > 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: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> > --- > .../platform/mtk-vcodec/mtk_vcodec_enc.c | 39 ++++--------------- > 1 file changed, 7 insertions(+), 32 deletions(-) > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > index be28f2401839..5caaeb4773ca 100644 > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > @@ -399,7 +399,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; > > @@ -414,12 +414,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]; > @@ -460,7 +454,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; > > @@ -475,12 +469,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]; > @@ -520,14 +508,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; > @@ -596,15 +583,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: > @@ -630,15 +613,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) */ > @@ -805,11 +784,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; > > @@ -829,11 +806,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)", > -- > 2.17.1 > _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek
next prev parent reply other threads:[~2021-12-27 7:07 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-17 13:06 [PATCH v2 0/7] media: mtk-vcodec: few fixes Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-11-17 13:06 ` [PATCH v2 1/7] media: mtk-vcodec: enc: add vp8 profile ctrl Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-11-17 13:06 ` [PATCH v2 2/7] media: mtk-vcodec: call v4l2_m2m_ctx_release first when file is released Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-12-27 7:06 ` Alexandre Courbot 2021-12-27 7:06 ` Alexandre Courbot 2021-11-17 13:06 ` [PATCH v2 3/7] media: mtk-vcodec: enc: use "stream_started" flag for "stop/start_streaming" Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-11-25 8:30 ` Hans Verkuil 2021-11-25 8:30 ` Hans Verkuil 2021-11-17 13:06 ` [PATCH v2 4/7] media: mtk-vcodec: fix debugging defines Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-11-18 16:03 ` kernel test robot 2021-11-18 16:03 ` kernel test robot 2021-11-26 8:11 ` kernel test robot 2021-11-17 13:06 ` [PATCH v2 5/7] media: mtk-vcodec: replace func vidioc_try_fmt with two funcs for out/cap Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-12-27 7:06 ` Alexandre Courbot 2021-12-27 7:06 ` Alexandre Courbot 2021-11-17 13:06 ` [PATCH v2 6/7] media: mtk-vcodec: don't check return val of mtk_venc_get_q_data Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-12-27 7:06 ` Alexandre Courbot [this message] 2021-12-27 7:06 ` Alexandre Courbot 2021-11-17 13:06 ` [PATCH v2 7/7] meida: mtk-vcodec: remove unused func parameter Dafna Hirschfeld 2021-11-17 13:06 ` Dafna Hirschfeld 2021-11-18 14:35 ` Nicolas Dufresne 2021-11-18 14:35 ` Nicolas Dufresne 2021-12-27 7:06 ` Alexandre Courbot 2021-12-27 7:06 ` Alexandre Courbot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAPBb6MXqwWDhCVrdvdUZ3U6P8-CJXo22mkQ_wrQ3_LLGacOvvg@mail.gmail.com \ --to=acourbot@chromium.org \ --cc=andrew-ct.chen@mediatek.com \ --cc=courbot@chromium.org \ --cc=dafna.hirschfeld@collabora.com \ --cc=dafna3@gmail.com \ --cc=eizan@chromium.org \ --cc=houlong.wei@mediatek.com \ --cc=hsinyi@chromium.org \ --cc=hverkuil@xs4all.nl \ --cc=irui.wang@mediatek.com \ --cc=kernel@collabora.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=maoguang.meng@mediatek.com \ --cc=matthias.bgg@gmail.com \ --cc=mchehab@kernel.org \ --cc=minghsiu.tsai@mediatek.com \ --cc=tfiga@chromium.org \ --cc=tiffany.lin@mediatek.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.