* [PATCH v3 00/76] media: Rationalise usage of v4l2_fh
@ 2025-08-10 1:29 Laurent Pinchart
2025-08-10 1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:29 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Abhinav Kumar,
Abhishek Tamboli, Akash Kumar, Alexandre Torgue, Alex Shi,
Alim Akhtar, Al Viro, Andrew-CT Chen, Andrzej Hajda,
Andrzej Pietrasiewicz, Andy Walls, AngeloGioacchino Del Regno,
Ariel Otilibili, Benjamin Gaignard, Benoit Parrot, Biju Das,
Bingbu Cao, Bin Liu, Bryan O'Donoghue, Chen-Yu Tsai,
Christian Gromm, Corentin Labbe, Daniel Almeida, Daniel Scally,
Detlev Casanova, Devarsh Thakkar, Dikshita Agarwal,
Dmitry Osipenko, Dongliang Mu, Dr. David Alan Gilbert,
Eduardo Valentin, Erling Ljunggren, Ezequiel Garcia,
Fabien Dessenne, Fabio Estevam, Geert Uytterhoeven,
Greg Kroah-Hartman, Hans de Goede, Hans Verkuil, Heiko Stuebner,
Houlong Wei, Hugues Fruchet, imx, Ingo Molnar, Jacek Anaszewski,
Jackson Lee, Jacob Chen, Jai Luthra, Jean-Christophe Trotin,
Jernej Skrabec, Jerome Brunet, Jiasheng Jiang, Jonathan Corbet,
Jonathan Hunter, kernel, Kevin Hilman, Kieran Bingham,
Kieran Bingham, Krzysztof Kozlowski, Lad Prabhakar, linux-amlogic,
linux-arm-kernel, linux-arm-msm, linux-doc, linux-mediatek,
linux-renesas-soc, linux-rockchip, linux-samsung-soc,
linux-staging, linux-stm32, linux-sunxi, linux-tegra, linux-usb,
Łukasz Stelmach, Magnus Damm, Ma Ke, Marek Szyprowski,
Martin Blumenstingl, Matthew Majewski, Matthias Brugger,
Maxime Coquelin, Maxime Ripard, Michael Grzeschik,
Michael Tretter, Michal Simek, Mike Isely, Minghsiu Tsai,
Ming Qian, Mirela Rabulea, mjpeg-users, Nas Chung, Neil Armstrong,
Nicolas Dufresne, Niklas Söderlund, Parthiban Veerasooran,
Paul Kocialkowski, Pengutronix Kernel Team, Philipp Zabel,
Ricardo Ribalda, Robert Foss, Sakari Ailus, Samuel Holland,
Sascha Hauer, Shawn Guo, Shuah Khan, Stanislaw Gruszka,
Steve Longerbeam, Sylwester Nawrocki, Sylwester Nawrocki,
Thierry Reding, Thomas Gleixner, Tianshu Qiu, Tiffany Lin,
Todor Tomov, Tomasz Figa, Tomi Valkeinen, Tommaso Merciai,
Tommaso Merciai, Uwe Kleine-König, Vikash Garodia,
Vladimir Zapolskiy, Xavier Roumegue, Yanteng Si, Yong Deng,
Yunfei Dong, Yunke Cao, Zhou Peng
Hello,
Apologies for sending v3 right after v2, I realized just a tad too late
that I made a mistake and sent the wrong patches.
This patch series refactors v4l2_fh support to make the API easier to
use, simplify drivers, and overall improve consistency through the whole
subsystem.
In V4L2, drivers that need to store per file handle data allocate their
per file handle data structure in the .open() handler and set the struct
file private_data field to point to it. The private_data field is
entirely managed by drivers, and is generally opaque to the V4L2
framework.
The V4L2 framework also needs to store per file handle data to support
features such as V4L2 events or per file handle controls. To make use of
those features, driver need to use the v4l2_fh structure to store per
file handle data, either as-is, or embedded in a driver-specific
structure. In either case, drivers must initialize the v4l2_fh structure
with v4l2_fh_init(), and set the file private_data field to point to the
v4l2_fh structure. The initialization operation sets the
V4L2_FL_USES_V4L2_FH flag in the video_device.flags field, which
indicates to the V4L2 core that private_data points to a valid v4l2_fh.
In practice, while v4l2_fh usage is optional, all V4L2 drivers make use
of it. As all new drivers are required to use v4l2_fh, this situation
will not change, and opens the door to lots of simplifications in the
V4L2 core and in drivers.
The series starts with patches 01/76 to 07/76 that align the behaviour
of all drivers, ensuring they all store a v4l2_fh pointer in the file
private_data. Seven drivers store a pointer to driver-specific
structures that embed v4l2_fh. This causes no issue in practice as the
v4l2_fh field is always the first one in all those structures, but the
code lacks coherency.
After that, the series eliminates direct access to the file
private_data. Patch 08/76 introduces a helper to retrieve the v4l2_fh
from the file, and patches 09/76 to 11/76 use the helper in drivers.
Patches 12/76 to 25/76 are assorted refactoring and cleanup that prepare
drivers to remove the last manual accesses to private_data. Patches
26/76 and 27/27 drop those, by setting private_data in the v4l2_fh_add()
helper, and resetting it to NULL in v4l2_fh_del(). Prior refactoring
makes it possible for those last two patches to be generated by
coccinelle with only small manual additions.
Patches 28/76 to 32/76 then move to simplify the V4L2 core. As all
drivers are guaranteed to use v4l2_fh, all the V4L2_FL_USES_V4L2_FH
checks can be dropped. Patch 32/76 does so. It however stops short of
dropping V4L2_FL_USES_V4L2_FH completely, and instead adds a temporary
check in the open file operation to verify that the driver uses v4l2_fh.
That check could be dropped after a few kernel releases.
The second part of the series, address a second source of inconsistent
behaviours in drivers. The V4L2 core passes to most ioctl handlers both
the file pointer and the file private_data pointer, with the latter
being passed as a void pointer. Not only is the void pointer redundant,
as driver can (and do in many cases) access the per file data from the
file private_data field, but passing a v4l2_fh through a void pointer is
error-prone as incorrect casts wouldn't be noticed by the compiler.
To fix this, patches 33/76 to 68/76 replace all usage of the void
pointer, retrieving instead the v4l2_fh from the file structure. Patches
69/76 and 70/76 then pass a NULL value through the ioctl void pointer
argument, to ensure no new driver will try to access the v4l2_fh from
there. They also rename the 'void *fh' argument to the ioctl handler
definitions to 'void *priv'.
Finally, patches 71/76 to 76/76 also rename the same arguments in
several locations:
- in the test drivers, the uvcvideo driver and the v4l2-pci-skeleton
driver due to their role as sample and reference code (71/76 to
73/76) ;
- in the V4L2 core (74/76) ; and
- in all drivers that use names other than the most common 'void *priv'
and 'void *fh', in order to standardize on those two names only (75/76
and 76/76).
Renaming all remaining 'void *fh' to 'void *priv' would be lots of
additional churn, and this series is big enough. Furthermore, we have
plans to introduce a new video_device_state argument to ioctl handlers.
We will likely remove the 'void *' argument at that time, to avoid
modifying all ioctl handlers in all drivers twice in a short amount of
time.
This series is based on the latest linux-media next branch. It has a
soft dependency on the "[PATCH 0/4] Remove the wl1273 FM Radio" series
([1]) in the sense that the wl1273 driver is the very last V4L2 driver
that does not use v4l2_fh. Merging this series first would break the
wl1273 driver (at runtime), but given that the driver is scheduled for
removal due to having no user, this shouldn't be an issue.
Compared to v1, all review comments have been addressed. The most
notable changes are
- the removal of the V4L2_FL_USES_V4L2_FH checks
- the push of the NULL private pointer to the ioctl wrappers
- the reintroduction of the 'void *' parameter name in the ioctl handler
definitions (now named 'priv'),
- the rename of the 'void *' arguments in drivers and in the V4L2 core
Link to v1: https://lore.kernel.org/r/20250802-media-private-data-v1-0-eb140ddd6a9d@ideasonboard.com
[1] https://lore.kernel.org/linux-media/20250625133258.78133-1-linux@treblig.org/
Jacopo Mondi (37):
media: rcar-vin: Do not set file->private_data
media: rzg2l-cru: Do not set file->private_data
media: camss: Remove custom .release fop()
media: zoran: Remove zoran_fh structure
media: zoran: Rename __fh to fh
media: v4l2-ioctl: Access v4l2_fh from private_data
media: allegro: Access v4l2_fh from file
media: meson-ge2d: Access v4l2_fh from file
media: coda: Access v4l2_fh from file
media: wave5: Access v4l2_fh from file
media: m2m-deinterlace: Access v4l2_fh from file
media: mtk: jpeg: Access v4l2_fh from file->private_data
media: mtk_mdp_m2m: Access v4l2_fh from file
media: mtk: mdp3: Access v4l2_fh from file
media: mtk: vcodec: Access v4l2_fh from file
media: tegra-vde: Access v4l2_fh from file
media: imx-jpeg: Access v4l2_fh from file
media: imx-isi: Access v4l2_fh from file
media: nxp: mx2: Access v4l2_fh from file
media: renesas: Access v4l2_fh from file
media: rockhip: rga: Access v4l2_fh from file
media: rockchip: rkvdec: Access v4l2_fh from file
media: exynos-gsc: Access v4l2_fh from file
media: exynos4-is: Access v4l2_fh from file
media: s3c-camif: Access v4l2_fh from file
media: s5p-g2d: Access v4l2_fh from file
media: s5p-jpeg: Access v4l2_fh from file
media: s5p-mfc: Access v4l2_fh from file
media: bdisp: Access v4l2_fh from file
media: st: delta: Access v4l2_fh from file
media: stm32: dma2d: Access v4l2_fh from file
media: omap3isp: Access v4l2_fh from file
media: cx18: Access v4l2_fh from file
media: ivtv: Access v4l2_fh from file
media: usb: hdpvr: Access v4l2_fh from file
media: usb: uvc: Access v4l2_fh from file
media: staging: imx: Access v4l2_fh from file
Laurent Pinchart (39):
media: pci: saa7164: Store v4l2_fh pointer in file->private_data
media: imagination: Store v4l2_fh pointer in file->private_data
media: ti: vpe: Store v4l2_fh pointer in file->private_data
media: usb: hdpvr: Store v4l2_fh pointer in file->private_data
media: usb: pvrusb2: Store v4l2_fh pointer in file->private_data
media: usb: uvcvideo: Store v4l2_fh pointer in file->private_data
media: staging: most: Store v4l2_fh pointer in file->private_data
media: Wrap file->private_data access with a helper function
media: Replace file->private_data access with file_to_v4l2_fh()
media: nvidia: tegra-vde: Replace file->private_data access
media: Replace file->private_data access with custom functions
media: pci: ivtv: Don't create fake v4l2_fh
media: amphion: Make some vpu_v4l2 functions static
media: amphion: Delete v4l2_fh synchronously in .release()
media: visl: Drop visl_v4l2fh_to_ctx() function
media: v4l2-fh: Move piece of documentation to correct function
media: camss: Replace .open() file operation with v4l2_fh_open()
media: chips-media: wave5: Pass file pointer to
wave5_cleanup_instance()
media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init()
media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init()
media: qcom: iris: Drop unused argument to iris_get_inst()
media: qcom: venus: Pass file pointer to venus_close_common()
media: Set file->private_data in v4l2_fh_add()
media: Reset file->private_data to NULL in v4l2_fh_del()
media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually
media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH
check
media: v4l2-dev: Make open and release file operations mandatory
media: Drop V4L2_FL_USES_V4L2_FH checks
media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv
media: hantro: Access v4l2_fh from file->private_data
media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
media: v4l2-ioctl: Push NULL fh argument down to ioctl wrappers
media: test-drivers: Rename second ioctl handlers argument to 'void
*priv'
media: uvcvideo: Rename second ioctl handlers argument to 'void *priv'
media: v4l2-pci-skeleton: Rename second ioctl handlers argument to
'void *priv'
media: v4l2-core: Rename second ioctl handlers argument to 'void
*priv'
media: v4l2: Rename second ioctl handlers argument to 'void *priv'
media: staging: Rename second ioctl handlers argument to 'void *priv'
Documentation/driver-api/media/v4l2-fh.rst | 59 ++-
.../zh_CN/video4linux/v4l2-framework.txt | 16 +-
.../extron-da-hd-4k-plus.c | 4 +-
.../media/common/videobuf2/videobuf2-v4l2.c | 12 +-
drivers/media/pci/bt8xx/bttv-driver.c | 14 +-
drivers/media/pci/bt8xx/bttv-vbi.c | 6 +-
drivers/media/pci/cobalt/cobalt-v4l2.c | 60 +--
drivers/media/pci/cx18/cx18-driver.h | 2 +-
drivers/media/pci/cx18/cx18-fileops.c | 11 +-
drivers/media/pci/cx18/cx18-ioctl.c | 64 +--
.../media/pci/intel/ipu6/ipu6-isys-video.c | 1 -
drivers/media/pci/ivtv/ivtv-alsa-pcm.c | 2 -
drivers/media/pci/ivtv/ivtv-driver.h | 7 +-
drivers/media/pci/ivtv/ivtv-fileops.c | 40 +-
drivers/media/pci/ivtv/ivtv-ioctl.c | 124 ++---
drivers/media/pci/ivtv/ivtv-irq.c | 4 +-
drivers/media/pci/saa7134/saa7134-video.c | 4 +-
drivers/media/pci/saa7164/saa7164-encoder.c | 30 +-
drivers/media/pci/saa7164/saa7164-vbi.c | 25 +-
drivers/media/pci/saa7164/saa7164.h | 10 +
drivers/media/pci/zoran/zoran.h | 6 -
drivers/media/pci/zoran/zoran_driver.c | 35 +-
.../media/platform/allegro-dvt/allegro-core.c | 33 +-
.../media/platform/amlogic/meson-ge2d/ge2d.c | 25 +-
drivers/media/platform/amphion/vpu.h | 2 +-
drivers/media/platform/amphion/vpu_v4l2.c | 22 +-
drivers/media/platform/amphion/vpu_v4l2.h | 8 -
.../platform/chips-media/coda/coda-common.c | 50 +-
.../platform/chips-media/wave5/wave5-helper.c | 10 +-
.../platform/chips-media/wave5/wave5-helper.h | 2 +-
.../chips-media/wave5/wave5-vpu-dec.c | 23 +-
.../chips-media/wave5/wave5-vpu-enc.c | 29 +-
.../platform/chips-media/wave5/wave5-vpu.h | 5 +
.../platform/imagination/e5010-jpeg-enc.c | 23 +-
.../platform/imagination/e5010-jpeg-enc.h | 5 +
drivers/media/platform/m2m-deinterlace.c | 26 +-
.../platform/mediatek/jpeg/mtk_jpeg_core.c | 37 +-
.../media/platform/mediatek/mdp/mtk_mdp_m2m.c | 29 +-
.../platform/mediatek/mdp3/mtk-mdp3-m2m.c | 25 +-
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 36 +-
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 9 +-
.../vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
.../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 37 +-
.../vcodec/encoder/mtk_vcodec_enc_drv.c | 9 +-
.../vcodec/encoder/mtk_vcodec_enc_drv.h | 4 +-
.../media/platform/nvidia/tegra-vde/v4l2.c | 35 +-
drivers/media/platform/nxp/dw100/dw100.c | 7 +-
.../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 45 +-
drivers/media/platform/nxp/imx-pxp.c | 7 +-
.../platform/nxp/imx8-isi/imx8-isi-m2m.c | 21 +-
drivers/media/platform/nxp/mx2_emmaprp.c | 24 +-
.../media/platform/qcom/camss/camss-video.c | 43 +-
drivers/media/platform/qcom/iris/iris_vidc.c | 36 +-
drivers/media/platform/qcom/venus/core.c | 4 +-
drivers/media/platform/qcom/venus/core.h | 4 +-
drivers/media/platform/qcom/venus/vdec.c | 5 +-
drivers/media/platform/qcom/venus/venc.c | 5 +-
.../platform/renesas/rcar-vin/rcar-v4l2.c | 2 -
drivers/media/platform/renesas/rcar_fdp1.c | 17 +-
drivers/media/platform/renesas/rcar_jpu.c | 27 +-
.../platform/renesas/rzg2l-cru/rzg2l-video.c | 1 -
.../media/platform/renesas/vsp1/vsp1_histo.c | 6 +-
.../media/platform/renesas/vsp1/vsp1_video.c | 18 +-
drivers/media/platform/rockchip/rga/rga.c | 30 +-
drivers/media/platform/rockchip/rga/rga.h | 5 +
.../media/platform/rockchip/rkvdec/rkvdec.c | 21 +-
.../media/platform/rockchip/rkvdec/rkvdec.h | 4 +-
.../platform/samsung/exynos-gsc/gsc-core.h | 6 +-
.../platform/samsung/exynos-gsc/gsc-m2m.c | 37 +-
.../platform/samsung/exynos4-is/fimc-core.h | 5 +-
.../platform/samsung/exynos4-is/fimc-m2m.c | 19 +-
.../samsung/s3c-camif/camif-capture.c | 26 +-
drivers/media/platform/samsung/s5p-g2d/g2d.c | 40 +-
.../platform/samsung/s5p-jpeg/jpeg-core.c | 33 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc.c | 17 +-
.../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +-
.../platform/samsung/s5p-mfc/s5p_mfc_dec.c | 34 +-
.../platform/samsung/s5p-mfc/s5p_mfc_enc.c | 38 +-
.../media/platform/st/sti/bdisp/bdisp-v4l2.c | 30 +-
.../media/platform/st/sti/delta/delta-v4l2.c | 41 +-
drivers/media/platform/st/sti/hva/hva-v4l2.c | 38 +-
drivers/media/platform/st/sti/hva/hva.h | 2 -
drivers/media/platform/st/stm32/dma2d/dma2d.c | 28 +-
.../sunxi/sun6i-csi/sun6i_csi_capture.c | 16 +-
.../media/platform/sunxi/sun8i-di/sun8i-di.c | 10 +-
.../sunxi/sun8i-rotate/sun8i_rotate.c | 10 +-
.../platform/synopsys/hdmirx/snps_hdmirx.c | 8 +-
.../platform/ti/j721e-csi2rx/j721e-csi2rx.c | 2 +-
drivers/media/platform/ti/omap/omap_vout.c | 6 +-
drivers/media/platform/ti/omap3isp/ispvideo.c | 36 +-
drivers/media/platform/ti/omap3isp/ispvideo.h | 6 +-
drivers/media/platform/ti/vpe/vpe.c | 21 +-
drivers/media/platform/verisilicon/hantro.h | 4 +-
.../media/platform/verisilicon/hantro_drv.c | 10 +-
.../media/platform/verisilicon/hantro_v4l2.c | 22 +-
drivers/media/platform/xilinx/xilinx-dma.c | 10 +-
.../radio/si4713/radio-platform-si4713.c | 10 +-
.../media/test-drivers/vicodec/vicodec-core.c | 21 +-
drivers/media/test-drivers/vim2m.c | 7 +-
.../media/test-drivers/vimc/vimc-capture.c | 2 +-
drivers/media/test-drivers/visl/visl-core.c | 5 +-
drivers/media/test-drivers/visl/visl.h | 7 +-
drivers/media/test-drivers/vivid/vivid-core.c | 100 ++--
.../media/test-drivers/vivid/vivid-radio-rx.c | 12 +-
.../media/test-drivers/vivid/vivid-radio-rx.h | 8 +-
.../media/test-drivers/vivid/vivid-radio-tx.c | 8 +-
.../media/test-drivers/vivid/vivid-radio-tx.h | 4 +-
.../media/test-drivers/vivid/vivid-sdr-cap.c | 18 +-
.../media/test-drivers/vivid/vivid-sdr-cap.h | 18 +-
.../media/test-drivers/vivid/vivid-vbi-cap.c | 10 +-
.../media/test-drivers/vivid/vivid-vbi-cap.h | 8 +-
.../media/test-drivers/vivid/vivid-vbi-out.c | 8 +-
.../media/test-drivers/vivid/vivid-vbi-out.h | 6 +-
.../media/test-drivers/vivid/vivid-vid-cap.c | 24 +-
.../media/test-drivers/vivid/vivid-vid-cap.h | 24 +-
.../test-drivers/vivid/vivid-vid-common.c | 8 +-
.../test-drivers/vivid/vivid-vid-common.h | 8 +-
.../media/test-drivers/vivid/vivid-vid-out.c | 16 +-
.../media/test-drivers/vivid/vivid-vid-out.h | 16 +-
drivers/media/usb/cx231xx/cx231xx-417.c | 2 +-
drivers/media/usb/gspca/gspca.c | 18 +-
drivers/media/usb/hdpvr/hdpvr-video.c | 69 +--
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 69 +--
drivers/media/usb/uvc/uvc_metadata.c | 22 +-
drivers/media/usb/uvc/uvc_v4l2.c | 85 ++--
drivers/media/usb/uvc/uvcvideo.h | 5 +
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 9 +-
drivers/media/v4l2-core/v4l2-ctrls-api.c | 11 +-
drivers/media/v4l2-core/v4l2-dev.c | 45 +-
drivers/media/v4l2-core/v4l2-fh.c | 16 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 456 +++++++++---------
drivers/media/v4l2-core/v4l2-mem2mem.c | 50 +-
drivers/media/v4l2-core/v4l2-subdev.c | 16 +-
.../staging/media/imx/imx-media-csc-scaler.c | 26 +-
drivers/staging/media/ipu7/ipu7-isys-video.c | 1 -
drivers/staging/media/meson/vdec/vdec.c | 29 +-
drivers/staging/media/meson/vdec/vdec.h | 5 +
drivers/staging/media/sunxi/cedrus/cedrus.c | 8 +-
drivers/staging/media/sunxi/cedrus/cedrus.h | 5 +
.../staging/media/sunxi/cedrus/cedrus_video.c | 5 -
.../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 16 +-
.../media/sunxi/sun6i-isp/sun6i_isp_params.c | 6 +-
drivers/staging/most/video/video.c | 19 +-
drivers/usb/gadget/function/uvc.h | 5 +
drivers/usb/gadget/function/uvc_v4l2.c | 8 +-
include/media/v4l2-ctrls.h | 4 +-
include/media/v4l2-dev.h | 2 +-
include/media/v4l2-fh.h | 30 +-
include/media/v4l2-ioctl.h | 238 ++++-----
include/media/v4l2-mem2mem.h | 42 +-
samples/v4l/v4l2-pci-skeleton.c | 10 +-
151 files changed, 1792 insertions(+), 1806 deletions(-)
base-commit: d968e50b5c26642754492dea23cbd3592bde62d8
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
@ 2025-08-10 1:29 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 19/76] media: camss: Replace .open() file operation with v4l2_fh_open() Laurent Pinchart
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:29 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Andy Walls,
Ming Qian, Zhou Peng, Devarsh Thakkar, Xavier Roumegue,
Philipp Zabel, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Benoit Parrot, Hans Verkuil,
Daniel Almeida, Mike Isely, Hans de Goede, Parthiban Veerasooran,
Christian Gromm, Greg Kroah-Hartman, Dr. David Alan Gilbert,
Matthew Majewski, Uwe Kleine-König, Shuah Khan,
Ricardo Ribalda, Michael Grzeschik, Akash Kumar, Abhishek Tamboli,
imx, linux-arm-kernel, linux-arm-msm, linux-samsung-soc,
linux-sunxi, linux-staging, linux-usb
Accessing file->private_data manually to retrieve the v4l2_fh pointer is
error-prone, as the field is a void * and will happily cast implicitly
to any pointer type.
Replace all remaining locations that read the v4l2_fh pointer directly
from file->private_data with usage of the file_to_v4l2_fh() function.
The change was generated manually.
No functional change is intended, this only paves the way to remove
direct accesses to file->private_data and make V4L2 drivers safer.
Other accesses to the field will be addressed separately.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/pci/cx18/cx18-driver.h | 2 +-
drivers/media/pci/cx18/cx18-fileops.c | 2 +-
drivers/media/pci/saa7164/saa7164.h | 4 ++--
drivers/media/platform/amphion/vpu.h | 2 +-
drivers/media/platform/imagination/e5010-jpeg-enc.h | 2 +-
drivers/media/platform/nxp/dw100/dw100.c | 2 +-
drivers/media/platform/nxp/imx-pxp.c | 2 +-
drivers/media/platform/qcom/iris/iris_vidc.c | 2 +-
drivers/media/platform/qcom/venus/core.h | 2 +-
.../media/platform/samsung/s3c-camif/camif-capture.c | 6 +++---
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 2 +-
.../media/platform/sunxi/sun8i-rotate/sun8i_rotate.c | 2 +-
drivers/media/platform/ti/vpe/vpe.c | 2 +-
drivers/media/test-drivers/vicodec/vicodec-core.c | 2 +-
drivers/media/test-drivers/vim2m.c | 2 +-
drivers/media/test-drivers/visl/visl.h | 2 +-
drivers/media/test-drivers/vivid/vivid-core.c | 4 ++--
drivers/media/test-drivers/vivid/vivid-radio-rx.c | 4 ++--
drivers/media/test-drivers/vivid/vivid-radio-tx.c | 4 ++--
drivers/media/usb/hdpvr/hdpvr-video.c | 12 ++++++------
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 2 +-
drivers/media/usb/uvc/uvcvideo.h | 2 +-
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 4 ++--
drivers/staging/most/video/video.c | 2 +-
drivers/usb/gadget/function/uvc.h | 5 +++++
drivers/usb/gadget/function/uvc_v4l2.c | 2 +-
27 files changed, 43 insertions(+), 38 deletions(-)
diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h
index 485ca9747c4c..92acd23a8c4d 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -414,7 +414,7 @@ static inline struct cx18_open_id *fh2id(struct v4l2_fh *fh)
static inline struct cx18_open_id *file2id(struct file *file)
{
- return fh2id(file->private_data);
+ return fh2id(file_to_v4l2_fh(file));
}
/* forward declaration of struct defined in cx18-cards.h */
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index af25628b11ba..89e38b303630 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -709,7 +709,7 @@ int cx18_v4l2_close(struct file *filp)
}
if (id->type == CX18_ENC_STREAM_TYPE_YUV &&
- filp->private_data == vdev->queue->owner) {
+ file_to_v4l2_fh(filp) == vdev->queue->owner) {
vb2_queue_release(vdev->queue);
vdev->queue->owner = NULL;
}
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h
index 7b511f7f1cfc..94e987e7b5e5 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -182,7 +182,7 @@ struct saa7164_encoder_fh {
static inline struct saa7164_encoder_fh *to_saa7164_encoder_fh(struct file *filp)
{
- return container_of(filp->private_data, struct saa7164_encoder_fh, fh);
+ return container_of(file_to_v4l2_fh(filp), struct saa7164_encoder_fh, fh);
}
struct saa7164_vbi_fh {
@@ -193,7 +193,7 @@ struct saa7164_vbi_fh {
static inline struct saa7164_vbi_fh *to_saa7164_vbi_fh(struct file *filp)
{
- return container_of(filp->private_data, struct saa7164_vbi_fh, fh);
+ return container_of(file_to_v4l2_fh(filp), struct saa7164_vbi_fh, fh);
}
struct saa7164_histogram_bucket {
diff --git a/drivers/media/platform/amphion/vpu.h b/drivers/media/platform/amphion/vpu.h
index cac0f1a64fea..bfd171a3ded4 100644
--- a/drivers/media/platform/amphion/vpu.h
+++ b/drivers/media/platform/amphion/vpu.h
@@ -328,7 +328,7 @@ static inline const char *vpu_core_type_desc(enum vpu_core_type type)
static inline struct vpu_inst *to_inst(struct file *filp)
{
- return container_of(filp->private_data, struct vpu_inst, fh);
+ return container_of(file_to_v4l2_fh(filp), struct vpu_inst, fh);
}
#define ctrl_to_inst(ctrl) \
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.h b/drivers/media/platform/imagination/e5010-jpeg-enc.h
index eefaf60489d3..da57bc1baa46 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.h
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.h
@@ -122,7 +122,7 @@ struct e5010_context {
static inline struct e5010_context *to_e5010_context(struct file *filp)
{
- return container_of(filp->private_data, struct e5010_context, fh);
+ return container_of(file_to_v4l2_fh(filp), struct e5010_context, fh);
}
/*
diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c
index 3d1db1121bf9..2460f09a6813 100644
--- a/drivers/media/platform/nxp/dw100/dw100.c
+++ b/drivers/media/platform/nxp/dw100/dw100.c
@@ -266,7 +266,7 @@ static inline int dw100_dump_regs(struct seq_file *m)
static inline struct dw100_ctx *dw100_file2ctx(struct file *file)
{
- return container_of(file->private_data, struct dw100_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct dw100_ctx, fh);
}
static struct dw100_q_data *dw100_get_q_data(struct dw100_ctx *ctx,
diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index 7f8ffbac582f..879b1803a2b3 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -248,7 +248,7 @@ struct pxp_ctx {
static inline struct pxp_ctx *file2ctx(struct file *file)
{
- return container_of(file->private_data, struct pxp_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct pxp_ctx, fh);
}
static struct pxp_q_data *get_q_data(struct pxp_ctx *ctx,
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index c417e8c31f80..0c3b47b9958a 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -69,7 +69,7 @@ static void iris_remove_session(struct iris_inst *inst)
static inline struct iris_inst *iris_get_inst(struct file *filp, void *fh)
{
- return container_of(filp->private_data, struct iris_inst, fh);
+ return container_of(file_to_v4l2_fh(filp), struct iris_inst, fh);
}
static void iris_m2m_device_run(void *priv)
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 5b1ba1c69adb..3c0c5f9dbe7b 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -535,7 +535,7 @@ struct venus_inst {
static inline struct venus_inst *to_inst(struct file *filp)
{
- return container_of(filp->private_data, struct venus_inst, fh);
+ return container_of(file_to_v4l2_fh(filp), struct venus_inst, fh);
}
static inline void *to_hfi_priv(struct venus_core *core)
diff --git a/drivers/media/platform/samsung/s3c-camif/camif-capture.c b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
index 3e566b65f417..cae15a4ce5fd 100644
--- a/drivers/media/platform/samsung/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
@@ -572,7 +572,7 @@ static int s3c_camif_close(struct file *file)
mutex_lock(&camif->lock);
- if (vp->owner == file->private_data) {
+ if (vp->owner == file_to_v4l2_fh(file)) {
camif_stop_capture(vp);
vb2_queue_release(&vp->vb_queue);
vp->owner = NULL;
@@ -595,7 +595,7 @@ static __poll_t s3c_camif_poll(struct file *file,
__poll_t ret;
mutex_lock(&camif->lock);
- if (vp->owner && vp->owner != file->private_data)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
ret = EPOLLERR;
else
ret = vb2_poll(&vp->vb_queue, file, wait);
@@ -609,7 +609,7 @@ static int s3c_camif_mmap(struct file *file, struct vm_area_struct *vma)
struct camif_vp *vp = video_drvdata(file);
int ret;
- if (vp->owner && vp->owner != file->private_data)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
ret = -EBUSY;
else
ret = vb2_mmap(&vp->vb_queue, vma);
diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index 3e7f2df70408..43755043e8af 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -309,7 +309,7 @@ static void deinterlace_init(struct deinterlace_dev *dev)
static inline struct deinterlace_ctx *deinterlace_file2ctx(struct file *file)
{
- return container_of(file->private_data, struct deinterlace_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct deinterlace_ctx, fh);
}
static bool deinterlace_check_format(u32 pixelformat)
diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
index abd10b218aa1..d0608b5d900f 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -170,7 +170,7 @@ static irqreturn_t rotate_irq(int irq, void *data)
static inline struct rotate_ctx *rotate_file2ctx(struct file *file)
{
- return container_of(file->private_data, struct rotate_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct rotate_ctx, fh);
}
static void rotate_prepare_format(struct v4l2_pix_format *pix_fmt)
diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
index b76b5d18c963..4b9b2bec7377 100644
--- a/drivers/media/platform/ti/vpe/vpe.c
+++ b/drivers/media/platform/ti/vpe/vpe.c
@@ -424,7 +424,7 @@ struct vpe_ctx {
static inline struct vpe_ctx *to_vpe_ctx(struct file *filp)
{
- return container_of(filp->private_data, struct vpe_ctx, fh);
+ return container_of(file_to_v4l2_fh(filp), struct vpe_ctx, fh);
}
/*
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
index c45f5cf12ded..e27f6761cba1 100644
--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
@@ -144,7 +144,7 @@ static const struct v4l2_event vicodec_eos_event = {
static inline struct vicodec_ctx *file2ctx(struct file *file)
{
- return container_of(file->private_data, struct vicodec_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct vicodec_ctx, fh);
}
static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx,
diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
index 1d1a9e768505..55d885be5bcc 100644
--- a/drivers/media/test-drivers/vim2m.c
+++ b/drivers/media/test-drivers/vim2m.c
@@ -236,7 +236,7 @@ struct vim2m_ctx {
static inline struct vim2m_ctx *file2ctx(struct file *file)
{
- return container_of(file->private_data, struct vim2m_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct vim2m_ctx, fh);
}
static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx,
diff --git a/drivers/media/test-drivers/visl/visl.h b/drivers/media/test-drivers/visl/visl.h
index 434e9efbf9b2..ad3d0ab791d6 100644
--- a/drivers/media/test-drivers/visl/visl.h
+++ b/drivers/media/test-drivers/visl/visl.h
@@ -163,7 +163,7 @@ struct visl_ctrl_desc {
static inline struct visl_ctx *visl_file_to_ctx(struct file *file)
{
- return container_of(file->private_data, struct visl_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct visl_ctx, fh);
}
static inline struct visl_ctx *visl_v4l2fh_to_ctx(struct v4l2_fh *v4l2_fh)
diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index 8d56168c72aa..9c9a93a3b540 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -654,11 +654,11 @@ static int vivid_fop_release(struct file *file)
v4l2_info(&dev->v4l2_dev, "reconnect\n");
vivid_reconnect(dev);
}
- if (file->private_data == dev->radio_rx_rds_owner) {
+ if (file_to_v4l2_fh(file) == dev->radio_rx_rds_owner) {
dev->radio_rx_rds_last_block = 0;
dev->radio_rx_rds_owner = NULL;
}
- if (file->private_data == dev->radio_tx_rds_owner) {
+ if (file_to_v4l2_fh(file) == dev->radio_tx_rds_owner) {
dev->radio_tx_rds_last_block = 0;
dev->radio_tx_rds_owner = NULL;
}
diff --git a/drivers/media/test-drivers/vivid/vivid-radio-rx.c b/drivers/media/test-drivers/vivid/vivid-radio-rx.c
index 79c1723bd84c..be711cae2d49 100644
--- a/drivers/media/test-drivers/vivid/vivid-radio-rx.c
+++ b/drivers/media/test-drivers/vivid/vivid-radio-rx.c
@@ -42,13 +42,13 @@ ssize_t vivid_radio_rx_read(struct file *file, char __user *buf,
if (mutex_lock_interruptible(&dev->mutex))
return -ERESTARTSYS;
if (dev->radio_rx_rds_owner &&
- file->private_data != dev->radio_rx_rds_owner) {
+ file_to_v4l2_fh(file) != dev->radio_rx_rds_owner) {
mutex_unlock(&dev->mutex);
return -EBUSY;
}
if (dev->radio_rx_rds_owner == NULL) {
vivid_radio_rds_init(dev);
- dev->radio_rx_rds_owner = file->private_data;
+ dev->radio_rx_rds_owner = file_to_v4l2_fh(file);
}
retry:
diff --git a/drivers/media/test-drivers/vivid/vivid-radio-tx.c b/drivers/media/test-drivers/vivid/vivid-radio-tx.c
index 049d40b948bb..f6e80b8d00a6 100644
--- a/drivers/media/test-drivers/vivid/vivid-radio-tx.c
+++ b/drivers/media/test-drivers/vivid/vivid-radio-tx.c
@@ -39,11 +39,11 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf,
if (mutex_lock_interruptible(&dev->mutex))
return -ERESTARTSYS;
if (dev->radio_tx_rds_owner &&
- file->private_data != dev->radio_tx_rds_owner) {
+ file_to_v4l2_fh(file) != dev->radio_tx_rds_owner) {
mutex_unlock(&dev->mutex);
return -EBUSY;
}
- dev->radio_tx_rds_owner = file->private_data;
+ dev->radio_tx_rds_owner = file_to_v4l2_fh(file);
retry:
timestamp = ktime_sub(ktime_get(), dev->radio_rds_init_time);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 4c431bd9b503..ea17f1a5f5b0 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -390,7 +390,7 @@ static int hdpvr_release(struct file *file)
struct hdpvr_device *dev = video_drvdata(file);
mutex_lock(&dev->io_mutex);
- if (file->private_data == dev->owner) {
+ if (file_to_v4l2_fh(file) == dev->owner) {
hdpvr_stop_streaming(dev);
dev->owner = NULL;
}
@@ -426,7 +426,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
mutex_unlock(&dev->io_mutex);
goto err;
}
- dev->owner = file->private_data;
+ dev->owner = file_to_v4l2_fh(file);
print_buffer_status();
}
mutex_unlock(&dev->io_mutex);
@@ -541,7 +541,7 @@ static __poll_t hdpvr_poll(struct file *filp, poll_table *wait)
"start_streaming failed\n");
dev->status = STATUS_IDLE;
} else {
- dev->owner = filp->private_data;
+ dev->owner = file_to_v4l2_fh(filp);
}
print_buffer_status();
@@ -1048,7 +1048,7 @@ static int vidioc_encoder_cmd(struct file *filp, void *priv,
switch (a->cmd) {
case V4L2_ENC_CMD_START:
- if (dev->owner && filp->private_data != dev->owner) {
+ if (dev->owner && file_to_v4l2_fh(filp) != dev->owner) {
res = -EBUSY;
break;
}
@@ -1056,12 +1056,12 @@ static int vidioc_encoder_cmd(struct file *filp, void *priv,
break;
res = hdpvr_start_streaming(dev);
if (!res)
- dev->owner = filp->private_data;
+ dev->owner = file_to_v4l2_fh(filp);
else
dev->status = STATUS_IDLE;
break;
case V4L2_ENC_CMD_STOP:
- if (dev->owner && filp->private_data != dev->owner) {
+ if (dev->owner && file_to_v4l2_fh(filp) != dev->owner) {
res = -EBUSY;
break;
}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 7dc7c90ebf62..481b03bbecf8 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -48,7 +48,7 @@ struct pvr2_v4l2_fh {
static inline struct pvr2_v4l2_fh *to_pvr2_v4l2_fh(struct file *filp)
{
- return container_of(filp->private_data, struct pvr2_v4l2_fh, fh);
+ return container_of(file_to_v4l2_fh(filp), struct pvr2_v4l2_fh, fh);
}
struct pvr2_v4l2 {
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 8b5625203048..70dc80e2b213 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -639,7 +639,7 @@ struct uvc_fh {
static inline struct uvc_fh *to_uvc_fh(struct file *filp)
{
- return container_of(filp->private_data, struct uvc_fh, vfh);
+ return container_of(file_to_v4l2_fh(filp), struct uvc_fh, vfh);
}
/* ------------------------------------------------------------------------
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 8c07400bd280..8a5559225ff2 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -678,7 +678,7 @@ static inline bool ctrl_is_pointer(struct file *file, u32 id)
const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags))
- fh = file->private_data;
+ fh = file_to_v4l2_fh(file);
if (fh && fh->ctrl_handler)
hdl = fh->ctrl_handler;
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 46da373066f4..8c81852c3046 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1197,7 +1197,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops,
vfd = video_devdata(file);
if (!test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags))
return -ENOTTY;
- vfh = file->private_data;
+ vfh = file_to_v4l2_fh(file);
return v4l2_prio_change(vfd->prio, &vfh->prio, *p);
}
@@ -3084,7 +3084,7 @@ static long __video_do_ioctl(struct file *file,
}
if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags))
- vfh = file->private_data;
+ vfh = file_to_v4l2_fh(file);
/*
* We need to serialize streamon/off with queueing new requests.
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index bce7ffeac8fe..116331cead2a 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -54,7 +54,7 @@ struct comp_fh {
static inline struct comp_fh *to_comp_fh(struct file *filp)
{
- return container_of(filp->private_data, struct comp_fh, fh);
+ return container_of(file_to_v4l2_fh(filp), struct comp_fh, fh);
}
static LIST_HEAD(video_devices);
diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
index 6f44dd732315..9e79cbe50715 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -196,6 +196,11 @@ struct uvc_file_handle {
#define to_uvc_file_handle(handle) \
container_of(handle, struct uvc_file_handle, vfh)
+static inline struct uvc_file_handle *file_to_uvc_file_handle(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct uvc_file_handle, vfh);
+}
+
/* ------------------------------------------------------------------------
* Functions
*/
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index fc9a8d31a1e9..886300a29b90 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -685,7 +685,7 @@ uvc_v4l2_release(struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct uvc_device *uvc = video_get_drvdata(vdev);
- struct uvc_file_handle *handle = to_uvc_file_handle(file->private_data);
+ struct uvc_file_handle *handle = file_to_uvc_file_handle(file);
struct uvc_video *video = handle->device;
mutex_lock(&video->mutex);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 19/76] media: camss: Replace .open() file operation with v4l2_fh_open()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
2025-08-10 1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 20/76] media: camss: Remove custom .release fop() Laurent Pinchart
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Robert Foss,
Todor Tomov, Bryan O'Donoghue, Vladimir Zapolskiy,
linux-arm-msm
The custom video_open() function in the camss driver open-codes the
v4l2_fh_open() helper, with an additional mutex that protects the whole
function. Given that the function does not modify any data guarded by
the lock, there's no need for using the mutex and the function can be
replaced by v4l2_fh_open().
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
.../media/platform/qcom/camss/camss-video.c | 32 +------------------
1 file changed, 1 insertion(+), 31 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 8d05802d1735..c5d02f9ebc6a 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -604,36 +604,6 @@ static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = {
* V4L2 file operations
*/
-static int video_open(struct file *file)
-{
- struct video_device *vdev = video_devdata(file);
- struct camss_video *video = video_drvdata(file);
- struct v4l2_fh *vfh;
- int ret;
-
- mutex_lock(&video->lock);
-
- vfh = kzalloc(sizeof(*vfh), GFP_KERNEL);
- if (vfh == NULL) {
- ret = -ENOMEM;
- goto error_alloc;
- }
-
- v4l2_fh_init(vfh, vdev);
- v4l2_fh_add(vfh);
-
- file->private_data = vfh;
-
- mutex_unlock(&video->lock);
-
- return 0;
-
-error_alloc:
- mutex_unlock(&video->lock);
-
- return ret;
-}
-
static int video_release(struct file *file)
{
vb2_fop_release(file);
@@ -646,7 +616,7 @@ static int video_release(struct file *file)
static const struct v4l2_file_operations msm_vid_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = video_ioctl2,
- .open = video_open,
+ .open = v4l2_fh_open,
.release = video_release,
.poll = vb2_fop_poll,
.mmap = vb2_fop_mmap,
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 20/76] media: camss: Remove custom .release fop()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
2025-08-10 1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 19/76] media: camss: Replace .open() file operation with v4l2_fh_open() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 22/76] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Laurent Pinchart
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Robert Foss,
Todor Tomov, Bryan O'Donoghue, Vladimir Zapolskiy,
linux-arm-msm
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
The 'file->private_data' pointer is reset in the vb2_fop_release()
call path. For this reason a custom handler for the .release
file operation is not needed and the driver can use
vb2_fop_release() directly.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/qcom/camss/camss-video.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index c5d02f9ebc6a..831486e14754 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -604,20 +604,11 @@ static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = {
* V4L2 file operations
*/
-static int video_release(struct file *file)
-{
- vb2_fop_release(file);
-
- file->private_data = NULL;
-
- return 0;
-}
-
static const struct v4l2_file_operations msm_vid_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = video_ioctl2,
.open = v4l2_fh_open,
- .release = video_release,
+ .release = vb2_fop_release,
.poll = vb2_fop_poll,
.mmap = vb2_fop_mmap,
.read = vb2_fop_read,
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 22/76] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (2 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 20/76] media: camss: Remove custom .release fop() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 23/76] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Laurent Pinchart
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
linux-arm-msm
In preparation for a tree-wide rework automated with coccinelle that
will need to access a struct file pointer in the iris_v4l2_fh_init() and
iris_v4l2_fh_deinit() functions, pass it from the callers. There is not
functional change yet.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/qcom/iris/iris_vidc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 0c3b47b9958a..d5f99519def4 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -21,14 +21,14 @@
#define STEP_WIDTH 1
#define STEP_HEIGHT 1
-static void iris_v4l2_fh_init(struct iris_inst *inst)
+static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)
{
v4l2_fh_init(&inst->fh, inst->core->vdev_dec);
inst->fh.ctrl_handler = &inst->ctrl_handler;
v4l2_fh_add(&inst->fh);
}
-static void iris_v4l2_fh_deinit(struct iris_inst *inst)
+static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)
{
v4l2_fh_del(&inst->fh);
inst->fh.ctrl_handler = NULL;
@@ -164,7 +164,7 @@ int iris_open(struct file *filp)
init_completion(&inst->completion);
init_completion(&inst->flush_completion);
- iris_v4l2_fh_init(inst);
+ iris_v4l2_fh_init(inst, filp);
inst->m2m_dev = v4l2_m2m_init(&iris_m2m_ops);
if (IS_ERR_OR_NULL(inst->m2m_dev)) {
@@ -194,7 +194,7 @@ int iris_open(struct file *filp)
fail_m2m_release:
v4l2_m2m_release(inst->m2m_dev);
fail_v4l2_fh_deinit:
- iris_v4l2_fh_deinit(inst);
+ iris_v4l2_fh_deinit(inst, filp);
mutex_destroy(&inst->ctx_q_lock);
mutex_destroy(&inst->lock);
kfree(inst);
@@ -259,7 +259,7 @@ int iris_close(struct file *filp)
iris_vdec_inst_deinit(inst);
iris_session_close(inst);
iris_inst_change_state(inst, IRIS_INST_DEINIT);
- iris_v4l2_fh_deinit(inst);
+ iris_v4l2_fh_deinit(inst, filp);
iris_destroy_all_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
iris_destroy_all_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
iris_check_num_queued_internal_buffers(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 23/76] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (3 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 22/76] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 24/76] media: qcom: iris: Drop unused argument to iris_get_inst() Laurent Pinchart
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
linux-arm-msm
In preparation for a tree-wide rework automated with coccinelle that
will affect file->private_data, v4l2_fh_add() and v4l2_fh_del(), move
setting file->private_data from the callers to the iris_v4l2_fh_init()
and iris_v4l2_fh_deinit() functions. There is not functional change yet.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/qcom/iris/iris_vidc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index d5f99519def4..73c96498759c 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -26,10 +26,12 @@ static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)
v4l2_fh_init(&inst->fh, inst->core->vdev_dec);
inst->fh.ctrl_handler = &inst->ctrl_handler;
v4l2_fh_add(&inst->fh);
+ filp->private_data = &inst->fh;
}
static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)
{
+ filp->private_data = NULL;
v4l2_fh_del(&inst->fh);
inst->fh.ctrl_handler = NULL;
v4l2_fh_exit(&inst->fh);
@@ -185,7 +187,6 @@ int iris_open(struct file *filp)
iris_add_session(inst);
inst->fh.m2m_ctx = inst->m2m_ctx;
- filp->private_data = &inst->fh;
return 0;
@@ -269,7 +270,6 @@ int iris_close(struct file *filp)
mutex_destroy(&inst->ctx_q_lock);
mutex_destroy(&inst->lock);
kfree(inst);
- filp->private_data = NULL;
return 0;
}
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 24/76] media: qcom: iris: Drop unused argument to iris_get_inst()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (4 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 23/76] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 25/76] media: qcom: venus: Pass file pointer to venus_close_common() Laurent Pinchart
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
linux-arm-msm
The second argument to the iris_get_inst() function is never used. Drop
it.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/qcom/iris/iris_vidc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 73c96498759c..64ebec2ca6b3 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -69,7 +69,7 @@ static void iris_remove_session(struct iris_inst *inst)
mutex_unlock(&core->lock);
}
-static inline struct iris_inst *iris_get_inst(struct file *filp, void *fh)
+static inline struct iris_inst *iris_get_inst(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct iris_inst, fh);
}
@@ -251,7 +251,7 @@ static void iris_check_num_queued_internal_buffers(struct iris_inst *inst, u32 p
int iris_close(struct file *filp)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
v4l2_ctrl_handler_free(&inst->ctrl_handler);
v4l2_m2m_ctx_release(inst->m2m_ctx);
@@ -276,14 +276,14 @@ int iris_close(struct file *filp)
static int iris_enum_fmt(struct file *filp, void *fh, struct v4l2_fmtdesc *f)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
return iris_vdec_enum_fmt(inst, f);
}
static int iris_try_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format *f)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
int ret;
mutex_lock(&inst->lock);
@@ -295,7 +295,7 @@ static int iris_try_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_form
static int iris_s_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format *f)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
int ret;
mutex_lock(&inst->lock);
@@ -307,7 +307,7 @@ static int iris_s_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format
static int iris_g_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format *f)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
int ret = 0;
mutex_lock(&inst->lock);
@@ -326,7 +326,7 @@ static int iris_g_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format
static int iris_enum_framesizes(struct file *filp, void *fh,
struct v4l2_frmsizeenum *fsize)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
struct platform_inst_caps *caps;
if (fsize->index)
@@ -359,7 +359,7 @@ static int iris_querycap(struct file *filp, void *fh, struct v4l2_capability *ca
static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -394,7 +394,7 @@ static int iris_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subs
static int iris_dec_cmd(struct file *filp, void *fh,
struct v4l2_decoder_cmd *dec)
{
- struct iris_inst *inst = iris_get_inst(filp, NULL);
+ struct iris_inst *inst = iris_get_inst(filp);
int ret = 0;
mutex_lock(&inst->lock);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 25/76] media: qcom: venus: Pass file pointer to venus_close_common()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (5 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 24/76] media: qcom: iris: Drop unused argument to iris_get_inst() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 26/76] media: Set file->private_data in v4l2_fh_add() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 27/76] media: Reset file->private_data to NULL in v4l2_fh_del() Laurent Pinchart
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Vikash Garodia,
Dikshita Agarwal, Bryan O'Donoghue, linux-arm-msm
In preparation for a tree-wide rework automated with coccinelle that
will need to access a struct file pointer in the venus_close_common()
function, pass it from the callers. There is not functional change yet.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/media/platform/qcom/venus/core.c | 2 +-
drivers/media/platform/qcom/venus/core.h | 2 +-
drivers/media/platform/qcom/venus/vdec.c | 2 +-
drivers/media/platform/qcom/venus/venc.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 4c049c694d9c..5e1ace16a490 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -596,7 +596,7 @@ static __maybe_unused int venus_runtime_suspend(struct device *dev)
return ret;
}
-void venus_close_common(struct venus_inst *inst)
+void venus_close_common(struct venus_inst *inst, struct file *filp)
{
/*
* Make sure we don't have IRQ/IRQ-thread currently running
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 3c0c5f9dbe7b..db7b69b91db5 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -573,5 +573,5 @@ is_fw_rev_or_older(struct venus_core *core, u32 vmajor, u32 vminor, u32 vrev)
(core)->venus_ver.rev <= vrev);
}
-void venus_close_common(struct venus_inst *inst);
+void venus_close_common(struct venus_inst *inst, struct file *filp);
#endif
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 29b0d6a5303d..d10ca6d89f6d 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -1755,7 +1755,7 @@ static int vdec_close(struct file *file)
vdec_pm_get(inst);
cancel_work_sync(&inst->delayed_process_work);
- venus_close_common(inst);
+ venus_close_common(inst, file);
ida_destroy(&inst->dpb_ids);
vdec_pm_put(inst, false);
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index c0a0ccdded80..0838d64ce8fe 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1537,7 +1537,7 @@ static int venc_close(struct file *file)
struct venus_inst *inst = to_inst(file);
venc_pm_get(inst);
- venus_close_common(inst);
+ venus_close_common(inst, file);
inst->enc_state = VENUS_ENC_STATE_DEINIT;
venc_pm_put(inst, false);
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 26/76] media: Set file->private_data in v4l2_fh_add()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (6 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 25/76] media: qcom: venus: Pass file pointer to venus_close_common() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 27/76] media: Reset file->private_data to NULL in v4l2_fh_del() Laurent Pinchart
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Alex Shi,
Yanteng Si, Dongliang Mu, Jonathan Corbet, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Ming Qian,
Zhou Peng, Philipp Zabel, Nas Chung, Jackson Lee, Devarsh Thakkar,
Bin Liu, Matthias Brugger, AngeloGioacchino Del Regno,
Minghsiu Tsai, Houlong Wei, Andrew-CT Chen, Tiffany Lin,
Yunfei Dong, Dmitry Osipenko, Thierry Reding, Jonathan Hunter,
Xavier Roumegue, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Kieran Bingham, Geert Uytterhoeven,
Magnus Damm, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Marek Szyprowski, Andrzej Hajda,
Fabien Dessenne, Hugues Fruchet, Jean-Christophe Trotin,
Maxime Coquelin, Alexandre Torgue, Jernej Skrabec, Chen-Yu Tsai,
Samuel Holland, Benoit Parrot, Nicolas Dufresne,
Benjamin Gaignard, Hans Verkuil, Daniel Almeida, Mike Isely,
Hans de Goede, Steve Longerbeam, Greg Kroah-Hartman,
Maxime Ripard, Paul Kocialkowski, Parthiban Veerasooran,
Christian Gromm, Ariel Otilibili, Uwe Kleine-König,
Jiasheng Jiang, Sakari Ailus, Matthew Majewski, Shuah Khan,
Tomi Valkeinen, Lad Prabhakar, Tommaso Merciai, Michael Grzeschik,
Abhishek Tamboli, Akash Kumar, linux-doc, linux-amlogic,
linux-arm-kernel, linux-mediatek, linux-tegra, imx, linux-arm-msm,
linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-stm32,
linux-sunxi, linux-staging, linux-usb
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>
---
Documentation/driver-api/media/v4l2-fh.rst | 42 ++++++++++---------
.../zh_CN/video4linux/v4l2-framework.txt | 5 +--
drivers/media/pci/cx18/cx18-fileops.c | 3 +-
drivers/media/pci/ivtv/ivtv-fileops.c | 4 +-
drivers/media/pci/saa7164/saa7164-encoder.c | 3 +-
drivers/media/pci/saa7164/saa7164-vbi.c | 3 +-
.../media/platform/allegro-dvt/allegro-core.c | 3 +-
.../media/platform/amlogic/meson-ge2d/ge2d.c | 3 +-
drivers/media/platform/amphion/vpu_v4l2.c | 3 +-
.../platform/chips-media/coda/coda-common.c | 3 +-
.../chips-media/wave5/wave5-vpu-dec.c | 3 +-
.../chips-media/wave5/wave5-vpu-enc.c | 3 +-
.../platform/imagination/e5010-jpeg-enc.c | 3 +-
drivers/media/platform/m2m-deinterlace.c | 3 +-
.../platform/mediatek/jpeg/mtk_jpeg_core.c | 3 +-
.../media/platform/mediatek/mdp/mtk_mdp_m2m.c | 3 +-
.../platform/mediatek/mdp3/mtk-mdp3-m2m.c | 3 +-
.../vcodec/decoder/mtk_vcodec_dec_drv.c | 3 +-
.../vcodec/encoder/mtk_vcodec_enc_drv.c | 3 +-
.../media/platform/nvidia/tegra-vde/v4l2.c | 3 +-
drivers/media/platform/nxp/dw100/dw100.c | 3 +-
.../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 3 +-
drivers/media/platform/nxp/imx-pxp.c | 3 +-
.../platform/nxp/imx8-isi/imx8-isi-m2m.c | 3 +-
drivers/media/platform/nxp/mx2_emmaprp.c | 3 +-
drivers/media/platform/qcom/iris/iris_vidc.c | 3 +-
drivers/media/platform/qcom/venus/vdec.c | 3 +-
drivers/media/platform/qcom/venus/venc.c | 3 +-
drivers/media/platform/renesas/rcar_fdp1.c | 3 +-
drivers/media/platform/renesas/rcar_jpu.c | 3 +-
.../media/platform/renesas/vsp1/vsp1_video.c | 4 +-
drivers/media/platform/rockchip/rga/rga.c | 3 +-
.../media/platform/rockchip/rkvdec/rkvdec.c | 3 +-
.../platform/samsung/exynos-gsc/gsc-m2m.c | 3 +-
.../platform/samsung/exynos4-is/fimc-m2m.c | 3 +-
drivers/media/platform/samsung/s5p-g2d/g2d.c | 3 +-
.../platform/samsung/s5p-jpeg/jpeg-core.c | 3 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc.c | 3 +-
.../media/platform/st/sti/bdisp/bdisp-v4l2.c | 3 +-
.../media/platform/st/sti/delta/delta-v4l2.c | 3 +-
drivers/media/platform/st/sti/hva/hva-v4l2.c | 3 +-
drivers/media/platform/st/stm32/dma2d/dma2d.c | 3 +-
.../media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +-
.../sunxi/sun8i-rotate/sun8i_rotate.c | 3 +-
drivers/media/platform/ti/omap3isp/ispvideo.c | 3 +-
drivers/media/platform/ti/vpe/vpe.c | 3 +-
.../media/platform/verisilicon/hantro_drv.c | 3 +-
.../media/test-drivers/vicodec/vicodec-core.c | 3 +-
drivers/media/test-drivers/vim2m.c | 3 +-
drivers/media/test-drivers/visl/visl-core.c | 3 +-
drivers/media/usb/hdpvr/hdpvr-video.c | 3 +-
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 3 +-
drivers/media/usb/uvc/uvc_v4l2.c | 3 +-
drivers/media/v4l2-core/v4l2-fh.c | 7 ++--
drivers/media/v4l2-core/v4l2-subdev.c | 3 +-
.../staging/media/imx/imx-media-csc-scaler.c | 3 +-
drivers/staging/media/meson/vdec/vdec.c | 3 +-
drivers/staging/media/sunxi/cedrus/cedrus.c | 3 +-
drivers/staging/most/video/video.c | 4 +-
drivers/usb/gadget/function/uvc_v4l2.c | 3 +-
include/media/v4l2-fh.h | 5 ++-
61 files changed, 89 insertions(+), 144 deletions(-)
diff --git a/Documentation/driver-api/media/v4l2-fh.rst b/Documentation/driver-api/media/v4l2-fh.rst
index 2c87b74578d9..a7393067f5db 100644
--- a/Documentation/driver-api/media/v4l2-fh.rst
+++ b/Documentation/driver-api/media/v4l2-fh.rst
@@ -11,25 +11,22 @@ data that is used by the V4L2 framework.
since it is also used to implement priority handling
(:ref:`VIDIOC_G_PRIORITY`).
-The users of :c:type:`v4l2_fh` (in the V4L2 framework, not the driver) know
-whether a driver uses :c:type:`v4l2_fh` as its ``file->private_data`` pointer
-by testing the ``V4L2_FL_USES_V4L2_FH`` bit in :c:type:`video_device`->flags.
-This bit is set whenever :c:func:`v4l2_fh_init` is called.
+struct v4l2_fh is allocated in the driver's ``open()`` file operation handler.
+It is typically embedded in a larger driver-specific structure. The
+:c:type:`v4l2_fh` must be initialized with a call to :c:func:`v4l2_fh_init`,
+and added to the video device with :c:func:`v4l2_fh_add`. This associates the
+:c:type:`v4l2_fh` with the :c:type:`file` by setting ``file->private_data`` to
+point to the :c:type:`v4l2_fh`.
-struct v4l2_fh is allocated as a part of the driver's own file handle
-structure and ``file->private_data`` is set to it in the driver's ``open()``
-function by the driver. The :c:type:`v4l2_fh` file handle can be retrieved
-from the :c:type:`file` using :c:func:`file_to_v4l2_fh`. Drivers must not
-access ``file->private_data`` directly.
+Similarly, the struct v4l2_fh is freed in the driver's ``release()`` file
+operation handler. It must be removed from the video device with
+:c:func:`v4l2_fh_del` and cleaned up with :c:func:`v4l2_fh_exit` before being
+freed.
-In many cases the struct v4l2_fh will be embedded in a larger
-structure. In that case you should call:
-
-#) :c:func:`v4l2_fh_init` and :c:func:`v4l2_fh_add` in ``open()``
-#) :c:func:`v4l2_fh_del` and :c:func:`v4l2_fh_exit` in ``release()``
-
-Drivers can extract their own file handle structure by using the container_of
-macro.
+Drivers must not access ``file->private_data`` directly. They can retrieve the
+:c:type:`v4l2_fh` associated with a :c:type:`file` by calling
+:c:func:`file_to_v4l2_fh`. Drivers can extract their own file handle structure
+by using the container_of macro.
Example:
@@ -58,8 +55,7 @@ Example:
...
- file->private_data = &my_fh->fh;
- v4l2_fh_add(&my_fh->fh);
+ v4l2_fh_add(&my_fh->fh, file);
return 0;
}
@@ -84,7 +80,7 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:
:c:type:`v4l2_file_operations`->open() handler.
:c:func:`v4l2_fh_add <v4l2_fh_add>`
-(:c:type:`fh <v4l2_fh>`)
+(:c:type:`fh <v4l2_fh>`, struct file \*filp)
- Add a :c:type:`v4l2_fh` to :c:type:`video_device` file handle list.
Must be called once the file handle is completely initialized.
@@ -138,6 +134,12 @@ associated device node:
- Same, but it calls v4l2_fh_is_singular with filp->private_data.
+.. note::
+ The V4L2 framework knows whether a driver uses :c:type:`v4l2_fh` as its
+ ``file->private_data`` pointer by testing the ``V4L2_FL_USES_V4L2_FH``
+ bit in :c:type:`video_device`->flags. This bit is set whenever
+ :c:func:`v4l2_fh_init` is called.
+
V4L2 fh functions and data structures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
index a9eb62fa1531..2d38ae17d940 100644
--- a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
+++ b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
@@ -812,8 +812,7 @@ int my_open(struct file *file)
...
- file->private_data = &my_fh->fh;
- v4l2_fh_add(&my_fh->fh);
+ v4l2_fh_add(&my_fh->fh, file);
return 0;
}
@@ -836,7 +835,7 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
初始化文件句柄。这*必须*在驱动的 v4l2_file_operations->open()
函数中执行。
-void v4l2_fh_add(struct v4l2_fh *fh)
+void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)
添加一个 v4l2_fh 到 video_device 文件句柄列表。一旦文件句柄
初始化完成就必须调用。
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index 89e38b303630..f90b547f5d67 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -743,8 +743,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
item->type = s->type;
item->open_id = cx->open_id++;
- filp->private_data = &item->fh;
- v4l2_fh_add(&item->fh);
+ v4l2_fh_add(&item->fh, filp);
if (item->type == CX18_ENC_STREAM_TYPE_RAD &&
v4l2_fh_is_singular_file(filp)) {
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index 67964a3c382c..aa5f5f16427c 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -998,9 +998,7 @@ static int ivtv_open(struct file *filp)
v4l2_fh_init(&item->fh, &s->vdev);
item->itv = itv;
item->type = s->type;
-
- filp->private_data = &item->fh;
- v4l2_fh_add(&item->fh);
+ v4l2_fh_add(&item->fh, filp);
if (item->type == IVTV_ENC_STREAM_TYPE_RAD &&
v4l2_fh_is_singular_file(filp)) {
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index 296f50b6b8d3..e6e353a251cf 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -725,8 +725,7 @@ static int fops_open(struct file *file)
fh->port = port;
v4l2_fh_init(&fh->fh, video_devdata(file));
- v4l2_fh_add(&fh->fh);
- file->private_data = &fh->fh;
+ v4l2_fh_add(&fh->fh, file);
return 0;
}
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index a7e398f30472..181442fcb43b 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -428,8 +428,7 @@ static int fops_open(struct file *file)
fh->port = port;
v4l2_fh_init(&fh->fh, video_devdata(file));
- v4l2_fh_add(&fh->fh);
- file->private_data = &fh->fh;
+ v4l2_fh_add(&fh->fh, file);
return 0;
}
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index 74977f3ae484..8c30f3cd4fc5 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3219,8 +3219,7 @@ static int allegro_open(struct file *file)
}
list_add(&channel->list, &dev->channels);
- file->private_data = &channel->fh;
- v4l2_fh_add(&channel->fh);
+ v4l2_fh_add(&channel->fh, file);
allegro_channel_adjust(channel);
diff --git a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
index c7df29a2d820..d36891b546bc 100644
--- a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
+++ b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
@@ -860,8 +860,7 @@ static int ge2d_open(struct file *file)
return ret;
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ge2d_setup_ctrls(ctx);
diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
index 57ca6262bb04..e13bfe09af1b 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.c
+++ b/drivers/media/platform/amphion/vpu_v4l2.c
@@ -760,7 +760,7 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
inst->min_buffer_cap = 2;
inst->min_buffer_out = 2;
v4l2_fh_init(&inst->fh, func->vfd);
- v4l2_fh_add(&inst->fh);
+ v4l2_fh_add(&inst->fh, file);
ret = call_vop(inst, ctrl_init);
if (ret)
@@ -774,7 +774,6 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
}
inst->fh.ctrl_handler = &inst->ctrl_handler;
- file->private_data = &inst->fh;
inst->state = VPU_CODEC_STATE_DEINIT;
inst->workqueue = alloc_ordered_workqueue("vpu_inst", WQ_MEM_RECLAIM);
if (inst->workqueue) {
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index 459b59149390..7d874fd502b8 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -2642,8 +2642,7 @@ static int coda_open(struct file *file)
if (ctx->ops->seq_end_work)
INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->dev = dev;
ctx->idx = idx;
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index f3188d720ed3..88eb933a5144 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1761,8 +1761,7 @@ static int wave5_vpu_open_dec(struct file *filp)
return -ENOMEM;
v4l2_fh_init(&inst->v4l2_fh, vdev);
- filp->private_data = &inst->v4l2_fh;
- v4l2_fh_add(&inst->v4l2_fh);
+ v4l2_fh_add(&inst->v4l2_fh, filp);
INIT_LIST_HEAD(&inst->list);
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
index b69a1206fa12..322c1498758a 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
@@ -1587,8 +1587,7 @@ static int wave5_vpu_open_enc(struct file *filp)
return -ENOMEM;
v4l2_fh_init(&inst->v4l2_fh, vdev);
- filp->private_data = &inst->v4l2_fh;
- v4l2_fh_add(&inst->v4l2_fh);
+ v4l2_fh_add(&inst->v4l2_fh, filp);
INIT_LIST_HEAD(&inst->list);
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index 295461325862..1da00ff4b1e3 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -742,8 +742,7 @@ static int e5010_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, vdev);
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->e5010 = e5010;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(e5010->m2m_dev, ctx, queue_init);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 1812c07837ad..a343dffd19f0 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -847,7 +847,6 @@ static int deinterlace_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = pcdev;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
@@ -866,7 +865,7 @@ static int deinterlace_open(struct file *file)
}
ctx->colorspace = V4L2_COLORSPACE_REC709;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n",
ctx, ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index 3a7a6eb53d89..5178a1b170fe 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -1176,8 +1176,7 @@ static int mtk_jpeg_open(struct file *file)
INIT_LIST_HEAD(&ctx->dst_done_queue);
spin_lock_init(&ctx->done_queue_lock);
v4l2_fh_init(&ctx->fh, vfd);
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->jpeg = jpeg;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx,
diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
index 2d894b5bfaa7..7a1a8e51dbca 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
@@ -1070,14 +1070,13 @@ static int mtk_mdp_m2m_open(struct file *file)
mutex_init(&ctx->slock);
ctx->id = mdp->id_counter++;
v4l2_fh_init(&ctx->fh, vfd);
- file->private_data = &ctx->fh;
ret = mtk_mdp_ctrls_create(ctx);
if (ret)
goto error_ctrls;
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
INIT_LIST_HEAD(&ctx->list);
ctx->mdp_dev = mdp;
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index 886ff25c70eb..847d6b310e74 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -590,14 +590,13 @@ static int mdp_m2m_open(struct file *file)
ctx->mdp_dev = mdp;
v4l2_fh_init(&ctx->fh, vdev);
- file->private_data = &ctx->fh;
ret = mdp_m2m_ctrls_create(ctx);
if (ret)
goto err_exit_fh;
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
mutex_init(&ctx->ctx_lock);
ctx->m2m_ctx = v4l2_m2m_ctx_init(mdp->m2m_dev, ctx, mdp_m2m_queue_init);
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
index 18801883c31a..952a77c383bd 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
@@ -206,8 +206,7 @@ static int fops_vcodec_open(struct file *file)
mutex_lock(&dev->dev_mutex);
ctx->id = dev->id_counter++;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
INIT_LIST_HEAD(&ctx->list);
ctx->dev = dev;
if (ctx->dev->vdec_pdata->is_subdev_supported) {
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
index e26a6c3ffa0c..9cacb6cbcf28 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
@@ -129,8 +129,7 @@ static int fops_vcodec_open(struct file *file)
*/
ctx->id = dev->id_counter++;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
INIT_LIST_HEAD(&ctx->list);
ctx->dev = dev;
init_waitqueue_head(&ctx->queue[0]);
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index 393dc3f07d5c..688b776b3010 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -832,8 +832,7 @@ static int tegra_open(struct file *file)
goto free_ctrls;
}
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
tegra_reset_coded_fmt(ctx);
tegra_try_coded_fmt(file, &ctx->fh, &ctx->coded_fmt);
diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c
index 2460f09a6813..2bd30910ddf9 100644
--- a/drivers/media/platform/nxp/dw100/dw100.c
+++ b/drivers/media/platform/nxp/dw100/dw100.c
@@ -607,7 +607,6 @@ static int dw100_open(struct file *file)
mutex_init(&ctx->vq_mutex);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dw_dev = dw_dev;
ctx->q_data[DW100_QUEUE_SRC].fmt = &formats[0];
@@ -651,7 +650,7 @@ static int dw100_open(struct file *file)
goto err;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
return 0;
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index 8eef7ebd0428..d7cecc56a9eb 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -2205,8 +2205,7 @@ static int mxc_jpeg_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, mxc_vfd);
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->mxc_jpeg = mxc_jpeg;
diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index 879b1803a2b3..9602409f3ece 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -1660,7 +1660,6 @@ static int pxp_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
hdl = &ctx->hdl;
v4l2_ctrl_handler_init(hdl, 4);
@@ -1699,7 +1698,7 @@ static int pxp_open(struct file *file)
goto open_unlock;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
atomic_inc(&dev->num_inst);
dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
index 6444392c5e62..d6df6e2725f5 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -673,7 +673,6 @@ static int mxc_isi_m2m_open(struct file *file)
mutex_init(&ctx->vb2_lock);
v4l2_fh_init(&ctx->fh, vdev);
- file->private_data = &ctx->fh;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(m2m->m2m_dev, ctx,
&mxc_isi_m2m_queue_init);
@@ -694,7 +693,7 @@ static int mxc_isi_m2m_open(struct file *file)
if (ret)
goto err_ctrls;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
return 0;
diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.c
index 5c8c6285ec1e..8c8f834e6250 100644
--- a/drivers/media/platform/nxp/mx2_emmaprp.c
+++ b/drivers/media/platform/nxp/mx2_emmaprp.c
@@ -730,7 +730,6 @@ static int emmaprp_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = pcdev;
if (mutex_lock_interruptible(&pcdev->dev_mutex)) {
@@ -752,7 +751,7 @@ static int emmaprp_open(struct file *file)
clk_prepare_enable(pcdev->clk_emma_ahb);
ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1];
ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
mutex_unlock(&pcdev->dev_mutex);
dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 64ebec2ca6b3..cdd34a3b71ff 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -25,8 +25,7 @@ static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)
{
v4l2_fh_init(&inst->fh, inst->core->vdev_dec);
inst->fh.ctrl_handler = &inst->ctrl_handler;
- v4l2_fh_add(&inst->fh);
- filp->private_data = &inst->fh;
+ v4l2_fh_add(&inst->fh, filp);
}
static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index d10ca6d89f6d..55c27345b7d8 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -1732,9 +1732,8 @@ static int vdec_open(struct file *file)
v4l2_fh_init(&inst->fh, core->vdev_dec);
inst->fh.ctrl_handler = &inst->ctrl_handler;
- v4l2_fh_add(&inst->fh);
+ v4l2_fh_add(&inst->fh, file);
inst->fh.m2m_ctx = inst->m2m_ctx;
- file->private_data = &inst->fh;
return 0;
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 0838d64ce8fe..fba07557a399 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1515,9 +1515,8 @@ static int venc_open(struct file *file)
v4l2_fh_init(&inst->fh, core->vdev_enc);
inst->fh.ctrl_handler = &inst->ctrl_handler;
- v4l2_fh_add(&inst->fh);
+ v4l2_fh_add(&inst->fh, file);
inst->fh.m2m_ctx = inst->m2m_ctx;
- file->private_data = &inst->fh;
return 0;
diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
index 12a5dcc0ca6c..f1ea303ac038 100644
--- a/drivers/media/platform/renesas/rcar_fdp1.c
+++ b/drivers/media/platform/renesas/rcar_fdp1.c
@@ -2093,7 +2093,6 @@ static int fdp1_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->fdp1 = fdp1;
/* Initialise Queues */
@@ -2142,7 +2141,7 @@ static int fdp1_open(struct file *file)
if (ret < 0)
goto error_pm;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n",
ctx, ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
index 7d5e9df53dfb..d0d4ee3f8bdc 100644
--- a/drivers/media/platform/renesas/rcar_jpu.c
+++ b/drivers/media/platform/renesas/rcar_jpu.c
@@ -1231,8 +1231,7 @@ static int jpu_open(struct file *file)
v4l2_fh_init(&ctx->fh, vfd);
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->jpu = jpu;
ctx->encoder = vfd == &jpu->vfd_encoder;
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c
index 656fb5e6cb30..b6dc1ee3dc50 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_video.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c
@@ -1079,9 +1079,7 @@ static int vsp1_video_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(vfh, &video->video);
- v4l2_fh_add(vfh);
-
- file->private_data = vfh;
+ v4l2_fh_add(vfh, file);
ret = vsp1_device_get(video->vsp1);
if (ret < 0) {
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 8a6e618d605c..d88817023996 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -395,8 +395,7 @@ static int rga_open(struct file *file)
return ret;
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
rga_setup_ctrls(ctx);
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 41ab90cbcc0c..2fbad685e92c 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -938,8 +938,7 @@ static int rkvdec_open(struct file *filp)
if (ret)
goto err_cleanup_m2m_ctx;
- filp->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, filp);
return 0;
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
index 968bb4327b7a..39d84ffd1b05 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
@@ -625,8 +625,7 @@ static int gsc_m2m_open(struct file *file)
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->gsc_dev = gsc;
/* Default color format */
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
index feedf60dad09..b002b02a899e 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
@@ -634,8 +634,7 @@ static int fimc_m2m_open(struct file *file)
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrls.handler;
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
/* Setup the device context for memory-to-memory mode */
ctx->state = FIMC_CTX_M2M;
diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
index 44fcedbbc90a..e34cae9c9cf6 100644
--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
@@ -257,8 +257,7 @@ static int g2d_open(struct file *file)
return ret;
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
g2d_setup_ctrls(ctx);
diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
index a5ecfe03db09..9e35dd939ad7 100644
--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
@@ -970,8 +970,7 @@ static int s5p_jpeg_open(struct file *file)
v4l2_fh_init(&ctx->fh, vfd);
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->jpeg = jpeg;
if (vfd == jpeg->vfd_encoder) {
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index dd9761df59df..74629db05121 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -801,8 +801,7 @@ static int s5p_mfc_open(struct file *file)
}
init_waitqueue_head(&ctx->queue);
v4l2_fh_init(&ctx->fh, vdev);
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->dev = dev;
INIT_LIST_HEAD(&ctx->src_queue);
INIT_LIST_HEAD(&ctx->dst_queue);
diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
index f3844e4e47ca..5e983799e298 100644
--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
@@ -608,8 +608,7 @@ static int bdisp_open(struct file *file)
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
/* Default format */
ctx->src = bdisp_dflt_fmt;
diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.c
index a12fdbd8abed..3063a98ed25b 100644
--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c
@@ -1639,8 +1639,7 @@ static int delta_open(struct file *file)
ctx->dev = delta;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
INIT_WORK(&ctx->run_work, delta_run_work);
mutex_init(&ctx->lock);
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c
index 29142c806cb7..2f9413fa7318 100644
--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c
@@ -1174,8 +1174,7 @@ static int hva_open(struct file *file)
INIT_WORK(&ctx->run_work, hva_run_work);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ret = hva_ctrls_setup(ctx);
if (ret) {
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index f4c5d73447a7..b2bced06a1e6 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -304,8 +304,7 @@ static int dma2d_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
dma2d_setup_ctrls(ctx);
diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index e9c7c99fbc55..7823eb97faf7 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -730,7 +730,6 @@ static int deinterlace_open(struct file *file)
deinterlace_prepare_format(&ctx->dst_fmt);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
@@ -740,7 +739,7 @@ static int deinterlace_open(struct file *file)
goto err_free;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
mutex_unlock(&dev->dev_mutex);
diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
index 9ea65cb7187f..368a858b8c0f 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -659,7 +659,6 @@ static int rotate_open(struct file *file)
rotate_set_cap_format(ctx, &ctx->dst_fmt, ctx->rotate);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx,
@@ -669,7 +668,7 @@ static int rotate_open(struct file *file)
goto err_free;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ret = rotate_setup_ctrls(ctx);
if (ret)
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
index b76d40aeca17..d10a2b96c13c 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -1297,7 +1297,7 @@ static int isp_video_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(&handle->vfh, &video->video);
- v4l2_fh_add(&handle->vfh);
+ v4l2_fh_add(&handle->vfh, file);
/* If this is the first user, initialise the pipeline. */
if (omap3isp_get(video->isp) == NULL) {
@@ -1333,7 +1333,6 @@ static int isp_video_open(struct file *file)
handle->timeperframe.denominator = 1;
handle->video = video;
- file->private_data = &handle->vfh;
done:
if (ret < 0) {
diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
index 4b9b2bec7377..a47c5d31c475 100644
--- a/drivers/media/platform/ti/vpe/vpe.c
+++ b/drivers/media/platform/ti/vpe/vpe.c
@@ -2310,7 +2310,6 @@ static int vpe_open(struct file *file)
init_adb_hdrs(ctx);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
hdl = &ctx->hdl;
v4l2_ctrl_handler_init(hdl, 1);
@@ -2364,7 +2363,7 @@ static int vpe_open(struct file *file)
goto exit_fh;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
/*
* for now, just report the creation of the first instance, we can later
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index b20b9c7f4131..aadc3d8fb3d1 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -663,8 +663,7 @@ static int hantro_open(struct file *filp)
}
v4l2_fh_init(&ctx->fh, vdev);
- filp->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, filp);
hantro_reset_fmts(ctx);
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
index e27f6761cba1..f20d9d9643f5 100644
--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
@@ -1848,7 +1848,6 @@ static int vicodec_open(struct file *file)
ctx->is_stateless = true;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
hdl = &ctx->hdl;
v4l2_ctrl_handler_init(hdl, 5);
@@ -1932,7 +1931,7 @@ static int vicodec_open(struct file *file)
goto open_unlock;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
open_unlock:
mutex_unlock(vfd->lock);
diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
index 55d885be5bcc..24574025f58f 100644
--- a/drivers/media/test-drivers/vim2m.c
+++ b/drivers/media/test-drivers/vim2m.c
@@ -1389,7 +1389,6 @@ static int vim2m_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
hdl = &ctx->hdl;
v4l2_ctrl_handler_init(hdl, 4);
@@ -1433,7 +1432,7 @@ static int vim2m_open(struct file *file)
goto open_unlock;
}
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
atomic_inc(&dev->num_inst);
dprintk(dev, 1, "Created instance: %p, m2m_ctx: %p\n",
diff --git a/drivers/media/test-drivers/visl/visl-core.c b/drivers/media/test-drivers/visl/visl-core.c
index 5bf3136b36eb..0f43ec23f40b 100644
--- a/drivers/media/test-drivers/visl/visl-core.c
+++ b/drivers/media/test-drivers/visl/visl-core.c
@@ -341,7 +341,6 @@ static int visl_open(struct file *file)
ctx->tpg_str_buf = kzalloc(TPG_STR_BUF_SZ, GFP_KERNEL);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
rc = visl_init_ctrls(ctx);
@@ -361,7 +360,7 @@ static int visl_open(struct file *file)
if (rc)
goto free_m2m_ctx;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
dprintk(dev, "Created instance: %p, m2m_ctx: %p\n",
ctx, ctx->fh.m2m_ctx);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index ea17f1a5f5b0..6c6e467f8554 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -380,8 +380,7 @@ static int hdpvr_open(struct file *file)
return -ENOMEM;
fh->legacy_mode = true;
v4l2_fh_init(&fh->fh, video_devdata(file));
- v4l2_fh_add(&fh->fh);
- file->private_data = &fh->fh;
+ v4l2_fh_add(&fh->fh, file);
return 0;
}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 481b03bbecf8..04c77af0c51e 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -1003,10 +1003,9 @@ static int pvr2_v4l2_open(struct file *file)
}
fhp->file = file;
- file->private_data = &fhp->fh;
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
- v4l2_fh_add(&fhp->fh);
+ v4l2_fh_add(&fhp->fh, file);
return 0;
}
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 6dd329a972fd..09677ed639ae 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -600,10 +600,9 @@ static int uvc_v4l2_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(&handle->vfh, &stream->vdev);
- v4l2_fh_add(&handle->vfh);
+ v4l2_fh_add(&handle->vfh, file);
handle->chain = stream->chain;
handle->stream = stream;
- file->private_data = &handle->vfh;
return 0;
}
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index 7a5f7aa5e253..b59b1084d8cd 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -41,10 +41,12 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
}
EXPORT_SYMBOL_GPL(v4l2_fh_init);
-void v4l2_fh_add(struct v4l2_fh *fh)
+void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)
{
unsigned long flags;
+ filp->private_data = fh;
+
v4l2_prio_open(fh->vdev->prio, &fh->prio);
spin_lock_irqsave(&fh->vdev->fh_lock, flags);
list_add(&fh->list, &fh->vdev->fh_list);
@@ -57,11 +59,10 @@ int v4l2_fh_open(struct file *filp)
struct video_device *vdev = video_devdata(filp);
struct v4l2_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL);
- filp->private_data = fh;
if (fh == NULL)
return -ENOMEM;
v4l2_fh_init(fh, vdev);
- v4l2_fh_add(fh);
+ v4l2_fh_add(fh, filp);
return 0;
}
EXPORT_SYMBOL_GPL(v4l2_fh_open);
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 29d3b788b288..bf35ac436249 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -86,8 +86,7 @@ static int subdev_open(struct file *file)
}
v4l2_fh_init(&subdev_fh->vfh, vdev);
- v4l2_fh_add(&subdev_fh->vfh);
- file->private_data = &subdev_fh->vfh;
+ v4l2_fh_add(&subdev_fh->vfh, file);
if (sd->v4l2_dev->mdev && sd->entity.graph_obj.mdev->dev) {
struct module *owner;
diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index fb67b383436d..7fedb33dda34 100644
--- a/drivers/staging/media/imx/imx-media-csc-scaler.c
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -765,8 +765,7 @@ static int ipu_csc_scaler_open(struct file *file)
ctx->rot_mode = IPU_ROTATE_NONE;
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
ctx->priv = priv;
ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(priv->m2m_dev, ctx,
diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
index f1ee53f9f298..b92666ff50a1 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -908,9 +908,8 @@ static int vdec_open(struct file *file)
v4l2_fh_init(&sess->fh, core->vdev_dec);
sess->fh.ctrl_handler = &sess->ctrl_handler;
- v4l2_fh_add(&sess->fh);
+ v4l2_fh_add(&sess->fh, file);
sess->fh.m2m_ctx = sess->m2m_ctx;
- file->private_data = &sess->fh;
return 0;
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 80b43187f6ee..ebefd646dbdb 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -366,7 +366,6 @@ static int cedrus_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = &ctx->fh;
ctx->dev = dev;
ctx->bit_depth = 8;
@@ -383,7 +382,7 @@ static int cedrus_open(struct file *file)
if (ret)
goto err_m2m_release;
- v4l2_fh_add(&ctx->fh);
+ v4l2_fh_add(&ctx->fh, file);
mutex_unlock(&dev->dev_mutex);
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 116331cead2a..24a68e3e5419 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -96,9 +96,7 @@ static int comp_vdev_open(struct file *filp)
fh->mdev = mdev;
v4l2_fh_init(&fh->fh, vdev);
- filp->private_data = &fh->fh;
-
- v4l2_fh_add(&fh->fh);
+ v4l2_fh_add(&fh->fh, filp);
ret = most_start_channel(mdev->iface, mdev->ch_idx, &comp);
if (ret) {
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 886300a29b90..680f25d17dc2 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -672,10 +672,9 @@ uvc_v4l2_open(struct file *file)
return -ENOMEM;
v4l2_fh_init(&handle->vfh, vdev);
- v4l2_fh_add(&handle->vfh);
+ v4l2_fh_add(&handle->vfh, file);
handle->device = &uvc->video;
- file->private_data = &handle->vfh;
return 0;
}
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 14e7136e693f..d8fcf49f10e0 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -87,11 +87,14 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev);
* v4l2_fh_add - Add the fh to the list of file handles on a video_device.
*
* @fh: pointer to &struct v4l2_fh
+ * @filp: pointer to &struct file associated with @fh
+ *
+ * The function sets filp->private_data to point to @fh.
*
* .. note::
* The @fh file handle must be initialised first.
*/
-void v4l2_fh_add(struct v4l2_fh *fh);
+void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp);
/**
* v4l2_fh_open - Ancillary routine that can be used as the open\(\) op
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v3 27/76] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
` (7 preceding siblings ...)
2025-08-10 1:30 ` [PATCH v3 26/76] media: Set file->private_data in v4l2_fh_add() Laurent Pinchart
@ 2025-08-10 1:30 ` Laurent Pinchart
8 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2025-08-10 1:30 UTC (permalink / raw)
To: linux-media
Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Alex Shi,
Yanteng Si, Dongliang Mu, Jonathan Corbet, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Ming Qian,
Zhou Peng, Philipp Zabel, Nas Chung, Jackson Lee, Devarsh Thakkar,
Bin Liu, Matthias Brugger, AngeloGioacchino Del Regno,
Minghsiu Tsai, Houlong Wei, Andrew-CT Chen, Tiffany Lin,
Yunfei Dong, Dmitry Osipenko, Thierry Reding, Jonathan Hunter,
Xavier Roumegue, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Kieran Bingham, Geert Uytterhoeven,
Magnus Damm, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Marek Szyprowski, Andrzej Hajda,
Fabien Dessenne, Hugues Fruchet, Jean-Christophe Trotin,
Maxime Coquelin, Alexandre Torgue, Jernej Skrabec, Chen-Yu Tsai,
Samuel Holland, Benoit Parrot, Nicolas Dufresne,
Benjamin Gaignard, Hans Verkuil, Daniel Almeida, Mike Isely,
Steve Longerbeam, Greg Kroah-Hartman, Maxime Ripard,
Paul Kocialkowski, Parthiban Veerasooran, Christian Gromm,
Ariel Otilibili, Uwe Kleine-König, Jiasheng Jiang,
Sakari Ailus, Matthew Majewski, Shuah Khan, Tomi Valkeinen,
Lad Prabhakar, Tommaso Merciai, Michael Grzeschik,
Abhishek Tamboli, Akash Kumar, linux-doc, linux-amlogic,
linux-arm-kernel, linux-mediatek, linux-tegra, imx, linux-arm-msm,
linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-stm32,
linux-sunxi, linux-staging, linux-usb
Multiple drivers that use v4l2_fh and call v4l2_fh_del() manually reset
the file->private_data pointer to NULL in their video device .release()
file operation handler. Move the code to the v4l2_fh_del() 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 release;
type ret;
@@
ret release(..., struct file *filp, ...)
{
<...
- filp->private_data = NULL;
...
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
...>
}
@@
expression fh;
identifier filp;
identifier release;
type ret;
@@
ret release(..., struct file *filp, ...)
{
<...
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
...
- filp->private_data = NULL;
...>
}
@@
expression fh;
identifier filp;
identifier release;
type ret;
@@
ret release(..., struct file *filp, ...)
{
<...
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
...>
}
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_del() prototype and reset file->private_data, and to
include/media/v4l2-fh.h to update the v4l2_fh_del() function prototype
and its documentation.
Additionally, white space issues have been fixed manually in
drivers/usb/gadget/function/uvc_v4l2.c
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
.../translations/zh_CN/video4linux/v4l2-framework.txt | 4 ++--
drivers/media/pci/cx18/cx18-fileops.c | 4 ++--
drivers/media/pci/ivtv/ivtv-fileops.c | 4 ++--
drivers/media/pci/saa7164/saa7164-encoder.c | 2 +-
drivers/media/pci/saa7164/saa7164-vbi.c | 2 +-
drivers/media/platform/allegro-dvt/allegro-core.c | 2 +-
drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 2 +-
drivers/media/platform/amphion/vpu_v4l2.c | 4 ++--
drivers/media/platform/chips-media/coda/coda-common.c | 4 ++--
drivers/media/platform/chips-media/wave5/wave5-helper.c | 2 +-
drivers/media/platform/imagination/e5010-jpeg-enc.c | 4 ++--
drivers/media/platform/m2m-deinterlace.c | 2 +-
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 4 ++--
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 4 ++--
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 4 ++--
.../platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
.../platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 4 ++--
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 2 +-
drivers/media/platform/nxp/dw100/dw100.c | 2 +-
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 4 ++--
drivers/media/platform/nxp/imx-pxp.c | 2 +-
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 2 +-
drivers/media/platform/nxp/mx2_emmaprp.c | 2 +-
drivers/media/platform/qcom/iris/iris_vidc.c | 3 +--
drivers/media/platform/qcom/venus/core.c | 2 +-
drivers/media/platform/renesas/rcar_fdp1.c | 2 +-
drivers/media/platform/renesas/rcar_jpu.c | 4 ++--
drivers/media/platform/renesas/vsp1/vsp1_video.c | 2 +-
drivers/media/platform/rockchip/rga/rga.c | 2 +-
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c | 4 ++--
drivers/media/platform/samsung/exynos4-is/fimc-m2m.c | 4 ++--
drivers/media/platform/samsung/s5p-g2d/g2d.c | 2 +-
drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 4 ++--
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 4 ++--
drivers/media/platform/st/sti/delta/delta-v4l2.c | 4 ++--
drivers/media/platform/st/sti/hva/hva-v4l2.c | 4 ++--
drivers/media/platform/st/stm32/dma2d/dma2d.c | 2 +-
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 2 +-
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c | 2 +-
drivers/media/platform/ti/omap3isp/ispvideo.c | 5 ++---
drivers/media/platform/ti/vpe/vpe.c | 2 +-
drivers/media/platform/verisilicon/hantro_drv.c | 4 ++--
drivers/media/test-drivers/vicodec/vicodec-core.c | 2 +-
drivers/media/test-drivers/vim2m.c | 2 +-
drivers/media/test-drivers/visl/visl-core.c | 2 +-
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 3 +--
drivers/media/v4l2-core/v4l2-fh.c | 7 ++++---
drivers/media/v4l2-core/v4l2-subdev.c | 5 ++---
drivers/staging/media/imx/imx-media-csc-scaler.c | 4 ++--
drivers/staging/media/meson/vdec/vdec.c | 2 +-
drivers/staging/media/sunxi/cedrus/cedrus.c | 2 +-
drivers/staging/most/video/video.c | 4 ++--
drivers/usb/gadget/function/uvc_v4l2.c | 3 +--
include/media/v4l2-fh.h | 5 ++++-
57 files changed, 89 insertions(+), 90 deletions(-)
diff --git a/Documentation/driver-api/media/v4l2-fh.rst b/Documentation/driver-api/media/v4l2-fh.rst
index a7393067f5db..afcad22ead7c 100644
--- a/Documentation/driver-api/media/v4l2-fh.rst
+++ b/Documentation/driver-api/media/v4l2-fh.rst
@@ -65,7 +65,7 @@ Example:
struct my_fh *my_fh = container_of(fh, struct my_fh, fh);
...
- v4l2_fh_del(&my_fh->fh);
+ v4l2_fh_del(&my_fh->fh, file);
v4l2_fh_exit(&my_fh->fh);
kfree(my_fh);
return 0;
@@ -86,7 +86,7 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:
Must be called once the file handle is completely initialized.
:c:func:`v4l2_fh_del <v4l2_fh_del>`
-(:c:type:`fh <v4l2_fh>`)
+(:c:type:`fh <v4l2_fh>`, struct file \*filp)
- Unassociate the file handle from :c:type:`video_device`. The file handle
exit function may now be called.
diff --git a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
index 2d38ae17d940..1653c6e2cb46 100644
--- a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
+++ b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
@@ -822,7 +822,7 @@ int my_release(struct file *file)
struct my_fh *my_fh = container_of(fh, struct my_fh, fh);
...
- v4l2_fh_del(&my_fh->fh);
+ v4l2_fh_del(&my_fh->fh, file);
v4l2_fh_exit(&my_fh->fh);
kfree(my_fh);
return 0;
@@ -840,7 +840,7 @@ void v4l2_fh_add(struct v4l2_fh *fh, struct file *filp)
添加一个 v4l2_fh 到 video_device 文件句柄列表。一旦文件句柄
初始化完成就必须调用。
-void v4l2_fh_del(struct v4l2_fh *fh)
+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp)
从 video_device() 中解除文件句柄的关联。文件句柄的退出函数也
将被调用。
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index f90b547f5d67..d49fa4c4119b 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -713,7 +713,7 @@ int cx18_v4l2_close(struct file *filp)
vb2_queue_release(vdev->queue);
vdev->queue->owner = NULL;
}
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
v4l2_fh_exit(fh);
/* 'Unclaim' this stream */
@@ -751,7 +751,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
if (atomic_read(&cx->ana_capturing) > 0) {
/* switching to radio while capture is
in progress is not polite */
- v4l2_fh_del(&item->fh);
+ v4l2_fh_del(&item->fh, filp);
v4l2_fh_exit(&item->fh);
kfree(item);
return -EBUSY;
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index aa5f5f16427c..0040a5e7f654 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -911,7 +911,7 @@ int ivtv_v4l2_close(struct file *filp)
ivtv_unmute(itv);
}
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
v4l2_fh_exit(fh);
/* Easy case first: this stream was never claimed by us */
@@ -1006,7 +1006,7 @@ static int ivtv_open(struct file *filp)
if (atomic_read(&itv->capturing) > 0) {
/* switching to radio while capture is
in progress is not polite */
- v4l2_fh_del(&item->fh);
+ v4l2_fh_del(&item->fh, filp);
v4l2_fh_exit(&item->fh);
kfree(item);
return -EBUSY;
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index e6e353a251cf..66d650b5f69a 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -746,7 +746,7 @@ static int fops_release(struct file *file)
}
}
- v4l2_fh_del(&fh->fh);
+ v4l2_fh_del(&fh->fh, file);
v4l2_fh_exit(&fh->fh);
kfree(fh);
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index 181442fcb43b..57e4362c0d19 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -449,7 +449,7 @@ static int fops_release(struct file *file)
}
}
- v4l2_fh_del(&fh->fh);
+ v4l2_fh_del(&fh->fh, file);
v4l2_fh_exit(&fh->fh);
kfree(fh);
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index 8c30f3cd4fc5..5e3b1f5d7206 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3241,7 +3241,7 @@ static int allegro_release(struct file *file)
v4l2_ctrl_handler_free(&channel->ctrl_handler);
- v4l2_fh_del(&channel->fh);
+ v4l2_fh_del(&channel->fh, file);
v4l2_fh_exit(&channel->fh);
kfree(channel);
diff --git a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
index d36891b546bc..b1b0b6535fb1 100644
--- a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
+++ b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
@@ -883,7 +883,7 @@ static int ge2d_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
index e13bfe09af1b..fcb2eff813ac 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.c
+++ b/drivers/media/platform/amphion/vpu_v4l2.c
@@ -791,7 +791,7 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
return 0;
error:
- v4l2_fh_del(&inst->fh);
+ v4l2_fh_del(&inst->fh, file);
v4l2_fh_exit(&inst->fh);
vpu_inst_put(inst);
return ret;
@@ -812,7 +812,7 @@ int vpu_v4l2_close(struct file *file)
call_void_vop(inst, release);
vpu_inst_unlock(inst);
- v4l2_fh_del(&inst->fh);
+ v4l2_fh_del(&inst->fh, file);
v4l2_fh_exit(&inst->fh);
vpu_inst_unregister(inst);
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index 7d874fd502b8..583759eed610 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -2725,7 +2725,7 @@ static int coda_open(struct file *file)
err_clk_enable:
pm_runtime_put_sync(dev->dev);
err_pm_get:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
err_coda_name_init:
ida_free(&dev->ida, ctx->idx);
@@ -2763,7 +2763,7 @@ static int coda_release(struct file *file)
clk_disable_unprepare(dev->clk_ahb);
clk_disable_unprepare(dev->clk_per);
pm_runtime_put_sync(dev->dev);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
ida_free(&dev->ida, ctx->idx);
if (ctx->ops->release)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.c
index ed8ff04a899d..0bce62f0c039 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-helper.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c
@@ -46,7 +46,7 @@ void wave5_cleanup_instance(struct vpu_instance *inst, struct file *filp)
wave5_vdi_free_dma_memory(inst->dev, &inst->bitstream_vbuf);
v4l2_ctrl_handler_free(&inst->v4l2_ctrl_hdl);
if (inst->v4l2_fh.vdev) {
- v4l2_fh_del(&inst->v4l2_fh);
+ v4l2_fh_del(&inst->v4l2_fh, filp);
v4l2_fh_exit(&inst->v4l2_fh);
}
list_del_init(&inst->list);
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index 1da00ff4b1e3..c4e0097cb8b7 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -769,7 +769,7 @@ static int e5010_open(struct file *file)
err_ctrls_setup:
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
exit:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&e5010->mutex);
free:
@@ -786,7 +786,7 @@ static int e5010_release(struct file *file)
mutex_lock(&e5010->mutex);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&e5010->mutex);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index a343dffd19f0..51c2f206cb1f 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -880,7 +880,7 @@ static int deinterlace_release(struct file *file)
dprintk(pcdev, "Releasing instance %p\n", ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
kfree(ctx->xt);
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index 5178a1b170fe..de15d6f0b490 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -1201,7 +1201,7 @@ static int mtk_jpeg_open(struct file *file)
return 0;
error:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&jpeg->lock);
free:
@@ -1217,7 +1217,7 @@ static int mtk_jpeg_release(struct file *file)
mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&jpeg->lock);
diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
index 7a1a8e51dbca..7e89a8443707 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
@@ -1130,7 +1130,7 @@ static int mtk_mdp_m2m_open(struct file *file)
error_m2m_ctx:
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
error_ctrls:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&mdp->lock);
err_lock:
@@ -1148,7 +1148,7 @@ static int mtk_mdp_m2m_release(struct file *file)
mutex_lock(&mdp->lock);
v4l2_m2m_ctx_release(ctx->m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mtk_mdp_vpu_deinit(&ctx->vpu);
mdp->ctx_num--;
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index 847d6b310e74..e68ae19d71a9 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -633,7 +633,7 @@ static int mdp_m2m_open(struct file *file)
v4l2_m2m_ctx_release(ctx->m2m_ctx);
err_release_handler:
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
err_exit_fh:
v4l2_fh_exit(&ctx->fh);
ida_free(&mdp->mdp_ida, ctx->id);
@@ -657,7 +657,7 @@ static int mdp_m2m_release(struct file *file)
mdp_vpu_put_locked(mdp);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
ida_free(&mdp->mdp_ida, ctx->id);
mutex_unlock(&mdp->m2m_lock);
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
index 952a77c383bd..46d176e6de63 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c
@@ -282,7 +282,7 @@ static int fops_vcodec_open(struct file *file)
err_m2m_ctx_init:
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
err_ctrls_setup:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&dev->dev_mutex);
@@ -307,7 +307,7 @@ static int fops_vcodec_release(struct file *file)
v4l2_m2m_ctx_release(ctx->m2m_ctx);
mtk_vcodec_dec_release(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
index 9cacb6cbcf28..fb1c3bdc2dae 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c
@@ -191,7 +191,7 @@ static int fops_vcodec_open(struct file *file)
err_m2m_ctx_init:
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
err_ctrls_setup:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&dev->dev_mutex);
@@ -209,7 +209,7 @@ static int fops_vcodec_release(struct file *file)
v4l2_m2m_ctx_release(ctx->m2m_ctx);
mtk_vcodec_enc_release(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index 688b776b3010..0c50f4ff82e0 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -856,7 +856,7 @@ static int tegra_release(struct file *file)
struct tegra_ctx *ctx = fh_to_tegra_ctx(fh);
struct tegra_vde *vde = ctx->vde;
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, file);
v4l2_m2m_ctx_release(fh->m2m_ctx);
v4l2_ctrl_handler_free(&ctx->hdl);
v4l2_fh_exit(fh);
diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c
index 2bd30910ddf9..97744c7b7c03 100644
--- a/drivers/media/platform/nxp/dw100/dw100.c
+++ b/drivers/media/platform/nxp/dw100/dw100.c
@@ -667,7 +667,7 @@ static int dw100_release(struct file *file)
{
struct dw100_ctx *ctx = dw100_file2ctx(file);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index d7cecc56a9eb..a34e644b2cb1 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -2238,7 +2238,7 @@ static int mxc_jpeg_open(struct file *file)
err_ctrls_setup:
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
error:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&mxc_jpeg->lock);
free:
@@ -2751,7 +2751,7 @@ static int mxc_jpeg_release(struct file *file)
ctx->slot);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&mxc_jpeg->lock);
diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index 9602409f3ece..6cc9b07ea53a 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -1716,7 +1716,7 @@ static int pxp_release(struct file *file)
dprintk(dev, "Releasing instance %p\n", ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
index d6df6e2725f5..31298307c672 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -716,7 +716,7 @@ static int mxc_isi_m2m_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mxc_isi_m2m_ctx_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_destroy(&ctx->vb2_lock);
diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.c
index 8c8f834e6250..d23da93304bd 100644
--- a/drivers/media/platform/nxp/mx2_emmaprp.c
+++ b/drivers/media/platform/nxp/mx2_emmaprp.c
@@ -769,7 +769,7 @@ static int emmaprp_release(struct file *file)
mutex_lock(&pcdev->dev_mutex);
clk_disable_unprepare(pcdev->clk_emma_ahb);
clk_disable_unprepare(pcdev->clk_emma_ipg);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(&pcdev->dev_mutex);
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index cdd34a3b71ff..541ae86f7892 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -30,8 +30,7 @@ static void iris_v4l2_fh_init(struct iris_inst *inst, struct file *filp)
static void iris_v4l2_fh_deinit(struct iris_inst *inst, struct file *filp)
{
- filp->private_data = NULL;
- v4l2_fh_del(&inst->fh);
+ v4l2_fh_del(&inst->fh, filp);
inst->fh.ctrl_handler = NULL;
v4l2_fh_exit(&inst->fh);
}
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 5e1ace16a490..90de29f166ad 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -607,7 +607,7 @@ void venus_close_common(struct venus_inst *inst, struct file *filp)
v4l2_m2m_ctx_release(inst->m2m_ctx);
v4l2_m2m_release(inst->m2m_dev);
hfi_session_destroy(inst);
- v4l2_fh_del(&inst->fh);
+ v4l2_fh_del(&inst->fh, filp);
v4l2_fh_exit(&inst->fh);
v4l2_ctrl_handler_free(&inst->ctrl_handler);
diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
index f1ea303ac038..e2dba0e4f315 100644
--- a/drivers/media/platform/renesas/rcar_fdp1.c
+++ b/drivers/media/platform/renesas/rcar_fdp1.c
@@ -2166,7 +2166,7 @@ static int fdp1_release(struct file *file)
dprintk(fdp1, "Releasing instance %p\n", ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
mutex_lock(&fdp1->dev_mutex);
diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
index d0d4ee3f8bdc..0b479dfa2917 100644
--- a/drivers/media/platform/renesas/rcar_jpu.c
+++ b/drivers/media/platform/renesas/rcar_jpu.c
@@ -1276,7 +1276,7 @@ static int jpu_open(struct file *file)
device_prepare_rollback:
mutex_unlock(&jpu->mutex);
v4l_prepare_rollback:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
return ret;
@@ -1289,7 +1289,7 @@ static int jpu_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c
index b6dc1ee3dc50..75f9a1a85d55 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_video.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c
@@ -1083,7 +1083,7 @@ static int vsp1_video_open(struct file *file)
ret = vsp1_device_get(video->vsp1);
if (ret < 0) {
- v4l2_fh_del(vfh);
+ v4l2_fh_del(vfh, file);
v4l2_fh_exit(vfh);
kfree(vfh);
}
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index d88817023996..45c42c7ad846 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -418,7 +418,7 @@ static int rga_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 2fbad685e92c..481c2488f9ac 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -954,7 +954,7 @@ static int rkvdec_release(struct file *filp)
{
struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(filp);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, filp);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
v4l2_fh_exit(&ctx->fh);
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
index 39d84ffd1b05..2999fb2610f0 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
@@ -654,7 +654,7 @@ static int gsc_m2m_open(struct file *file)
error_ctrls:
gsc_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
error_fh:
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
@@ -675,7 +675,7 @@ static int gsc_m2m_release(struct file *file)
v4l2_m2m_ctx_release(ctx->m2m_ctx);
gsc_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
if (--gsc->m2m.refcnt <= 0)
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
index b002b02a899e..609fd84f89d4 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
@@ -663,7 +663,7 @@ static int fimc_m2m_open(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
error_c:
fimc_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
error_fh:
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
@@ -684,7 +684,7 @@ static int fimc_m2m_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
fimc_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
if (--fimc->m2m.refcnt <= 0)
diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
index e34cae9c9cf6..922262f61e7b 100644
--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
@@ -280,7 +280,7 @@ static int g2d_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(&dev->mutex);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
v4l2_info(&dev->v4l2_dev, "instance closed\n");
diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
index 9e35dd939ad7..65f256db4c76 100644
--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
@@ -1005,7 +1005,7 @@ static int s5p_jpeg_open(struct file *file)
return 0;
error:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&jpeg->lock);
free:
@@ -1021,7 +1021,7 @@ static int s5p_jpeg_release(struct file *file)
mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
mutex_unlock(&jpeg->lock);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index 74629db05121..a5e756049620 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -955,7 +955,7 @@ static int s5p_mfc_open(struct file *file)
err_bad_node:
dev->ctx[ctx->num] = NULL;
err_no_ctx:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
err_alloc:
@@ -1010,7 +1010,7 @@ static int s5p_mfc_release(struct file *file)
if (dev)
dev->ctx[ctx->num] = NULL;
s5p_mfc_dec_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
/* vdev is gone if dev is null */
if (dev)
v4l2_fh_exit(&ctx->fh);
diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
index 5e983799e298..38b2a2924443 100644
--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
@@ -634,7 +634,7 @@ static int bdisp_open(struct file *file)
error_ctrls:
bdisp_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
error_fh:
v4l2_fh_exit(&ctx->fh);
bdisp_hw_free_nodes(ctx);
@@ -659,7 +659,7 @@ static int bdisp_release(struct file *file)
bdisp_ctrls_delete(ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
if (--bdisp->m2m.refcnt <= 0)
diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.c
index 3063a98ed25b..385b26d21408 100644
--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c
@@ -1684,7 +1684,7 @@ static int delta_open(struct file *file)
return 0;
err_fh_del:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
err:
@@ -1712,7 +1712,7 @@ static int delta_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
/* disable ST231 clocks */
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c
index 2f9413fa7318..3581b73a99b8 100644
--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c
@@ -1218,7 +1218,7 @@ static int hva_open(struct file *file)
err_ctrls:
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
err_fh:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
out:
@@ -1249,7 +1249,7 @@ static int hva_release(struct file *file)
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
#ifdef CONFIG_VIDEO_STI_HVA_DEBUGFS
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index b2bced06a1e6..bc0f81e78018 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -326,7 +326,7 @@ static int dma2d_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(&dev->mutex);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index 7823eb97faf7..eb519afb30ca 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -759,7 +759,7 @@ static int deinterlace_release(struct file *file)
mutex_lock(&dev->dev_mutex);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
index 368a858b8c0f..89992feaab60 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -695,7 +695,7 @@ static int rotate_release(struct file *file)
mutex_lock(&dev->dev_mutex);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
index d10a2b96c13c..2c0008444b7e 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -1336,7 +1336,7 @@ static int isp_video_open(struct file *file)
done:
if (ret < 0) {
- v4l2_fh_del(&handle->vfh);
+ v4l2_fh_del(&handle->vfh, file);
v4l2_fh_exit(&handle->vfh);
kfree(handle);
}
@@ -1360,10 +1360,9 @@ static int isp_video_release(struct file *file)
v4l2_pipeline_pm_put(&video->video.entity);
/* Release the file handle. */
- v4l2_fh_del(vfh);
+ v4l2_fh_del(vfh, file);
v4l2_fh_exit(vfh);
kfree(handle);
- file->private_data = NULL;
omap3isp_put(video->isp);
diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
index a47c5d31c475..6029d4e8e0bd 100644
--- a/drivers/media/platform/ti/vpe/vpe.c
+++ b/drivers/media/platform/ti/vpe/vpe.c
@@ -2421,7 +2421,7 @@ static int vpe_release(struct file *file)
vpdma_free_desc_buf(&ctx->sc_coeff_v);
vpdma_free_desc_buf(&ctx->sc_coeff_h);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index aadc3d8fb3d1..4cc9d00fd293 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -677,7 +677,7 @@ static int hantro_open(struct file *filp)
return 0;
err_fh_free:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, filp);
v4l2_fh_exit(&ctx->fh);
err_ctx_free:
kfree(ctx);
@@ -693,7 +693,7 @@ static int hantro_release(struct file *filp)
* to this file.
*/
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, filp);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
kfree(ctx);
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
index f20d9d9643f5..c340fd226040 100644
--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
@@ -1946,7 +1946,7 @@ static int vicodec_release(struct file *file)
mutex_lock(vfd->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mutex_unlock(vfd->lock);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
kvfree(ctx->state.compressed_frame);
diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
index 24574025f58f..d0e760118c82 100644
--- a/drivers/media/test-drivers/vim2m.c
+++ b/drivers/media/test-drivers/vim2m.c
@@ -1450,7 +1450,7 @@ static int vim2m_release(struct file *file)
dprintk(dev, 1, "Releasing instance %p\n", ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/test-drivers/visl/visl-core.c b/drivers/media/test-drivers/visl/visl-core.c
index 0f43ec23f40b..26c6c6835f79 100644
--- a/drivers/media/test-drivers/visl/visl-core.c
+++ b/drivers/media/test-drivers/visl/visl-core.c
@@ -389,7 +389,7 @@ static int visl_release(struct file *file)
dprintk(dev, "Releasing instance %p\n", ctx);
tpg_free(&ctx->tpg);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->hdl);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 04c77af0c51e..f9535a484738 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -900,9 +900,8 @@ static int pvr2_v4l2_release(struct file *file)
fhp->rhp = NULL;
}
- v4l2_fh_del(&fhp->fh);
+ v4l2_fh_del(&fhp->fh, file);
v4l2_fh_exit(&fhp->fh);
- file->private_data = NULL;
pvr2_channel_done(&fhp->channel);
pvr2_trace(PVR2_TRACE_STRUCT,
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index b59b1084d8cd..df3ba9d4674b 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -67,7 +67,7 @@ int v4l2_fh_open(struct file *filp)
}
EXPORT_SYMBOL_GPL(v4l2_fh_open);
-void v4l2_fh_del(struct v4l2_fh *fh)
+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp)
{
unsigned long flags;
@@ -75,6 +75,8 @@ void v4l2_fh_del(struct v4l2_fh *fh)
list_del_init(&fh->list);
spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
v4l2_prio_close(fh->vdev->prio, fh->prio);
+
+ filp->private_data = NULL;
}
EXPORT_SYMBOL_GPL(v4l2_fh_del);
@@ -94,10 +96,9 @@ int v4l2_fh_release(struct file *filp)
struct v4l2_fh *fh = file_to_v4l2_fh(filp);
if (fh) {
- v4l2_fh_del(fh);
+ v4l2_fh_del(fh, filp);
v4l2_fh_exit(fh);
kfree(fh);
- filp->private_data = NULL;
}
return 0;
}
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index bf35ac436249..41e4aca77b7f 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -109,7 +109,7 @@ static int subdev_open(struct file *file)
err:
module_put(subdev_fh->owner);
- v4l2_fh_del(&subdev_fh->vfh);
+ v4l2_fh_del(&subdev_fh->vfh, file);
v4l2_fh_exit(&subdev_fh->vfh);
subdev_fh_free(subdev_fh);
kfree(subdev_fh);
@@ -127,11 +127,10 @@ static int subdev_close(struct file *file)
if (sd->internal_ops && sd->internal_ops->close)
sd->internal_ops->close(sd, subdev_fh);
module_put(subdev_fh->owner);
- v4l2_fh_del(vfh);
+ v4l2_fh_del(vfh, file);
v4l2_fh_exit(vfh);
subdev_fh_free(subdev_fh);
kfree(subdev_fh);
- file->private_data = NULL;
return 0;
}
diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index 7fedb33dda34..dc7f9a77cbe6 100644
--- a/drivers/staging/media/imx/imx-media-csc-scaler.c
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -792,7 +792,7 @@ static int ipu_csc_scaler_open(struct file *file)
err_ctrls:
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
err_ctx:
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
return ret;
@@ -807,7 +807,7 @@ static int ipu_csc_scaler_release(struct file *file)
v4l2_ctrl_handler_free(&ctx->ctrl_hdlr);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_fh_exit(&ctx->fh);
kfree(ctx);
diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
index b92666ff50a1..49e497a32973 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -926,7 +926,7 @@ static int vdec_close(struct file *file)
v4l2_m2m_ctx_release(sess->m2m_ctx);
v4l2_m2m_release(sess->m2m_dev);
- v4l2_fh_del(&sess->fh);
+ v4l2_fh_del(&sess->fh, file);
v4l2_fh_exit(&sess->fh);
mutex_destroy(&sess->lock);
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index ebefd646dbdb..bff42ea1871f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -404,7 +404,7 @@ static int cedrus_release(struct file *file)
mutex_lock(&dev->dev_mutex);
- v4l2_fh_del(&ctx->fh);
+ v4l2_fh_del(&ctx->fh, file);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->hdl);
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 24a68e3e5419..32f71d9a9cf7 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -107,7 +107,7 @@ static int comp_vdev_open(struct file *filp)
return 0;
err_rm:
- v4l2_fh_del(&fh->fh);
+ v4l2_fh_del(&fh->fh, filp);
v4l2_fh_exit(&fh->fh);
err_dec:
@@ -143,7 +143,7 @@ static int comp_vdev_close(struct file *filp)
most_stop_channel(mdev->iface, mdev->ch_idx, &comp);
mdev->mute = false;
- v4l2_fh_del(&fh->fh);
+ v4l2_fh_del(&fh->fh, filp);
v4l2_fh_exit(&fh->fh);
atomic_dec(&mdev->access_ref);
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 680f25d17dc2..fd4b998ccd16 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -692,8 +692,7 @@ uvc_v4l2_release(struct file *file)
uvc_v4l2_disable(uvc);
mutex_unlock(&video->mutex);
- file->private_data = NULL;
- v4l2_fh_del(&handle->vfh);
+ v4l2_fh_del(&handle->vfh, file);
v4l2_fh_exit(&handle->vfh);
kfree(handle);
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index d8fcf49f10e0..5e4c76163512 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -114,12 +114,15 @@ int v4l2_fh_open(struct file *filp);
* v4l2_fh_del - Remove file handle from the list of file handles.
*
* @fh: pointer to &struct v4l2_fh
+ * @filp: pointer to &struct file associated with @fh
+ *
+ * The function resets filp->private_data to NULL.
*
* .. note::
* Must be called in v4l2_file_operations->release\(\) handler if the driver
* uses &struct v4l2_fh.
*/
-void v4l2_fh_del(struct v4l2_fh *fh);
+void v4l2_fh_del(struct v4l2_fh *fh, struct file *filp);
/**
* v4l2_fh_exit - Release resources related to a file handle.
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-08-10 1:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-10 1:29 [PATCH v3 00/76] media: Rationalise usage of v4l2_fh Laurent Pinchart
2025-08-10 1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 19/76] media: camss: Replace .open() file operation with v4l2_fh_open() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 20/76] media: camss: Remove custom .release fop() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 22/76] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 23/76] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 24/76] media: qcom: iris: Drop unused argument to iris_get_inst() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 25/76] media: qcom: venus: Pass file pointer to venus_close_common() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 26/76] media: Set file->private_data in v4l2_fh_add() Laurent Pinchart
2025-08-10 1:30 ` [PATCH v3 27/76] media: Reset file->private_data to NULL in v4l2_fh_del() Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).