Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 36e354ecf71e..c5376de8cb8a 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1094,12 +1094,9 @@ static int cio2_v4l2_try_fmt(struct file *file, void *fh, struct v4l2_format *f) mpix->pixelformat = fmt->fourcc; mpix->colorspace = V4L2_COLORSPACE_RAW; mpix->field = V4L2_FIELD_NONE; - memset(mpix->reserved, 0, sizeof(mpix->reserved)); mpix->plane_fmt[0].bytesperline = cio2_bytesperline(mpix->width); mpix->plane_fmt[0].sizeimage = mpix->plane_fmt[0].bytesperline * mpix->height; - memset(mpix->plane_fmt[0].reserved, 0, - sizeof(mpix->plane_fmt[0].reserved)); /* use default */ mpix->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/staging/media/ipu3/ipu3-v4l2.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 4dc8d9165f63..60aa02eb7d2a 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -773,9 +773,6 @@ static int imgu_try_fmt(struct file *file, void *fh, struct v4l2_format *f) pixm->pixelformat = fmt->fourcc; - memset(pixm->plane_fmt[0].reserved, 0, - sizeof(pixm->plane_fmt[0].reserved)); - return 0; } -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index 724c7333b6e5..ace4528cdc5e 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -199,7 +199,6 @@ static const struct mtk_mdp_fmt *mtk_mdp_try_fmt_mplane(struct mtk_mdp_ctx *ctx, pix_mp->ycbcr_enc = ctx->ycbcr_enc; pix_mp->quantization = ctx->quant; } - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); max_w = variant->pix_max->target_rot_dis_w; max_h = variant->pix_max->target_rot_dis_h; @@ -247,8 +246,6 @@ static const struct mtk_mdp_fmt *mtk_mdp_try_fmt_mplane(struct mtk_mdp_ctx *ctx, pix_mp->plane_fmt[i].bytesperline = bpl; if (pix_mp->plane_fmt[i].sizeimage < sizeimage) pix_mp->plane_fmt[i].sizeimage = sizeimage; - memset(pix_mp->plane_fmt[i].reserved, 0, - sizeof(pix_mp->plane_fmt[i].reserved)); mtk_mdp_dbg(2, "[%d] p%d, bpl:%d, sizeimage:%u (%u)", ctx->id, i, bpl, pix_mp->plane_fmt[i].sizeimage, sizeimage); } -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 5 ----- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 8 -------- 2 files changed, 13 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index c768a587a944..d746c41ea805 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -715,12 +715,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, } } - for (i = 0; i < pix_fmt_mp->num_planes; i++) - memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, - sizeof(pix_fmt_mp->plane_fmt[0].reserved)); - pix_fmt_mp->flags = 0; - memset(&pix_fmt_mp->reserved, 0x0, sizeof(pix_fmt_mp->reserved)); return 0; } diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 21de1431cfcb..db1f62cc38b3 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -320,13 +320,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, } } - for (i = 0; i < pix_fmt_mp->num_planes; i++) - memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, - sizeof(pix_fmt_mp->plane_fmt[0].reserved)); - pix_fmt_mp->flags = 0; - memset(&pix_fmt_mp->reserved, 0x0, - sizeof(pix_fmt_mp->reserved)); return 0; } @@ -532,8 +526,6 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv, for (i = 0; i < pix->num_planes; i++) { pix->plane_fmt[i].bytesperline = q_data->bytesperline[i]; pix->plane_fmt[i].sizeimage = q_data->sizeimage[i]; - memset(&(pix->plane_fmt[i].reserved[0]), 0x0, - sizeof(pix->plane_fmt[i].reserved)); } pix->flags = 0; -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: linux-renesas-soc@vger.kernel.org Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/rcar_fdp1.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c index c9448de885b6..01c1fbb97bf6 100644 --- a/drivers/media/platform/rcar_fdp1.c +++ b/drivers/media/platform/rcar_fdp1.c @@ -1439,8 +1439,6 @@ static void fdp1_compute_stride(struct v4l2_pix_format_mplane *pix, pix->plane_fmt[i].sizeimage = pix->plane_fmt[i].bytesperline * pix->height / vsub; - memset(pix->plane_fmt[i].reserved, 0, - sizeof(pix->plane_fmt[i].reserved)); } if (fmt->num_planes == 3) { @@ -1448,8 +1446,6 @@ static void fdp1_compute_stride(struct v4l2_pix_format_mplane *pix, pix->plane_fmt[2].bytesperline = pix->plane_fmt[1].bytesperline; pix->plane_fmt[2].sizeimage = pix->plane_fmt[1].sizeimage; - memset(pix->plane_fmt[2].reserved, 0, - sizeof(pix->plane_fmt[2].reserved)); } } -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/rcar_jpu.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c index 9b99ff368698..2bddc957cb87 100644 --- a/drivers/media/platform/rcar_jpu.c +++ b/drivers/media/platform/rcar_jpu.c @@ -793,7 +793,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, pix->colorspace = fmt->colorspace; pix->field = V4L2_FIELD_NONE; pix->num_planes = fmt->num_planes; - memset(pix->reserved, 0, sizeof(pix->reserved)); jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX, fmt->h_align, &pix->height, JPU_HEIGHT_MIN, @@ -808,8 +807,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE + (JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h); pix->plane_fmt[0].bytesperline = 0; - memset(pix->plane_fmt[0].reserved, 0, - sizeof(pix->plane_fmt[0].reserved)); } else { unsigned int i, bpl = 0; @@ -822,8 +819,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, for (i = 0; i < pix->num_planes; ++i) { pix->plane_fmt[i].bytesperline = bpl; pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8; - memset(pix->plane_fmt[i].reserved, 0, - sizeof(pix->plane_fmt[i].reserved)); } } -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Maxime Ripard <mripard@kernel.org> Cc: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c index 1a2f65d83a6c..4785faddf630 100644 --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c @@ -113,8 +113,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi, pix->num_planes = _fmt->num_planes; pix->pixelformat = _fmt->fourcc; - memset(pix->reserved, 0, sizeof(pix->reserved)); - /* Align the width and height on the subsampling */ width = ALIGN(pix->width, _fmt->hsub); height = ALIGN(pix->height, _fmt->vsub); @@ -131,8 +129,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi, bpl = pix->width / hsub * _fmt->bpp[i] / 8; pix->plane_fmt[i].bytesperline = bpl; pix->plane_fmt[i].sizeimage = bpl * pix->height / vsub; - memset(pix->plane_fmt[i].reserved, 0, - sizeof(pix->plane_fmt[i].reserved)); } } -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Benoit Parrot <bparrot@ti.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/platform/ti-vpe/vpe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c index 779dd74b82d0..10251b787674 100644 --- a/drivers/media/platform/ti-vpe/vpe.c +++ b/drivers/media/platform/ti-vpe/vpe.c @@ -1683,7 +1683,6 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, } } - memset(pix->reserved, 0, sizeof(pix->reserved)); for (i = 0; i < pix->num_planes; i++) { plane_fmt = &pix->plane_fmt[i]; depth = fmt->vpdma_fmt[i]->depth; @@ -1713,7 +1712,6 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, plane_fmt->bytesperline * depth) >> 3; } - memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); } return 0; -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/test-drivers/vicodec/vicodec-core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c index 025f3ff77302..33f1c893c1b6 100644 --- a/drivers/media/test-drivers/vicodec/vicodec-core.c +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c @@ -811,9 +811,6 @@ static int vidioc_g_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) pix_mp->xfer_func = ctx->state.xfer_func; pix_mp->ycbcr_enc = ctx->state.ycbcr_enc; pix_mp->quantization = ctx->state.quantization; - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); - memset(pix_mp->plane_fmt[0].reserved, 0, - sizeof(pix_mp->plane_fmt[0].reserved)); break; default: return -EINVAL; @@ -886,8 +883,6 @@ static int vidioc_try_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) info->sizeimage_mult / info->sizeimage_div; if (pix_mp->pixelformat == V4L2_PIX_FMT_FWHT) plane->sizeimage += sizeof(struct fwht_cframe_hdr); - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); - memset(plane->reserved, 0, sizeof(plane->reserved)); break; default: return -EINVAL; -- 2.30.0.284.gd98b1dd5eaa7-goog
Core code already clears reserved fields of struct v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields"). Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/staging/media/ipu3/ipu3-v4l2.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 4dc8d9165f63..60aa02eb7d2a 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -773,9 +773,6 @@ static int imgu_try_fmt(struct file *file, void *fh, struct v4l2_format *f) pixm->pixelformat = fmt->fourcc; - memset(pixm->plane_fmt[0].reserved, 0, - sizeof(pixm->plane_fmt[0].reserved)); - return 0; } -- 2.30.0.284.gd98b1dd5eaa7-goog
Hi Ricardo,
Thanks a lot for doing this media-wide cleanup.
Aside from a silly typo here in the commit title, s/sum4i-csi/sun4i-csi,
all the patches seem fine.
Thanks,
Ezequiel
On Mon, 11 Jan 2021 at 11:56, Ricardo Ribalda <ribalda@chromium.org> wrote:
>
> Core code already clears reserved fields of struct
> v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero
> v4l2_plane_pix_format reserved fields").
>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> index 1a2f65d83a6c..4785faddf630 100644
> --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> @@ -113,8 +113,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi,
> pix->num_planes = _fmt->num_planes;
> pix->pixelformat = _fmt->fourcc;
>
> - memset(pix->reserved, 0, sizeof(pix->reserved));
> -
> /* Align the width and height on the subsampling */
> width = ALIGN(pix->width, _fmt->hsub);
> height = ALIGN(pix->height, _fmt->vsub);
> @@ -131,8 +129,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi,
> bpl = pix->width / hsub * _fmt->bpp[i] / 8;
> pix->plane_fmt[i].bytesperline = bpl;
> pix->plane_fmt[i].sizeimage = bpl * pix->height / vsub;
> - memset(pix->plane_fmt[i].reserved, 0,
> - sizeof(pix->plane_fmt[i].reserved));
> }
> }
>
> --
> 2.30.0.284.gd98b1dd5eaa7-goog
>
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: linux-renesas-soc@vger.kernel.org > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> I love a good cleanup series. Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/platform/rcar_fdp1.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c > index c9448de885b6..01c1fbb97bf6 100644 > --- a/drivers/media/platform/rcar_fdp1.c > +++ b/drivers/media/platform/rcar_fdp1.c > @@ -1439,8 +1439,6 @@ static void fdp1_compute_stride(struct v4l2_pix_format_mplane *pix, > pix->plane_fmt[i].sizeimage = pix->plane_fmt[i].bytesperline > * pix->height / vsub; > > - memset(pix->plane_fmt[i].reserved, 0, > - sizeof(pix->plane_fmt[i].reserved)); > } > > if (fmt->num_planes == 3) { > @@ -1448,8 +1446,6 @@ static void fdp1_compute_stride(struct v4l2_pix_format_mplane *pix, > pix->plane_fmt[2].bytesperline = pix->plane_fmt[1].bytesperline; > pix->plane_fmt[2].sizeimage = pix->plane_fmt[1].sizeimage; > > - memset(pix->plane_fmt[2].reserved, 0, > - sizeof(pix->plane_fmt[2].reserved)); > } > } > >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/platform/rcar_jpu.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c > index 9b99ff368698..2bddc957cb87 100644 > --- a/drivers/media/platform/rcar_jpu.c > +++ b/drivers/media/platform/rcar_jpu.c There's a memset(cap->reserved...) in jpu_querycap() Is that also applicable and covered by the core? Looking at v4l_querycap() it doesn't seem to be so: Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > @@ -793,7 +793,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, > pix->colorspace = fmt->colorspace; > pix->field = V4L2_FIELD_NONE; > pix->num_planes = fmt->num_planes; > - memset(pix->reserved, 0, sizeof(pix->reserved)); > > jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX, > fmt->h_align, &pix->height, JPU_HEIGHT_MIN, > @@ -808,8 +807,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, > pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE + > (JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h); > pix->plane_fmt[0].bytesperline = 0; > - memset(pix->plane_fmt[0].reserved, 0, > - sizeof(pix->plane_fmt[0].reserved)); > } else { > unsigned int i, bpl = 0; > > @@ -822,8 +819,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, > for (i = 0; i < pix->num_planes; ++i) { > pix->plane_fmt[i].bytesperline = bpl; > pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8; > - memset(pix->plane_fmt[i].reserved, 0, > - sizeof(pix->plane_fmt[i].reserved)); > } > } > >
Hi Ricardo, Well I've started, so I may as well finish and do the rest too. On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). Indeed, these are the only memsets here ... With the $TITLE fixed as spotted by Ezequiel, Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > > Cc: Maxime Ripard <mripard@kernel.org> > Cc: Chen-Yu Tsai <wens@csie.org> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 4 ---- > 1 file changed, 4 deletions(-) > > diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c > index 1a2f65d83a6c..4785faddf630 100644 > --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c > +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c > @@ -113,8 +113,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi, > pix->num_planes = _fmt->num_planes; > pix->pixelformat = _fmt->fourcc; > > - memset(pix->reserved, 0, sizeof(pix->reserved)); > - > /* Align the width and height on the subsampling */ > width = ALIGN(pix->width, _fmt->hsub); > height = ALIGN(pix->height, _fmt->vsub); > @@ -131,8 +129,6 @@ static void _sun4i_csi_try_fmt(struct sun4i_csi *csi, > bpl = pix->width / hsub * _fmt->bpp[i] / 8; > pix->plane_fmt[i].bytesperline = bpl; > pix->plane_fmt[i].sizeimage = bpl * pix->height / vsub; > - memset(pix->plane_fmt[i].reserved, 0, > - sizeof(pix->plane_fmt[i].reserved)); > } > } > >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > Cc: Benoit Parrot <bparrot@ti.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/platform/ti-vpe/vpe.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c > index 779dd74b82d0..10251b787674 100644 > --- a/drivers/media/platform/ti-vpe/vpe.c > +++ b/drivers/media/platform/ti-vpe/vpe.c > @@ -1683,7 +1683,6 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, > } > } > > - memset(pix->reserved, 0, sizeof(pix->reserved)); > for (i = 0; i < pix->num_planes; i++) { > plane_fmt = &pix->plane_fmt[i]; > depth = fmt->vpdma_fmt[i]->depth; > @@ -1713,7 +1712,6 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, > plane_fmt->bytesperline * > depth) >> 3; > } > - memset(plane_fmt->reserved, 0, sizeof(plane_fmt->reserved)); > } > > return 0; >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/test-drivers/vicodec/vicodec-core.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c > index 025f3ff77302..33f1c893c1b6 100644 > --- a/drivers/media/test-drivers/vicodec/vicodec-core.c > +++ b/drivers/media/test-drivers/vicodec/vicodec-core.c > @@ -811,9 +811,6 @@ static int vidioc_g_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) > pix_mp->xfer_func = ctx->state.xfer_func; > pix_mp->ycbcr_enc = ctx->state.ycbcr_enc; > pix_mp->quantization = ctx->state.quantization; > - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); > - memset(pix_mp->plane_fmt[0].reserved, 0, > - sizeof(pix_mp->plane_fmt[0].reserved)); > break; > default: > return -EINVAL; > @@ -886,8 +883,6 @@ static int vidioc_try_fmt(struct vicodec_ctx *ctx, struct v4l2_format *f) > info->sizeimage_mult / info->sizeimage_div; > if (pix_mp->pixelformat == V4L2_PIX_FMT_FWHT) > plane->sizeimage += sizeof(struct fwht_cframe_hdr); > - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); > - memset(plane->reserved, 0, sizeof(plane->reserved)); > break; > default: > return -EINVAL; >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Sakari Ailus <sakari.ailus@linux.intel.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/staging/media/ipu3/ipu3-v4l2.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c > index 4dc8d9165f63..60aa02eb7d2a 100644 > --- a/drivers/staging/media/ipu3/ipu3-v4l2.c > +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c The ipu3-css.c also has a memset on the plane formats in the migu_css_queue_init(), but that's possibly still out of scope for this patch ('just') struct v4l2_pix_format_mplane *const f = &queue->fmt.mpix; memset(f->reserved, 0, sizeof(f->reserved)); I can't yet see anything that clears the reserved formats on queue initialisations, so I don't think we can remove that yet unless I've missed something anyway. Seems like there is a lot more that could be cleared in core ... But - as I said, I think that's out of scope here so Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > @@ -773,9 +773,6 @@ static int imgu_try_fmt(struct file *file, void *fh, struct v4l2_format *f) > > pixm->pixelformat = fmt->fourcc; > > - memset(pixm->plane_fmt[0].reserved, 0, > - sizeof(pixm->plane_fmt[0].reserved)); > - > return 0; > } > >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Sakari Ailus <sakari.ailus@linux.intel.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/pci/intel/ipu3/ipu3-cio2.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > index 36e354ecf71e..c5376de8cb8a 100644 > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > @@ -1094,12 +1094,9 @@ static int cio2_v4l2_try_fmt(struct file *file, void *fh, struct v4l2_format *f) > mpix->pixelformat = fmt->fourcc; > mpix->colorspace = V4L2_COLORSPACE_RAW; > mpix->field = V4L2_FIELD_NONE; > - memset(mpix->reserved, 0, sizeof(mpix->reserved)); > mpix->plane_fmt[0].bytesperline = cio2_bytesperline(mpix->width); > mpix->plane_fmt[0].sizeimage = mpix->plane_fmt[0].bytesperline * > mpix->height; > - memset(mpix->plane_fmt[0].reserved, 0, > - sizeof(mpix->plane_fmt[0].reserved)); > > /* use default */ > mpix->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Sakari Ailus <sakari.ailus@linux.intel.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> This is just 9/9 of the series right ? ;-) -- Kieran > --- > drivers/staging/media/ipu3/ipu3-v4l2.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c > index 4dc8d9165f63..60aa02eb7d2a 100644 > --- a/drivers/staging/media/ipu3/ipu3-v4l2.c > +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c > @@ -773,9 +773,6 @@ static int imgu_try_fmt(struct file *file, void *fh, struct v4l2_format *f) > > pixm->pixelformat = fmt->fourcc; > > - memset(pixm->plane_fmt[0].reserved, 0, > - sizeof(pixm->plane_fmt[0].reserved)); > - > return 0; > } > >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Matthias Brugger <matthias.bgg@gmail.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c > index 724c7333b6e5..ace4528cdc5e 100644 > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c > @@ -199,7 +199,6 @@ static const struct mtk_mdp_fmt *mtk_mdp_try_fmt_mplane(struct mtk_mdp_ctx *ctx, > pix_mp->ycbcr_enc = ctx->ycbcr_enc; > pix_mp->quantization = ctx->quant; > } > - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); > > max_w = variant->pix_max->target_rot_dis_w; > max_h = variant->pix_max->target_rot_dis_h; > @@ -247,8 +246,6 @@ static const struct mtk_mdp_fmt *mtk_mdp_try_fmt_mplane(struct mtk_mdp_ctx *ctx, > pix_mp->plane_fmt[i].bytesperline = bpl; > if (pix_mp->plane_fmt[i].sizeimage < sizeimage) > pix_mp->plane_fmt[i].sizeimage = sizeimage; > - memset(pix_mp->plane_fmt[i].reserved, 0, > - sizeof(pix_mp->plane_fmt[i].reserved)); > mtk_mdp_dbg(2, "[%d] p%d, bpl:%d, sizeimage:%u (%u)", ctx->id, > i, bpl, pix_mp->plane_fmt[i].sizeimage, sizeimage); > } >
Hi Ricardo, On 11/01/2021 14:54, Ricardo Ribalda wrote: > Core code already clears reserved fields of struct > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > v4l2_plane_pix_format reserved fields"). > > Cc: Matthias Brugger <matthias.bgg@gmail.com> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> There's also another memset.*reserved occurring in platform/mtk-vcodec/mtk_vcodec_enc.c: vidioc_enum_fmt() While v4l2-core/v4l2-ioctl.c has: > static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, > struct file *file, void *fh, void *arg) > { > struct video_device *vdev = video_devdata(file); > struct v4l2_fmtdesc *p = arg; > int ret = check_fmt(file, p->type); > u32 mbus_code; > u32 cap_mask; > > if (ret) > return ret; > ret = -EINVAL; > > if (!(vdev->device_caps & V4L2_CAP_IO_MC)) > p->mbus_code = 0; > > mbus_code = p->mbus_code; > CLEAR_AFTER_FIELD(p, type); So would that mean ^^^ should also be sufficient to remove the need for that memset? With that fixed or resolved: Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 5 ----- > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 8 -------- > 2 files changed, 13 deletions(-) > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c > index c768a587a944..d746c41ea805 100644 > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c > @@ -715,12 +715,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, > } > } > > - for (i = 0; i < pix_fmt_mp->num_planes; i++) > - memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > - sizeof(pix_fmt_mp->plane_fmt[0].reserved)); > - > pix_fmt_mp->flags = 0; > - memset(&pix_fmt_mp->reserved, 0x0, sizeof(pix_fmt_mp->reserved)); > return 0; > } > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > index 21de1431cfcb..db1f62cc38b3 100644 > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c > @@ -320,13 +320,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, > } > } > > - for (i = 0; i < pix_fmt_mp->num_planes; i++) > - memset(&(pix_fmt_mp->plane_fmt[i].reserved[0]), 0x0, > - sizeof(pix_fmt_mp->plane_fmt[0].reserved)); > - > pix_fmt_mp->flags = 0; > - memset(&pix_fmt_mp->reserved, 0x0, > - sizeof(pix_fmt_mp->reserved)); > > return 0; > } > @@ -532,8 +526,6 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv, > for (i = 0; i < pix->num_planes; i++) { > pix->plane_fmt[i].bytesperline = q_data->bytesperline[i]; > pix->plane_fmt[i].sizeimage = q_data->sizeimage[i]; > - memset(&(pix->plane_fmt[i].reserved[0]), 0x0, > - sizeof(pix->plane_fmt[i].reserved)); > } > > pix->flags = 0; >
Hi Kieran On Tue, Jan 12, 2021 at 12:59 PM Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> wrote: > > Hi Ricardo, > > On 11/01/2021 14:54, Ricardo Ribalda wrote: > > Core code already clears reserved fields of struct > > v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero > > v4l2_plane_pix_format reserved fields"). > > > > Cc: Sakari Ailus <sakari.ailus@linux.intel.com> > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > This is just 9/9 of the series right ? ;-) I was just testing that you were doing a good review :P My bad, I sent the mails with git email-send 00* and I forgot to clean before :(. I already marked the patch as obsolete in patchwork. Sorry for wasting your time Best regards! > -- > Kieran > > > --- > > drivers/staging/media/ipu3/ipu3-v4l2.c | 3 --- > > 1 file changed, 3 deletions(-) > > > > diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c > > index 4dc8d9165f63..60aa02eb7d2a 100644 > > --- a/drivers/staging/media/ipu3/ipu3-v4l2.c > > +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c > > @@ -773,9 +773,6 @@ static int imgu_try_fmt(struct file *file, void *fh, struct v4l2_format *f) > > > > pixm->pixelformat = fmt->fourcc; > > > > - memset(pixm->plane_fmt[0].reserved, 0, > > - sizeof(pixm->plane_fmt[0].reserved)); > > - > > return 0; > > } > > > > > -- Ricardo Ribalda
On 12/01/2021 12:07, Kieran Bingham wrote: > Hi Ricardo, > > On 11/01/2021 14:54, Ricardo Ribalda wrote: >> Core code already clears reserved fields of struct >> v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero >> v4l2_plane_pix_format reserved fields"). >> >> Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com> >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> >> --- >> drivers/media/platform/rcar_jpu.c | 5 ----- >> 1 file changed, 5 deletions(-) >> >> diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c >> index 9b99ff368698..2bddc957cb87 100644 >> --- a/drivers/media/platform/rcar_jpu.c >> +++ b/drivers/media/platform/rcar_jpu.c > > There's a memset(cap->reserved...) in jpu_querycap() > > Is that also applicable and covered by the core? Yes: VIDIOC_QUERYCAP is a read-only ioctl: the core will always zero the struct in that case before handing it over to the driver. This is something for a separate patch, though. There may well be more drivers that do this for querycap. Regards, Hans > > Looking at v4l_querycap() it doesn't seem to be so: > > > Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > >> @@ -793,7 +793,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, >> pix->colorspace = fmt->colorspace; >> pix->field = V4L2_FIELD_NONE; >> pix->num_planes = fmt->num_planes; >> - memset(pix->reserved, 0, sizeof(pix->reserved)); >> >> jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX, >> fmt->h_align, &pix->height, JPU_HEIGHT_MIN, >> @@ -808,8 +807,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, >> pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE + >> (JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h); >> pix->plane_fmt[0].bytesperline = 0; >> - memset(pix->plane_fmt[0].reserved, 0, >> - sizeof(pix->plane_fmt[0].reserved)); >> } else { >> unsigned int i, bpl = 0; >> >> @@ -822,8 +819,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo, >> for (i = 0; i < pix->num_planes; ++i) { >> pix->plane_fmt[i].bytesperline = bpl; >> pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8; >> - memset(pix->plane_fmt[i].reserved, 0, >> - sizeof(pix->plane_fmt[i].reserved)); >> } >> } >> >> >