]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
media: Set file->private_data in v4l2_fh_add()
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 10 Aug 2025 01:30:08 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:39 +0000 (08:33 +0200)
commit47f4b1acb4d505b1e7e81d8e0ebce774422b8c2e
treec9ce39c2d32a1de1a34911b4ead3caab0278b076
parent32eab51811051c23a1b9dfd6024e0b41b7a64261
media: Set file->private_data in v4l2_fh_add()

All the drivers that use v4l2_fh and call v4l2_fh_add() manually store a
pointer to the v4l2_fh instance in file->private_data in their video
device .open() file operation handler. Move the code to the
v4l2_fh_add() function to avoid direct access to file->private_data in
drivers. This requires adding a file pointer argument to the function.

Changes to drivers have been generated with the following coccinelle
semantic patch:

@@
expression fh;
identifier filp;
identifier open;
type ret;
@@
ret open(..., struct file *filp, ...)
{
<...
- filp->private_data = fh;
...
- v4l2_fh_add(fh);
+ v4l2_fh_add(fh, filp);
...>
}

@@
expression fh;
identifier filp;
identifier open;
type ret;
@@
ret open(..., struct file *filp, ...)
{
<...
- v4l2_fh_add(fh);
+ v4l2_fh_add(fh, filp);
...
- filp->private_data = fh;
...>
}

Manual changes have been applied to Documentation/ to update the usage
patterns, to drivers/media/v4l2-core/v4l2-fh.c to update the
v4l2_fh_add() prototype set file->private_data, and to
include/media/v4l2-fh.h to update the v4l2_fh_add() function prototype
and its documentation.

Additionally, white space issues have been fixed manually in
drivers/media/platform/nvidia/tegra-vde/v4l2.c,
drivers/media/platform/rockchip/rkvdec/rkvdec.c,
drivers/media/v4l2-core/v4l2-fh.c and
drivers/staging/most/video/video.c.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
61 files changed:
Documentation/driver-api/media/v4l2-fh.rst
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
drivers/media/pci/cx18/cx18-fileops.c
drivers/media/pci/ivtv/ivtv-fileops.c
drivers/media/pci/saa7164/saa7164-encoder.c
drivers/media/pci/saa7164/saa7164-vbi.c
drivers/media/platform/allegro-dvt/allegro-core.c
drivers/media/platform/amlogic/meson-ge2d/ge2d.c
drivers/media/platform/amphion/vpu_v4l2.c
drivers/media/platform/chips-media/coda/coda-common.c
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
drivers/media/platform/imagination/e5010-jpeg-enc.c
drivers/media/platform/m2m-deinterlace.c
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
drivers/media/platform/nvidia/tegra-vde/v4l2.c
drivers/media/platform/nxp/dw100/dw100.c
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
drivers/media/platform/nxp/imx-pxp.c
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
drivers/media/platform/nxp/mx2_emmaprp.c
drivers/media/platform/qcom/iris/iris_vidc.c
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/venc.c
drivers/media/platform/renesas/rcar_fdp1.c
drivers/media/platform/renesas/rcar_jpu.c
drivers/media/platform/renesas/vsp1/vsp1_video.c
drivers/media/platform/rockchip/rga/rga.c
drivers/media/platform/rockchip/rkvdec/rkvdec.c
drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
drivers/media/platform/samsung/s5p-g2d/g2d.c
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
drivers/media/platform/st/sti/delta/delta-v4l2.c
drivers/media/platform/st/sti/hva/hva-v4l2.c
drivers/media/platform/st/stm32/dma2d/dma2d.c
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
drivers/media/platform/ti/omap3isp/ispvideo.c
drivers/media/platform/ti/vpe/vpe.c
drivers/media/platform/verisilicon/hantro_drv.c
drivers/media/test-drivers/vicodec/vicodec-core.c
drivers/media/test-drivers/vim2m.c
drivers/media/test-drivers/visl/visl-core.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/v4l2-core/v4l2-fh.c
drivers/media/v4l2-core/v4l2-subdev.c
drivers/staging/media/imx/imx-media-csc-scaler.c
drivers/staging/media/meson/vdec/vdec.c
drivers/staging/media/sunxi/cedrus/cedrus.c
drivers/staging/most/video/video.c
drivers/usb/gadget/function/uvc_v4l2.c
include/media/v4l2-fh.h