* [PATCH 00/65] media: Rationalise usage of v4l2_fh
@ 2025-08-02 9:22 Jacopo Mondi
2025-08-02 9:22 ` [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data Jacopo Mondi
` (64 more replies)
0 siblings, 65 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh abstraction layer provides to drivers support to represent
per-open file handle context and associate driver-specific data to them.
Currently drivers that do not require custom per-file handle data can
use the v4l2_fh_open() and v4l2_fh_release() helpers as handlers
v4l2_file_operations open() and close() functions. The two helpers
set the file->private_data pointer to the newly allocated v4l2_fh.
Drivers that instead store per-file handle data and represent them with
driver-specific types that embed an instance of struct v4l2_fh have
instead to use different helpers: v4l2_fh_init() and v4l2_fh_add() it's
their responsibility to initialize file->private_data with what they
consider more opportune.
Unfortunately this leads to inconsistencies and slightly different
implementations in drivers, which increase the maintenance burden.
The series starts with patches from Laurent to address some of
these inconsistencies. Some drivers in-facts set the file->private_data
pointer to their own driver-specific types that embed the v4l2_fh.
As the driver-specific type can be accessed with a simple container_of
we can make all drivers set file->private_data to point to the v4l2_fh
to make all the code base use the same pattern.
Once all drivers have been made consistent we can modify the framework
to automate the file->private_data initialisation by modifying
v4l2_fh_add() to set file->private_data to the v4l2_fh allocated by
drivers as part of their private structures. Once that's done we can now
remove all direct accesses to file->private_data by providing the
file_to_v4l2_fh helper.
Now that all drivers that use v4l2_fh are guaranteed to have
file->private_data initialised we can remove accesses to the 'void
*priv' filed provided by v4l2-ioctl to drivers to make sure they always
go through the file * and retrieve the driver specific type from the
v4l2_fh there embedded. This guarantees a more robust data type layout
and make usage of v4l2_fh more consistent and clear across the code
base.
Once that's done, the v4l2-ioctl layer can be modified to stop passing
file->private_data as the second argument to all ioctl handlers, as it
is not ideal to have access to the same data through two different entry
point.
As mentioned in the commit message of the last patch, there are plans to
re-use the second ioctl argument to provide drivers a
video_device_state. This patch series paves the way for that by making
sure the argument can be re-used safely.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Jacopo Mondi (36):
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: 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: Set queue owner using 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: zoran: Remove access to __fh
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 (29):
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: hantro: Access v4l2_fh from file->private_data
media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check
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-ioctl: Stop passing fh pointer to ioctl handlers
Documentation/driver-api/media/v4l2-fh.rst | 56 ++---
.../zh_CN/video4linux/v4l2-framework.txt | 11 +-
drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
drivers/media/pci/cx18/cx18-driver.h | 2 +-
drivers/media/pci/cx18/cx18-fileops.c | 11 +-
drivers/media/pci/cx18/cx18-ioctl.c | 64 +++---
drivers/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/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 | 3 +-
drivers/media/platform/allegro-dvt/allegro-core.c | 32 +--
drivers/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 -
.../media/platform/chips-media/coda/coda-common.c | 50 +++--
.../platform/chips-media/wave5/wave5-helper.c | 10 +-
.../platform/chips-media/wave5/wave5-helper.h | 2 +-
.../platform/chips-media/wave5/wave5-vpu-dec.c | 23 +-
.../platform/chips-media/wave5/wave5-vpu-enc.c | 29 ++-
.../media/platform/chips-media/wave5/wave5-vpu.h | 5 +
.../media/platform/imagination/e5010-jpeg-enc.c | 23 +-
.../media/platform/imagination/e5010-jpeg-enc.h | 5 +
drivers/media/platform/m2m-deinterlace.c | 26 ++-
.../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 37 ++--
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 29 ++-
.../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 25 ++-
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 36 ++--
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 9 +-
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 5 +
.../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 37 ++--
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 9 +-
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 4 +-
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 35 ++-
drivers/media/platform/nxp/dw100/dw100.c | 7 +-
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 45 ++--
drivers/media/platform/nxp/imx-pxp.c | 7 +-
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 21 +-
drivers/media/platform/nxp/mx2_emmaprp.c | 24 ++-
drivers/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 +-
.../media/platform/renesas/rcar-vin/rcar-v4l2.c | 2 -
drivers/media/platform/renesas/rcar_fdp1.c | 17 +-
drivers/media/platform/renesas/rcar_jpu.c | 27 ++-
.../media/platform/renesas/rzg2l-cru/rzg2l-video.c | 1 -
drivers/media/platform/renesas/vsp1/vsp1_histo.c | 6 +-
drivers/media/platform/renesas/vsp1/vsp1_video.c | 18 +-
drivers/media/platform/rockchip/rga/rga.c | 16 +-
drivers/media/platform/rockchip/rga/rga.h | 5 +
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 21 +-
drivers/media/platform/rockchip/rkvdec/rkvdec.h | 4 +-
.../media/platform/samsung/exynos-gsc/gsc-core.h | 6 +-
.../media/platform/samsung/exynos-gsc/gsc-m2m.c | 37 ++--
.../media/platform/samsung/exynos4-is/fimc-core.h | 5 +-
.../media/platform/samsung/exynos4-is/fimc-m2m.c | 19 +-
.../platform/samsung/s3c-camif/camif-capture.c | 26 +--
drivers/media/platform/samsung/s5p-g2d/g2d.c | 22 +-
.../media/platform/samsung/s5p-jpeg/jpeg-core.c | 33 ++-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 13 +-
.../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +
.../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 22 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 24 +--
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 30 +--
drivers/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 | 18 +-
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 10 +-
.../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 10 +-
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 +-
drivers/media/platform/verisilicon/hantro_drv.c | 10 +-
drivers/media/platform/verisilicon/hantro_v4l2.c | 22 +-
drivers/media/platform/xilinx/xilinx-dma.c | 10 +-
drivers/media/test-drivers/vicodec/vicodec-core.c | 7 +-
drivers/media/test-drivers/vim2m.c | 7 +-
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 | 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 | 39 ++--
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 69 +++---
drivers/media/usb/uvc/uvc_metadata.c | 10 +-
drivers/media/usb/uvc/uvc_v4l2.c | 47 ++--
drivers/media/usb/uvc/uvcvideo.h | 5 +
drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
drivers/media/v4l2-core/v4l2-ctrls-api.c | 9 +-
drivers/media/v4l2-core/v4l2-fh.c | 16 +-
drivers/media/v4l2-core/v4l2-ioctl.c | 53 ++---
drivers/media/v4l2-core/v4l2-mem2mem.c | 34 +--
drivers/media/v4l2-core/v4l2-subdev.c | 16 +-
drivers/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 +
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 -
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-fh.h | 28 ++-
include/media/v4l2-ioctl.h | 236 ++++++++++-----------
117 files changed, 1203 insertions(+), 1185 deletions(-)
---
base-commit: d968e50b5c26642754492dea23cbd3592bde62d8
change-id: 20250801-media-private-data-4515851e7e1d
Best regards,
--
Jacopo Mondi <jacopo.mondi@ideasonboard.com>
^ permalink raw reply [flat|nested] 101+ messages in thread
* [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 02/65] media: imagination: " Jacopo Mondi
` (63 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
saa7164 instead stores the pointer to the driver-specific structure that
embeds the v4l2_fh. Switch to storing the v4l2_fh pointer itself to
standardize behaviour across drivers. This also prepares for future
refactoring that depends on v4l2_fh being stored in private_data.
This also fixes a bug in the vidioc_g_std() in saa7164-vbi.c that casts
the private_data void pointer to a saa7164_encoder_fh instead of a
saa7164_vbi_fh. The bug has no practical consequence as the two
structures are identical.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/saa7164/saa7164-encoder.c | 27 +++++++++++++--------------
drivers/media/pci/saa7164/saa7164-vbi.c | 22 +++++++++++-----------
drivers/media/pci/saa7164/saa7164.h | 10 ++++++++++
3 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index bf73e9e83f52324ca494816f7d9fa2fae7de6774..296f50b6b8d38e0ab617f0990d8f697ba96b0016 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -219,7 +219,7 @@ int saa7164_s_std(struct saa7164_port *port, v4l2_std_id id)
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_s_std(fh->port, id);
}
@@ -232,7 +232,7 @@ int saa7164_g_std(struct saa7164_port *port, v4l2_std_id *id)
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_g_std(fh->port, id);
}
@@ -277,7 +277,7 @@ int saa7164_g_input(struct saa7164_port *port, unsigned int *i)
static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_g_input(fh->port, i);
}
@@ -301,14 +301,14 @@ int saa7164_s_input(struct saa7164_port *port, unsigned int i)
static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_s_input(fh->port, i);
}
int saa7164_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_dev *dev = port->dev;
@@ -347,7 +347,7 @@ int saa7164_g_frequency(struct saa7164_port *port, struct v4l2_frequency *f)
static int vidioc_g_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_g_frequency(fh->port, f);
}
@@ -400,7 +400,7 @@ int saa7164_s_frequency(struct saa7164_port *port,
static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
return saa7164_s_frequency(fh->port, f);
}
@@ -483,7 +483,7 @@ static int saa7164_s_ctrl(struct v4l2_ctrl *ctrl)
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_dev *dev = port->dev;
@@ -510,7 +510,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
@@ -726,14 +726,14 @@ 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;
+ file->private_data = &fh->fh;
return 0;
}
static int fops_release(struct file *file)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_dev *dev = port->dev;
@@ -787,7 +787,7 @@ saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
static ssize_t fops_read(struct file *file, char __user *buffer,
size_t count, loff_t *pos)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_user_buffer *ubuf = NULL;
struct saa7164_dev *dev = port->dev;
@@ -893,8 +893,7 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
static __poll_t fops_poll(struct file *file, poll_table *wait)
{
__poll_t req_events = poll_requested_events(wait);
- struct saa7164_encoder_fh *fh =
- (struct saa7164_encoder_fh *)file->private_data;
+ struct saa7164_encoder_fh *fh = to_saa7164_encoder_fh(file);
struct saa7164_port *port = fh->port;
__poll_t mask = v4l2_ctrl_poll(file, wait);
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index ac958a5fca78e5094d7befd8c125fa4233bb6999..a7e398f304725c7fa5aa4cf1edf0deb0df059641 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -144,28 +144,28 @@ static int saa7164_vbi_initialize(struct saa7164_port *port)
/* -- V4L2 --------------------------------------------------------- */
static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_s_std(fh->port->enc_port, id);
}
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id)
{
- struct saa7164_encoder_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_std(fh->port->enc_port, id);
}
static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_input(fh->port->enc_port, i);
}
static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_s_input(fh->port->enc_port, i);
}
@@ -173,7 +173,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
static int vidioc_g_frequency(struct file *file, void *priv,
struct v4l2_frequency *f)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
return saa7164_g_frequency(fh->port->enc_port, f);
}
@@ -181,7 +181,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
static int vidioc_s_frequency(struct file *file, void *priv,
const struct v4l2_frequency *f)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
int ret = saa7164_s_frequency(fh->port->enc_port, f);
if (ret == 0)
@@ -192,7 +192,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_dev *dev = port->dev;
@@ -429,14 +429,14 @@ 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;
+ file->private_data = &fh->fh;
return 0;
}
static int fops_release(struct file *file)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_dev *dev = port->dev;
@@ -489,7 +489,7 @@ saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
static ssize_t fops_read(struct file *file, char __user *buffer,
size_t count, loff_t *pos)
{
- struct saa7164_vbi_fh *fh = file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
struct saa7164_port *port = fh->port;
struct saa7164_user_buffer *ubuf = NULL;
struct saa7164_dev *dev = port->dev;
@@ -596,7 +596,7 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
static __poll_t fops_poll(struct file *file, poll_table *wait)
{
- struct saa7164_vbi_fh *fh = (struct saa7164_vbi_fh *)file->private_data;
+ struct saa7164_vbi_fh *fh = to_saa7164_vbi_fh(file);
struct saa7164_port *port = fh->port;
__poll_t mask = 0;
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h
index e1bac1fe19d3098792b2051b537857e3f13054d5..7b511f7f1cfc305a9ffe60722b9ebe093163787d 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -180,12 +180,22 @@ struct saa7164_encoder_fh {
atomic_t v4l_reading;
};
+static inline struct saa7164_encoder_fh *to_saa7164_encoder_fh(struct file *filp)
+{
+ return container_of(filp->private_data, struct saa7164_encoder_fh, fh);
+}
+
struct saa7164_vbi_fh {
struct v4l2_fh fh;
struct saa7164_port *port;
atomic_t v4l_reading;
};
+static inline struct saa7164_vbi_fh *to_saa7164_vbi_fh(struct file *filp)
+{
+ return container_of(filp->private_data, struct saa7164_vbi_fh, fh);
+}
+
struct saa7164_histogram_bucket {
u32 val;
u32 count;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 02/65] media: imagination: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 03/65] media: ti: vpe: " Jacopo Mondi
` (62 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
e5010-jpeg-enc driver instead stores the pointer to the driver-specific
structure that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer
itself to standardize behaviour across drivers. This also prepares for
future refactoring that depends on v4l2_fh being stored in private_data.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/imagination/e5010-jpeg-enc.c | 18 +++++++++---------
drivers/media/platform/imagination/e5010-jpeg-enc.h | 5 +++++
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index ae868d9f73e13fdac747ef603e08ea13cd66d3a6..295461325862fb2bcac755cf815955955b37e6f0 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -253,7 +253,7 @@ static int e5010_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
{
int i, index = 0;
struct e5010_fmt *fmt = NULL;
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
if (!V4L2_TYPE_IS_MULTIPLANAR(f->type)) {
v4l2_err(&ctx->e5010->v4l2_dev, "ENUMFMT with Invalid type: %d\n", f->type);
@@ -279,7 +279,7 @@ static int e5010_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
static int e5010_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
struct e5010_q_data *queue;
int i;
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
@@ -380,14 +380,14 @@ static int e5010_jpeg_try_fmt(struct v4l2_format *f, struct e5010_context *ctx)
static int e5010_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
return e5010_jpeg_try_fmt(f, ctx);
}
static int e5010_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
struct vb2_queue *vq;
int ret = 0, i = 0;
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
@@ -462,7 +462,7 @@ static int e5010_enum_framesizes(struct file *file, void *priv, struct v4l2_frms
static int e5010_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
struct e5010_q_data *queue;
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -490,7 +490,7 @@ static int e5010_g_selection(struct file *file, void *fh, struct v4l2_selection
static int e5010_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
struct e5010_q_data *queue;
struct vb2_queue *vq;
struct v4l2_rect base_rect;
@@ -742,7 +742,7 @@ static int e5010_open(struct file *file)
}
v4l2_fh_init(&ctx->fh, vdev);
- file->private_data = ctx;
+ file->private_data = &ctx->fh;
v4l2_fh_add(&ctx->fh);
ctx->e5010 = e5010;
@@ -781,7 +781,7 @@ static int e5010_open(struct file *file)
static int e5010_release(struct file *file)
{
struct e5010_dev *e5010 = video_drvdata(file);
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
dprintk(e5010, 1, "Releasing instance: 0x%p, m2m_ctx: 0x%p\n", ctx, ctx->fh.m2m_ctx);
mutex_lock(&e5010->mutex);
@@ -1262,7 +1262,7 @@ static void e5010_buf_queue(struct vb2_buffer *vb)
static int e5010_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
- struct e5010_context *ctx = file->private_data;
+ struct e5010_context *ctx = to_e5010_context(file);
int ret;
struct vb2_queue *cap_vq;
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.h b/drivers/media/platform/imagination/e5010-jpeg-enc.h
index 71f49ead68980c83fd81b19fd63d9abd47abef64..eefaf60489d3fba518acd12709f2e4831686620b 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.h
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.h
@@ -120,6 +120,11 @@ struct e5010_context {
u8 chroma_qp[QP_TABLE_SIZE];
};
+static inline struct e5010_context *to_e5010_context(struct file *filp)
+{
+ return container_of(filp->private_data, struct e5010_context, fh);
+}
+
/*
* Buffer structure
* Contains info for all buffers
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 03/65] media: ti: vpe: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 02/65] media: imagination: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 04/65] media: usb: hdpvr: " Jacopo Mondi
` (61 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
ti-vpe driver instead stores the pointer to the driver-specific
structure that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer
itself to standardize behaviour across drivers. This also prepares for
future refactoring that depends on v4l2_fh being stored in private_data.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/ti/vpe/vpe.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
index 636d76ecebcd7e6f4e98d6fe4873bf98b0f0239e..b76b5d18c963d9a3313d34cfe0e12772738d336f 100644
--- a/drivers/media/platform/ti/vpe/vpe.c
+++ b/drivers/media/platform/ti/vpe/vpe.c
@@ -422,6 +422,10 @@ struct vpe_ctx {
unsigned int src_mv_buf_selector;
};
+static inline struct vpe_ctx *to_vpe_ctx(struct file *filp)
+{
+ return container_of(filp->private_data, struct vpe_ctx, fh);
+}
/*
* M2M devices get 2 queues.
@@ -1562,7 +1566,7 @@ static int vpe_enum_fmt(struct file *file, void *priv,
static int vpe_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
struct vb2_queue *vq;
struct vpe_q_data *q_data;
@@ -1719,7 +1723,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
static int vpe_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
struct vpe_fmt *fmt = find_format(f);
if (V4L2_TYPE_IS_OUTPUT(f->type))
@@ -1783,7 +1787,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct v4l2_format *f)
static int vpe_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
int ret;
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
ret = vpe_try_fmt(file, priv, f);
if (ret)
@@ -1871,7 +1875,7 @@ static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s)
static int vpe_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
struct vpe_q_data *q_data;
struct v4l2_pix_format_mplane *pix;
bool use_c_rect = false;
@@ -1935,7 +1939,7 @@ static int vpe_g_selection(struct file *file, void *fh,
static int vpe_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
struct vpe_q_data *q_data;
struct v4l2_selection sel = *s;
int ret;
@@ -2306,7 +2310,7 @@ static int vpe_open(struct file *file)
init_adb_hdrs(ctx);
v4l2_fh_init(&ctx->fh, video_devdata(file));
- file->private_data = ctx;
+ file->private_data = &ctx->fh;
hdl = &ctx->hdl;
v4l2_ctrl_handler_init(hdl, 1);
@@ -2400,7 +2404,7 @@ static int vpe_open(struct file *file)
static int vpe_release(struct file *file)
{
struct vpe_dev *dev = video_drvdata(file);
- struct vpe_ctx *ctx = file->private_data;
+ struct vpe_ctx *ctx = to_vpe_ctx(file);
vpe_dbg(dev, "releasing instance %p\n", ctx);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 04/65] media: usb: hdpvr: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (2 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 03/65] media: ti: vpe: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 05/65] media: usb: pvrusb2: " Jacopo Mondi
` (60 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
hdpvr driver instead stores the pointer to the driver-specific structure
that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer itself to
standardize behaviour across drivers. This also prepares for future
refactoring that depends on v4l2_fh being stored in private_data.
No extensive driver refactoring is required, as file->private_data is
only used to check if a file handle is the owner of the device by
comparing pointer values. The private_data pointer is actually compared
to a struct v4l2_fh pointer, which happens to be the first field of the
hdpvr_fh structure.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/usb/hdpvr/hdpvr-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index fd7d2a9d0449ab9ba68ddfa148a167797ea243fc..4c431bd9b50352ed1bd3da3e62625c9cff6c149d 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -381,7 +381,7 @@ static int hdpvr_open(struct file *file)
fh->legacy_mode = true;
v4l2_fh_init(&fh->fh, video_devdata(file));
v4l2_fh_add(&fh->fh);
- file->private_data = fh;
+ file->private_data = &fh->fh;
return 0;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 05/65] media: usb: pvrusb2: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (3 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 04/65] media: usb: hdpvr: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 06/65] media: usb: uvcvideo: " Jacopo Mondi
` (59 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
pvrusb2 driver instead stores the pointer to the driver-specific
structure that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer
itself to standardize behaviour across drivers. This also prepares for
future refactoring that depends on v4l2_fh being stored in private_data.
While at it, drop unneeded structure forward declarations.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 65 +++++++++++++++++---------------
1 file changed, 34 insertions(+), 31 deletions(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index ad38e12405419caad056af8866b14ea621f0c2a1..7dc7c90ebf621c594bf5236276c402462d694a0a 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -21,8 +21,6 @@
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
-struct pvr2_v4l2_dev;
-struct pvr2_v4l2_fh;
struct pvr2_v4l2;
struct pvr2_v4l2_dev {
@@ -48,6 +46,11 @@ struct pvr2_v4l2_fh {
unsigned int input_cnt;
};
+static inline struct pvr2_v4l2_fh *to_pvr2_v4l2_fh(struct file *filp)
+{
+ return container_of(filp->private_data, struct pvr2_v4l2_fh, fh);
+}
+
struct pvr2_v4l2 {
struct pvr2_channel channel;
@@ -108,7 +111,7 @@ static struct v4l2_format pvr_format [] = {
*/
static int pvr2_querycap(struct file *file, void *priv, struct v4l2_capability *cap)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
strscpy(cap->driver, "pvrusb2", sizeof(cap->driver));
@@ -123,7 +126,7 @@ static int pvr2_querycap(struct file *file, void *priv, struct v4l2_capability *
static int pvr2_g_std(struct file *file, void *priv, v4l2_std_id *std)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int val = 0;
int ret;
@@ -136,7 +139,7 @@ static int pvr2_g_std(struct file *file, void *priv, v4l2_std_id *std)
static int pvr2_s_std(struct file *file, void *priv, v4l2_std_id std)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int ret;
@@ -148,7 +151,7 @@ static int pvr2_s_std(struct file *file, void *priv, v4l2_std_id std)
static int pvr2_querystd(struct file *file, void *priv, v4l2_std_id *std)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int val = 0;
int ret;
@@ -161,7 +164,7 @@ static int pvr2_querystd(struct file *file, void *priv, v4l2_std_id *std)
static int pvr2_enum_input(struct file *file, void *priv, struct v4l2_input *vi)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct pvr2_ctrl *cptr;
struct v4l2_input tmp;
@@ -209,7 +212,7 @@ static int pvr2_enum_input(struct file *file, void *priv, struct v4l2_input *vi)
static int pvr2_g_input(struct file *file, void *priv, unsigned int *i)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
unsigned int idx;
struct pvr2_ctrl *cptr;
@@ -231,7 +234,7 @@ static int pvr2_g_input(struct file *file, void *priv, unsigned int *i)
static int pvr2_s_input(struct file *file, void *priv, unsigned int inp)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int ret;
@@ -286,7 +289,7 @@ static int pvr2_s_audio(struct file *file, void *priv, const struct v4l2_audio *
static int pvr2_g_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
if (vt->index != 0)
@@ -298,7 +301,7 @@ static int pvr2_g_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
static int pvr2_s_tuner(struct file *file, void *priv, const struct v4l2_tuner *vt)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int ret;
@@ -314,7 +317,7 @@ static int pvr2_s_tuner(struct file *file, void *priv, const struct v4l2_tuner *
static int pvr2_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *vf)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
unsigned long fv;
struct v4l2_tuner vt;
@@ -349,7 +352,7 @@ static int pvr2_s_frequency(struct file *file, void *priv, const struct v4l2_fre
static int pvr2_g_frequency(struct file *file, void *priv, struct v4l2_frequency *vf)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int val = 0;
int cur_input;
@@ -391,7 +394,7 @@ static int pvr2_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtd
static int pvr2_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *vf)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int val;
@@ -411,7 +414,7 @@ static int pvr2_g_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format
static int pvr2_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *vf)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int lmin, lmax, ldef;
struct pvr2_ctrl *hcp, *vcp;
@@ -449,7 +452,7 @@ static int pvr2_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
static int pvr2_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *vf)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct pvr2_ctrl *hcp, *vcp;
int ret = pvr2_try_fmt_vid_cap(file, fh, vf);
@@ -466,7 +469,7 @@ static int pvr2_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format
static int pvr2_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct pvr2_v4l2_dev *pdi = fh->pdi;
int ret;
@@ -485,7 +488,7 @@ static int pvr2_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
static int pvr2_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
if (!fh->pdi->stream) {
@@ -500,7 +503,7 @@ static int pvr2_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
static int pvr2_query_ext_ctrl(struct file *file, void *priv,
struct v4l2_query_ext_ctrl *vc)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct pvr2_ctrl *cptr;
int val;
@@ -561,7 +564,7 @@ static int pvr2_query_ext_ctrl(struct file *file, void *priv,
static int pvr2_querymenu(struct file *file, void *priv, struct v4l2_querymenu *vm)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
unsigned int cnt = 0;
int ret;
@@ -577,7 +580,7 @@ static int pvr2_querymenu(struct file *file, void *priv, struct v4l2_querymenu *
static int pvr2_g_ext_ctrls(struct file *file, void *priv,
struct v4l2_ext_controls *ctls)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct v4l2_ext_control *ctrl;
struct pvr2_ctrl *cptr;
@@ -612,7 +615,7 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv,
static int pvr2_s_ext_ctrls(struct file *file, void *priv,
struct v4l2_ext_controls *ctls)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct v4l2_ext_control *ctrl;
unsigned int idx;
@@ -637,7 +640,7 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv,
static int pvr2_try_ext_ctrls(struct file *file, void *priv,
struct v4l2_ext_controls *ctls)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct v4l2_ext_control *ctrl;
struct pvr2_ctrl *pctl;
@@ -659,7 +662,7 @@ static int pvr2_try_ext_ctrls(struct file *file, void *priv,
static int pvr2_g_pixelaspect(struct file *file, void *priv,
int type, struct v4l2_fract *f)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct v4l2_cropcap cap = { .type = type };
int ret;
@@ -675,7 +678,7 @@ static int pvr2_g_pixelaspect(struct file *file, void *priv,
static int pvr2_g_selection(struct file *file, void *priv,
struct v4l2_selection *sel)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
struct v4l2_cropcap cap;
int val = 0;
@@ -726,7 +729,7 @@ static int pvr2_g_selection(struct file *file, void *priv,
static int pvr2_s_selection(struct file *file, void *priv,
struct v4l2_selection *sel)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
int ret;
@@ -758,7 +761,7 @@ static int pvr2_s_selection(struct file *file, void *priv,
static int pvr2_log_status(struct file *file, void *priv)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
pvr2_hdw_trigger_module_log(hdw);
@@ -882,7 +885,7 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
static int pvr2_v4l2_release(struct file *file)
{
- struct pvr2_v4l2_fh *fhp = file->private_data;
+ struct pvr2_v4l2_fh *fhp = to_pvr2_v4l2_fh(file);
struct pvr2_v4l2 *vp = fhp->pdi->v4lp;
struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw;
@@ -1000,7 +1003,7 @@ static int pvr2_v4l2_open(struct file *file)
}
fhp->file = file;
- file->private_data = fhp;
+ file->private_data = &fhp->fh;
fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
v4l2_fh_add(&fhp->fh);
@@ -1055,7 +1058,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
static ssize_t pvr2_v4l2_read(struct file *file,
char __user *buff, size_t count, loff_t *ppos)
{
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
int ret;
if (fh->fw_mode_flag) {
@@ -1117,7 +1120,7 @@ static ssize_t pvr2_v4l2_read(struct file *file,
static __poll_t pvr2_v4l2_poll(struct file *file, poll_table *wait)
{
__poll_t mask = 0;
- struct pvr2_v4l2_fh *fh = file->private_data;
+ struct pvr2_v4l2_fh *fh = to_pvr2_v4l2_fh(file);
int ret;
if (fh->fw_mode_flag) {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 06/65] media: usb: uvcvideo: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (4 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 05/65] media: usb: pvrusb2: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 07/65] media: staging: most: " Jacopo Mondi
` (58 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
uvcvideo driver instead stores the pointer to the driver-specific
structure that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer
itself to standardize behaviour across drivers. This also prepares for
future refactoring that depends on v4l2_fh being stored in private_data.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/usb/uvc/uvc_v4l2.c | 10 +++++-----
drivers/media/usb/uvc/uvcvideo.h | 5 +++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 160f9cf6e6dbdbf39e3eff56a5d5ea1d977fbe22..6dd329a972fda5c2574231b8526105676df3d4a1 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -603,14 +603,14 @@ static int uvc_v4l2_open(struct file *file)
v4l2_fh_add(&handle->vfh);
handle->chain = stream->chain;
handle->stream = stream;
- file->private_data = handle;
+ file->private_data = &handle->vfh;
return 0;
}
static int uvc_v4l2_release(struct file *file)
{
- struct uvc_fh *handle = file->private_data;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
uvc_dbg(stream->dev, CALLS, "%s\n", __func__);
@@ -626,7 +626,7 @@ static int uvc_v4l2_release(struct file *file)
static int uvc_ioctl_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct uvc_fh *handle = file->private_data;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
struct uvc_streaming *stream = handle->stream;
@@ -1170,7 +1170,7 @@ static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp,
static long uvc_v4l2_compat_ioctl32(struct file *file,
unsigned int cmd, unsigned long arg)
{
- struct uvc_fh *handle = file->private_data;
+ struct uvc_fh *handle = to_uvc_fh(file);
union {
struct uvc_xu_control_mapping xmap;
struct uvc_xu_control_query xqry;
@@ -1221,7 +1221,7 @@ static long uvc_v4l2_compat_ioctl32(struct file *file,
static long uvc_v4l2_unlocked_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
- struct uvc_fh *handle = file->private_data;
+ struct uvc_fh *handle = to_uvc_fh(file);
unsigned int converted_cmd = v4l2_translate_cmd(cmd);
int ret;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 757254fc4fe930ae61c9d0425f04d4cd074a617e..8b56252030480b8a5d2ef6de24902b544357ff02 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -637,6 +637,11 @@ struct uvc_fh {
unsigned int pending_async_ctrls;
};
+static inline struct uvc_fh *to_uvc_fh(struct file *filp)
+{
+ return container_of(filp->private_data, struct uvc_fh, vfh);
+}
+
/* ------------------------------------------------------------------------
* Debugging, printing and logging
*/
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 07/65] media: staging: most: Store v4l2_fh pointer in file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (5 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 06/65] media: usb: uvcvideo: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 08/65] media: Wrap file->private_data access with a helper function Jacopo Mondi
` (57 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Most V4L2 drivers store the v4l2_fh pointer in file->private_data. The
most driver instead stores the pointer to the driver-specific structure
that embeds the v4l2_fh. Switch to storing the v4l2_fh pointer itself to
standardize behaviour across drivers. This also prepares for future
refactoring that depends on v4l2_fh being stored in private_data.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/staging/most/video/video.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 2b3cdb1ce1404cd13655c780f1215c364ce1a70f..bce7ffeac8fe50d3442f4993ae49ab5fc96ec3cd 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -52,6 +52,11 @@ struct comp_fh {
u32 offs;
};
+static inline struct comp_fh *to_comp_fh(struct file *filp)
+{
+ return container_of(filp->private_data, struct comp_fh, fh);
+}
+
static LIST_HEAD(video_devices);
static DEFINE_SPINLOCK(list_lock);
@@ -91,7 +96,7 @@ static int comp_vdev_open(struct file *filp)
fh->mdev = mdev;
v4l2_fh_init(&fh->fh, vdev);
- filp->private_data = fh;
+ filp->private_data = &fh->fh;
v4l2_fh_add(&fh->fh);
@@ -115,7 +120,7 @@ static int comp_vdev_open(struct file *filp)
static int comp_vdev_close(struct file *filp)
{
- struct comp_fh *fh = filp->private_data;
+ struct comp_fh *fh = to_comp_fh(filp);
struct most_video_dev *mdev = fh->mdev;
struct mbo *mbo, *tmp;
@@ -151,7 +156,7 @@ static int comp_vdev_close(struct file *filp)
static ssize_t comp_vdev_read(struct file *filp, char __user *buf,
size_t count, loff_t *pos)
{
- struct comp_fh *fh = filp->private_data;
+ struct comp_fh *fh = to_comp_fh(filp);
struct most_video_dev *mdev = fh->mdev;
int ret = 0;
@@ -200,7 +205,7 @@ static ssize_t comp_vdev_read(struct file *filp, char __user *buf,
static __poll_t comp_vdev_poll(struct file *filp, poll_table *wait)
{
- struct comp_fh *fh = filp->private_data;
+ struct comp_fh *fh = to_comp_fh(filp);
struct most_video_dev *mdev = fh->mdev;
__poll_t mask = 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 08/65] media: Wrap file->private_data access with a helper function
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (6 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 07/65] media: staging: most: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 09/65] media: Replace file->private_data access with file_to_v4l2_fh() Jacopo Mondi
` (56 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Accessing file->private_data manually to retrieve the v4l2_fh pointer is
error-prone, as the field is a void * and will happily convert
implicitly to any pointer type. To avoid direct access to
file->private_data, introduce a new inline function that retrieves the
v4l2_fh pointer, and use it to replace common access patterns through
the kernel.
Changes to drivers have been generated with the following coccinelle
semantic patch:
@@
struct file *filp;
identifier fh;
@@
- struct v4l2_fh *fh = filp->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(filp);
Manual changes have been applied to Documentation/ to update the usage
patterns, and to include/media/v4l2-fh.h to add the new function.
While at it, fix a typo in the title of v4l2-fh.rst: the file describes
the "file handles" API, not "file handlers".
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Documentation/driver-api/media/v4l2-fh.rst | 16 ++++++----
.../zh_CN/video4linux/v4l2-framework.txt | 2 +-
drivers/media/common/videobuf2/videobuf2-v4l2.c | 2 +-
drivers/media/pci/cx18/cx18-fileops.c | 2 +-
drivers/media/pci/ivtv/ivtv-fileops.c | 2 +-
drivers/media/platform/allegro-dvt/allegro-core.c | 2 +-
.../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 2 +-
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 2 +-
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 4 +--
drivers/media/platform/renesas/vsp1/vsp1_histo.c | 6 ++--
drivers/media/platform/renesas/vsp1/vsp1_video.c | 12 ++++----
drivers/media/platform/ti/omap3isp/ispvideo.c | 2 +-
drivers/media/platform/xilinx/xilinx-dma.c | 10 +++----
drivers/media/usb/uvc/uvc_metadata.c | 10 +++----
drivers/media/v4l2-core/v4l2-ctrls-api.c | 4 +--
drivers/media/v4l2-core/v4l2-fh.c | 2 +-
drivers/media/v4l2-core/v4l2-mem2mem.c | 34 +++++++++++-----------
drivers/media/v4l2-core/v4l2-subdev.c | 8 ++---
include/media/v4l2-fh.h | 14 +++++++++
19 files changed, 77 insertions(+), 59 deletions(-)
diff --git a/Documentation/driver-api/media/v4l2-fh.rst b/Documentation/driver-api/media/v4l2-fh.rst
index 3eeaa8da0c9ec6a0005975551d624b48cecf7229..2c87b74578d97a171ad06d3eb60a02cd58b557b1 100644
--- a/Documentation/driver-api/media/v4l2-fh.rst
+++ b/Documentation/driver-api/media/v4l2-fh.rst
@@ -1,7 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0
-V4L2 File handlers
-------------------
+V4L2 File handles
+-----------------
struct v4l2_fh provides a way to easily keep file handle specific
data that is used by the V4L2 framework.
@@ -18,7 +18,9 @@ This bit is set whenever :c:func:`v4l2_fh_init` is called.
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.
+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.
In many cases the struct v4l2_fh will be embedded in a larger
structure. In that case you should call:
@@ -63,7 +65,7 @@ Example:
int my_release(struct file *file)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct my_fh *my_fh = container_of(fh, struct my_fh, fh);
...
@@ -78,11 +80,9 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:
:c:func:`v4l2_fh_init <v4l2_fh_init>`
(:c:type:`fh <v4l2_fh>`, :c:type:`vdev <video_device>`)
-
- Initialise the file handle. This **MUST** be performed in the driver's
:c:type:`v4l2_file_operations`->open() handler.
-
:c:func:`v4l2_fh_add <v4l2_fh_add>`
(:c:type:`fh <v4l2_fh>`)
@@ -101,6 +101,10 @@ Below is a short description of the :c:type:`v4l2_fh` functions used:
- Uninitialise the file handle. After uninitialisation the :c:type:`v4l2_fh`
memory can be freed.
+:c:func:`file_to_v4l2_fh <file_to_v4l2_fh>`
+(struct file \*filp)
+
+- Retrieve the :c:type:`v4l2_fh` instance associated with a :c:type:`file`.
If struct v4l2_fh is not embedded, then you can use these helper functions:
diff --git a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
index 9cc97ec75d7a4ff6a7d91a0013ac4306200c1fd8..a9eb62fa1531c69110ff17945fa2fcfa596f4df8 100644
--- a/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
+++ b/Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
@@ -819,7 +819,7 @@ int my_open(struct file *file)
int my_release(struct file *file)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct my_fh *my_fh = container_of(fh, struct my_fh, fh);
...
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index 1cd26faee50338aefeb670c6865da7c2d43f44d3..f29307e59be591d77a49e143b2880a31673b5e2f 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -979,7 +979,7 @@ __poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
res = vb2_core_poll(q, file, wait);
if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
poll_wait(file, &fh->wait, wait);
if (v4l2_event_pending(fh))
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index cefa91b37f890c8b27d932b832c05ac158eae216..af25628b11bad9ee983e1921dc89044756986940 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -678,7 +678,7 @@ void cx18_stop_capture(struct cx18_stream *s, int gop_end)
int cx18_v4l2_close(struct file *filp)
{
- struct v4l2_fh *fh = filp->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(filp);
struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx;
struct cx18_stream *s = &cx->streams[id->type];
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index cfa28d0355863b08b72cefce9377833e1c1440d6..230d498108b5b0d44a238cd87dcea061811af814 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -877,7 +877,7 @@ static void ivtv_stop_decoding(struct ivtv_open_id *id, int flags, u64 pts)
int ivtv_v4l2_close(struct file *filp)
{
- struct v4l2_fh *fh = filp->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(filp);
struct ivtv_open_id *id = fh2id(fh);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index eb03df0d8652745ef533b9b7aa6c105a140ad022..1f134e08923a528cc676f825da68951c97ac2f25 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3483,7 +3483,7 @@ static int allegro_enum_framesizes(struct file *file, void *fh,
static int allegro_ioctl_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct allegro_channel *channel = fh_to_channel(fh);
int err;
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index 7eb12449b63a59072eb3b3b86b0883c23d5a4c34..329e5787c2c282c43dcee80ceb0f1ba337324b74 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -588,7 +588,7 @@ static int mtk_jpeg_enc_s_selection(struct file *file, void *priv,
static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
struct vb2_queue *vq;
struct vb2_buffer *vb;
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index e3726cab0c82c92cf0d552b8e8061fd22badfa90..531a85e3fe49ad0aa94fb96cbc7a84d474faae94 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -853,7 +853,7 @@ static int tegra_open(struct file *file)
static int tegra_release(struct file *file)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct tegra_ctx *ctx = fh_to_tegra_ctx(fh);
struct tegra_vde *vde = ctx->vde;
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index 8681dd1930334cb455a91bbfd054fcf88ee27cbb..1b2148578cb6751056b4111c6542f01d76c292c8 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -1604,7 +1604,7 @@ static void mxc_jpeg_device_run(void *priv)
static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *cmd)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
unsigned long flags;
int ret;
@@ -1637,7 +1637,7 @@ static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
static int mxc_jpeg_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
unsigned long flags;
int ret;
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_histo.c b/drivers/media/platform/renesas/vsp1/vsp1_histo.c
index c762202877babdc651a63997f4340f6a37a301ac..390ea50f1595ad7702bec46e9b9f3e237c73a622 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_histo.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_histo.c
@@ -392,7 +392,7 @@ static const struct v4l2_subdev_ops histo_ops = {
static int histo_v4l2_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_histogram *histo = vdev_to_histo(vfh->vdev);
cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
@@ -409,7 +409,7 @@ static int histo_v4l2_querycap(struct file *file, void *fh,
static int histo_v4l2_enum_format(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_histogram *histo = vdev_to_histo(vfh->vdev);
if (f->index > 0 || f->type != histo->queue.type)
@@ -423,7 +423,7 @@ static int histo_v4l2_enum_format(struct file *file, void *fh,
static int histo_v4l2_get_format(struct file *file, void *fh,
struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_histogram *histo = vdev_to_histo(vfh->vdev);
struct v4l2_meta_format *meta = &format->fmt.meta;
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c
index bc66fbdde3cc1590072c3917cfe3005fade58307..656fb5e6cb303cfcde1d91c839a9aceca79c77f7 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_video.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c
@@ -896,7 +896,7 @@ static const struct vb2_ops vsp1_video_queue_qops = {
static int
vsp1_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
@@ -912,7 +912,7 @@ vsp1_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
static int vsp1_video_enum_format(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
const struct vsp1_format_info *info;
@@ -933,7 +933,7 @@ static int vsp1_video_enum_format(struct file *file, void *fh,
static int
vsp1_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
if (format->type != video->queue.type)
@@ -949,7 +949,7 @@ vsp1_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
static int
vsp1_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
if (format->type != video->queue.type)
@@ -961,7 +961,7 @@ vsp1_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
static int
vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
const struct vsp1_format_info *info;
int ret;
@@ -991,7 +991,7 @@ vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
static int
vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct vsp1_video *video = to_vsp1_video(vfh->vdev);
struct media_device *mdev = &video->vsp1->media_dev;
struct vsp1_pipeline *pipe;
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
index 78e30298c7ad155c70a2a369daa8c232b97e55b7..a777135c6a6ca51c85c5a75b76cbc4a8421963ec 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -1348,7 +1348,7 @@ static int isp_video_open(struct file *file)
static int isp_video_release(struct file *file)
{
struct isp_video *video = video_drvdata(file);
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct isp_video_fh *handle = to_isp_video_fh(vfh);
/* Disable streaming and free the buffers queue resources. */
diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c
index 18bfa6001909dfa6efc23b3ca432a39a1b316afc..fcfe0883aba5fb8bcf954ce4be956edb39e610cb 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -469,7 +469,7 @@ static const struct vb2_ops xvip_dma_queue_qops = {
static int
xvip_dma_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
cap->capabilities = dma->xdev->v4l2_caps | V4L2_CAP_STREAMING |
@@ -491,7 +491,7 @@ xvip_dma_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
static int
xvip_dma_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
if (f->index > 0)
@@ -505,7 +505,7 @@ xvip_dma_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
static int
xvip_dma_get_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
format->fmt.pix = dma->format;
@@ -565,7 +565,7 @@ __xvip_dma_try_format(struct xvip_dma *dma, struct v4l2_pix_format *pix,
static int
xvip_dma_try_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
__xvip_dma_try_format(dma, &format->fmt.pix, NULL);
@@ -575,7 +575,7 @@ xvip_dma_try_format(struct file *file, void *fh, struct v4l2_format *format)
static int
xvip_dma_set_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
const struct xvip_video_format *info;
diff --git a/drivers/media/usb/uvc/uvc_metadata.c b/drivers/media/usb/uvc/uvc_metadata.c
index 229e08ff323eed9129d835b24ea2e8085bb713b8..4cbf6ce314fdd548eb72127bf8f671f8a465783a 100644
--- a/drivers/media/usb/uvc/uvc_metadata.c
+++ b/drivers/media/usb/uvc/uvc_metadata.c
@@ -26,7 +26,7 @@
static int uvc_meta_v4l2_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct uvc_video_chain *chain = stream->chain;
@@ -42,7 +42,7 @@ static int uvc_meta_v4l2_querycap(struct file *file, void *fh,
static int uvc_meta_v4l2_get_format(struct file *file, void *fh,
struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct v4l2_meta_format *fmt = &format->fmt.meta;
@@ -60,7 +60,7 @@ static int uvc_meta_v4l2_get_format(struct file *file, void *fh,
static int uvc_meta_v4l2_try_format(struct file *file, void *fh,
struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct uvc_device *dev = stream->dev;
struct v4l2_meta_format *fmt = &format->fmt.meta;
@@ -86,7 +86,7 @@ static int uvc_meta_v4l2_try_format(struct file *file, void *fh,
static int uvc_meta_v4l2_set_format(struct file *file, void *fh,
struct v4l2_format *format)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct v4l2_meta_format *fmt = &format->fmt.meta;
int ret;
@@ -115,7 +115,7 @@ static int uvc_meta_v4l2_set_format(struct file *file, void *fh,
static int uvc_meta_v4l2_enum_formats(struct file *file, void *fh,
struct v4l2_fmtdesc *fdesc)
{
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct uvc_streaming *stream = video_get_drvdata(vfh->vdev);
struct uvc_device *dev = stream->dev;
u32 i = fdesc->index;
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c
index d49a68b36c28ba4b38b90b86b5bdfa631d86ada1..d46b2c8f3d23596293210125b148c3da99c52cac 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-api.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c
@@ -1253,7 +1253,7 @@ EXPORT_SYMBOL(v4l2_querymenu);
int v4l2_ctrl_log_status(struct file *file, void *fh)
{
struct video_device *vfd = video_devdata(file);
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev)
v4l2_ctrl_handler_log_status(vfh->ctrl_handler,
@@ -1348,7 +1348,7 @@ EXPORT_SYMBOL(v4l2_ctrl_subdev_subscribe_event);
*/
__poll_t v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
poll_wait(file, &fh->wait, wait);
if (v4l2_event_pending(fh))
diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
index 90eec79ee995a2d214590beeacc91b9f8f33236d..7a5f7aa5e25341df62bb4e3380bf19f46e2df955 100644
--- a/drivers/media/v4l2-core/v4l2-fh.c
+++ b/drivers/media/v4l2-core/v4l2-fh.c
@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(v4l2_fh_exit);
int v4l2_fh_release(struct file *filp)
{
- struct v4l2_fh *fh = filp->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(filp);
if (fh) {
v4l2_fh_del(fh);
diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index eb22d6172462da2cc6256087540223210c42b181..e67e67f76f7237452c0fd705df7afa0da4a65069 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -971,7 +971,7 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
rc = v4l2_m2m_poll_for_data(file, m2m_ctx, wait);
if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
poll_wait(file, &fh->wait, wait);
if (v4l2_event_pending(fh))
@@ -1004,7 +1004,7 @@ unsigned long v4l2_m2m_get_unmapped_area(struct file *file, unsigned long addr,
unsigned long len, unsigned long pgoff,
unsigned long flags)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
unsigned long offset = pgoff << PAGE_SHIFT;
struct vb2_queue *vq;
@@ -1371,7 +1371,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_request_queue);
int v4l2_m2m_ioctl_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *rb)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_reqbufs(file, fh->m2m_ctx, rb);
}
@@ -1380,7 +1380,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_reqbufs);
int v4l2_m2m_ioctl_create_bufs(struct file *file, void *priv,
struct v4l2_create_buffers *create)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_create_bufs(file, fh->m2m_ctx, create);
}
@@ -1389,7 +1389,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_create_bufs);
int v4l2_m2m_ioctl_remove_bufs(struct file *file, void *priv,
struct v4l2_remove_buffers *remove)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct vb2_queue *q = v4l2_m2m_get_vq(fh->m2m_ctx, remove->type);
if (!q)
@@ -1404,7 +1404,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_remove_bufs);
int v4l2_m2m_ioctl_querybuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_querybuf(file, fh->m2m_ctx, buf);
}
@@ -1413,7 +1413,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_querybuf);
int v4l2_m2m_ioctl_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_qbuf(file, fh->m2m_ctx, buf);
}
@@ -1422,7 +1422,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_qbuf);
int v4l2_m2m_ioctl_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_dqbuf(file, fh->m2m_ctx, buf);
}
@@ -1431,7 +1431,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_dqbuf);
int v4l2_m2m_ioctl_prepare_buf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_prepare_buf(file, fh->m2m_ctx, buf);
}
@@ -1440,7 +1440,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_prepare_buf);
int v4l2_m2m_ioctl_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *eb)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_expbuf(file, fh->m2m_ctx, eb);
}
@@ -1449,7 +1449,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_expbuf);
int v4l2_m2m_ioctl_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_streamon(file, fh->m2m_ctx, type);
}
@@ -1458,7 +1458,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_streamon);
int v4l2_m2m_ioctl_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_streamoff(file, fh->m2m_ctx, type);
}
@@ -1542,7 +1542,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_decoder_cmd);
int v4l2_m2m_ioctl_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *ec)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_encoder_cmd(file, fh->m2m_ctx, ec);
}
@@ -1551,7 +1551,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_encoder_cmd);
int v4l2_m2m_ioctl_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *dc)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_decoder_cmd(file, fh->m2m_ctx, dc);
}
@@ -1572,7 +1572,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_stateless_try_decoder_cmd);
int v4l2_m2m_ioctl_stateless_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *dc)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct vb2_v4l2_buffer *out_vb, *cap_vb;
struct v4l2_m2m_dev *m2m_dev = fh->m2m_ctx->m2m_dev;
unsigned long flags;
@@ -1617,7 +1617,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_ioctl_stateless_decoder_cmd);
int v4l2_m2m_fop_mmap(struct file *file, struct vm_area_struct *vma)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
return v4l2_m2m_mmap(file, fh->m2m_ctx, vma);
}
@@ -1625,7 +1625,7 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_fop_mmap);
__poll_t v4l2_m2m_fop_poll(struct file *file, poll_table *wait)
{
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
struct v4l2_m2m_ctx *m2m_ctx = fh->m2m_ctx;
__poll_t ret;
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 4fd25fea3b58477056729665706ddbacc436379c..29d3b788b288675c9ec849bb14e1936356d95743 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -122,7 +122,7 @@ static int subdev_close(struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
if (sd->internal_ops && sd->internal_ops->close)
@@ -612,7 +612,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg,
{
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
bool ro_subdev = test_bit(V4L2_FL_SUBDEV_RO_DEVNODE, &vdev->flags);
bool streams_subdev = sd->flags & V4L2_SUBDEV_FL_STREAMS;
@@ -1135,7 +1135,7 @@ static long subdev_do_ioctl_lock(struct file *file, unsigned int cmd, void *arg)
if (video_is_registered(vdev)) {
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct v4l2_fh *vfh = file->private_data;
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
struct v4l2_subdev_state *state;
@@ -1192,7 +1192,7 @@ static __poll_t subdev_poll(struct file *file, poll_table *wait)
{
struct video_device *vdev = video_devdata(file);
struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct v4l2_fh *fh = file->private_data;
+ struct v4l2_fh *fh = file_to_v4l2_fh(file);
if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
return EPOLLERR;
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index b5b3e00c8e6a0b082d9cd8a0c972a5094adcb6f2..823fa8ebeb8fbe36f05a1c31d3d3a9b7bba4de4d 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -56,6 +56,20 @@ struct v4l2_fh {
struct v4l2_m2m_ctx *m2m_ctx;
};
+/**
+ * file_to_v4l2_fh - Return the v4l2_fh associated with a struct file
+ *
+ * @filp: pointer to &struct file
+ *
+ * This function should be used by drivers to retrieve the &struct v4l2_fh
+ * instance pointer stored in the file private_data instead of accessing the
+ * private_data field directly.
+ */
+static inline struct v4l2_fh *file_to_v4l2_fh(struct file *filp)
+{
+ return filp->private_data;
+}
+
/**
* v4l2_fh_init - Initialise the file handle.
*
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 09/65] media: Replace file->private_data access with file_to_v4l2_fh()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (7 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 08/65] media: Wrap file->private_data access with a helper function Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access Jacopo Mondi
` (55 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@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 +-
drivers/media/platform/samsung/s3c-camif/camif-capture.c | 6 +++---
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 2 +-
drivers/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 485ca9747c4c1c4a78c7bb2cd998927b075d44e9..92acd23a8c4d0d44069accf02c8464bc27a15458 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 af25628b11bad9ee983e1921dc89044756986940..89e38b3036309af0747362bafad5024413c2c5bd 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 7b511f7f1cfc305a9ffe60722b9ebe093163787d..94e987e7b5e5d4af8f3cdc7c148eb2b33b1076b9 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 cac0f1a64feafc41d9f050f58004ae47f2e2ac90..bfd171a3ded40e66d0b601d9eb3e749cb39de58c 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 eefaf60489d3fba518acd12709f2e4831686620b..da57bc1baa46403c4a91f56e152334fa9dd83369 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 3d1db1121bf9cd4da0a8cf22f853bdfb375e74e0..2460f09a6813a320f7637bc332e641b7741ced21 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 7f8ffbac582fcf6a968e5ab000827d7086c18261..879b1803a2b38c6748fa4748f25504665f8106bb 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 c417e8c31f806e03555cd5e2a662a6efe5d58f3e..0c3b47b9958aa3388d91ffda9b2acfbb53f09f59 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 5b1ba1c69adba14c3560a4bc6d09435529f295a6..3c0c5f9dbe7bd54975e44ae87ee3df442305c0fe 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 3e566b65f4178a799e9172831dab6b7fa2004887..cae15a4ce5fd83f00ced8b2dfbb5f5a6f7483ca4 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 3e7f2df70408b882f6c9d47b66a8e092f6960927..43755043e8af907fe6755cfe6848ceb655444dfc 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 abd10b218aa1dc552004fe7ebcb815b3d6b8a43d..d0608b5d900fc83a6c63979d21ab3b4ce9a67af9 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 b76b5d18c963d9a3313d34cfe0e12772738d336f..4b9b2bec7377d724c272ff76fb8116b65227c542 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 c45f5cf12ded3c8b57483b148bf7bbffb8a458c5..e27f6761cba18e78e1833745e77347f7405957e0 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 1d1a9e7685050e53575a3bf09e9ff1df5aea0ee0..55d885be5bcc0541e4ea539a2fafeeb2d76680e3 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 434e9efbf9b21db4b1b903035d18e2a12f716947..ad3d0ab791d6aec4fb120dcfe86000e498f6713d 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 8d56168c72aa09f94ba2f0bdb2415e7247e08c14..9c9a93a3b5402741642253bbd1487f723d58fcf5 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 79c1723bd84cbf18060817a3b03f8d1e83990a38..be711cae2d492f8d259fda2dc0392a84f22565a4 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 049d40b948bb25276650d8ac6a83c8adf8221e51..f6e80b8d00a673dea89311e067375a8e460b81aa 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 4c431bd9b50352ed1bd3da3e62625c9cff6c149d..ea17f1a5f5b0a01d7ae159b7f00d65ce952f4974 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 7dc7c90ebf621c594bf5236276c402462d694a0a..481b03bbecf8134f75b3988e45fc392f07ae90fd 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 8b56252030480b8a5d2ef6de24902b544357ff02..70dc80e2b213dff333665022b3410b175d072793 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 8c07400bd280dea5d2e66e2759658c423bcd3866..8a5559225ff27cde3b1b7322abd16bac8c1617b9 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 46da373066f4ec786b87ef18b8372abee621332f..8c81852c30466865eca36fd41923f6d05dbf9293 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 bce7ffeac8fe50d3442f4993ae49ab5fc96ec3cd..116331cead2a6676f2c018b3f8fc10b0716dfc3a 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 6f44dd732315074e215f75e5df99c289f9cebe35..9e79cbe50715791a7f7ddd3bc20e9a28d221db61 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 fc9a8d31a1e983945838a6ac84f5b9090ac13697..886300a29b908a6dda3e2dfcb6b3414f782b172b 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (8 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 09/65] media: Replace file->private_data access with file_to_v4l2_fh() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
` (54 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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.
The tegra-vde driver accesses file->private_data in the tegra_open()
function, right after setting the field to &ctx->fh. Replace the
accesses with usage of &ctx->fh.
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index 531a85e3fe49ad0aa94fb96cbc7a84d474faae94..393dc3f07d5c78ff5ab0ae7b6368914859564458 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -836,10 +836,10 @@ static int tegra_open(struct file *file)
v4l2_fh_add(&ctx->fh);
tegra_reset_coded_fmt(ctx);
- tegra_try_coded_fmt(file, file->private_data, &ctx->coded_fmt);
+ tegra_try_coded_fmt(file, &ctx->fh, &ctx->coded_fmt);
tegra_reset_decoded_fmt(ctx);
- tegra_try_decoded_fmt(file, file->private_data, &ctx->decoded_fmt);
+ tegra_try_decoded_fmt(file, &ctx->fh, &ctx->decoded_fmt);
return 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 11/65] media: Replace file->private_data access with custom functions
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (9 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-06 8:16 ` Hans Verkuil
2025-08-18 14:10 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 12/65] media: pci: ivtv: Don't create fake v4l2_fh Jacopo Mondi
` (53 subsequent siblings)
64 siblings, 2 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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 and cast it to driver-specific file handle
structures with driver-specific functions that use file_to_v4l2_fh() and
perform the same cast.
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/ivtv/ivtv-driver.h | 5 ++++
drivers/media/pci/ivtv/ivtv-fileops.c | 10 +++----
drivers/media/pci/ivtv/ivtv-ioctl.c | 8 +++---
drivers/media/platform/allegro-dvt/allegro-core.c | 7 ++++-
drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 8 ++++--
.../media/platform/chips-media/coda/coda-common.c | 7 ++++-
.../platform/chips-media/wave5/wave5-helper.c | 2 +-
.../media/platform/chips-media/wave5/wave5-vpu.h | 5 ++++
drivers/media/platform/m2m-deinterlace.c | 7 ++++-
.../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 ++++-
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 7 ++++-
.../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 7 ++++-
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 2 +-
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 5 ++++
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 2 +-
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 5 ++++
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 7 ++++-
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 7 ++++-
drivers/media/platform/nxp/mx2_emmaprp.c | 7 ++++-
drivers/media/platform/renesas/rcar_fdp1.c | 7 ++++-
drivers/media/platform/renesas/rcar_jpu.c | 7 ++++-
drivers/media/platform/rockchip/rga/rga.c | 3 +--
drivers/media/platform/rockchip/rga/rga.h | 5 ++++
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 ++++
.../media/platform/samsung/exynos-gsc/gsc-core.h | 6 +++++
.../media/platform/samsung/exynos-gsc/gsc-m2m.c | 6 ++---
.../media/platform/samsung/exynos4-is/fimc-core.h | 5 ++++
.../media/platform/samsung/exynos4-is/fimc-m2m.c | 2 +-
drivers/media/platform/samsung/s5p-g2d/g2d.c | 7 +++--
.../media/platform/samsung/s5p-jpeg/jpeg-core.c | 9 +++++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 6 ++---
.../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +++++
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 7 ++++-
drivers/media/platform/st/sti/delta/delta-v4l2.c | 26 +++++++++++-------
drivers/media/platform/st/sti/hva/hva-v4l2.c | 31 ++++++++++++----------
drivers/media/platform/st/sti/hva/hva.h | 2 --
drivers/media/platform/st/stm32/dma2d/dma2d.c | 7 +++--
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +--
.../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +--
drivers/media/platform/ti/omap3isp/ispvideo.c | 4 +--
drivers/media/platform/ti/omap3isp/ispvideo.h | 6 +++++
drivers/media/platform/verisilicon/hantro.h | 5 ++++
drivers/media/platform/verisilicon/hantro_drv.c | 3 +--
drivers/staging/media/imx/imx-media-csc-scaler.c | 7 ++++-
drivers/staging/media/meson/vdec/vdec.c | 24 ++++++-----------
drivers/staging/media/meson/vdec/vdec.h | 5 ++++
drivers/staging/media/sunxi/cedrus/cedrus.c | 3 +--
drivers/staging/media/sunxi/cedrus/cedrus.h | 5 ++++
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 ----
50 files changed, 237 insertions(+), 100 deletions(-)
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index a6ffa99e16bc64a5b7d3e48c1ab32b49a7989242..cad548b28e360ecfe2bcb9fcb5d12cd8823c3727 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -388,6 +388,11 @@ static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
return container_of(fh, struct ivtv_open_id, fh);
}
+static inline struct ivtv_open_id *file2id(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct ivtv_open_id, fh);
+}
+
struct yuv_frame_info
{
u32 update;
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index 230d498108b5b0d44a238cd87dcea061811af814..cc91695a5b7605dcd964bd2c68bb12f645dc302f 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -502,7 +502,7 @@ int ivtv_start_capture(struct ivtv_open_id *id)
ssize_t ivtv_v4l2_read(struct file * filp, char __user *buf, size_t count, loff_t * pos)
{
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
ssize_t rc;
@@ -564,7 +564,7 @@ static int ivtv_schedule_dma(struct ivtv_stream *s)
static ssize_t ivtv_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
{
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
struct yuv_playback_info *yi = &itv->yuv_info;
@@ -719,7 +719,7 @@ static ssize_t ivtv_write(struct file *filp, const char __user *user_buf, size_t
ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
{
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
ssize_t res;
@@ -732,7 +732,7 @@ ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t c
__poll_t ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
{
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
__poll_t res = 0;
@@ -767,7 +767,7 @@ __poll_t ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
__poll_t ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait)
{
__poll_t req_events = poll_requested_events(wait);
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
int eof = test_bit(IVTV_F_S_STREAMOFF, &s->s_flags);
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 7947dcd615e882da5240ed6b10dde8449036d019..d888435b71fb6f6873d9d884248a67364576bf33 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -727,7 +727,7 @@ static int ivtv_s_register(struct file *file, void *fh, const struct v4l2_dbg_re
static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
{
- struct ivtv_open_id *id = fh2id(file->private_data);
+ struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
struct ivtv *itv = id->itv;
strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
@@ -1584,7 +1584,7 @@ static int ivtv_log_status(struct file *file, void *fh)
static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
{
- struct ivtv_open_id *id = fh2id(file->private_data);
+ struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
struct ivtv *itv = id->itv;
IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd);
@@ -1593,7 +1593,7 @@ static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd
static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
{
- struct ivtv_open_id *id = fh2id(file->private_data);
+ struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
struct ivtv *itv = id->itv;
IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd);
@@ -1602,7 +1602,7 @@ static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder
static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
{
- struct ivtv_open_id *id = fh2id(filp->private_data);
+ struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(filp));
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index 1f134e08923a528cc676f825da68951c97ac2f25..74977f3ae4844022c04de877f31b4fc6aaac0749 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -302,6 +302,11 @@ struct allegro_channel {
unsigned int error;
};
+static inline struct allegro_channel *file_to_channel(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct allegro_channel, fh);
+}
+
static inline int
allegro_channel_get_i_frame_qp(struct allegro_channel *channel)
{
@@ -3229,7 +3234,7 @@ static int allegro_open(struct file *file)
static int allegro_release(struct file *file)
{
- struct allegro_channel *channel = fh_to_channel(file->private_data);
+ struct allegro_channel *channel = file_to_channel(file);
v4l2_m2m_ctx_release(channel->fh.m2m_ctx);
diff --git a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
index 0c004bb8ba05059245e73a306ed2d20dc18c9197..c7df29a2d82012b7fc290edf3f629a0c3ed7bcc8 100644
--- a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
+++ b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
@@ -82,6 +82,11 @@ struct ge2d_ctx {
u32 xy_swap;
};
+static inline struct ge2d_ctx *file_to_ge2d_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct ge2d_ctx, fh);
+}
+
struct meson_ge2d {
struct v4l2_device v4l2_dev;
struct v4l2_m2m_dev *m2m_dev;
@@ -871,8 +876,7 @@ static int ge2d_open(struct file *file)
static int ge2d_release(struct file *file)
{
- struct ge2d_ctx *ctx =
- container_of(file->private_data, struct ge2d_ctx, fh);
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct meson_ge2d *ge2d = ctx->ge2d;
mutex_lock(&ge2d->mutex);
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index e6e3f5ec24f691fd5eac1896efc69d8541a49bf3..92fb24cace8ef75e70eb2aae96bc169a7cf97563 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -56,6 +56,11 @@
#define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh)
+static inline struct coda_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct coda_ctx, fh);
+}
+
int coda_debug;
module_param(coda_debug, int, 0644);
MODULE_PARM_DESC(coda_debug, "Debug level (0-2)");
@@ -2733,7 +2738,7 @@ static int coda_open(struct file *file)
static int coda_release(struct file *file)
{
struct coda_dev *dev = video_drvdata(file);
- struct coda_ctx *ctx = fh_to_ctx(file->private_data);
+ struct coda_ctx *ctx = file_to_ctx(file);
coda_dbg(1, ctx, "release instance (%p)\n", ctx);
diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.c
index 2c9d8cbca6e4b7e688408099a9d73e12eed5435b..031dea0ee61c6c5afddf7ff47d67d85826f16d8d 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-helper.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c
@@ -59,7 +59,7 @@ int wave5_vpu_release_device(struct file *filp,
int (*close_func)(struct vpu_instance *inst, u32 *fail_res),
char *name)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(filp->private_data);
+ struct vpu_instance *inst = file_to_vpu_inst(filp);
int ret = 0;
v4l2_m2m_ctx_release(inst->v4l2_fh.m2m_ctx);
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.h b/drivers/media/platform/chips-media/wave5/wave5-vpu.h
index 3847332551fc06555b4ba78d12abd2bc653ffea7..1e8fda9a010da3e7df3b37cfd3e39510d9e85bb3 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu.h
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.h
@@ -46,6 +46,11 @@ static inline struct vpu_instance *wave5_to_vpu_inst(struct v4l2_fh *vfh)
return container_of(vfh, struct vpu_instance, v4l2_fh);
}
+static inline struct vpu_instance *file_to_vpu_inst(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct vpu_instance, v4l2_fh);
+}
+
static inline struct vpu_instance *wave5_ctrl_to_vpu_inst(struct v4l2_ctrl *vctrl)
{
return container_of(vctrl->handler, struct vpu_instance, v4l2_ctrl_hdl);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 5188f31890966735c6eba990587627f43ff84378..1812c07837ad33e10db9005fd2009b4ea2a799d0 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -142,6 +142,11 @@ struct deinterlace_ctx {
struct dma_interleaved_template *xt;
};
+static inline struct deinterlace_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct deinterlace_ctx, fh);
+}
+
/*
* mem2mem callbacks
*/
@@ -872,7 +877,7 @@ static int deinterlace_open(struct file *file)
static int deinterlace_release(struct file *file)
{
struct deinterlace_dev *pcdev = video_drvdata(file);
- struct deinterlace_ctx *ctx = file->private_data;
+ struct deinterlace_ctx *ctx = file_to_ctx(file);
dprintk(pcdev, "Releasing instance %p\n", ctx);
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index 329e5787c2c282c43dcee80ceb0f1ba337324b74..bf7cae1993d5e21975bc9dffcbcfb3fe1843d575 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -124,6 +124,11 @@ static inline struct mtk_jpeg_ctx *mtk_jpeg_fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mtk_jpeg_ctx, fh);
}
+static inline struct mtk_jpeg_ctx *mtk_jpeg_file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mtk_jpeg_ctx, fh);
+}
+
static inline struct mtk_jpeg_src_buf *mtk_jpeg_vb2_to_srcbuf(
struct vb2_buffer *vb)
{
@@ -1208,7 +1213,7 @@ static int mtk_jpeg_open(struct file *file)
static int mtk_jpeg_release(struct file *file)
{
struct mtk_jpeg_dev *jpeg = video_drvdata(file);
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(file->private_data);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
index d0fd77dcf8e20fcd7a483f1fd0ce234f5ac2bf6b..e3e01a9a0f78cb2fe665132bd1bde66afa63bddb 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
@@ -353,6 +353,11 @@ static inline struct mtk_mdp_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mtk_mdp_ctx, fh);
}
+static inline struct mtk_mdp_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mtk_mdp_ctx, fh);
+}
+
static inline struct mtk_mdp_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct mtk_mdp_ctx, ctrl_handler);
@@ -1137,7 +1142,7 @@ static int mtk_mdp_m2m_open(struct file *file)
static int mtk_mdp_m2m_release(struct file *file)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(file->private_data);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct mtk_mdp_dev *mdp = ctx->mdp_dev;
flush_workqueue(mdp->job_wq);
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index 59ce5cce069836a6902df686f4dd91b13fa729f2..8ebab14c535bfe023d720964965d97f758e5eb63 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -15,6 +15,11 @@ static inline struct mdp_m2m_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mdp_m2m_ctx, fh);
}
+static inline struct mdp_m2m_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mdp_m2m_ctx, fh);
+}
+
static inline struct mdp_m2m_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct mdp_m2m_ctx, ctrl_handler);
@@ -643,7 +648,7 @@ static int mdp_m2m_open(struct file *file)
static int mdp_m2m_release(struct file *file)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(file->private_data);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
struct mdp_dev *mdp = video_drvdata(file);
struct device *dev = &mdp->pdev->dev;
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 9247d92d431d8570609423156b989878f7901f1c..18801883c31a80b2179eb0d9280150eeb4aa3770 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
@@ -294,7 +294,7 @@ static int fops_vcodec_open(struct file *file)
static int fops_vcodec_release(struct file *file)
{
struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file->private_data);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
index aececca7ecf8936bb2b3b55c99354af983746b30..75156c77405e59e148ed820dba70d90aa7e1fae8 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h
@@ -314,6 +314,11 @@ static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mtk_vcodec_dec_ctx, fh);
}
+static inline struct mtk_vcodec_dec_ctx *file_to_dec_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mtk_vcodec_dec_ctx, fh);
+}
+
static inline struct mtk_vcodec_dec_ctx *ctrl_to_dec_ctx(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct mtk_vcodec_dec_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 a1e4483abcdbdec22afc4747f439ea56c7181b75..e26a6c3ffa0cee17385575215b55b575b14e58f4 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
@@ -203,7 +203,7 @@ static int fops_vcodec_open(struct file *file)
static int fops_vcodec_release(struct file *file)
{
struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(file->private_data);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
mtk_v4l2_venc_dbg(1, ctx, "[%d] encoder", ctx->id);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
index 0bd85d0fb379acbba3ac07c01e780cf57bef0305..402e7d31d03d1985ad5ff2831faffc5c31b63467 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
@@ -222,6 +222,11 @@ static inline struct mtk_vcodec_enc_ctx *fh_to_enc_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mtk_vcodec_enc_ctx, fh);
}
+static inline struct mtk_vcodec_enc_ctx *file_to_enc_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mtk_vcodec_enc_ctx, fh);
+}
+
static inline struct mtk_vcodec_enc_ctx *ctrl_to_enc_ctx(struct v4l2_ctrl *ctrl)
{
return container_of(ctrl->handler, struct mtk_vcodec_enc_ctx, ctrl_hdl);
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index 1b2148578cb6751056b4111c6542f01d76c292c8..a17a020ea4c698bfa57253f0f53a17230d52dea3 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -649,6 +649,11 @@ static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mxc_jpeg_ctx, fh);
}
+static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mxc_jpeg_ctx, fh);
+}
+
static int enum_fmt(const struct mxc_jpeg_fmt *mxc_formats, int n,
struct v4l2_fmtdesc *f, u32 type)
{
@@ -2735,7 +2740,7 @@ static const struct v4l2_ioctl_ops mxc_jpeg_ioctl_ops = {
static int mxc_jpeg_release(struct file *file)
{
struct mxc_jpeg_dev *mxc_jpeg = video_drvdata(file);
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(file->private_data);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct device *dev = mxc_jpeg->dev;
mutex_lock(&mxc_jpeg->lock);
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 22e49d3a128732c077beb7ac2e2f688e0899f8e2..9226e42b95fc91ed5490be1599a539f0fdeeb123 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -79,6 +79,11 @@ static inline struct mxc_isi_m2m_ctx *to_isi_m2m_ctx(struct v4l2_fh *fh)
return container_of(fh, struct mxc_isi_m2m_ctx, fh);
}
+static inline struct mxc_isi_m2m_ctx *file_to_isi_m2m_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
+}
+
static inline struct mxc_isi_m2m_ctx_queue_data *
mxc_isi_m2m_ctx_qdata(struct mxc_isi_m2m_ctx *ctx, enum v4l2_buf_type type)
{
@@ -707,7 +712,7 @@ static int mxc_isi_m2m_open(struct file *file)
static int mxc_isi_m2m_release(struct file *file)
{
struct mxc_isi_m2m *m2m = video_drvdata(file);
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(file->private_data);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
mxc_isi_m2m_ctx_ctrls_delete(ctx);
diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.c
index 0c6cc120fd2a443db4dbc583f2cdb1cfd61b6a7e..5c8c6285ec1e7b2e8df64132228e71e1b097183e 100644
--- a/drivers/media/platform/nxp/mx2_emmaprp.c
+++ b/drivers/media/platform/nxp/mx2_emmaprp.c
@@ -214,6 +214,11 @@ struct emmaprp_ctx {
struct emmaprp_q_data q_data[2];
};
+static inline struct emmaprp_ctx *file_to_emmaprp_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct emmaprp_ctx, fh);
+}
+
static struct emmaprp_q_data *get_q_data(struct emmaprp_ctx *ctx,
enum v4l2_buf_type type)
{
@@ -758,7 +763,7 @@ static int emmaprp_open(struct file *file)
static int emmaprp_release(struct file *file)
{
struct emmaprp_dev *pcdev = video_drvdata(file);
- struct emmaprp_ctx *ctx = file->private_data;
+ struct emmaprp_ctx *ctx = file_to_emmaprp_ctx(file);
dprintk(pcdev, "Releasing instance %p\n", ctx);
diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
index 5d453a7a89889fa3fd115da5f87b4bb24554a3c6..f11ea9dc5027bdd89262270f4e3979a06650d9bc 100644
--- a/drivers/media/platform/renesas/rcar_fdp1.c
+++ b/drivers/media/platform/renesas/rcar_fdp1.c
@@ -635,6 +635,11 @@ static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct fdp1_ctx, fh);
}
+static inline struct fdp1_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct fdp1_ctx, fh);
+}
+
static struct fdp1_q_data *get_q_data(struct fdp1_ctx *ctx,
enum v4l2_buf_type type)
{
@@ -2158,7 +2163,7 @@ static int fdp1_open(struct file *file)
static int fdp1_release(struct file *file)
{
struct fdp1_dev *fdp1 = video_drvdata(file);
- struct fdp1_ctx *ctx = fh_to_ctx(file->private_data);
+ struct fdp1_ctx *ctx = file_to_ctx(file);
dprintk(fdp1, "Releasing instance %p\n", ctx);
diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
index 81038df71bb5d9b4b7464cedd7ca9bf38744921e..3ee51f53b0cd1c221cefd0ce93acbcda55faa4a6 100644
--- a/drivers/media/platform/renesas/rcar_jpu.c
+++ b/drivers/media/platform/renesas/rcar_jpu.c
@@ -485,6 +485,11 @@ static struct jpu_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct jpu_ctx, fh);
}
+static struct jpu_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct jpu_ctx, fh);
+}
+
static void jpu_set_tbl(struct jpu *jpu, u32 reg, const unsigned int *tbl,
unsigned int len) {
unsigned int i;
@@ -1281,7 +1286,7 @@ static int jpu_open(struct file *file)
static int jpu_release(struct file *file)
{
struct jpu *jpu = video_drvdata(file);
- struct jpu_ctx *ctx = fh_to_ctx(file->private_data);
+ struct jpu_ctx *ctx = file_to_ctx(file);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 3dccab5fa4a131289c18150e6afbf3309cde318b..8a6e618d605c216b5113062d90df03dc632dc7c8 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -411,8 +411,7 @@ static int rga_open(struct file *file)
static int rga_release(struct file *file)
{
- struct rga_ctx *ctx =
- container_of(file->private_data, struct rga_ctx, fh);
+ struct rga_ctx *ctx = file_to_rga_ctx(file);
struct rockchip_rga *rga = ctx->rga;
mutex_lock(&rga->mutex);
diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/platform/rockchip/rga/rga.h
index 530e12de73c4f574f13e60fc2540b425263bd3ef..72a28b120fabfdce39e7773358d0c9528019e882 100644
--- a/drivers/media/platform/rockchip/rga/rga.h
+++ b/drivers/media/platform/rockchip/rga/rga.h
@@ -68,6 +68,11 @@ struct rga_ctx {
u32 fill_color;
};
+static inline struct rga_ctx *file_to_rga_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct rga_ctx, fh);
+}
+
struct rockchip_rga {
struct v4l2_device v4l2_dev;
struct v4l2_m2m_dev *m2m_dev;
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index d707088ec0dc1f6a18b2d168ebdf20b443f2240e..41ab90cbcc0cdbe279f6512decc4301b6cff2dfa 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -953,7 +953,7 @@ static int rkvdec_open(struct file *filp)
static int rkvdec_release(struct file *filp)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(filp->private_data);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(filp);
v4l2_fh_del(&ctx->fh);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
index f6e8bf38add3a0bf00a5dedd244931aca4a28e0a..35effe9467845fdfc4ffea432211d1d2e75a08b0 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
@@ -129,6 +129,11 @@ static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
return container_of(fh, struct rkvdec_ctx, fh);
}
+static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh);
+}
+
struct rkvdec_aux_buf {
void *cpu;
dma_addr_t dma;
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-core.h b/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
index b9777e07fb6d14f8e9a97ee593a09a412326f157..a5491fe39e0f686c75c888c4632150f32326c36e 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
@@ -86,6 +86,7 @@ enum gsc_yuv_fmt {
};
#define fh_to_ctx(__fh) container_of(__fh, struct gsc_ctx, fh)
+
#define is_rgb(x) (!!((x) & 0x1))
#define is_yuv420(x) (!!((x) & 0x2))
#define is_yuv422(x) (!!((x) & 0x4))
@@ -381,6 +382,11 @@ struct gsc_ctx {
enum v4l2_colorspace out_colorspace;
};
+static inline struct gsc_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct gsc_ctx, fh);
+}
+
void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm);
int gsc_register_m2m_device(struct gsc_dev *gsc);
void gsc_unregister_m2m_device(struct gsc_dev *gsc);
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
index 4bda1c369c44c41265a42f2bab6f70ec532881bd..968bb4327b7a1697641815dfb08dc64251f5e927 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
@@ -666,7 +666,7 @@ static int gsc_m2m_open(struct file *file)
static int gsc_m2m_release(struct file *file)
{
- struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_dev *gsc = ctx->gsc_dev;
pr_debug("pid: %d, state: 0x%lx, refcnt= %d",
@@ -690,7 +690,7 @@ static int gsc_m2m_release(struct file *file)
static __poll_t gsc_m2m_poll(struct file *file,
struct poll_table_struct *wait)
{
- struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_dev *gsc = ctx->gsc_dev;
__poll_t ret;
@@ -705,7 +705,7 @@ static __poll_t gsc_m2m_poll(struct file *file,
static int gsc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
{
- struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_dev *gsc = ctx->gsc_dev;
int ret;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-core.h b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
index 63385152a2ffe82e9871497733971cfc8a1a1238..25711df062e79eb2066f0f6eab1c1733f16c9c2d 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
@@ -498,6 +498,11 @@ struct fimc_ctx {
#define fh_to_ctx(__fh) container_of(__fh, struct fimc_ctx, fh)
+static inline struct fimc_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct fimc_ctx, fh);
+}
+
static inline void set_frame_bounds(struct fimc_frame *f, u32 width, u32 height)
{
f->o_width = width;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
index 951433c8e92a5b75bad59f2e0dbf7d56f6726dee..feedf60dad09bd413cb8fe65d965fd39b26b8764 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
@@ -675,7 +675,7 @@ static int fimc_m2m_open(struct file *file)
static int fimc_m2m_release(struct file *file)
{
- struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct fimc_ctx *ctx = file_to_ctx(file);
struct fimc_dev *fimc = ctx->fimc_dev;
dbg("pid: %d, state: 0x%lx, refcnt= %d",
diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
index ffed16a34493be2edbdaee13619467417487c1e7..44fcedbbc90a9863827aacbcd5f56d850cb552ea 100644
--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
@@ -25,7 +25,10 @@
#include "g2d.h"
#include "g2d-regs.h"
-#define fh2ctx(__fh) container_of(__fh, struct g2d_ctx, fh)
+static inline struct g2d_ctx *file2ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh);
+}
static struct g2d_fmt formats[] = {
{
@@ -272,7 +275,7 @@ static int g2d_open(struct file *file)
static int g2d_release(struct file *file)
{
struct g2d_dev *dev = video_drvdata(file);
- struct g2d_ctx *ctx = fh2ctx(file->private_data);
+ struct g2d_ctx *ctx = file2ctx(file);
mutex_lock(&dev->mutex);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
index ac4cf269456a93ccb61c4978d81663e18124ca11..a8d0dddb1fb5b5344ac9c96657fcf17a575d6a26 100644
--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
@@ -585,6 +585,11 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct s5p_jpeg_ctx, fh);
}
+static inline struct s5p_jpeg_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct s5p_jpeg_ctx, fh);
+}
+
static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx)
{
switch (ctx->jpeg->variant->version) {
@@ -1012,7 +1017,7 @@ static int s5p_jpeg_open(struct file *file)
static int s5p_jpeg_release(struct file *file)
{
struct s5p_jpeg *jpeg = video_drvdata(file);
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
@@ -1828,7 +1833,7 @@ static int s5p_jpeg_g_selection(struct file *file, void *priv,
static int s5p_jpeg_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
struct v4l2_rect *rect = &s->r;
int ret = -EINVAL;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index 73fdcd362265ad123b3633b832e40fd3ca70c227..dd9761df59df5dd7b07b4e9afd2d7939c46cb2de 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -970,7 +970,7 @@ static int s5p_mfc_open(struct file *file)
/* Release MFC context */
static int s5p_mfc_release(struct file *file)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = ctx->dev;
/* if dev is null, do cleanup that doesn't need dev */
@@ -1027,7 +1027,7 @@ static int s5p_mfc_release(struct file *file)
static __poll_t s5p_mfc_poll(struct file *file,
struct poll_table_struct *wait)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = ctx->dev;
struct vb2_queue *src_q, *dst_q;
struct vb2_buffer *src_vb = NULL, *dst_vb = NULL;
@@ -1078,7 +1078,7 @@ static __poll_t s5p_mfc_poll(struct file *file,
/* Mmap */
static int s5p_mfc_mmap(struct file *file, struct vm_area_struct *vma)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
int ret;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 86c316c1ff8f69cd0f172fa14477331e325ed8f5..bdc25f6982d1eb6e846f1604484ea39968526bc0 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -768,6 +768,12 @@ struct mfc_control {
((f && f->op) ? f->op(args) : (typeof(f->op(args)))(-ENODEV))
#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
+
+static inline struct s5p_mfc_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct s5p_mfc_ctx, fh);
+}
+
#define ctrl_to_ctx(__ctrl) \
container_of((__ctrl)->handler, struct s5p_mfc_ctx, ctrl_handler)
diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
index 1eb934490c0b57d89557afa3cc776cdbe4a529ff..26c4e48e5e84bcf315692515448ae615727c454f 100644
--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
@@ -35,6 +35,11 @@
#define fh_to_ctx(__fh) container_of(__fh, struct bdisp_ctx, fh)
+static inline struct bdisp_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct bdisp_ctx, fh);
+}
+
enum bdisp_dev_flags {
ST_M2M_OPEN, /* Driver opened */
ST_M2M_RUNNING, /* HW device running */
@@ -644,7 +649,7 @@ static int bdisp_open(struct file *file)
static int bdisp_release(struct file *file)
{
- struct bdisp_ctx *ctx = fh_to_ctx(file->private_data);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct bdisp_dev *bdisp = ctx->bdisp_dev;
dev_dbg(bdisp->dev, "%s\n", __func__);
diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.c
index 196e6a40335d14898ff7abbb38d2de2f5bcf6789..8282e72af67084ddbb94ed78df87a07e1e8b860f 100644
--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c
@@ -25,6 +25,12 @@
#define DELTA_PREFIX "[---:----]"
#define to_ctx(__fh) container_of(__fh, struct delta_ctx, fh)
+
+static inline struct delta_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct delta_ctx, fh);
+}
+
#define to_au(__vbuf) container_of(__vbuf, struct delta_au, vbuf)
#define to_frame(__vbuf) container_of(__vbuf, struct delta_frame, vbuf)
@@ -382,7 +388,7 @@ static int delta_open_decoder(struct delta_ctx *ctx, u32 streamformat,
static int delta_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
strscpy(cap->driver, DELTA_NAME, sizeof(cap->driver));
@@ -396,7 +402,7 @@ static int delta_querycap(struct file *file, void *priv,
static int delta_enum_fmt_stream(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
if (unlikely(f->index >= delta->nb_of_streamformats))
@@ -410,7 +416,7 @@ static int delta_enum_fmt_stream(struct file *file, void *priv,
static int delta_enum_fmt_frame(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
if (unlikely(f->index >= delta->nb_of_pixelformats))
@@ -424,7 +430,7 @@ static int delta_enum_fmt_frame(struct file *file, void *priv,
static int delta_g_fmt_stream(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
struct v4l2_pix_format *pix = &f->fmt.pix;
struct delta_streaminfo *streaminfo = &ctx->streaminfo;
@@ -452,7 +458,7 @@ static int delta_g_fmt_stream(struct file *file, void *fh,
static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
struct v4l2_pix_format *pix = &f->fmt.pix;
struct delta_frameinfo *frameinfo = &ctx->frameinfo;
@@ -491,7 +497,7 @@ static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
static int delta_try_fmt_stream(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
struct v4l2_pix_format *pix = &f->fmt.pix;
u32 streamformat = pix->pixelformat;
@@ -545,7 +551,7 @@ static int delta_try_fmt_stream(struct file *file, void *priv,
static int delta_try_fmt_frame(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
struct v4l2_pix_format *pix = &f->fmt.pix;
u32 pixelformat = pix->pixelformat;
@@ -605,7 +611,7 @@ static int delta_try_fmt_frame(struct file *file, void *priv,
static int delta_s_fmt_stream(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
struct vb2_queue *vq;
struct v4l2_pix_format *pix = &f->fmt.pix;
@@ -641,7 +647,7 @@ static int delta_s_fmt_stream(struct file *file, void *fh,
static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
const struct delta_dec *dec = ctx->dec;
struct v4l2_pix_format *pix = &f->fmt.pix;
@@ -1690,7 +1696,7 @@ static int delta_open(struct file *file)
static int delta_release(struct file *file)
{
- struct delta_ctx *ctx = to_ctx(file->private_data);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_dev *delta = ctx->dev;
const struct delta_dec *dec = ctx->dec;
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c
index 5366c0f92549bb090967a1337ce55d0b0f1d76ce..29142c806cb74a510b2f27e79c9e10ca4088b1e9 100644
--- a/drivers/media/platform/st/sti/hva/hva-v4l2.c
+++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c
@@ -36,7 +36,10 @@
#define to_type_str(type) (type == V4L2_BUF_TYPE_VIDEO_OUTPUT ? \
"frame" : "stream")
-#define fh_to_ctx(f) (container_of(f, struct hva_ctx, fh))
+static inline struct hva_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct hva_ctx, fh);
+}
/* registry of available encoders */
static const struct hva_enc *hva_encoders[] = {
@@ -254,7 +257,7 @@ static void hva_dbg_summary(struct hva_ctx *ctx)
static int hva_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_dev *hva = ctx_to_hdev(ctx);
strscpy(cap->driver, HVA_NAME, sizeof(cap->driver));
@@ -268,7 +271,7 @@ static int hva_querycap(struct file *file, void *priv,
static int hva_enum_fmt_stream(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_dev *hva = ctx_to_hdev(ctx);
if (unlikely(f->index >= hva->nb_of_streamformats))
@@ -282,7 +285,7 @@ static int hva_enum_fmt_stream(struct file *file, void *priv,
static int hva_enum_fmt_frame(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_dev *hva = ctx_to_hdev(ctx);
if (unlikely(f->index >= hva->nb_of_pixelformats))
@@ -295,7 +298,7 @@ static int hva_enum_fmt_frame(struct file *file, void *priv,
static int hva_g_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_streaminfo *streaminfo = &ctx->streaminfo;
f->fmt.pix.width = streaminfo->width;
@@ -314,7 +317,7 @@ static int hva_g_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
static int hva_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_frameinfo *frameinfo = &ctx->frameinfo;
f->fmt.pix.width = frameinfo->width;
@@ -335,7 +338,7 @@ static int hva_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
static int hva_try_fmt_stream(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct device *dev = ctx_to_dev(ctx);
struct v4l2_pix_format *pix = &f->fmt.pix;
u32 streamformat = pix->pixelformat;
@@ -399,7 +402,7 @@ static int hva_try_fmt_stream(struct file *file, void *priv,
static int hva_try_fmt_frame(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct device *dev = ctx_to_dev(ctx);
struct v4l2_pix_format *pix = &f->fmt.pix;
u32 pixelformat = pix->pixelformat;
@@ -449,7 +452,7 @@ static int hva_try_fmt_frame(struct file *file, void *priv,
static int hva_s_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct device *dev = ctx_to_dev(ctx);
struct vb2_queue *vq;
int ret;
@@ -479,7 +482,7 @@ static int hva_s_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
static int hva_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct device *dev = ctx_to_dev(ctx);
struct v4l2_pix_format *pix = &f->fmt.pix;
struct vb2_queue *vq;
@@ -517,7 +520,7 @@ static int hva_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
static int hva_g_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct v4l2_fract *time_per_frame = &ctx->ctrls.time_per_frame;
if (sp->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -533,7 +536,7 @@ static int hva_g_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
static int hva_s_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct v4l2_fract *time_per_frame = &ctx->ctrls.time_per_frame;
if (sp->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -553,7 +556,7 @@ static int hva_s_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct device *dev = ctx_to_dev(ctx);
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -1225,7 +1228,7 @@ static int hva_open(struct file *file)
static int hva_release(struct file *file)
{
- struct hva_ctx *ctx = fh_to_ctx(file->private_data);
+ struct hva_ctx *ctx = file_to_ctx(file);
struct hva_dev *hva = ctx_to_hdev(ctx);
struct device *dev = ctx_to_dev(ctx);
const struct hva_enc *enc = ctx->enc;
diff --git a/drivers/media/platform/st/sti/hva/hva.h b/drivers/media/platform/st/sti/hva/hva.h
index ba6b893416ec47ce371ee9ed886a8ac5acc6cecf..1fe561082a7439a05588c6b399ae1afa5fc0f92c 100644
--- a/drivers/media/platform/st/sti/hva/hva.h
+++ b/drivers/media/platform/st/sti/hva/hva.h
@@ -13,8 +13,6 @@
#include <media/videobuf2-v4l2.h>
#include <media/v4l2-mem2mem.h>
-#define fh_to_ctx(f) (container_of(f, struct hva_ctx, fh))
-
#define hva_to_dev(h) (h->dev)
#define ctx_to_dev(c) (c->hva_dev->dev)
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index 48fa781aab06c14cd64e9b9eb1a278a2ef8ca7fc..f4c5d73447a7c3efb0ad5d9bb8a09432c1a8fa60 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -45,7 +45,10 @@
* whole of a destination image with a pixel format conversion.
*/
-#define fh2ctx(__fh) container_of(__fh, struct dma2d_ctx, fh)
+static inline struct dma2d_ctx *file2ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct dma2d_ctx, fh);
+}
static const struct dma2d_fmt formats[] = {
{
@@ -318,7 +321,7 @@ static int dma2d_open(struct file *file)
static int dma2d_release(struct file *file)
{
struct dma2d_dev *dev = video_drvdata(file);
- struct dma2d_ctx *ctx = fh2ctx(file->private_data);
+ struct dma2d_ctx *ctx = file2ctx(file);
mutex_lock(&dev->mutex);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index 43755043e8af907fe6755cfe6848ceb655444dfc..e9c7c99fbc559de85c33736a8f459cd216b8cdbf 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -756,8 +756,7 @@ static int deinterlace_open(struct file *file)
static int deinterlace_release(struct file *file)
{
struct deinterlace_dev *dev = video_drvdata(file);
- struct deinterlace_ctx *ctx = container_of(file->private_data,
- struct deinterlace_ctx, fh);
+ struct deinterlace_ctx *ctx = deinterlace_file2ctx(file);
mutex_lock(&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 d0608b5d900fc83a6c63979d21ab3b4ce9a67af9..9ea65cb7187fee323051b1cb62b342e119f7bb3d 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -691,8 +691,7 @@ static int rotate_open(struct file *file)
static int rotate_release(struct file *file)
{
struct rotate_dev *dev = video_drvdata(file);
- struct rotate_ctx *ctx = container_of(file->private_data,
- struct rotate_ctx, fh);
+ struct rotate_ctx *ctx = rotate_file2ctx(file);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
index a777135c6a6ca51c85c5a75b76cbc4a8421963ec..b76d40aeca17cf5b8b7619cadf0afe66ff283a9d 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -1373,7 +1373,7 @@ static int isp_video_release(struct file *file)
static __poll_t isp_video_poll(struct file *file, poll_table *wait)
{
- struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
__poll_t ret;
@@ -1386,7 +1386,7 @@ static __poll_t isp_video_poll(struct file *file, poll_table *wait)
static int isp_video_mmap(struct file *file, struct vm_area_struct *vma)
{
- struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
return vb2_mmap(&vfh->queue, vma);
}
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.h b/drivers/media/platform/ti/omap3isp/ispvideo.h
index 1d23df576e6b35f01d8b49a96a0acf1772c2e2c2..355812770e18ef5353ac68e65426a3180a6d91ab 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.h
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.h
@@ -195,6 +195,12 @@ struct isp_video_fh {
};
#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
+
+static inline struct isp_video_fh *file_to_isp_video_fh(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct isp_video_fh, vfh);
+}
+
#define isp_video_queue_to_isp_video_fh(q) \
container_of(q, struct isp_video_fh, queue)
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 81328c63b796f30be4736c8f263ce72548ed3a24..0f10714f1953945472e11d8c8ad87f8ec009b39f 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -387,6 +387,11 @@ static __always_inline struct hantro_ctx *fh_to_ctx(struct v4l2_fh *fh)
return container_of(fh, struct hantro_ctx, fh);
}
+static __always_inline struct hantro_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct hantro_ctx, fh);
+}
+
/* Register accessors. */
static __always_inline void vepu_write_relaxed(struct hantro_dev *vpu,
u32 val, u32 reg)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 8542238e0fb1d21576f87b8ebb37585a0144c949..b20b9c7f41319e1d9586d641200aeeebbd1ee761 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -687,8 +687,7 @@ static int hantro_open(struct file *filp)
static int hantro_release(struct file *filp)
{
- struct hantro_ctx *ctx =
- container_of(filp->private_data, struct hantro_ctx, fh);
+ struct hantro_ctx *ctx = file_to_ctx(filp);
/*
* No need for extra locking because this was the last reference
diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index 19fd31cb9bb0354b310d40da1f116bb96fd9b0c8..05a54242356c53d19770086dfcc2ed81e1cda4c1 100644
--- a/drivers/staging/media/imx/imx-media-csc-scaler.c
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -66,6 +66,11 @@ struct ipu_csc_scaler_ctx {
unsigned int sequence;
};
+static inline struct ipu_csc_scaler_ctx *file_to_ctx(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct ipu_csc_scaler_ctx, fh);
+}
+
static struct ipu_csc_scaler_q_data *get_q_data(struct ipu_csc_scaler_ctx *ctx,
enum v4l2_buf_type type)
{
@@ -797,7 +802,7 @@ static int ipu_csc_scaler_open(struct file *file)
static int ipu_csc_scaler_release(struct file *file)
{
struct ipu_csc_scaler_priv *priv = video_drvdata(file);
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(file->private_data);
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
dev_dbg(priv->dev, "Releasing instance %p\n", ctx);
diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
index 6d34a482492e8838cf9dbb104315b87abf3f3e3b..f1ee53f9f29868ae7cb02ce00764631f821ee74b 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -558,8 +558,7 @@ vdec_try_fmt_common(struct amvdec_session *sess, u32 size,
static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
vdec_try_fmt_common(sess, sess->core->platform->num_formats, f);
@@ -568,8 +567,7 @@ static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
@@ -596,8 +594,7 @@ static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
u32 num_formats = sess->core->platform->num_formats;
const struct amvdec_format *fmt_out;
@@ -658,8 +655,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
const struct vdec_platform *platform = sess->core->platform;
const struct amvdec_format *fmt_out;
@@ -688,8 +684,7 @@ static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
static int vdec_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *fsize)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
const struct amvdec_format *formats = sess->core->platform->formats;
const struct amvdec_format *fmt;
u32 num_formats = sess->core->platform->num_formats;
@@ -713,8 +708,7 @@ static int vdec_enum_framesizes(struct file *file, void *fh,
static int
vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops;
struct device *dev = sess->core->dev;
int ret;
@@ -773,8 +767,7 @@ static int vdec_subscribe_event(struct v4l2_fh *fh,
static int vdec_g_pixelaspect(struct file *file, void *fh, int type,
struct v4l2_fract *f)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
return -EINVAL;
@@ -930,8 +923,7 @@ static int vdec_open(struct file *file)
static int vdec_close(struct file *file)
{
- struct amvdec_session *sess =
- container_of(file->private_data, struct amvdec_session, fh);
+ struct amvdec_session *sess = file_to_amvdec_session(file);
v4l2_m2m_ctx_release(sess->m2m_ctx);
v4l2_m2m_release(sess->m2m_dev);
diff --git a/drivers/staging/media/meson/vdec/vdec.h b/drivers/staging/media/meson/vdec/vdec.h
index 2586851777000ef4afaf91824ea3f32168a94dd1..7a5d8e871d708db9639563c056ba4b3fe9930eec 100644
--- a/drivers/staging/media/meson/vdec/vdec.h
+++ b/drivers/staging/media/meson/vdec/vdec.h
@@ -282,6 +282,11 @@ struct amvdec_session {
void *priv;
};
+static inline struct amvdec_session *file_to_amvdec_session(struct file *filp)
+{
+ return container_of(file_to_v4l2_fh(filp), struct amvdec_session, fh);
+}
+
u32 amvdec_get_output_size(struct amvdec_session *sess);
#endif
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
index 52a9588462ce5898705cc351fa461f3c49600ad2..80b43187f6eef827c7212a601aa2056dbc606bd4 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
@@ -401,8 +401,7 @@ static int cedrus_open(struct file *file)
static int cedrus_release(struct file *file)
{
struct cedrus_dev *dev = video_drvdata(file);
- struct cedrus_ctx *ctx = container_of(file->private_data,
- struct cedrus_ctx, fh);
+ struct cedrus_ctx *ctx = cedrus_file2ctx(file);
mutex_lock(&dev->dev_mutex);
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h
index 522c184e2afc99c195a39889893b3d4dfc2bfad9..c4b1217c14b6464b5b730c2af4083c58c36c0edf 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus.h
+++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
@@ -155,6 +155,11 @@ struct cedrus_ctx {
} codec;
};
+static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file)
+{
+ return container_of(file_to_v4l2_fh(file), struct cedrus_ctx, fh);
+}
+
struct cedrus_dec_ops {
void (*irq_clear)(struct cedrus_ctx *ctx);
void (*irq_disable)(struct cedrus_ctx *ctx);
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index 9fae2c7493d090878a9f4f0f3923b1c6fd96dbe3..ad4ec349077547ea3428c7341f152d729d775bb2 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -83,11 +83,6 @@ static struct cedrus_format cedrus_formats[] = {
#define CEDRUS_FORMATS_COUNT ARRAY_SIZE(cedrus_formats)
-static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file)
-{
- return container_of(file->private_data, struct cedrus_ctx, fh);
-}
-
static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
u32 pixelformat, u32 directions)
{
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 12/65] media: pci: ivtv: Don't create fake v4l2_fh
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (10 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static Jacopo Mondi
` (52 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The ivtv driver has a structure named ivtv_open_id that models an open
file handle for the device. It embeds a v4l2_fh instance for file
handles that correspond to a V4L2 video device, and stores a pointer to
that v4l2_fh in struct ivtv_stream to identify which open file handle
owns a particular stream.
In addition to video devices, streams can be owned by ALSA PCM devices.
Those devices do not make use of the v4l2_fh instance for obvious
reasons, but the snd_ivtv_pcm_capture_open() function still initializes
a "fake" v4l2_fh for the sole purpose of using it as an open file handle
identifier. The v4l2_fh is not properly destroyed when the ALSA PCM
device is closed, leading to possible resource leaks.
Fortunately, the v4l2_fh instance pointed to by ivtv_stream is not
accessed, only the pointer value is used for comparison. Replace it with
a pointer to the ivtv_open_id structure that embeds the v4l2_fh, and
don't initialize the v4l2_fh for ALSA PCM devices.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/ivtv/ivtv-alsa-pcm.c | 2 --
drivers/media/pci/ivtv/ivtv-driver.h | 3 ++-
drivers/media/pci/ivtv/ivtv-fileops.c | 18 +++++++++---------
drivers/media/pci/ivtv/ivtv-irq.c | 4 ++--
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index 8f346d7da9c8defb12191c3addb12a118547b9a0..269a799ec046c67265484945acf89a5fbd40a3f4 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -148,14 +148,12 @@ static int snd_ivtv_pcm_capture_open(struct snd_pcm_substream *substream)
s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
- v4l2_fh_init(&item.fh, &s->vdev);
item.itv = itv;
item.type = s->type;
/* See if the stream is available */
if (ivtv_claim_stream(&item, item.type)) {
/* No, it's already in use */
- v4l2_fh_exit(&item.fh);
snd_ivtv_unlock(itvsc);
return -EBUSY;
}
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index cad548b28e360ecfe2bcb9fcb5d12cd8823c3727..38c4ceb04cf834906ed877b57c20fcbdb390da13 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -322,6 +322,7 @@ struct ivtv_queue {
};
struct ivtv; /* forward reference */
+struct ivtv_open_id;
struct ivtv_stream {
/* These first four fields are always set, even if the stream
@@ -331,7 +332,7 @@ struct ivtv_stream {
const char *name; /* name of the stream */
int type; /* stream type */
- struct v4l2_fh *fh; /* pointer to the streaming filehandle */
+ struct ivtv_open_id *id; /* pointer to the streaming ivtv_open_id */
spinlock_t qlock; /* locks access to the queues */
unsigned long s_flags; /* status flags, see above */
int dma; /* can be PCI_DMA_TODEVICE, PCI_DMA_FROMDEVICE or PCI_DMA_NONE */
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index cc91695a5b7605dcd964bd2c68bb12f645dc302f..67964a3c382c6627a7b3ce6380a2da97dcc47c3d 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -39,16 +39,16 @@ int ivtv_claim_stream(struct ivtv_open_id *id, int type)
if (test_and_set_bit(IVTV_F_S_CLAIMED, &s->s_flags)) {
/* someone already claimed this stream */
- if (s->fh == &id->fh) {
+ if (s->id == id) {
/* yes, this file descriptor did. So that's OK. */
return 0;
}
- if (s->fh == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI ||
+ if (s->id == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI ||
type == IVTV_ENC_STREAM_TYPE_VBI)) {
/* VBI is handled already internally, now also assign
the file descriptor to this stream for external
reading of the stream. */
- s->fh = &id->fh;
+ s->id = id;
IVTV_DEBUG_INFO("Start Read VBI\n");
return 0;
}
@@ -56,7 +56,7 @@ int ivtv_claim_stream(struct ivtv_open_id *id, int type)
IVTV_DEBUG_INFO("Stream %d is busy\n", type);
return -EBUSY;
}
- s->fh = &id->fh;
+ s->id = id;
if (type == IVTV_DEC_STREAM_TYPE_VBI) {
/* Enable reinsertion interrupt */
ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT);
@@ -94,7 +94,7 @@ void ivtv_release_stream(struct ivtv_stream *s)
struct ivtv *itv = s->itv;
struct ivtv_stream *s_vbi;
- s->fh = NULL;
+ s->id = NULL;
if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) &&
test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) {
/* this stream is still in use internally */
@@ -126,7 +126,7 @@ void ivtv_release_stream(struct ivtv_stream *s)
/* was already cleared */
return;
}
- if (s_vbi->fh) {
+ if (s_vbi->id) {
/* VBI stream still claimed by a file descriptor */
return;
}
@@ -359,7 +359,7 @@ static ssize_t ivtv_read(struct ivtv_stream *s, char __user *ubuf, size_t tot_co
size_t tot_written = 0;
int single_frame = 0;
- if (atomic_read(&itv->capturing) == 0 && s->fh == NULL) {
+ if (atomic_read(&itv->capturing) == 0 && s->id == NULL) {
/* shouldn't happen */
IVTV_DEBUG_WARN("Stream %s not initialized before read\n", s->name);
return -EIO;
@@ -831,7 +831,7 @@ void ivtv_stop_capture(struct ivtv_open_id *id, int gop_end)
id->type == IVTV_ENC_STREAM_TYPE_VBI) &&
test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) {
/* Also used internally, don't stop capturing */
- s->fh = NULL;
+ s->id = NULL;
}
else {
ivtv_stop_v4l2_encode_stream(s, gop_end);
@@ -915,7 +915,7 @@ int ivtv_v4l2_close(struct file *filp)
v4l2_fh_exit(fh);
/* Easy case first: this stream was never claimed by us */
- if (s->fh != &id->fh)
+ if (s->id != id)
goto close_done;
/* 'Unclaim' this stream */
diff --git a/drivers/media/pci/ivtv/ivtv-irq.c b/drivers/media/pci/ivtv/ivtv-irq.c
index 748c14e879632ae6f62c3cc1981a168b01ed060d..20ba5ae9c6d1d0e6e4d856d1f083e30a0f9be321 100644
--- a/drivers/media/pci/ivtv/ivtv-irq.c
+++ b/drivers/media/pci/ivtv/ivtv-irq.c
@@ -305,7 +305,7 @@ static void dma_post(struct ivtv_stream *s)
ivtv_process_vbi_data(itv, buf, 0, s->type);
s->q_dma.bytesused += buf->bytesused;
}
- if (s->fh == NULL) {
+ if (s->id == NULL) {
ivtv_queue_move(s, &s->q_dma, NULL, &s->q_free, 0);
return;
}
@@ -330,7 +330,7 @@ static void dma_post(struct ivtv_stream *s)
set_bit(IVTV_F_I_HAVE_WORK, &itv->i_flags);
}
- if (s->fh)
+ if (s->id)
wake_up(&s->waitq);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (11 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 12/65] media: pci: ivtv: Don't create fake v4l2_fh Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-05 1:34 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release() Jacopo Mondi
` (51 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Some functions defined in vpu_v4l2.c are never used outside of that
compilation unit. Make them static.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/amphion/vpu_v4l2.c | 12 +++++++++---
drivers/media/platform/amphion/vpu_v4l2.h | 8 --------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
index 74668fa362e24fd34829b500e99c8455a9413fc1..306d94e0f8e79faaacfa35b28e5786860f7bd1ca 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.c
+++ b/drivers/media/platform/amphion/vpu_v4l2.c
@@ -24,6 +24,11 @@
#include "vpu_msgs.h"
#include "vpu_helpers.h"
+static char *vpu_type_name(u32 type)
+{
+ return V4L2_TYPE_IS_OUTPUT(type) ? "output" : "capture";
+}
+
void vpu_inst_lock(struct vpu_inst *inst)
{
mutex_lock(&inst->lock);
@@ -42,7 +47,7 @@ dma_addr_t vpu_get_vb_phy_addr(struct vb2_buffer *vb, u32 plane_no)
vb->planes[plane_no].data_offset;
}
-unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no)
+static unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no)
{
if (plane_no >= vb->num_planes)
return 0;
@@ -81,7 +86,7 @@ void vpu_v4l2_set_error(struct vpu_inst *inst)
vpu_inst_unlock(inst);
}
-int vpu_notify_eos(struct vpu_inst *inst)
+static int vpu_notify_eos(struct vpu_inst *inst)
{
static const struct v4l2_event ev = {
.id = 0,
@@ -573,7 +578,8 @@ static void vpu_vb2_buf_finish(struct vb2_buffer *vb)
call_void_vop(inst, on_queue_empty, q->type);
}
-void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type, enum vb2_buffer_state state)
+static void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type,
+ enum vb2_buffer_state state)
{
struct vb2_v4l2_buffer *buf;
diff --git a/drivers/media/platform/amphion/vpu_v4l2.h b/drivers/media/platform/amphion/vpu_v4l2.h
index 56f2939fa84d07b7ea07e889ab5ad3bb7ca9ab5c..4a87b06ae520306ede356b6f3309d8b4a67c204a 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.h
+++ b/drivers/media/platform/amphion/vpu_v4l2.h
@@ -26,15 +26,12 @@ void vpu_skip_frame(struct vpu_inst *inst, int count);
struct vb2_v4l2_buffer *vpu_find_buf_by_sequence(struct vpu_inst *inst, u32 type, u32 sequence);
struct vb2_v4l2_buffer *vpu_find_buf_by_idx(struct vpu_inst *inst, u32 type, u32 idx);
void vpu_v4l2_set_error(struct vpu_inst *inst);
-int vpu_notify_eos(struct vpu_inst *inst);
int vpu_notify_source_change(struct vpu_inst *inst);
int vpu_set_last_buffer_dequeued(struct vpu_inst *inst, bool eos);
-void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type, enum vb2_buffer_state state);
int vpu_get_num_buffers(struct vpu_inst *inst, u32 type);
bool vpu_is_source_empty(struct vpu_inst *inst);
dma_addr_t vpu_get_vb_phy_addr(struct vb2_buffer *vb, u32 plane_no);
-unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no);
static inline struct vpu_format *vpu_get_format(struct vpu_inst *inst, u32 type)
{
if (V4L2_TYPE_IS_OUTPUT(type))
@@ -43,11 +40,6 @@ static inline struct vpu_format *vpu_get_format(struct vpu_inst *inst, u32 type)
return &inst->cap_format;
}
-static inline char *vpu_type_name(u32 type)
-{
- return V4L2_TYPE_IS_OUTPUT(type) ? "output" : "capture";
-}
-
static inline int vpu_vb_is_codecconfig(struct vb2_v4l2_buffer *vbuf)
{
#ifdef V4L2_BUF_FLAG_CODECCONFIG
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (12 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-05 1:43 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 15/65] media: visl: Drop visl_v4l2fh_to_ctx() function Jacopo Mondi
` (50 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The v4l2_fh initialized and added in vpu_v4l2_open() is delete and
cleaned up when the last reference to the vpu_inst is released. This may
happen later than at vpu_v4l2_close() time.
Not deleting and cleaning up the v4l2_fh when closing the file handle to
the video device is not ideal, as the v4l2_fh will still be present in
the video device's fh_list, and will store a copy of events queued to
the video device. There may also be other side effects of keeping alive
an object that represents an open file handle after the file handle is
closed.
The v4l2_fh instance is embedded in the vpu_inst structure, and is
accessed in two different ways:
- in vpu_notify_eos() and vpu_notify_source_change(), to queue V4L2
events to the file handle ; and
- through the driver to access the v4l2_fh.m2m_ctx pointer.
The v4l2_fh.m2m_ctx pointer is not touched by v4l2_fh_del() and
v4l2_fh_exit(). It is set to NULL by the driver when closing the file
handle, in vpu_v4l2_close().
The vpu_notify_eos() and vpu_notify_source_change() functions are called
in vpu_set_last_buffer_dequeued() and vdec_handle_resolution_change()
respectively, only if the v4l2_fh.m2m_ctx pointer is not NULL. There is
therefore a guarantee that no new event will be queued to the v4l2_fh
after vpu_v4l2_close() destroys the m2m_ctx.
The vpu_notify_eos() function is also called from vpu_vb2_buf_finish(),
which is guaranteed to be called for all queued buffers when
vpu_v4l2_close() calls v4l2_m2m_ctx_release(), and will not be called
later.
It is therefore safe to assume that the driver will not touch the
v4l2_fh, except to check the m2m_ctx pointer, after vpu_v4l2_close()
destroys the m2m_ctx. We can safely delete and cleanup the v4l2_fh
synchronously in vpu_v4l2_close().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/amphion/vpu_v4l2.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c
index 306d94e0f8e79faaacfa35b28e5786860f7bd1ca..57ca6262bb04b356a85e217ef51cfb13cb9a0a36 100644
--- a/drivers/media/platform/amphion/vpu_v4l2.c
+++ b/drivers/media/platform/amphion/vpu_v4l2.c
@@ -724,8 +724,6 @@ static int vpu_v4l2_release(struct vpu_inst *inst)
v4l2_ctrl_handler_free(&inst->ctrl_handler);
mutex_destroy(&inst->lock);
- v4l2_fh_del(&inst->fh);
- v4l2_fh_exit(&inst->fh);
call_void_vop(inst, cleanup);
@@ -794,6 +792,8 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst *inst)
return 0;
error:
+ v4l2_fh_del(&inst->fh);
+ v4l2_fh_exit(&inst->fh);
vpu_inst_put(inst);
return ret;
}
@@ -813,6 +813,9 @@ int vpu_v4l2_close(struct file *file)
call_void_vop(inst, release);
vpu_inst_unlock(inst);
+ v4l2_fh_del(&inst->fh);
+ v4l2_fh_exit(&inst->fh);
+
vpu_inst_unregister(inst);
vpu_inst_put(inst);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 15/65] media: visl: Drop visl_v4l2fh_to_ctx() function
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (13 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 16/65] media: v4l2-fh: Move piece of documentation to correct function Jacopo Mondi
` (49 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The visl_v4l2fh_to_ctx() function is unused. Drop it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/test-drivers/visl/visl.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/drivers/media/test-drivers/visl/visl.h b/drivers/media/test-drivers/visl/visl.h
index ad3d0ab791d6aec4fb120dcfe86000e498f6713d..2971e8b37ff6660f68b5f4bbf199e0f8657f6686 100644
--- a/drivers/media/test-drivers/visl/visl.h
+++ b/drivers/media/test-drivers/visl/visl.h
@@ -166,11 +166,6 @@ static inline struct visl_ctx *visl_file_to_ctx(struct file *file)
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)
-{
- return container_of(v4l2_fh, struct visl_ctx, fh);
-}
-
void *visl_find_control_data(struct visl_ctx *ctx, u32 id);
struct v4l2_ctrl *visl_find_control(struct visl_ctx *ctx, u32 id);
u32 visl_control_num_elems(struct visl_ctx *ctx, u32 id);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 16/65] media: v4l2-fh: Move piece of documentation to correct function
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (14 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 15/65] media: visl: Drop visl_v4l2fh_to_ctx() function Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 17/65] media: rcar-vin: Do not set file->private_data Jacopo Mondi
` (48 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The paragraph in the v4l2_fh_del() documentation that indicates the
function sets filp->private_data was added in the wrong place. It is
meant for v4l2_fh_open(). Move it to where it belongs.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
include/media/v4l2-fh.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
index 823fa8ebeb8fbe36f05a1c31d3d3a9b7bba4de4d..14e7136e693f0a7b8b25959200603028e0db36ac 100644
--- a/include/media/v4l2-fh.h
+++ b/include/media/v4l2-fh.h
@@ -101,6 +101,9 @@ void v4l2_fh_add(struct v4l2_fh *fh);
*
* It allocates a v4l2_fh and inits and adds it to the &struct video_device
* associated with the file pointer.
+ *
+ * On error filp->private_data will be %NULL, otherwise it will point to
+ * the &struct v4l2_fh.
*/
int v4l2_fh_open(struct file *filp);
@@ -109,9 +112,6 @@ int v4l2_fh_open(struct file *filp);
*
* @fh: pointer to &struct v4l2_fh
*
- * On error filp->private_data will be %NULL, otherwise it will point to
- * the &struct v4l2_fh.
- *
* .. note::
* Must be called in v4l2_file_operations->release\(\) handler if the driver
* uses &struct v4l2_fh.
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 17/65] media: rcar-vin: Do not set file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (15 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 16/65] media: v4l2-fh: Move piece of documentation to correct function Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 13:26 ` Niklas Söderlund
2025-08-02 9:22 ` [PATCH 18/65] media: rzg2l-cru: " Jacopo Mondi
` (47 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The R-Car VIN driver sets file->private_data to the driver-specific
structure, but the following call to v4l2_fh_open() overwrites it
with a pointer to the just allocated v4l2_fh.
Remove the mis-leading assignment in the driver.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
index 62eddf3a35fc91434cb2e584a01819380a7a6dd8..079dbaf016c25139e2ac82be63d8fce0d11fd208 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
@@ -588,8 +588,6 @@ static int rvin_open(struct file *file)
if (ret)
goto err_pm;
- file->private_data = vin;
-
ret = v4l2_fh_open(file);
if (ret)
goto err_unlock;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 18/65] media: rzg2l-cru: Do not set file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (16 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 17/65] media: rcar-vin: Do not set file->private_data Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-04 10:01 ` Tommaso Merciai
2025-08-02 9:22 ` [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open() Jacopo Mondi
` (46 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The RZ G2/L CRU driver sets file->private_data to the driver-specific
structure, but the following call to v4l2_fh_open() overwrites it
with a pointer to the just allocated v4l2_fh.
Remove the mis-leading assignment in the driver.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
index a8817a7066b22f8a8dd1fdab50efabc486e4dfdb..941badc90ff55c5225644f88de1d70239eb3a247 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
@@ -1078,7 +1078,6 @@ static int rzg2l_cru_open(struct file *file)
if (ret)
return ret;
- file->private_data = cru;
ret = v4l2_fh_open(file);
if (ret)
goto err_unlock;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (17 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 18/65] media: rzg2l-cru: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-24 19:04 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 20/65] media: camss: Remove custom .release fop() Jacopo Mondi
` (45 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/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 8d05802d1735a35cb1a1a0a81c6666b1517dd2e6..c5d02f9ebc6aa9bfd6910944f3d40a2e5f0a908f 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,
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 20/65] media: camss: Remove custom .release fop()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (18 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-24 19:07 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 21/65] media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance() Jacopo Mondi
` (44 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
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 c5d02f9ebc6aa9bfd6910944f3d40a2e5f0a908f..831486e14754ab3a24b077e21be14ea3169220a4 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,
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 21/65] media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (19 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 20/65] media: camss: Remove custom .release fop() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 22/65] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Jacopo Mondi
` (43 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
In preparation for a tree-wide rework automated with coccinelle that
will need to access a struct file pointer in the
wave5_cleanup_instance() function, pass it from the callers. There is
not functional change yet.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/chips-media/wave5/wave5-helper.c | 4 ++--
drivers/media/platform/chips-media/wave5/wave5-helper.h | 2 +-
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 2 +-
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.c
index 031dea0ee61c6c5afddf7ff47d67d85826f16d8d..ed8ff04a899da0a3c9e0f037dac2c9548c98920f 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-helper.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c
@@ -27,7 +27,7 @@ const char *state_to_str(enum vpu_instance_state state)
}
}
-void wave5_cleanup_instance(struct vpu_instance *inst)
+void wave5_cleanup_instance(struct vpu_instance *inst, struct file *filp)
{
int i;
@@ -78,7 +78,7 @@ int wave5_vpu_release_device(struct file *filp,
}
}
- wave5_cleanup_instance(inst);
+ wave5_cleanup_instance(inst, filp);
return ret;
}
diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.h b/drivers/media/platform/chips-media/wave5/wave5-helper.h
index 9937fce553fc33000bd31abcfc6d7345f6f7e485..976a402e426ff329490717925a08a76d777cbe3e 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-helper.h
+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.h
@@ -14,7 +14,7 @@
#define MAX_FMTS 12
const char *state_to_str(enum vpu_instance_state state);
-void wave5_cleanup_instance(struct vpu_instance *inst);
+void wave5_cleanup_instance(struct vpu_instance *inst, struct file *filp);
int wave5_vpu_release_device(struct file *filp,
int (*close_func)(struct vpu_instance *inst, u32 *fail_res),
char *name);
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 fd71f0c43ac37a0bb56f669d4b89d6054cb181d5..f3188d720ed3e183f3400816a9c939014213711d 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1840,7 +1840,7 @@ static int wave5_vpu_open_dec(struct file *filp)
return 0;
cleanup_inst:
- wave5_cleanup_instance(inst);
+ wave5_cleanup_instance(inst, filp);
return ret;
}
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 1e5fc5f8b856c5329b2c6007649285a28749b6aa..b69a1206fa12c2ff5f3a32d269b8fd3b80a597aa 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
@@ -1784,7 +1784,7 @@ static int wave5_vpu_open_enc(struct file *filp)
return 0;
cleanup_inst:
- wave5_cleanup_instance(inst);
+ wave5_cleanup_instance(inst, filp);
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 22/65] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (20 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 21/65] media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 23/65] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Jacopo Mondi
` (42 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@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 0c3b47b9958aa3388d91ffda9b2acfbb53f09f59..d5f99519def45d1c5859e641eed490ec9ad5784a 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 23/65] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (21 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 22/65] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 24/65] media: qcom: iris: Drop unused argument to iris_get_inst() Jacopo Mondi
` (41 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@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 d5f99519def45d1c5859e641eed490ec9ad5784a..73c96498759cbde8e1d9870336023e7773f6f28b 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;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 24/65] media: qcom: iris: Drop unused argument to iris_get_inst()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (22 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 23/65] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 25/65] media: qcom: venus: Pass file pointer to venus_close_common() Jacopo Mondi
` (40 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The second argument to the iris_get_inst() function is never used. Drop
it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@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 73c96498759cbde8e1d9870336023e7773f6f28b..64ebec2ca6b3d58118ac1a6f4ddeed2e43de6d5b 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 25/65] media: qcom: venus: Pass file pointer to venus_close_common()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (23 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 24/65] media: qcom: iris: Drop unused argument to iris_get_inst() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 26/65] media: Set file->private_data in v4l2_fh_add() Jacopo Mondi
` (39 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@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 4c049c694d9c43845c4c0eb51e260808dc9136ac..5e1ace16a4903999c7fd7a985317dae8dd2410ba 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 3c0c5f9dbe7bd54975e44ae87ee3df442305c0fe..db7b69b91db5649bbd9cad0866f0853f796897ac 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 29b0d6a5303d7ae08ac25a10e402ba65120eb666..d10ca6d89f6d76c052b27b1154c8dd9c49466e23 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 c0a0ccdded8015bf3c99ab2dff404a64afca8dff..0838d64ce8fee5dd8299d5c394e97910f10f7ee3 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 26/65] media: Set file->private_data in v4l2_fh_add()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (24 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 25/65] media: qcom: venus: Pass file pointer to venus_close_common() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
` (38 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Documentation/driver-api/media/v4l2-fh.rst | 46 +++++++++++-----------
.../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 +-
drivers/media/platform/allegro-dvt/allegro-core.c | 3 +-
drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 3 +-
drivers/media/platform/amphion/vpu_v4l2.c | 3 +-
.../media/platform/chips-media/coda/coda-common.c | 3 +-
.../platform/chips-media/wave5/wave5-vpu-dec.c | 3 +-
.../platform/chips-media/wave5/wave5-vpu-enc.c | 3 +-
.../media/platform/imagination/e5010-jpeg-enc.c | 3 +-
drivers/media/platform/m2m-deinterlace.c | 3 +-
.../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 3 +-
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 3 +-
.../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 3 +-
.../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 3 +-
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 3 +-
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 3 +-
drivers/media/platform/nxp/dw100/dw100.c | 3 +-
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 3 +-
drivers/media/platform/nxp/imx-pxp.c | 3 +-
drivers/media/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 +-
drivers/media/platform/renesas/vsp1/vsp1_video.c | 4 +-
drivers/media/platform/rockchip/rga/rga.c | 3 +-
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 3 +-
.../media/platform/samsung/exynos-gsc/gsc-m2m.c | 3 +-
.../media/platform/samsung/exynos4-is/fimc-m2m.c | 3 +-
drivers/media/platform/samsung/s5p-g2d/g2d.c | 3 +-
.../media/platform/samsung/s5p-jpeg/jpeg-core.c | 3 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 3 +-
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 3 +-
drivers/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 +-
drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +-
.../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +-
drivers/media/platform/ti/omap3isp/ispvideo.c | 3 +-
drivers/media/platform/ti/vpe/vpe.c | 3 +-
drivers/media/platform/verisilicon/hantro_drv.c | 3 +-
drivers/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 +-
drivers/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, 91 insertions(+), 146 deletions(-)
diff --git a/Documentation/driver-api/media/v4l2-fh.rst b/Documentation/driver-api/media/v4l2-fh.rst
index 2c87b74578d97a171ad06d3eb60a02cd58b557b1..a7393067f5db2183aa677e15ece512296455e23b 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 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.
-
-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.
+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`.
+
+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.
+
+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 a9eb62fa1531c69110ff17945fa2fcfa596f4df8..2d38ae17d9404d9d40c63bc8329f3cc6999b7a11 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 89e38b3036309af0747362bafad5024413c2c5bd..f90b547f5d676308ed5c7956a8da02e208b9446e 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 67964a3c382c6627a7b3ce6380a2da97dcc47c3d..aa5f5f16427c48123cd314932a7d8bc48f07c031 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 296f50b6b8d38e0ab617f0990d8f697ba96b0016..e6e353a251cf548525c44e87695f7d45bde302a6 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 a7e398f304725c7fa5aa4cf1edf0deb0df059641..181442fcb43b08cd96f29c2357bcfadd3ddcedb4 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 74977f3ae4844022c04de877f31b4fc6aaac0749..8c30f3cd4fc545133f697973b0f002ea888a3a4a 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 c7df29a2d82012b7fc290edf3f629a0c3ed7bcc8..d36891b546bca417e8b98c5e0458ebb15e24c213 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 57ca6262bb04b356a85e217ef51cfb13cb9a0a36..e13bfe09af1bf0926bf6005b83a8aae7e34a2122 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 92fb24cace8ef75e70eb2aae96bc169a7cf97563..9d8a1c9bea6e9f4d9fc2c2ae165d587e3b3b9650 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 f3188d720ed3e183f3400816a9c939014213711d..88eb933a51448788373775e423ae2ac5042cf8b6 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 b69a1206fa12c2ff5f3a32d269b8fd3b80a597aa..322c1498758a0a569eb94cab0d6612ce18cd4c7b 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 295461325862fb2bcac755cf815955955b37e6f0..1da00ff4b1e36a6486ce54e02139f6489d6acf22 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 1812c07837ad33e10db9005fd2009b4ea2a799d0..a343dffd19f03c68557415afae2a8db4b3614d2e 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 bf7cae1993d5e21975bc9dffcbcfb3fe1843d575..4bf52e9d960431194c05870743cc628e4e4293e2 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 e3e01a9a0f78cb2fe665132bd1bde66afa63bddb..25efd76f290e4f29a60d326e92a5bcb05c2bbd1e 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 8ebab14c535bfe023d720964965d97f758e5eb63..18e542ad32e4fd0d0d262670b6440fb2e3661f7f 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 18801883c31a80b2179eb0d9280150eeb4aa3770..952a77c383bdb8dba94c74916674e729ee5aba35 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 e26a6c3ffa0cee17385575215b55b575b14e58f4..9cacb6cbcf28357826db2df7e15c3588e7b4d4c8 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 393dc3f07d5c78ff5ab0ae7b6368914859564458..688b776b30107df4ec3642a4bc0e896759ccf0fe 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 2460f09a6813a320f7637bc332e641b7741ced21..2bd30910ddf98401dfc9d8f2e3b19fe8672320e3 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 a17a020ea4c698bfa57253f0f53a17230d52dea3..13e681a0ec0abcb49b14455773da3ab2f5dc372b 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 879b1803a2b38c6748fa4748f25504665f8106bb..9602409f3ecef7e2a77a58f9c3376823a72ec551 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 9226e42b95fc91ed5490be1599a539f0fdeeb123..480669a2578ab2f4d6d5104658ba56ea776a6639 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 5c8c6285ec1e7b2e8df64132228e71e1b097183e..8c8f834e6250f5effcbb7f098f388a9ccc96302c 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 64ebec2ca6b3d58118ac1a6f4ddeed2e43de6d5b..cdd34a3b71ff4309829f0f159241c3815658bcb8 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 d10ca6d89f6d76c052b27b1154c8dd9c49466e23..55c27345b7d89bf400e216ed9aa59a871e501a44 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 0838d64ce8fee5dd8299d5c394e97910f10f7ee3..fba07557a3996a55fcd6a4f65376c418ec0c92a7 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 f11ea9dc5027bdd89262270f4e3979a06650d9bc..e0d12b579d87025e3f309f6593c068ad87f1856b 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 3ee51f53b0cd1c221cefd0ce93acbcda55faa4a6..26c5c77e4a17b26c453e3ea80b0f7c752e2f8029 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 656fb5e6cb303cfcde1d91c839a9aceca79c77f7..b6dc1ee3dc50ac8d0eb79408b06c601cb501e9b8 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 8a6e618d605c216b5113062d90df03dc632dc7c8..d88817023996b29afc79cdd6fbdd42dfc5829b13 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 41ab90cbcc0cdbe279f6512decc4301b6cff2dfa..2fbad685e92cee4916420565a28c778b1a5e1a8e 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 968bb4327b7a1697641815dfb08dc64251f5e927..39d84ffd1b05990ba4b8af281aba09e3f9cc5340 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 feedf60dad09bd413cb8fe65d965fd39b26b8764..b002b02a899efdd95df4ae8a5db59b9f144a61db 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 44fcedbbc90a9863827aacbcd5f56d850cb552ea..e34cae9c9cf65d3161822b68233d28472171f917 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 a8d0dddb1fb5b5344ac9c96657fcf17a575d6a26..c4ad0196ed8f1bf579365a0a21dd8c4a78bdaa10 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 dd9761df59df5dd7b07b4e9afd2d7939c46cb2de..74629db05121ac9181af9daa471c113876f9d323 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 26c4e48e5e84bcf315692515448ae615727c454f..57dcc625096b4b684cfde0051d200bf8c18e4ba4 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 8282e72af67084ddbb94ed78df87a07e1e8b860f..b2df94dcbe21709f5b31446c85408728e70d5bca 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 29142c806cb74a510b2f27e79c9e10ca4088b1e9..2f9413fa7318f42b390f96447dcb1a905836703e 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 f4c5d73447a7c3efb0ad5d9bb8a09432c1a8fa60..b2bced06a1e603f7479620d5db3c12ee89e5149e 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 e9c7c99fbc559de85c33736a8f459cd216b8cdbf..7823eb97faf7e9bd13286ab14db2b436fc5caf1f 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 9ea65cb7187fee323051b1cb62b342e119f7bb3d..368a858b8c0fdea462b85c8c71e22058d10a6c05 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 b76d40aeca17cf5b8b7619cadf0afe66ff283a9d..d10a2b96c13cf1f5103504a8bd10c65111392a1e 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 4b9b2bec7377d724c272ff76fb8116b65227c542..a47c5d31c47550cd9c6c8803b25cda1253f906a9 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 b20b9c7f41319e1d9586d641200aeeebbd1ee761..aadc3d8fb3d1c1267b370edac6723b99bd00f9bf 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 e27f6761cba18e78e1833745e77347f7405957e0..f20d9d9643f5e3d39f4807ad337f05c957594e1e 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 55d885be5bcc0541e4ea539a2fafeeb2d76680e3..24574025f58fc34a0b98e8048294624607e39e2a 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 5bf3136b36eb30be5cf6b7f65ca3ab7314d84f98..0f43ec23f40b40362979646b47b09b75b7786fb2 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 ea17f1a5f5b0a01d7ae159b7f00d65ce952f4974..6c6e467f85549e86598e73d29352a84de7df2f4d 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 481b03bbecf8134f75b3988e45fc392f07ae90fd..04c77af0c51ec2174193387253015383d6fac486 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 6dd329a972fda5c2574231b8526105676df3d4a1..09677ed639ae9252a57ce09cdbcfd567ad7aabc2 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 7a5f7aa5e25341df62bb4e3380bf19f46e2df955..b59b1084d8cdf1b62da12879e21dbe56c2109648 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 29d3b788b288675c9ec849bb14e1936356d95743..bf35ac436249fdbf218ed08a712abf546a49b4eb 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 05a54242356c53d19770086dfcc2ed81e1cda4c1..9dc0954ed9aac7088e42bea03c6aada4ee8f2ae8 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 f1ee53f9f29868ae7cb02ce00764631f821ee74b..b92666ff50a15196de0143f2ba5bf476c6f7729d 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 80b43187f6eef827c7212a601aa2056dbc606bd4..ebefd646dbdb4e998bf6a8a0f0be6d7e4bf7d28b 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 116331cead2a6676f2c018b3f8fc10b0716dfc3a..24a68e3e54195cf5f8952a35fe103d93bb0fd3e5 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 886300a29b908a6dda3e2dfcb6b3414f782b172b..680f25d17dc2c7b99529441de8f079abe3b3411f 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 14e7136e693f0a7b8b25959200603028e0db36ac..d8fcf49f10e09452b73499f4a9bd1285bc2835a5 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
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (25 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 26/65] media: Set file->private_data in v4l2_fh_add() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-06 12:45 ` Hans Verkuil
2025-08-18 14:12 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 28/65] media: v4l2-ioctl: Access v4l2_fh from private_data Jacopo Mondi
` (37 subsequent siblings)
64 siblings, 2 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
Documentation/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 ++--
.../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
.../media/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 a7393067f5db2183aa677e15ece512296455e23b..afcad22ead7c919a07475720058ec1ab3a5d5494 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 2d38ae17d9404d9d40c63bc8329f3cc6999b7a11..1653c6e2cb4659c71bdb5001a0a3ba0b1c3c9411 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 f90b547f5d676308ed5c7956a8da02e208b9446e..d49fa4c4119b6e14843a01a73c9662839ecc6c05 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 aa5f5f16427c48123cd314932a7d8bc48f07c031..0040a5e7f654149eb429400dd1db7197a9a3b54e 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 e6e353a251cf548525c44e87695f7d45bde302a6..66d650b5f69af1eac9117b9c65ac7c39883f6f21 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 181442fcb43b08cd96f29c2357bcfadd3ddcedb4..57e4362c0d19d0d3a5f0be1ee58cd141fdf62462 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 8c30f3cd4fc545133f697973b0f002ea888a3a4a..5e3b1f5d7206d84b8ccb9ea3b3f3f1fe75becf99 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 d36891b546bca417e8b98c5e0458ebb15e24c213..b1b0b6535fb1931c74ae9b2da28bea579cd1bc4c 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 e13bfe09af1bf0926bf6005b83a8aae7e34a2122..fcb2eff813ac456386ef163c53db8ac34a278dd7 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 9d8a1c9bea6e9f4d9fc2c2ae165d587e3b3b9650..a27d5a261a27fb78d4c7ca008146780698386333 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 ed8ff04a899da0a3c9e0f037dac2c9548c98920f..0bce62f0c03902ae367182ee04774c79accc4712 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 1da00ff4b1e36a6486ce54e02139f6489d6acf22..c4e0097cb8b7fa310c2c5519d7af4e6e3b378915 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 a343dffd19f03c68557415afae2a8db4b3614d2e..51c2f206cb1f601ec2f3d07fffbf63c86f4cdc01 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 4bf52e9d960431194c05870743cc628e4e4293e2..8e1883d034f5c67d418f5607c593c60f5d6ddbee 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 25efd76f290e4f29a60d326e92a5bcb05c2bbd1e..3d836b5efa3807e4dc882956040014e244eeb660 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 18e542ad32e4fd0d0d262670b6440fb2e3661f7f..2e0619542d2a9ad73457853e4f5008e6eb130cdd 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 952a77c383bdb8dba94c74916674e729ee5aba35..46d176e6de63e370693fe20cc04c52cde81f4d73 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 9cacb6cbcf28357826db2df7e15c3588e7b4d4c8..fb1c3bdc2daeb4b439d29bb6bbecc1ad786e9eb0 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 688b776b30107df4ec3642a4bc0e896759ccf0fe..0c50f4ff82e0a8f4935325d00691c58072182926 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 2bd30910ddf98401dfc9d8f2e3b19fe8672320e3..97744c7b7c034cadfdd3f6d76165b4da85fa3d16 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 13e681a0ec0abcb49b14455773da3ab2f5dc372b..fa7d74d8c1aabd3bf74482e214165d8c1a7e89da 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 9602409f3ecef7e2a77a58f9c3376823a72ec551..6cc9b07ea53a002c2eda0fd6062096f5527ad62c 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 480669a2578ab2f4d6d5104658ba56ea776a6639..850dd8ae95841d4470ac6bd7cb1e54a7510d6d5e 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 8c8f834e6250f5effcbb7f098f388a9ccc96302c..d23da93304bd6f55898cfb96319d2fa101036ca1 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 cdd34a3b71ff4309829f0f159241c3815658bcb8..541ae86f7892ab7ca89e9d5856ef10d189b2fb32 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 5e1ace16a4903999c7fd7a985317dae8dd2410ba..90de29f166ada7aa5afe611041df308b5dfe8312 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 e0d12b579d87025e3f309f6593c068ad87f1856b..e78d8fb104e9544d27c8ace38888995ca170483f 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 26c5c77e4a17b26c453e3ea80b0f7c752e2f8029..058fcfb967bd98440f33272db42f0d973299d572 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 b6dc1ee3dc50ac8d0eb79408b06c601cb501e9b8..75f9a1a85d558ff0afa2fdaf8c43a22ddbd694a8 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 d88817023996b29afc79cdd6fbdd42dfc5829b13..45c42c7ad846fab985e573ef7acf4a5bc1a4cac1 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 2fbad685e92cee4916420565a28c778b1a5e1a8e..481c2488f9ac64e70869ed21e5053cfbc4ed6e0e 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 39d84ffd1b05990ba4b8af281aba09e3f9cc5340..2999fb2610f0f61b63d0331f94883469ff43d751 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 b002b02a899efdd95df4ae8a5db59b9f144a61db..609fd84f89d4ad189d0f367bb37693f15f3a618e 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 e34cae9c9cf65d3161822b68233d28472171f917..922262f61e7b53baf1b5840d35149bf5b4b2e7ad 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 c4ad0196ed8f1bf579365a0a21dd8c4a78bdaa10..2a57efd181540183e7d2b66d51f9f2f274ddd100 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 74629db05121ac9181af9daa471c113876f9d323..a5e756049620cdf35df4526b9a4cb55985f6476e 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 57dcc625096b4b684cfde0051d200bf8c18e4ba4..fc7945d29bccc2fdf0fc48fc14d6698b321418d9 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 b2df94dcbe21709f5b31446c85408728e70d5bca..adff43271b2dc059abbbf82d90cd13482f6bca30 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 2f9413fa7318f42b390f96447dcb1a905836703e..3581b73a99b8ba5702e5d4d8d02cd5c832fa1555 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 b2bced06a1e603f7479620d5db3c12ee89e5149e..bc0f81e78018b20c38677eaea44358ddad7a9a52 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 7823eb97faf7e9bd13286ab14db2b436fc5caf1f..eb519afb30ca10c6f4370626d0dce9e7183b28e5 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 368a858b8c0fdea462b85c8c71e22058d10a6c05..89992feaab6082b438eec189c0de93568d09f911 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 d10a2b96c13cf1f5103504a8bd10c65111392a1e..2c0008444b7e2b532c9af061760e7399cdf3e45d 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 a47c5d31c47550cd9c6c8803b25cda1253f906a9..6029d4e8e0bd34d60f1addb91a51bf5fd0709341 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 aadc3d8fb3d1c1267b370edac6723b99bd00f9bf..4cc9d00fd2936dcfaa4574d8bd9a23b9ae9b5476 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 f20d9d9643f5e3d39f4807ad337f05c957594e1e..c340fd2260403e1750d1d094f7b1567c05a8f08d 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 24574025f58fc34a0b98e8048294624607e39e2a..d0e760118c822aa7696b1cde2a6be5c9982ad639 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 0f43ec23f40b40362979646b47b09b75b7786fb2..26c6c6835f793a6ac273856bc9b3336a06bae1cd 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 04c77af0c51ec2174193387253015383d6fac486..f9535a484738a9ef25795daa11a74ccb0b914be9 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 b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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 bf35ac436249fdbf218ed08a712abf546a49b4eb..41e4aca77b7fe432b1b27b3c1e7ffa8211297e1a 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 9dc0954ed9aac7088e42bea03c6aada4ee8f2ae8..c4ee0eebb3730e709c3d4a95935d0047a645e411 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 b92666ff50a15196de0143f2ba5bf476c6f7729d..49e497a32973b8df18c5143e0db68d0f7f42c36c 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 ebefd646dbdb4e998bf6a8a0f0be6d7e4bf7d28b..bff42ea1871f7376bfdb1dfad2ba7f22e862b0ea 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 24a68e3e54195cf5f8952a35fe103d93bb0fd3e5..32f71d9a9cf78ad74aa8b9a53f40c1d52123df52 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 680f25d17dc2c7b99529441de8f079abe3b3411f..fd4b998ccd16058eb796dd317971c0869f6bdeb8 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 d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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.
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 28/65] media: v4l2-ioctl: Access v4l2_fh from private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (26 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 29/65] media: allegro: Access v4l2_fh from file Jacopo Mondi
` (36 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
Now that it is guaranteed that file->private_data is set to point to the
'struct v4l2_fh' initialised by v4l2_fh_add() the v4l2-ioctl layer can
be modified to retrieve the v4l2_fh pointer from the file *.
As the __video_do_ioctl() function, that calls all the handlers modified
by this patch goes as:
static long __video_do_ioctl(struct file *file,
unsigned int cmd, void *arg)
{
void *fh = file->private_data;
...
ret = info->func(ops, file, fh, arg);
}
This patch introduces no functional changes and makes it possible to
remove in future the 'fh' argument to all ioctl handlers.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/v4l2-core/v4l2-ioctl.c | 46 ++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8c81852c30466865eca36fd41923f6d05dbf9293..44c2f5ef3dae407d9786c5278d13efc982be2ff0 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2297,8 +2297,8 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
struct video_device *vfd = video_devdata(file);
struct v4l2_query_ext_ctrl qec = {};
struct v4l2_queryctrl *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
int ret;
if (vfh && vfh->ctrl_handler)
@@ -2322,8 +2322,8 @@ static int v4l_query_ext_ctrl(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_query_ext_ctrl *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
if (vfh && vfh->ctrl_handler)
return v4l2_query_ext_ctrl(vfh->ctrl_handler, p);
@@ -2339,8 +2339,8 @@ static int v4l_querymenu(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_querymenu *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
if (vfh && vfh->ctrl_handler)
return v4l2_querymenu(vfh->ctrl_handler, p);
@@ -2356,8 +2356,8 @@ static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_control *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
@@ -2388,8 +2388,8 @@ static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_control *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
int ret;
@@ -2418,8 +2418,8 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_ext_controls *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
p->error_idx = p->count;
if (vfh && vfh->ctrl_handler)
@@ -2439,8 +2439,8 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_ext_controls *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
p->error_idx = p->count;
if (vfh && vfh->ctrl_handler)
@@ -2460,8 +2460,8 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,
{
struct video_device *vfd = video_devdata(file);
struct v4l2_ext_controls *p = arg;
- struct v4l2_fh *vfh =
- test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
+ struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ?
+ file_to_v4l2_fh(file) : NULL;
p->error_idx = p->count;
if (vfh && vfh->ctrl_handler)
@@ -2756,19 +2756,25 @@ static int v4l_dbg_g_chip_info(const struct v4l2_ioctl_ops *ops,
static int v4l_dqevent(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
{
- return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK);
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
+
+ return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);
}
static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
{
- return ops->vidioc_subscribe_event(fh, arg);
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
+
+ return ops->vidioc_subscribe_event(vfh, arg);
}
static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
{
- return ops->vidioc_unsubscribe_event(fh, arg);
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
+
+ return ops->vidioc_unsubscribe_event(vfh, arg);
}
static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops,
@@ -3072,7 +3078,7 @@ static long __video_do_ioctl(struct file *file,
bool write_only = false;
struct v4l2_ioctl_info default_info;
const struct v4l2_ioctl_info *info;
- void *fh = file->private_data;
+ void *fh = file_to_v4l2_fh(file);
struct v4l2_fh *vfh = NULL;
int dev_debug = vfd->dev_debug;
long ret = -ENOTTY;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 29/65] media: allegro: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (27 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 28/65] media: v4l2-ioctl: Access v4l2_fh from private_data Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-05 7:39 ` Michael Tretter
2025-08-02 9:22 ` [PATCH 30/65] media: meson-ge2d: " Jacopo Mondi
` (35 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it remove the only left user of fh_to_channel() and remove
the macro completely.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/allegro-dvt/allegro-core.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index 5e3b1f5d7206d84b8ccb9ea3b3f3f1fe75becf99..81c6afcf2d06f9e39015e49d355346238c5033d8 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -197,8 +197,6 @@ static const struct regmap_config allegro_sram_config = {
.cache_type = REGCACHE_NONE,
};
-#define fh_to_channel(__fh) container_of(__fh, struct allegro_channel, fh)
-
struct allegro_channel {
struct allegro_dev *dev;
struct v4l2_fh fh;
@@ -3284,7 +3282,7 @@ static int allegro_enum_fmt_vid(struct file *file, void *fh,
static int allegro_g_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
f->fmt.pix.field = V4L2_FIELD_NONE;
f->fmt.pix.width = channel->width;
@@ -3326,7 +3324,7 @@ static int allegro_try_fmt_vid_cap(struct file *file, void *fh,
static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
struct vb2_queue *vq;
int err;
@@ -3350,7 +3348,7 @@ static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
static int allegro_g_fmt_vid_out(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
f->fmt.pix.field = V4L2_FIELD_NONE;
@@ -3397,7 +3395,7 @@ static int allegro_try_fmt_vid_out(struct file *file, void *fh,
static int allegro_s_fmt_vid_out(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
int err;
err = allegro_try_fmt_vid_out(file, fh, f);
@@ -3438,7 +3436,7 @@ static int allegro_channel_cmd_start(struct allegro_channel *channel)
static int allegro_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *cmd)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
int err;
err = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, cmd);
@@ -3488,7 +3486,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
struct v4l2_fh *fh = file_to_v4l2_fh(file);
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
int err;
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -3503,7 +3501,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
static int allegro_g_parm(struct file *file, void *fh,
struct v4l2_streamparm *a)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
struct v4l2_fract *timeperframe;
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -3520,7 +3518,7 @@ static int allegro_g_parm(struct file *file, void *fh,
static int allegro_s_parm(struct file *file, void *fh,
struct v4l2_streamparm *a)
{
- struct allegro_channel *channel = fh_to_channel(fh);
+ struct allegro_channel *channel = file_to_channel(file);
struct v4l2_fract *timeperframe;
int div;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 30/65] media: meson-ge2d: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (28 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 29/65] media: allegro: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 31/65] media: coda: " Jacopo Mondi
` (34 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
index b1b0b6535fb1931c74ae9b2da28bea579cd1bc4c..5744853a40035e9973e605dd3ffec508641470f2 100644
--- a/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
+++ b/drivers/media/platform/amlogic/meson-ge2d/ge2d.c
@@ -457,7 +457,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f
static int vidioc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct ge2d_ctx *ctx = priv;
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct ge2d_frame *f;
bool use_frame = false;
@@ -507,7 +507,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
static int vidioc_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct ge2d_ctx *ctx = priv;
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct meson_ge2d *ge2d = ctx->ge2d;
struct ge2d_frame *f;
int ret = 0;
@@ -574,8 +574,8 @@ static void vidioc_setup_cap_fmt(struct ge2d_ctx *ctx, struct v4l2_pix_format *f
static int vidioc_try_fmt_cap(struct file *file, void *priv, struct v4l2_format *f)
{
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
const struct ge2d_fmt *fmt = find_fmt(f);
- struct ge2d_ctx *ctx = priv;
struct v4l2_pix_format fmt_cap;
vidioc_setup_cap_fmt(ctx, &fmt_cap);
@@ -595,7 +595,7 @@ static int vidioc_try_fmt_cap(struct file *file, void *priv, struct v4l2_format
static int vidioc_s_fmt_cap(struct file *file, void *priv, struct v4l2_format *f)
{
- struct ge2d_ctx *ctx = priv;
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct meson_ge2d *ge2d = ctx->ge2d;
struct vb2_queue *vq;
struct ge2d_frame *frm;
@@ -631,7 +631,7 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, struct v4l2_format *f
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct ge2d_ctx *ctx = priv;
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct vb2_queue *vq;
struct ge2d_frame *frm;
@@ -670,7 +670,7 @@ static int vidioc_try_fmt_out(struct file *file, void *priv, struct v4l2_format
static int vidioc_s_fmt_out(struct file *file, void *priv, struct v4l2_format *f)
{
- struct ge2d_ctx *ctx = priv;
+ struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
struct meson_ge2d *ge2d = ctx->ge2d;
struct vb2_queue *vq;
struct ge2d_frame *frm, *frm_cap;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 31/65] media: coda: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (29 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 30/65] media: meson-ge2d: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 32/65] media: wave5: " Jacopo Mondi
` (33 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/chips-media/coda/coda-common.c | 36 +++++++++++-----------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index a27d5a261a27fb78d4c7ca008146780698386333..a10576f702127ba6014799e7d3190c2785afd2a2 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -427,7 +427,7 @@ static struct vdoa_data *coda_get_vdoa_data(void)
static int coda_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
strscpy(cap->driver, CODA_NAME, sizeof(cap->driver));
strscpy(cap->card, coda_product_name(ctx->dev->devtype->product),
@@ -447,7 +447,7 @@ static int coda_enum_fmt(struct file *file, void *priv,
{
struct video_device *vdev = video_devdata(file);
const struct coda_video_device *cvd = to_coda_video_device(vdev);
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
const u32 *formats;
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -497,7 +497,7 @@ static int coda_g_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct coda_q_data *q_data;
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
q_data = get_q_data(ctx, f->type);
if (!q_data)
@@ -658,7 +658,7 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec,
static int coda_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
const struct coda_q_data *q_data_src;
const struct coda_codec *codec;
struct vb2_queue *src_vq;
@@ -764,7 +764,7 @@ static void coda_set_default_colorspace(struct v4l2_pix_format *fmt)
static int coda_try_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_dev *dev = ctx->dev;
const struct coda_q_data *q_data_dst;
const struct coda_codec *codec;
@@ -858,7 +858,7 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f,
static int coda_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_q_data *q_data_src;
const struct coda_codec *codec;
struct v4l2_rect r;
@@ -910,7 +910,7 @@ static int coda_s_fmt_vid_cap(struct file *file, void *priv,
static int coda_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
const struct coda_codec *codec;
struct v4l2_format f_cap;
struct vb2_queue *dst_vq;
@@ -966,7 +966,7 @@ static int coda_s_fmt_vid_out(struct file *file, void *priv,
static int coda_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *rb)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
int ret;
ret = v4l2_m2m_reqbufs(file, ctx->fh.m2m_ctx, rb);
@@ -986,7 +986,7 @@ static int coda_reqbufs(struct file *file, void *priv,
static int coda_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
if (ctx->inst_type == CODA_INST_DECODER &&
buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -997,7 +997,7 @@ static int coda_qbuf(struct file *file, void *priv,
static int coda_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
- struct coda_ctx *ctx = fh_to_ctx(priv);
+ struct coda_ctx *ctx = file_to_ctx(file);
int ret;
ret = v4l2_m2m_dqbuf(file, ctx->fh.m2m_ctx, buf);
@@ -1025,7 +1025,7 @@ void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,
static int coda_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_q_data *q_data;
struct v4l2_rect r, *rsel;
@@ -1071,7 +1071,7 @@ static int coda_g_selection(struct file *file, void *fh,
static int coda_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_q_data *q_data;
switch (s->target) {
@@ -1126,7 +1126,7 @@ static void coda_wake_up_capture_queue(struct coda_ctx *ctx)
static int coda_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *ec)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct vb2_v4l2_buffer *buf;
int ret;
@@ -1207,7 +1207,7 @@ static bool coda_mark_last_dst_buf(struct coda_ctx *ctx)
static int coda_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *dc)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_dev *dev = ctx->dev;
struct vb2_v4l2_buffer *buf;
struct vb2_queue *dst_vq;
@@ -1286,7 +1286,7 @@ static int coda_decoder_cmd(struct file *file, void *fh,
static int coda_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *fsize)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_q_data *q_data_dst;
const struct coda_codec *codec;
@@ -1319,7 +1319,7 @@ static int coda_enum_framesizes(struct file *file, void *fh,
static int coda_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *f)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct coda_q_data *q_data;
const struct coda_codec *codec;
@@ -1358,7 +1358,7 @@ static int coda_enum_frameintervals(struct file *file, void *fh,
static int coda_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct v4l2_fract *tpf;
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -1441,7 +1441,7 @@ static uint32_t coda_timeperframe_to_frate(struct v4l2_fract *timeperframe)
static int coda_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct coda_ctx *ctx = fh_to_ctx(fh);
+ struct coda_ctx *ctx = file_to_ctx(file);
struct v4l2_fract *tpf;
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 32/65] media: wave5: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (30 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 31/65] media: coda: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 33/65] media: m2m-deinterlace: " Jacopo Mondi
` (32 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../platform/chips-media/wave5/wave5-helper.c | 2 +-
.../platform/chips-media/wave5/wave5-vpu-dec.c | 18 ++++++++--------
.../platform/chips-media/wave5/wave5-vpu-enc.c | 24 +++++++++++-----------
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-helper.c b/drivers/media/platform/chips-media/wave5/wave5-helper.c
index 0bce62f0c03902ae367182ee04774c79accc4712..f03ad9c0de2215794b2456c39652785fff236966 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-helper.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-helper.c
@@ -142,7 +142,7 @@ int wave5_vpu_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subscr
int wave5_vpu_g_fmt_out(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
int i;
f->fmt.pix_mp.width = inst->src_fmt.width;
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 88eb933a51448788373775e423ae2ac5042cf8b6..72af0faa3ef2e6fb83749044eb91a58f39a3a986 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -506,7 +506,7 @@ static int wave5_vpu_dec_enum_fmt_cap(struct file *file, void *fh, struct v4l2_f
static int wave5_vpu_dec_try_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
struct dec_info *p_dec_info = &inst->codec_info->dec_info;
const struct v4l2_frmsize_stepwise *frmsize;
const struct vpu_format *vpu_fmt;
@@ -547,7 +547,7 @@ static int wave5_vpu_dec_try_fmt_cap(struct file *file, void *fh, struct v4l2_fo
static int wave5_vpu_dec_s_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
int i, ret;
dev_dbg(inst->dev->dev,
@@ -606,7 +606,7 @@ static int wave5_vpu_dec_s_fmt_cap(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_dec_g_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
int i;
f->fmt.pix_mp.width = inst->dst_fmt.width;
@@ -630,7 +630,7 @@ static int wave5_vpu_dec_g_fmt_cap(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_dec_enum_fmt_out(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct vpu_format *vpu_fmt;
dev_dbg(inst->dev->dev, "%s: index: %u\n", __func__, f->index);
@@ -647,7 +647,7 @@ static int wave5_vpu_dec_enum_fmt_out(struct file *file, void *fh, struct v4l2_f
static int wave5_vpu_dec_try_fmt_out(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct v4l2_frmsize_stepwise *frmsize;
const struct vpu_format *vpu_fmt;
int width, height;
@@ -678,7 +678,7 @@ static int wave5_vpu_dec_try_fmt_out(struct file *file, void *fh, struct v4l2_fo
static int wave5_vpu_dec_s_fmt_out(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct vpu_format *vpu_fmt;
int i, ret;
@@ -727,7 +727,7 @@ static int wave5_vpu_dec_s_fmt_out(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_dec_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
dev_dbg(inst->dev->dev, "%s: type: %u | target: %u\n", __func__, s->type, s->target);
@@ -761,7 +761,7 @@ static int wave5_vpu_dec_g_selection(struct file *file, void *fh, struct v4l2_se
static int wave5_vpu_dec_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -872,7 +872,7 @@ static int wave5_vpu_dec_start(struct vpu_instance *inst)
static int wave5_vpu_dec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dc)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
int ret;
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 322c1498758a0a569eb94cab0d6612ce18cd4c7b..279f23e1304a9e47e31c9a0bdd0efbf4c18622e1 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
@@ -360,7 +360,7 @@ static int wave5_vpu_enc_enum_framesizes(struct file *f, void *fh, struct v4l2_f
static int wave5_vpu_enc_enum_fmt_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct vpu_format *vpu_fmt;
dev_dbg(inst->dev->dev, "%s: index: %u\n", __func__, f->index);
@@ -377,7 +377,7 @@ static int wave5_vpu_enc_enum_fmt_cap(struct file *file, void *fh, struct v4l2_f
static int wave5_vpu_enc_try_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct v4l2_frmsize_stepwise *frmsize;
const struct vpu_format *vpu_fmt;
int width, height;
@@ -411,7 +411,7 @@ static int wave5_vpu_enc_try_fmt_cap(struct file *file, void *fh, struct v4l2_fo
static int wave5_vpu_enc_s_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
int i, ret;
dev_dbg(inst->dev->dev, "%s: fourcc: %u width: %u height: %u num_planes: %u field: %u\n",
@@ -445,7 +445,7 @@ static int wave5_vpu_enc_s_fmt_cap(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_enc_g_fmt_cap(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
int i;
f->fmt.pix_mp.width = inst->dst_fmt.width;
@@ -469,7 +469,7 @@ static int wave5_vpu_enc_g_fmt_cap(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_enc_enum_fmt_out(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct vpu_format *vpu_fmt;
dev_dbg(inst->dev->dev, "%s: index: %u\n", __func__, f->index);
@@ -486,7 +486,7 @@ static int wave5_vpu_enc_enum_fmt_out(struct file *file, void *fh, struct v4l2_f
static int wave5_vpu_enc_try_fmt_out(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct v4l2_frmsize_stepwise *frmsize;
const struct vpu_format *vpu_fmt;
int width, height;
@@ -515,7 +515,7 @@ static int wave5_vpu_enc_try_fmt_out(struct file *file, void *fh, struct v4l2_fo
static int wave5_vpu_enc_s_fmt_out(struct file *file, void *fh, struct v4l2_format *f)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
const struct vpu_format *vpu_fmt;
const struct v4l2_format_info *info;
int i, ret;
@@ -576,7 +576,7 @@ static int wave5_vpu_enc_s_fmt_out(struct file *file, void *fh, struct v4l2_form
static int wave5_vpu_enc_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
dev_dbg(inst->dev->dev, "%s: type: %u | target: %u\n", __func__, s->type, s->target);
@@ -605,7 +605,7 @@ static int wave5_vpu_enc_g_selection(struct file *file, void *fh, struct v4l2_se
static int wave5_vpu_enc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL;
@@ -628,7 +628,7 @@ static int wave5_vpu_enc_s_selection(struct file *file, void *fh, struct v4l2_se
static int wave5_vpu_enc_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *ec)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
int ret;
@@ -661,7 +661,7 @@ static int wave5_vpu_enc_encoder_cmd(struct file *file, void *fh, struct v4l2_en
static int wave5_vpu_enc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
dev_dbg(inst->dev->dev, "%s: type: %u\n", __func__, a->type);
@@ -681,7 +681,7 @@ static int wave5_vpu_enc_g_parm(struct file *file, void *fh, struct v4l2_streamp
static int wave5_vpu_enc_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct vpu_instance *inst = wave5_to_vpu_inst(fh);
+ struct vpu_instance *inst = file_to_vpu_inst(file);
dev_dbg(inst->dev->dev, "%s: type: %u\n", __func__, a->type);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 33/65] media: m2m-deinterlace: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (31 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 32/65] media: wave5: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 34/65] media: mtk: jpeg: Access v4l2_fh from file->private_data Jacopo Mondi
` (31 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/m2m-deinterlace.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 51c2f206cb1f601ec2f3d07fffbf63c86f4cdc01..e07e57d4206baa5e7a467298cb240c3a2cd57cd8 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -517,13 +517,13 @@ static int vidioc_g_fmt(struct deinterlace_ctx *ctx, struct v4l2_format *f)
static int vidioc_g_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- return vidioc_g_fmt(priv, f);
+ return vidioc_g_fmt(file_to_ctx(file), f);
}
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- return vidioc_g_fmt(priv, f);
+ return vidioc_g_fmt(file_to_ctx(file), f);
}
static int vidioc_try_fmt(struct v4l2_format *f, struct deinterlace_fmt *fmt)
@@ -544,8 +544,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct deinterlace_fmt *fmt)
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
+ struct deinterlace_ctx *ctx = file_to_ctx(file);
struct deinterlace_fmt *fmt;
- struct deinterlace_ctx *ctx = priv;
fmt = find_format(f);
if (!fmt || !(fmt->types & MEM2MEM_CAPTURE))
@@ -638,20 +638,20 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
ret = vidioc_try_fmt_vid_cap(file, priv, f);
if (ret)
return ret;
- return vidioc_s_fmt(priv, f);
+ return vidioc_s_fmt(file_to_ctx(file), f);
}
static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct deinterlace_ctx *ctx = priv;
+ struct deinterlace_ctx *ctx = file_to_ctx(file);
int ret;
ret = vidioc_try_fmt_vid_out(file, priv, f);
if (ret)
return ret;
- ret = vidioc_s_fmt(priv, f);
+ ret = vidioc_s_fmt(ctx, f);
if (!ret)
ctx->colorspace = f->fmt.pix.colorspace;
@@ -661,8 +661,8 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
static int vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
+ struct deinterlace_ctx *ctx = file_to_ctx(file);
struct deinterlace_q_data *s_q_data, *d_q_data;
- struct deinterlace_ctx *ctx = priv;
s_q_data = get_q_data(V4L2_BUF_TYPE_VIDEO_OUTPUT);
d_q_data = get_q_data(V4L2_BUF_TYPE_VIDEO_CAPTURE);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 34/65] media: mtk: jpeg: Access v4l2_fh from file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (32 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 33/65] media: m2m-deinterlace: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 35/65] media: mtk_mdp_m2m: Access v4l2_fh from file Jacopo Mondi
` (30 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused mtk_jpeg_fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 27 +++++++++-------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index 8e1883d034f5c67d418f5607c593c60f5d6ddbee..6268d651bdcfd212b58bf686c55660d64b659dfe 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -119,11 +119,6 @@ static inline struct mtk_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
return container_of(ctrl->handler, struct mtk_jpeg_ctx, ctrl_hdl);
}
-static inline struct mtk_jpeg_ctx *mtk_jpeg_fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mtk_jpeg_ctx, fh);
-}
-
static inline struct mtk_jpeg_ctx *mtk_jpeg_file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mtk_jpeg_ctx, fh);
@@ -217,7 +212,7 @@ static int mtk_jpeg_enum_fmt(struct mtk_jpeg_fmt *mtk_jpeg_formats, int n,
static int mtk_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct mtk_jpeg_dev *jpeg = ctx->jpeg;
return mtk_jpeg_enum_fmt(jpeg->variant->formats,
@@ -228,7 +223,7 @@ static int mtk_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
static int mtk_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct mtk_jpeg_dev *jpeg = ctx->jpeg;
return mtk_jpeg_enum_fmt(jpeg->variant->formats,
@@ -310,7 +305,7 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv,
struct vb2_queue *vq;
struct mtk_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct mtk_jpeg_dev *jpeg = ctx->jpeg;
int i;
@@ -356,7 +351,7 @@ static int mtk_jpeg_g_fmt_vid_mplane(struct file *file, void *priv,
static int mtk_jpeg_try_fmt_vid_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct mtk_jpeg_dev *jpeg = ctx->jpeg;
struct mtk_jpeg_fmt *fmt;
@@ -385,7 +380,7 @@ static int mtk_jpeg_try_fmt_vid_cap_mplane(struct file *file, void *priv,
static int mtk_jpeg_try_fmt_vid_out_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct mtk_jpeg_dev *jpeg = ctx->jpeg;
struct mtk_jpeg_fmt *fmt;
@@ -475,7 +470,7 @@ static int mtk_jpeg_s_fmt_vid_out_mplane(struct file *file, void *priv,
if (ret)
return ret;
- return mtk_jpeg_s_fmt_mplane(mtk_jpeg_fh_to_ctx(priv), f,
+ return mtk_jpeg_s_fmt_mplane(mtk_jpeg_file_to_ctx(file), f,
MTK_JPEG_FMT_FLAG_OUTPUT);
}
@@ -488,7 +483,7 @@ static int mtk_jpeg_s_fmt_vid_cap_mplane(struct file *file, void *priv,
if (ret)
return ret;
- return mtk_jpeg_s_fmt_mplane(mtk_jpeg_fh_to_ctx(priv), f,
+ return mtk_jpeg_s_fmt_mplane(mtk_jpeg_file_to_ctx(file), f,
MTK_JPEG_FMT_FLAG_CAPTURE);
}
@@ -517,7 +512,7 @@ static int mtk_jpeg_subscribe_event(struct v4l2_fh *fh,
static int mtk_jpeg_enc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL;
@@ -542,7 +537,7 @@ static int mtk_jpeg_enc_g_selection(struct file *file, void *priv,
static int mtk_jpeg_dec_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -571,7 +566,7 @@ static int mtk_jpeg_dec_g_selection(struct file *file, void *priv,
static int mtk_jpeg_enc_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL;
@@ -594,7 +589,7 @@ static int mtk_jpeg_enc_s_selection(struct file *file, void *priv,
static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
struct v4l2_fh *fh = file_to_v4l2_fh(file);
- struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(priv);
+ struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
struct vb2_queue *vq;
struct vb2_buffer *vb;
struct mtk_jpeg_src_buf *jpeg_src_buf;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 35/65] media: mtk_mdp_m2m: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (33 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 34/65] media: mtk: jpeg: Access v4l2_fh from file->private_data Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 36/65] media: mtk: mdp3: " Jacopo Mondi
` (29 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
index 3d836b5efa3807e4dc882956040014e244eeb660..03c07948dfdd07c6395c391ccad1788b08b1a867 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
@@ -348,11 +348,6 @@ static int mtk_mdp_try_crop(struct mtk_mdp_ctx *ctx, u32 type,
return 0;
}
-static inline struct mtk_mdp_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mtk_mdp_ctx, fh);
-}
-
static inline struct mtk_mdp_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mtk_mdp_ctx, fh);
@@ -594,7 +589,7 @@ static const struct vb2_ops mtk_mdp_m2m_qops = {
static int mtk_mdp_m2m_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct mtk_mdp_dev *mdp = ctx->mdp_dev;
strscpy(cap->driver, MTK_MDP_MODULE_NAME, sizeof(cap->driver));
@@ -632,7 +627,7 @@ static int mtk_mdp_m2m_enum_fmt_vid_out(struct file *file, void *priv,
static int mtk_mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct mtk_mdp_frame *frame;
struct v4l2_pix_format_mplane *pix_mp;
int i;
@@ -671,7 +666,7 @@ static int mtk_mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
static int mtk_mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
if (!mtk_mdp_try_fmt_mplane(ctx, f))
return -EINVAL;
@@ -681,7 +676,7 @@ static int mtk_mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
static int mtk_mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct vb2_queue *vq;
struct mtk_mdp_frame *frame;
struct v4l2_pix_format_mplane *pix_mp;
@@ -727,7 +722,7 @@ static int mtk_mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
static int mtk_mdp_m2m_reqbufs(struct file *file, void *fh,
struct v4l2_requestbuffers *reqbufs)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
}
@@ -735,7 +730,7 @@ static int mtk_mdp_m2m_reqbufs(struct file *file, void *fh,
static int mtk_mdp_m2m_streamon(struct file *file, void *fh,
enum v4l2_buf_type type)
{
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
int ret;
if (!mtk_mdp_ctx_state_is_set(ctx, MTK_MDP_VPU_INIT)) {
@@ -773,8 +768,8 @@ static inline bool mtk_mdp_is_target_crop(u32 target)
static int mtk_mdp_m2m_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct mtk_mdp_frame *frame;
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
bool valid = false;
if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -840,8 +835,8 @@ static int mtk_mdp_check_scaler_ratio(struct mtk_mdp_variant *var, int src_w,
static int mtk_mdp_m2m_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
+ struct mtk_mdp_ctx *ctx = file_to_ctx(file);
struct mtk_mdp_frame *frame;
- struct mtk_mdp_ctx *ctx = fh_to_ctx(fh);
struct v4l2_rect new_r;
struct mtk_mdp_variant *variant = ctx->mdp_dev->variant;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 36/65] media: mtk: mdp3: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (34 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 35/65] media: mtk_mdp_m2m: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:22 ` [PATCH 37/65] media: mtk: vcodec: " Jacopo Mondi
` (28 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index 2e0619542d2a9ad73457853e4f5008e6eb130cdd..9ef956b565a791429a477dc96567453cb189d817 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -10,11 +10,6 @@
#include <media/videobuf2-dma-contig.h>
#include "mtk-mdp3-m2m.h"
-static inline struct mdp_m2m_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mdp_m2m_ctx, fh);
-}
-
static inline struct mdp_m2m_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mdp_m2m_ctx, fh);
@@ -290,7 +285,7 @@ static int mdp_m2m_querycap(struct file *file, void *fh,
static int mdp_m2m_enum_fmt_mplane(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
return mdp_enum_fmt_mplane(ctx->mdp_dev, f);
}
@@ -298,7 +293,7 @@ static int mdp_m2m_enum_fmt_mplane(struct file *file, void *fh,
static int mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
struct mdp_frame *frame;
struct v4l2_pix_format_mplane *pix_mp;
@@ -316,7 +311,7 @@ static int mdp_m2m_g_fmt_mplane(struct file *file, void *fh,
static int mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
struct mdp_frame *frame = ctx_get_frame(ctx, f->type);
struct mdp_frame *capture;
const struct mdp_format *fmt;
@@ -359,7 +354,7 @@ static int mdp_m2m_s_fmt_mplane(struct file *file, void *fh,
static int mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
if (!mdp_try_fmt_mplane(ctx->mdp_dev, f, &ctx->curr_param, ctx->id))
return -EINVAL;
@@ -370,7 +365,7 @@ static int mdp_m2m_try_fmt_mplane(struct file *file, void *fh,
static int mdp_m2m_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
struct mdp_frame *frame;
bool valid = false;
@@ -422,7 +417,7 @@ static int mdp_m2m_g_selection(struct file *file, void *fh,
static int mdp_m2m_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct mdp_m2m_ctx *ctx = fh_to_ctx(fh);
+ struct mdp_m2m_ctx *ctx = file_to_ctx(file);
struct mdp_frame *frame = ctx_get_frame(ctx, s->type);
struct mdp_frame *capture;
struct v4l2_rect r;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 37/65] media: mtk: vcodec: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (35 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 36/65] media: mtk: mdp3: " Jacopo Mondi
@ 2025-08-02 9:22 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 38/65] media: tegra-vde: " Jacopo Mondi
` (27 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:22 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at modify mtk_vcodec_enc_get_chip_name() to accept a ctx instead
of a raw void *.
While at it, remove the now unused fh_to_enc_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 36 ++++++++++-----------
.../mediatek/vcodec/encoder/mtk_vcodec_enc.c | 37 +++++++++++-----------
.../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 5 ---
3 files changed, 36 insertions(+), 42 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
index 98838217b97d45ed2b5431fdf87c94e0ff79fc57..d691bd533103b100e7d1817e834696cc5b3990ce 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
@@ -87,7 +87,7 @@ static int stateful_try_decoder_cmd(struct file *file, void *priv, struct v4l2_d
static int stateful_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct vb2_queue *src_vq, *dst_vq;
int ret;
@@ -132,7 +132,7 @@ static int stateless_try_decoder_cmd(struct file *file, void *priv, struct v4l2_
static int stateless_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
int ret;
ret = v4l2_m2m_ioctl_stateless_try_decoder_cmd(file, priv, cmd);
@@ -158,7 +158,7 @@ static int stateless_decoder_cmd(struct file *file, void *priv, struct v4l2_deco
static int vidioc_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->dev->vdec_pdata->uses_stateless_api)
return stateless_try_decoder_cmd(file, priv, cmd);
@@ -168,7 +168,7 @@ static int vidioc_try_decoder_cmd(struct file *file, void *priv, struct v4l2_dec
static int vidioc_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->dev->vdec_pdata->uses_stateless_api)
return stateless_decoder_cmd(file, priv, cmd);
@@ -233,7 +233,7 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_dec_ctx *ctx)
static int vidioc_vdec_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_vdec_err(ctx, "[%d] Call on QBUF after unrecoverable error", ctx->id);
@@ -246,7 +246,7 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv,
static int vidioc_vdec_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_vdec_err(ctx, "[%d] Call on DQBUF after unrecoverable error", ctx->id);
@@ -259,7 +259,7 @@ static int vidioc_vdec_dqbuf(struct file *file, void *priv,
static int vidioc_vdec_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct device *dev = &ctx->dev->plat_dev->dev;
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
@@ -354,7 +354,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
fmt = mtk_vdec_find_format(f, dec_pdata);
@@ -372,7 +372,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
{
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
fmt = mtk_vdec_find_format(f, dec_pdata);
@@ -393,7 +393,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
static int vidioc_vdec_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct mtk_q_data *q_data;
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -442,7 +442,7 @@ static int vidioc_vdec_g_selection(struct file *file, void *priv,
static int vidioc_vdec_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -464,7 +464,7 @@ static int vidioc_vdec_s_selection(struct file *file, void *priv,
static int vidioc_vdec_s_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct v4l2_pix_format_mplane *pix_mp;
struct mtk_q_data *q_data;
int ret = 0;
@@ -594,7 +594,7 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
struct v4l2_frmsizeenum *fsize)
{
int i = 0;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
if (fsize->index != 0)
@@ -623,10 +623,10 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
return -EINVAL;
}
-static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv,
+static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
bool output_queue)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
const struct mtk_video_fmt *fmt;
int i, j = 0;
@@ -660,19 +660,19 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv,
static int vidioc_vdec_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- return vidioc_enum_fmt(f, priv, false);
+ return vidioc_enum_fmt(file, f, false);
}
static int vidioc_vdec_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- return vidioc_enum_fmt(f, priv, true);
+ return vidioc_enum_fmt(file, f, true);
}
static int vidioc_vdec_g_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
struct vb2_queue *vq;
struct mtk_q_data *q_data;
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
index a01dc25a769911cd85a8d19c58e0c0a12b92ad50..d815e962ab8981c53000851e8f2bc61faf28056d 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
@@ -159,7 +159,7 @@ static int vidioc_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *fsize)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(fh);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (fsize->index != 0)
return -EINVAL;
@@ -183,7 +183,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
const struct mtk_vcodec_enc_pdata *pdata =
- fh_to_enc_ctx(priv)->dev->venc_pdata;
+ file_to_enc_ctx(file)->dev->venc_pdata;
return vidioc_enum_fmt(f, pdata->capture_formats,
pdata->num_capture_formats);
@@ -193,15 +193,14 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
const struct mtk_vcodec_enc_pdata *pdata =
- fh_to_enc_ctx(priv)->dev->venc_pdata;
+ file_to_enc_ctx(file)->dev->venc_pdata;
return vidioc_enum_fmt(f, pdata->output_formats,
pdata->num_output_formats);
}
-static int mtk_vcodec_enc_get_chip_name(void *priv)
+static int mtk_vcodec_enc_get_chip_name(struct mtk_vcodec_enc_ctx *ctx)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
struct device *dev = &ctx->dev->plat_dev->dev;
if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-enc"))
@@ -221,9 +220,9 @@ static int mtk_vcodec_enc_get_chip_name(void *priv)
static int vidioc_venc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct device *dev = &ctx->dev->plat_dev->dev;
- int platform_name = mtk_vcodec_enc_get_chip_name(priv);
+ int platform_name = mtk_vcodec_enc_get_chip_name(ctx);
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
snprintf(cap->card, sizeof(cap->card), "MT%d video encoder", platform_name);
@@ -234,7 +233,7 @@ static int vidioc_venc_querycap(struct file *file, void *priv,
static int vidioc_venc_s_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct v4l2_fract *timeperframe = &a->parm.output.timeperframe;
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -257,7 +256,7 @@ static int vidioc_venc_s_parm(struct file *file, void *priv,
static int vidioc_venc_g_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
@@ -414,7 +413,7 @@ static void mtk_venc_set_param(struct mtk_vcodec_enc_ctx *ctx,
static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
@@ -469,7 +468,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
@@ -524,7 +523,7 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
int i;
@@ -557,7 +556,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
@@ -579,7 +578,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
@@ -600,7 +599,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
static int vidioc_venc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -630,7 +629,7 @@ static int vidioc_venc_g_selection(struct file *file, void *priv,
static int vidioc_venc_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -655,7 +654,7 @@ static int vidioc_venc_s_selection(struct file *file, void *priv,
static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_venc_err(ctx, "[%d] Call on QBUF after unrecoverable error",
@@ -669,7 +668,7 @@ static int vidioc_venc_qbuf(struct file *file, void *priv,
static int vidioc_venc_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
int ret;
if (ctx->state == MTK_STATE_ABORT) {
@@ -707,7 +706,7 @@ static int vidioc_venc_dqbuf(struct file *file, void *priv,
static int vidioc_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct vb2_queue *src_vq, *dst_vq;
int ret;
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
index 402e7d31d03d1985ad5ff2831faffc5c31b63467..5b304a5512366ed7109469a3b8f90b240baf2a11 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h
@@ -217,11 +217,6 @@ struct mtk_vcodec_enc_dev {
struct mtk_vcodec_dbgfs dbgfs;
};
-static inline struct mtk_vcodec_enc_ctx *fh_to_enc_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mtk_vcodec_enc_ctx, fh);
-}
-
static inline struct mtk_vcodec_enc_ctx *file_to_enc_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mtk_vcodec_enc_ctx, fh);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 38/65] media: tegra-vde: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (36 preceding siblings ...)
2025-08-02 9:22 ` [PATCH 37/65] media: mtk: vcodec: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 39/65] media: imx-jpeg: " Jacopo Mondi
` (26 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/nvidia/tegra-vde/v4l2.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index 0c50f4ff82e0a8f4935325d00691c58072182926..d94978ae2baf3394206ad7c3eb7a400aeee47cf7 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -46,9 +46,9 @@ static const struct v4l2_ctrl_config ctrl_cfgs[] = {
},
};
-static inline struct tegra_ctx *fh_to_tegra_ctx(struct v4l2_fh *fh)
+static inline struct tegra_ctx *file_to_tegra_ctx(struct file *file)
{
- return container_of(fh, struct tegra_ctx, fh);
+ return container_of(file_to_v4l2_fh(file), struct tegra_ctx, fh);
}
static void tegra_set_control_data(struct tegra_ctx *ctx, void *data, u32 id)
@@ -506,7 +506,7 @@ static int tegra_querycap(struct file *file, void *priv,
static int tegra_enum_decoded_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
if (WARN_ON(!ctx->coded_fmt_desc))
return -EINVAL;
@@ -522,7 +522,7 @@ static int tegra_enum_decoded_fmt(struct file *file, void *priv,
static int tegra_g_decoded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
*f = ctx->decoded_fmt;
return 0;
@@ -531,8 +531,8 @@ static int tegra_g_decoded_fmt(struct file *file, void *priv,
static int tegra_try_decoded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
const struct tegra_coded_fmt_desc *coded_desc;
unsigned int i;
@@ -571,7 +571,7 @@ static int tegra_try_decoded_fmt(struct file *file, void *priv,
static int tegra_s_decoded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
struct vb2_queue *vq;
int err;
@@ -593,7 +593,7 @@ static int tegra_s_decoded_fmt(struct file *file, void *priv,
static int tegra_enum_coded_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
const struct tegra_vde_soc *soc = ctx->vde->soc;
if (f->index >= soc->num_coded_fmts)
@@ -607,7 +607,7 @@ static int tegra_enum_coded_fmt(struct file *file, void *priv,
static int tegra_g_coded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
*f = ctx->coded_fmt;
return 0;
@@ -631,7 +631,7 @@ static int tegra_try_coded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
const struct tegra_vde_soc *soc = ctx->vde->soc;
int size = pix_mp->plane_fmt[0].sizeimage;
const struct tegra_coded_fmt_desc *desc;
@@ -656,7 +656,7 @@ static int tegra_try_coded_fmt(struct file *file, void *priv,
static int tegra_s_coded_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
const struct tegra_coded_fmt_desc *desc;
struct vb2_queue *peer_vq, *vq;
@@ -718,7 +718,7 @@ static int tegra_s_coded_fmt(struct file *file, void *priv,
static int tegra_enum_framesizes(struct file *file, void *priv,
struct v4l2_frmsizeenum *fsize)
{
- struct tegra_ctx *ctx = fh_to_tegra_ctx(priv);
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
const struct tegra_coded_fmt_desc *fmt;
if (fsize->index)
@@ -852,8 +852,8 @@ static int tegra_open(struct file *file)
static int tegra_release(struct file *file)
{
+ struct tegra_ctx *ctx = file_to_tegra_ctx(file);
struct v4l2_fh *fh = file_to_v4l2_fh(file);
- struct tegra_ctx *ctx = fh_to_tegra_ctx(fh);
struct tegra_vde *vde = ctx->vde;
v4l2_fh_del(fh, file);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 39/65] media: imx-jpeg: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (37 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 38/65] media: tegra-vde: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-05 1:58 ` [EXT] " Ming Qian
2025-08-02 9:23 ` [PATCH 40/65] media: imx-isi: " Jacopo Mondi
` (25 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused mxc_jpeg_fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 33 +++++++++++---------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index fa7d74d8c1aabd3bf74482e214165d8c1a7e89da..df3ccdf767baf0bf6687808e2c017063181a7220 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -644,11 +644,6 @@ static void print_mxc_buf(struct mxc_jpeg_dev *jpeg, struct vb2_buffer *buf,
}
}
-static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mxc_jpeg_ctx, fh);
-}
-
static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mxc_jpeg_ctx, fh);
@@ -1610,7 +1605,7 @@ static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *cmd)
{
struct v4l2_fh *fh = file_to_v4l2_fh(file);
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
unsigned long flags;
int ret;
@@ -1643,7 +1638,7 @@ static int mxc_jpeg_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
struct v4l2_fh *fh = file_to_v4l2_fh(file);
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
unsigned long flags;
int ret;
@@ -2260,7 +2255,7 @@ static int mxc_jpeg_querycap(struct file *file, void *priv,
static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_q_data *q_data = mxc_jpeg_get_q_data(ctx, f->type);
if (ctx->mxc_jpeg->mode == MXC_JPEG_ENCODE) {
@@ -2300,7 +2295,7 @@ static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
static int mxc_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
u32 type = ctx->mxc_jpeg->mode == MXC_JPEG_DECODE ? MXC_JPEG_FMT_TYPE_ENC :
MXC_JPEG_FMT_TYPE_RAW;
int ret;
@@ -2441,7 +2436,7 @@ static int mxc_jpeg_try_fmt(struct v4l2_format *f,
static int mxc_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
struct device *dev = jpeg->dev;
struct mxc_jpeg_q_data tmp_q;
@@ -2460,7 +2455,7 @@ static int mxc_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
static int mxc_jpeg_try_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
struct device *dev = jpeg->dev;
struct mxc_jpeg_q_data tmp_q;
@@ -2512,20 +2507,20 @@ static int mxc_jpeg_s_fmt(struct mxc_jpeg_ctx *ctx,
static int mxc_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
+ return mxc_jpeg_s_fmt(mxc_jpeg_file_to_ctx(file), f);
}
static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
int ret;
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct vb2_queue *dst_vq;
struct mxc_jpeg_q_data *q_data_cap;
enum v4l2_buf_type cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
struct v4l2_format fc;
- ret = mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
+ ret = mxc_jpeg_s_fmt(ctx, f);
if (ret)
return ret;
@@ -2554,7 +2549,7 @@ static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv,
static int mxc_jpeg_g_fmt_vid(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
struct device *dev = jpeg->dev;
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
@@ -2592,7 +2587,7 @@ static int mxc_jpeg_g_fmt_vid(struct file *file, void *priv,
static int mxc_jpeg_dec_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_q_data *q_data_cap;
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
@@ -2621,7 +2616,7 @@ static int mxc_jpeg_dec_g_selection(struct file *file, void *fh, struct v4l2_sel
static int mxc_jpeg_enc_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_q_data *q_data_out;
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -2649,7 +2644,7 @@ static int mxc_jpeg_enc_g_selection(struct file *file, void *fh, struct v4l2_sel
static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE)
return mxc_jpeg_dec_g_selection(file, fh, s);
@@ -2659,7 +2654,7 @@ static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selecti
static int mxc_jpeg_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
{
- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct mxc_jpeg_q_data *q_data_out;
if (ctx->mxc_jpeg->mode != MXC_JPEG_ENCODE)
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 40/65] media: imx-isi: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (38 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 39/65] media: imx-jpeg: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 41/65] media: nxp: mx2: " Jacopo Mondi
` (24 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused to_isi_m2m_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
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 850dd8ae95841d4470ac6bd7cb1e54a7510d6d5e..5501214cc6c0ce3e0188ae6d4ff4ae277b975911 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -74,11 +74,6 @@ to_isi_m2m_buffer(struct vb2_v4l2_buffer *buf)
return container_of(buf, struct mxc_isi_m2m_buffer, buf.vb);
}
-static inline struct mxc_isi_m2m_ctx *to_isi_m2m_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct mxc_isi_m2m_ctx, fh);
-}
-
static inline struct mxc_isi_m2m_ctx *file_to_isi_m2m_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
@@ -432,7 +427,7 @@ static int mxc_isi_m2m_try_fmt_vid(struct file *file, void *fh,
const enum mxc_isi_video_type type =
f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?
MXC_ISI_VIDEO_M2M_OUT : MXC_ISI_VIDEO_M2M_CAP;
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
__mxc_isi_m2m_try_fmt_vid(ctx, &f->fmt.pix_mp, type);
@@ -442,7 +437,7 @@ static int mxc_isi_m2m_try_fmt_vid(struct file *file, void *fh,
static int mxc_isi_m2m_g_fmt_vid(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
const struct mxc_isi_m2m_ctx_queue_data *qdata =
mxc_isi_m2m_ctx_qdata(ctx, f->type);
@@ -457,7 +452,7 @@ static int mxc_isi_m2m_s_fmt_vid(struct file *file, void *fh,
const enum mxc_isi_video_type type =
f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?
MXC_ISI_VIDEO_M2M_OUT : MXC_ISI_VIDEO_M2M_CAP;
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
const struct mxc_isi_format_info *info;
struct vb2_queue *vq;
@@ -489,7 +484,7 @@ static int mxc_isi_m2m_s_fmt_vid(struct file *file, void *fh,
static int mxc_isi_m2m_streamon(struct file *file, void *fh,
enum v4l2_buf_type type)
{
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
struct mxc_isi_m2m_ctx_queue_data *q = mxc_isi_m2m_ctx_qdata(ctx, type);
const struct v4l2_pix_format_mplane *out_pix = &ctx->queues.out.format;
const struct v4l2_pix_format_mplane *cap_pix = &ctx->queues.cap.format;
@@ -577,7 +572,7 @@ static int mxc_isi_m2m_streamon(struct file *file, void *fh,
static int mxc_isi_m2m_streamoff(struct file *file, void *fh,
enum v4l2_buf_type type)
{
- struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(fh);
+ struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
struct mxc_isi_m2m_ctx_queue_data *q = mxc_isi_m2m_ctx_qdata(ctx, type);
struct mxc_isi_m2m *m2m = ctx->m2m;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 41/65] media: nxp: mx2: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (39 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 40/65] media: imx-isi: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 42/65] media: renesas: " Jacopo Mondi
` (23 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/nxp/mx2_emmaprp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.c
index d23da93304bd6f55898cfb96319d2fa101036ca1..3aae8c0b690c0b1b0dd4f05a1c9184b089719a20 100644
--- a/drivers/media/platform/nxp/mx2_emmaprp.c
+++ b/drivers/media/platform/nxp/mx2_emmaprp.c
@@ -456,13 +456,13 @@ static int vidioc_g_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
static int vidioc_g_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- return vidioc_g_fmt(priv, f);
+ return vidioc_g_fmt(file_to_emmaprp_ctx(file), f);
}
static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- return vidioc_g_fmt(priv, f);
+ return vidioc_g_fmt(file_to_emmaprp_ctx(file), f);
}
static int vidioc_try_fmt(struct v4l2_format *f)
@@ -502,8 +502,8 @@ static int vidioc_try_fmt(struct v4l2_format *f)
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
+ struct emmaprp_ctx *ctx = file_to_emmaprp_ctx(file);
struct emmaprp_fmt *fmt;
- struct emmaprp_ctx *ctx = priv;
fmt = find_format(f);
if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) {
@@ -519,8 +519,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
+ struct emmaprp_ctx *ctx = file_to_emmaprp_ctx(file);
struct emmaprp_fmt *fmt;
- struct emmaprp_ctx *ctx = priv;
fmt = find_format(f);
if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) {
@@ -580,7 +580,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
if (ret)
return ret;
- return vidioc_s_fmt(priv, f);
+ return vidioc_s_fmt(file_to_emmaprp_ctx(file), f);
}
static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
@@ -592,7 +592,7 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
if (ret)
return ret;
- return vidioc_s_fmt(priv, f);
+ return vidioc_s_fmt(file_to_emmaprp_ctx(file), f);
}
static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 42/65] media: renesas: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (40 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 41/65] media: nxp: mx2: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-05 9:59 ` Kieran Bingham
2025-08-02 9:23 ` [PATCH 43/65] media: rockhip: rga: " Jacopo Mondi
` (22 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/renesas/rcar_fdp1.c | 11 +++--------
drivers/media/platform/renesas/rcar_jpu.c | 21 ++++++++-------------
2 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
index e78d8fb104e9544d27c8ace38888995ca170483f..84c3901a2e5dc3e7ccfb3b44062e839f8f19ee02 100644
--- a/drivers/media/platform/renesas/rcar_fdp1.c
+++ b/drivers/media/platform/renesas/rcar_fdp1.c
@@ -630,11 +630,6 @@ struct fdp1_ctx {
struct fdp1_field_buffer *previous;
};
-static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct fdp1_ctx, fh);
-}
-
static inline struct fdp1_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct fdp1_ctx, fh);
@@ -1411,8 +1406,8 @@ static int fdp1_enum_fmt_vid_out(struct file *file, void *priv,
static int fdp1_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
+ struct fdp1_ctx *ctx = file_to_ctx(file);
struct fdp1_q_data *q_data;
- struct fdp1_ctx *ctx = fh_to_ctx(priv);
if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
return -EINVAL;
@@ -1589,7 +1584,7 @@ static void fdp1_try_fmt_capture(struct fdp1_ctx *ctx,
static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct fdp1_ctx *ctx = fh_to_ctx(priv);
+ struct fdp1_ctx *ctx = file_to_ctx(file);
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
fdp1_try_fmt_output(ctx, NULL, &f->fmt.pix_mp);
@@ -1660,7 +1655,7 @@ static void fdp1_set_format(struct fdp1_ctx *ctx,
static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct fdp1_ctx *ctx = fh_to_ctx(priv);
+ struct fdp1_ctx *ctx = file_to_ctx(file);
struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
struct vb2_queue *vq = v4l2_m2m_get_vq(m2m_ctx, f->type);
diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
index 058fcfb967bd98440f33272db42f0d973299d572..9c70a74a2969fce6446b0f26e0637a68eade3942 100644
--- a/drivers/media/platform/renesas/rcar_jpu.c
+++ b/drivers/media/platform/renesas/rcar_jpu.c
@@ -480,11 +480,6 @@ static struct jpu_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
return container_of(c->handler, struct jpu_ctx, ctrl_handler);
}
-static struct jpu_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct jpu_ctx, fh);
-}
-
static struct jpu_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct jpu_ctx, fh);
@@ -661,7 +656,7 @@ static u8 jpu_parse_hdr(void *buffer, unsigned long size, unsigned int *width,
static int jpu_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct jpu_ctx *ctx = fh_to_ctx(priv);
+ struct jpu_ctx *ctx = file_to_ctx(file);
if (ctx->encoder)
strscpy(cap->card, DRV_NAME " encoder", sizeof(cap->card));
@@ -719,7 +714,7 @@ static int jpu_enum_fmt(struct v4l2_fmtdesc *f, u32 type)
static int jpu_enum_fmt_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct jpu_ctx *ctx = fh_to_ctx(priv);
+ struct jpu_ctx *ctx = file_to_ctx(file);
return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_CAPTURE :
JPU_DEC_CAPTURE);
@@ -728,7 +723,7 @@ static int jpu_enum_fmt_cap(struct file *file, void *priv,
static int jpu_enum_fmt_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct jpu_ctx *ctx = fh_to_ctx(priv);
+ struct jpu_ctx *ctx = file_to_ctx(file);
return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_OUTPUT : JPU_DEC_OUTPUT);
}
@@ -828,7 +823,7 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct jpu_ctx *ctx = fh_to_ctx(priv);
+ struct jpu_ctx *ctx = file_to_ctx(file);
if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
return -EINVAL;
@@ -839,7 +834,7 @@ static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct vb2_queue *vq;
- struct jpu_ctx *ctx = fh_to_ctx(priv);
+ struct jpu_ctx *ctx = file_to_ctx(file);
struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
struct jpu_fmt *fmtinfo;
struct jpu_q_data *q_data;
@@ -868,8 +863,8 @@ static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int jpu_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
+ struct jpu_ctx *ctx = file_to_ctx(file);
struct jpu_q_data *q_data;
- struct jpu_ctx *ctx = fh_to_ctx(priv);
if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
return -EINVAL;
@@ -902,8 +897,8 @@ static const struct v4l2_ctrl_ops jpu_ctrl_ops = {
static int jpu_streamon(struct file *file, void *priv, enum v4l2_buf_type type)
{
- struct jpu_ctx *ctx = fh_to_ctx(priv);
struct jpu_q_data *src_q_data, *dst_q_data, *orig, adj, *ref;
+ struct jpu_ctx *ctx = file_to_ctx(file);
enum v4l2_buf_type adj_type;
src_q_data = jpu_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
@@ -1284,8 +1279,8 @@ static int jpu_open(struct file *file)
static int jpu_release(struct file *file)
{
- struct jpu *jpu = video_drvdata(file);
struct jpu_ctx *ctx = file_to_ctx(file);
+ struct jpu *jpu = video_drvdata(file);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 43/65] media: rockhip: rga: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (41 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 42/65] media: renesas: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 44/65] media: rockchip: rkvdec: " Jacopo Mondi
` (21 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/rockchip/rga/rga.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 45c42c7ad846fab985e573ef7acf4a5bc1a4cac1..7c657df623f2897cd1ce2b6fa4c4b4de369f1c64 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -462,7 +462,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
- struct rga_ctx *ctx = prv;
+ struct rga_ctx *ctx = file_to_rga_ctx(file);
struct vb2_queue *vq;
struct rga_frame *frm;
@@ -504,7 +504,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
- struct rga_ctx *ctx = prv;
+ struct rga_ctx *ctx = file_to_rga_ctx(file);
struct rockchip_rga *rga = ctx->rga;
struct vb2_queue *vq;
struct rga_frame *frm;
@@ -561,7 +561,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_g_selection(struct file *file, void *prv,
struct v4l2_selection *s)
{
- struct rga_ctx *ctx = prv;
+ struct rga_ctx *ctx = file_to_rga_ctx(file);
struct rga_frame *f;
bool use_frame = false;
@@ -609,7 +609,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
static int vidioc_s_selection(struct file *file, void *prv,
struct v4l2_selection *s)
{
- struct rga_ctx *ctx = prv;
+ struct rga_ctx *ctx = file_to_rga_ctx(file);
struct rockchip_rga *rga = ctx->rga;
struct rga_frame *f;
int ret = 0;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 44/65] media: rockchip: rkvdec: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (42 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 43/65] media: rockhip: rga: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 16:02 ` Detlev Casanova
2025-08-02 9:23 ` [PATCH 45/65] media: exynos-gsc: " Jacopo Mondi
` (20 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_rkvdec_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/rockchip/rkvdec/rkvdec.c | 14 +++++++-------
drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 -----
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 481c2488f9ac64e70869ed21e5053cfbc4ed6e0e..9fa80ab3c62b7753e6c992aefd106ee99ed375e4 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -354,7 +354,7 @@ static int rkvdec_try_capture_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
const struct rkvdec_coded_fmt_desc *coded_desc;
/*
@@ -387,7 +387,7 @@ static int rkvdec_try_output_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
const struct rkvdec_coded_fmt_desc *desc;
desc = rkvdec_find_coded_fmt_desc(pix_mp->pixelformat);
@@ -418,7 +418,7 @@ static int rkvdec_try_output_fmt(struct file *file, void *priv,
static int rkvdec_s_capture_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
struct vb2_queue *vq;
int ret;
@@ -439,7 +439,7 @@ static int rkvdec_s_capture_fmt(struct file *file, void *priv,
static int rkvdec_s_output_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
const struct rkvdec_coded_fmt_desc *desc;
struct v4l2_format *cap_fmt;
@@ -504,7 +504,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv,
static int rkvdec_g_output_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
*f = ctx->coded_fmt;
return 0;
@@ -513,7 +513,7 @@ static int rkvdec_g_output_fmt(struct file *file, void *priv,
static int rkvdec_g_capture_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
*f = ctx->decoded_fmt;
return 0;
@@ -532,7 +532,7 @@ static int rkvdec_enum_output_fmt(struct file *file, void *priv,
static int rkvdec_enum_capture_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
+ struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
u32 fourcc;
fourcc = rkvdec_enum_decoded_fmt(ctx, f->index, ctx->image_fmt);
diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
index 35effe9467845fdfc4ffea432211d1d2e75a08b0..481aaa4bffe975fa106fb22e78bef90ade86a6cf 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
@@ -124,11 +124,6 @@ struct rkvdec_ctx {
void *priv;
};
-static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct rkvdec_ctx, fh);
-}
-
static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 45/65] media: exynos-gsc: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (43 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 44/65] media: rockchip: rkvdec: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 46/65] media: exynos4-is: " Jacopo Mondi
` (19 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/samsung/exynos-gsc/gsc-core.h | 2 --
.../media/platform/samsung/exynos-gsc/gsc-m2m.c | 24 +++++++++++-----------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-core.h b/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
index a5491fe39e0f686c75c888c4632150f32326c36e..265221abf4dcd87f2ab10758e145fa96ac9d420e 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
@@ -85,8 +85,6 @@ enum gsc_yuv_fmt {
GSC_CRCB,
};
-#define fh_to_ctx(__fh) container_of(__fh, struct gsc_ctx, fh)
-
#define is_rgb(x) (!!((x) & 0x1))
#define is_yuv420(x) (!!((x) & 0x2))
#define is_yuv422(x) (!!((x) & 0x4))
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
index 2999fb2610f0f61b63d0331f94883469ff43d751..722e2531e23f1bc01f5e9a9c08dfe4745cc2aa4f 100644
--- a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
@@ -297,7 +297,7 @@ static int gsc_m2m_enum_fmt(struct file *file, void *priv,
static int gsc_m2m_g_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return gsc_g_fmt_mplane(ctx, f);
}
@@ -305,7 +305,7 @@ static int gsc_m2m_g_fmt_mplane(struct file *file, void *fh,
static int gsc_m2m_try_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return gsc_try_fmt_mplane(ctx, f);
}
@@ -313,7 +313,7 @@ static int gsc_m2m_try_fmt_mplane(struct file *file, void *fh,
static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct vb2_queue *vq;
struct gsc_frame *frame;
struct v4l2_pix_format_mplane *pix;
@@ -359,7 +359,7 @@ static int gsc_m2m_s_fmt_mplane(struct file *file, void *fh,
static int gsc_m2m_reqbufs(struct file *file, void *fh,
struct v4l2_requestbuffers *reqbufs)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_dev *gsc = ctx->gsc_dev;
u32 max_cnt;
@@ -374,35 +374,35 @@ static int gsc_m2m_reqbufs(struct file *file, void *fh,
static int gsc_m2m_expbuf(struct file *file, void *fh,
struct v4l2_exportbuffer *eb)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_expbuf(file, ctx->m2m_ctx, eb);
}
static int gsc_m2m_querybuf(struct file *file, void *fh,
struct v4l2_buffer *buf)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
}
static int gsc_m2m_qbuf(struct file *file, void *fh,
struct v4l2_buffer *buf)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
}
static int gsc_m2m_dqbuf(struct file *file, void *fh,
struct v4l2_buffer *buf)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
}
static int gsc_m2m_streamon(struct file *file, void *fh,
enum v4l2_buf_type type)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
/* The source and target color format need to be set */
if (V4L2_TYPE_IS_OUTPUT(type)) {
@@ -418,7 +418,7 @@ static int gsc_m2m_streamon(struct file *file, void *fh,
static int gsc_m2m_streamoff(struct file *file, void *fh,
enum v4l2_buf_type type)
{
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
}
@@ -440,8 +440,8 @@ static int is_rectangle_enclosed(struct v4l2_rect *a, struct v4l2_rect *b)
static int gsc_m2m_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_frame *frame;
- struct gsc_ctx *ctx = fh_to_ctx(fh);
if ((s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
(s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT))
@@ -478,7 +478,7 @@ static int gsc_m2m_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
struct gsc_frame *frame;
- struct gsc_ctx *ctx = fh_to_ctx(fh);
+ struct gsc_ctx *ctx = file_to_ctx(file);
struct gsc_variant *variant = ctx->gsc_dev->variant;
struct v4l2_selection sel = *s;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 46/65] media: exynos4-is: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (44 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 45/65] media: exynos-gsc: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 47/65] media: s3c-camif: Set queue owner using file Jacopo Mondi
` (18 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/samsung/exynos4-is/fimc-core.h | 2 --
drivers/media/platform/samsung/exynos4-is/fimc-m2m.c | 10 +++++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-core.h b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
index 25711df062e79eb2066f0f6eab1c1733f16c9c2d..c23cbdee7afcdfedf1a2ef0433b98af6b4478eef 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
@@ -496,8 +496,6 @@ struct fimc_ctx {
struct fimc_ctrls ctrls;
};
-#define fh_to_ctx(__fh) container_of(__fh, struct fimc_ctx, fh)
-
static inline struct fimc_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct fimc_ctx, fh);
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
index 609fd84f89d4ad189d0f367bb37693f15f3a618e..562c57f186c61546175b4f902f1da18fbb2f25fe 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
@@ -249,7 +249,7 @@ static int fimc_m2m_enum_fmt(struct file *file, void *priv,
static int fimc_m2m_g_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct fimc_ctx *ctx = fh_to_ctx(fh);
+ struct fimc_ctx *ctx = file_to_ctx(file);
const struct fimc_frame *frame = ctx_get_frame(ctx, f->type);
if (IS_ERR(frame))
@@ -308,7 +308,7 @@ static int fimc_try_fmt_mplane(struct fimc_ctx *ctx, struct v4l2_format *f)
static int fimc_m2m_try_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct fimc_ctx *ctx = fh_to_ctx(fh);
+ struct fimc_ctx *ctx = file_to_ctx(file);
return fimc_try_fmt_mplane(ctx, f);
}
@@ -337,7 +337,7 @@ static void __set_frame_format(struct fimc_frame *frame,
static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
struct v4l2_format *f)
{
- struct fimc_ctx *ctx = fh_to_ctx(fh);
+ struct fimc_ctx *ctx = file_to_ctx(file);
struct fimc_dev *fimc = ctx->fimc_dev;
const struct fimc_fmt *fmt;
struct vb2_queue *vq;
@@ -376,7 +376,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
static int fimc_m2m_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct fimc_ctx *ctx = fh_to_ctx(fh);
+ struct fimc_ctx *ctx = file_to_ctx(file);
const struct fimc_frame *frame;
frame = ctx_get_frame(ctx, s->type);
@@ -484,7 +484,7 @@ static int fimc_m2m_try_selection(struct fimc_ctx *ctx,
static int fimc_m2m_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct fimc_ctx *ctx = fh_to_ctx(fh);
+ struct fimc_ctx *ctx = file_to_ctx(file);
struct fimc_dev *fimc = ctx->fimc_dev;
struct fimc_frame *f;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 47/65] media: s3c-camif: Set queue owner using file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (45 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 46/65] media: exynos4-is: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 48/65] media: s5p-g2d: Access v4l2_fh from file Jacopo Mondi
` (17 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The s3c-camif driver keeps track of which user owns the vb2 queue
by using the 'void *priv' argument passed to ioctl handlers.
As the driver uses v4l2_fh_open() the priv argument points to the
v4l2_fh handle associated with the open file.
Use file_to_v4l2_fh(file) instead of the raw 'priv' argument for better
consistency.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/samsung/s3c-camif/camif-capture.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/samsung/s3c-camif/camif-capture.c b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
index cae15a4ce5fd83f00ced8b2dfbb5f5a6f7483ca4..ed1a1d693293b33d8da3190ac8ee6dd212a64b88 100644
--- a/drivers/media/platform/samsung/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
@@ -791,7 +791,7 @@ static int s3c_camif_vidioc_s_fmt(struct file *file, void *priv,
out_frame->rect.top = 0;
if (vp->owner == NULL)
- vp->owner = priv;
+ vp->owner = file_to_v4l2_fh(file);
pr_debug("%ux%u. payload: %u. fmt: 0x%08x. %d %d. sizeimage: %d. bpl: %d\n",
out_frame->f_width, out_frame->f_height, vp->payload,
@@ -841,7 +841,7 @@ static int s3c_camif_streamon(struct file *file, void *priv,
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
if (s3c_vp_active(vp))
@@ -872,7 +872,7 @@ static int s3c_camif_streamoff(struct file *file, void *priv,
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
ret = vb2_streamoff(&vp->vb_queue, type);
@@ -888,9 +888,9 @@ static int s3c_camif_reqbufs(struct file *file, void *priv,
int ret;
pr_debug("[vp%d] rb count: %d, owner: %p, priv: %p\n",
- vp->id, rb->count, vp->owner, priv);
+ vp->id, rb->count, vp->owner, file_to_v4l2_fh(file));
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
if (rb->count)
@@ -910,7 +910,7 @@ static int s3c_camif_reqbufs(struct file *file, void *priv,
vp->reqbufs_count = rb->count;
if (vp->owner == NULL && rb->count > 0)
- vp->owner = priv;
+ vp->owner = file_to_v4l2_fh(file);
return ret;
}
@@ -929,7 +929,7 @@ static int s3c_camif_qbuf(struct file *file, void *priv,
pr_debug("[vp%d]\n", vp->id);
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
return vb2_qbuf(&vp->vb_queue, vp->vdev.v4l2_dev->mdev, buf);
@@ -942,7 +942,7 @@ static int s3c_camif_dqbuf(struct file *file, void *priv,
pr_debug("[vp%d] sequence: %d\n", vp->id, vp->frame_sequence);
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
return vb2_dqbuf(&vp->vb_queue, buf, file->f_flags & O_NONBLOCK);
@@ -954,14 +954,14 @@ static int s3c_camif_create_bufs(struct file *file, void *priv,
struct camif_vp *vp = video_drvdata(file);
int ret;
- if (vp->owner && vp->owner != priv)
+ if (vp->owner && vp->owner != file_to_v4l2_fh(file))
return -EBUSY;
create->count = max_t(u32, 1, create->count);
ret = vb2_create_bufs(&vp->vb_queue, create);
if (!ret && vp->owner == NULL)
- vp->owner = priv;
+ vp->owner = file_to_v4l2_fh(file);
return ret;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 48/65] media: s5p-g2d: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (46 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 47/65] media: s3c-camif: Set queue owner using file Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 49/65] media: s5p-jpeg: " Jacopo Mondi
` (16 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/samsung/s5p-g2d/g2d.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
index 922262f61e7b53baf1b5840d35149bf5b4b2e7ad..55f5130156b7e8690bd0eb204630a730d9f84bd6 100644
--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
@@ -307,7 +307,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
- struct g2d_ctx *ctx = prv;
+ struct g2d_ctx *ctx = file2ctx(file);
struct vb2_queue *vq;
struct g2d_frame *frm;
@@ -359,7 +359,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
- struct g2d_ctx *ctx = prv;
+ struct g2d_ctx *ctx = file2ctx(file);
struct g2d_dev *dev = ctx->dev;
struct vb2_queue *vq;
struct g2d_frame *frm;
@@ -400,7 +400,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_g_selection(struct file *file, void *prv,
struct v4l2_selection *s)
{
- struct g2d_ctx *ctx = prv;
+ struct g2d_ctx *ctx = file2ctx(file);
struct g2d_frame *f;
f = get_frame(ctx, s->type);
@@ -450,7 +450,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
static int vidioc_try_selection(struct file *file, void *prv,
const struct v4l2_selection *s)
{
- struct g2d_ctx *ctx = prv;
+ struct g2d_ctx *ctx = file2ctx(file);
struct g2d_dev *dev = ctx->dev;
struct g2d_frame *f;
@@ -478,7 +478,7 @@ static int vidioc_try_selection(struct file *file, void *prv,
static int vidioc_s_selection(struct file *file, void *prv,
struct v4l2_selection *s)
{
- struct g2d_ctx *ctx = prv;
+ struct g2d_ctx *ctx = file2ctx(file);
struct g2d_frame *f;
int ret;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 49/65] media: s5p-jpeg: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (47 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 48/65] media: s5p-g2d: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 50/65] media: s5p-mfc: " Jacopo Mondi
` (15 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/samsung/s5p-jpeg/jpeg-core.c | 25 +++++++++-------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
index 2a57efd181540183e7d2b66d51f9f2f274ddd100..81792f7f8b1671dba2023f99b2779784d9a14b8c 100644
--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
@@ -580,11 +580,6 @@ static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler);
}
-static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct s5p_jpeg_ctx, fh);
-}
-
static inline struct s5p_jpeg_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct s5p_jpeg_ctx, fh);
@@ -1015,8 +1010,8 @@ static int s5p_jpeg_open(struct file *file)
static int s5p_jpeg_release(struct file *file)
{
- struct s5p_jpeg *jpeg = video_drvdata(file);
struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
+ struct s5p_jpeg *jpeg = video_drvdata(file);
mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
@@ -1253,7 +1248,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
static int s5p_jpeg_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
if (ctx->mode == S5P_JPEG_ENCODE) {
strscpy(cap->driver, S5P_JPEG_M2M_NAME,
@@ -1301,7 +1296,7 @@ static int enum_fmt(struct s5p_jpeg_ctx *ctx,
static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
if (ctx->mode == S5P_JPEG_ENCODE)
return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
@@ -1314,7 +1309,7 @@ static int s5p_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
static int s5p_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
if (ctx->mode == S5P_JPEG_ENCODE)
return enum_fmt(ctx, sjpeg_formats, SJPEG_NUM_FORMATS, f,
@@ -1340,7 +1335,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
struct vb2_queue *vq;
struct s5p_jpeg_q_data *q_data = NULL;
struct v4l2_pix_format *pix = &f->fmt.pix;
- struct s5p_jpeg_ctx *ct = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ct = file_to_ctx(file);
vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type);
if (!vq)
@@ -1480,7 +1475,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt,
static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
struct v4l2_pix_format *pix = &f->fmt.pix;
struct s5p_jpeg_fmt *fmt;
int ret;
@@ -1539,7 +1534,7 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
struct s5p_jpeg_fmt *fmt;
fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat,
@@ -1686,7 +1681,7 @@ static int s5p_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
if (ret)
return ret;
- return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
+ return s5p_jpeg_s_fmt(file_to_ctx(file), f);
}
static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
@@ -1698,7 +1693,7 @@ static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
if (ret)
return ret;
- return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
+ return s5p_jpeg_s_fmt(file_to_ctx(file), f);
}
static int s5p_jpeg_subscribe_event(struct v4l2_fh *fh,
@@ -1795,7 +1790,7 @@ static int exynos3250_jpeg_try_crop(struct s5p_jpeg_ctx *ctx,
static int s5p_jpeg_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 50/65] media: s5p-mfc: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (48 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 49/65] media: s5p-jpeg: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 51/65] media: bdisp: " Jacopo Mondi
` (14 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
.../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 22 ++++++++++----------
.../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 24 +++++++++++-----------
2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index 3efbc336790629425c2a71e9feee8f073db55790..6a2703fe7e8cc3104fbaa3c7405e67295e87db5d 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -345,7 +345,7 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
/* Get format */
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct v4l2_pix_format_mplane *pix_mp;
mfc_debug_enter();
@@ -442,7 +442,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret = 0;
struct v4l2_pix_format_mplane *pix_mp;
const struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
@@ -598,7 +598,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *reqbufs)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (reqbufs->memory != V4L2_MEMORY_MMAP) {
mfc_debug(2, "Only V4L2_MEMORY_MMAP is supported\n");
@@ -619,7 +619,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
static int vidioc_querybuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret;
int i;
@@ -647,7 +647,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
/* Queue a buffer */
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (ctx->state == MFCINST_ERROR) {
mfc_err("Call on QBUF after unrecoverable error\n");
@@ -666,7 +666,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
const struct v4l2_event ev = {
.type = V4L2_EVENT_EOS
};
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret;
if (ctx->state == MFCINST_ERROR) {
@@ -695,7 +695,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
static int vidioc_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *eb)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return vb2_expbuf(&ctx->vq_src, eb);
@@ -708,7 +708,7 @@ static int vidioc_expbuf(struct file *file, void *priv,
static int vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret = -EINVAL;
mfc_debug_enter();
@@ -724,7 +724,7 @@ static int vidioc_streamon(struct file *file, void *priv,
static int vidioc_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return vb2_streamoff(&ctx->vq_src, type);
@@ -801,7 +801,7 @@ static const struct v4l2_ctrl_ops s5p_mfc_dec_ctrl_ops = {
static int vidioc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = ctx->dev;
u32 left, right, top, bottom;
u32 width, height;
@@ -856,7 +856,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
static int vidioc_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *cmd)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_buf *buf;
unsigned long flags;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 6c603dcd56649fcabe161173c64b9ea8bd055b93..c6787ccfaaa422a905dbb136d992f2d15b8e484f 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1389,8 +1389,8 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
mfc_debug(2, "f->type = %d ctx->state = %d\n", f->type, ctx->state);
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -1472,8 +1472,8 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
int ret = 0;
@@ -1531,7 +1531,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *reqbufs)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret = 0;
/* if memory is not mmp or userptr or dmabuf return error */
@@ -1601,7 +1601,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
static int vidioc_querybuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
int ret = 0;
/* if memory is not mmp or userptr or dmabuf return error */
@@ -1636,7 +1636,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
/* Queue a buffer */
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (ctx->state == MFCINST_ERROR) {
mfc_err("Call on QBUF after unrecoverable error\n");
@@ -1657,10 +1657,10 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
/* Dequeue a buffer */
static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
{
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
const struct v4l2_event ev = {
.type = V4L2_EVENT_EOS
};
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
int ret;
if (ctx->state == MFCINST_ERROR) {
@@ -1685,7 +1685,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
static int vidioc_expbuf(struct file *file, void *priv,
struct v4l2_exportbuffer *eb)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return vb2_expbuf(&ctx->vq_src, eb);
@@ -1698,7 +1698,7 @@ static int vidioc_expbuf(struct file *file, void *priv,
static int vidioc_streamon(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return vb2_streamon(&ctx->vq_src, type);
@@ -1711,7 +1711,7 @@ static int vidioc_streamon(struct file *file, void *priv,
static int vidioc_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return vb2_streamoff(&ctx->vq_src, type);
@@ -2284,7 +2284,7 @@ static const struct v4l2_ctrl_ops s5p_mfc_enc_ctrl_ops = {
static int vidioc_s_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
ctx->enc_params.rc_framerate_num =
@@ -2301,7 +2301,7 @@ static int vidioc_s_parm(struct file *file, void *priv,
static int vidioc_g_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
a->parm.output.timeperframe.denominator =
@@ -2318,7 +2318,7 @@ static int vidioc_g_parm(struct file *file, void *priv,
static int vidioc_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
- struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
+ struct s5p_mfc_ctx *ctx = file_to_ctx(file);
struct s5p_mfc_dev *dev = ctx->dev;
struct s5p_mfc_buf *buf;
unsigned long flags;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 51/65] media: bdisp: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (49 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 50/65] media: s5p-mfc: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 52/65] media: st: delta: " Jacopo Mondi
` (13 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
index fc7945d29bccc2fdf0fc48fc14d6698b321418d9..56169b70652d3aaf7c3c395a630a29023cbd9722 100644
--- a/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c
@@ -33,8 +33,6 @@
#define BDISP_MIN_H 1
#define BDISP_MAX_H 8191
-#define fh_to_ctx(__fh) container_of(__fh, struct bdisp_ctx, fh)
-
static inline struct bdisp_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct bdisp_ctx, fh);
@@ -686,7 +684,7 @@ static const struct v4l2_file_operations bdisp_fops = {
static int bdisp_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct bdisp_dev *bdisp = ctx->bdisp_dev;
strscpy(cap->driver, bdisp->pdev->name, sizeof(cap->driver));
@@ -698,7 +696,7 @@ static int bdisp_querycap(struct file *file, void *fh,
static int bdisp_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
const struct bdisp_fmt *fmt;
if (f->index >= ARRAY_SIZE(bdisp_formats))
@@ -718,7 +716,7 @@ static int bdisp_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
static int bdisp_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct v4l2_pix_format *pix;
struct bdisp_frame *frame = ctx_get_frame(ctx, f->type);
@@ -742,7 +740,7 @@ static int bdisp_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int bdisp_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct v4l2_pix_format *pix = &f->fmt.pix;
const struct bdisp_fmt *format;
u32 in_w, in_h;
@@ -792,7 +790,7 @@ static int bdisp_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int bdisp_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct vb2_queue *vq;
struct bdisp_frame *frame;
struct v4l2_pix_format *pix;
@@ -845,8 +843,8 @@ static int bdisp_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
static int bdisp_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct bdisp_frame *frame;
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
frame = ctx_get_frame(ctx, s->type);
if (IS_ERR(frame)) {
@@ -923,8 +921,8 @@ static int is_rect_enclosed(struct v4l2_rect *a, struct v4l2_rect *b)
static int bdisp_s_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
+ struct bdisp_ctx *ctx = file_to_ctx(file);
struct bdisp_frame *frame;
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
struct v4l2_rect *in, out;
bool valid = false;
@@ -1001,7 +999,7 @@ static int bdisp_s_selection(struct file *file, void *fh,
static int bdisp_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
{
- struct bdisp_ctx *ctx = fh_to_ctx(fh);
+ struct bdisp_ctx *ctx = file_to_ctx(file);
if ((type == V4L2_BUF_TYPE_VIDEO_OUTPUT) &&
!bdisp_ctx_state_is_set(BDISP_SRC_FMT, ctx)) {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 52/65] media: st: delta: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (50 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 51/65] media: bdisp: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 53/65] media: stm32: dma2d: " Jacopo Mondi
` (12 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it, remove the now unused fh_to_ctx() macro.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/st/sti/delta/delta-v4l2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/st/sti/delta/delta-v4l2.c b/drivers/media/platform/st/sti/delta/delta-v4l2.c
index adff43271b2dc059abbbf82d90cd13482f6bca30..6c1a53c771f746813a6062cb3ffc139250ff7146 100644
--- a/drivers/media/platform/st/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/st/sti/delta/delta-v4l2.c
@@ -24,8 +24,6 @@
#define DELTA_PREFIX "[---:----]"
-#define to_ctx(__fh) container_of(__fh, struct delta_ctx, fh)
-
static inline struct delta_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct delta_ctx, fh);
@@ -727,7 +725,7 @@ static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
static int delta_g_selection(struct file *file, void *fh,
struct v4l2_selection *s)
{
- struct delta_ctx *ctx = to_ctx(fh);
+ struct delta_ctx *ctx = file_to_ctx(file);
struct delta_frameinfo *frameinfo = &ctx->frameinfo;
struct v4l2_rect crop;
@@ -809,7 +807,7 @@ static int delta_try_decoder_cmd(struct file *file, void *fh,
return 0;
}
-static int delta_decoder_stop_cmd(struct delta_ctx *ctx, void *fh)
+static int delta_decoder_stop_cmd(struct delta_ctx *ctx)
{
const struct delta_dec *dec = ctx->dec;
struct delta_dev *delta = ctx->dev;
@@ -872,14 +870,14 @@ static int delta_decoder_stop_cmd(struct delta_ctx *ctx, void *fh)
static int delta_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *cmd)
{
- struct delta_ctx *ctx = to_ctx(fh);
+ struct delta_ctx *ctx = file_to_ctx(file);
int ret = 0;
ret = delta_try_decoder_cmd(file, fh, cmd);
if (ret)
return ret;
- return delta_decoder_stop_cmd(ctx, fh);
+ return delta_decoder_stop_cmd(ctx);
}
static int delta_subscribe_event(struct v4l2_fh *fh,
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 53/65] media: stm32: dma2d: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (51 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 52/65] media: st: delta: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data Jacopo Mondi
` (11 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/st/stm32/dma2d/dma2d.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index bc0f81e78018b20c38677eaea44358ddad7a9a52..a22f587a5f83fe114e5b1f0a7a0299638701fa71 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -354,7 +354,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
- struct dma2d_ctx *ctx = prv;
+ struct dma2d_ctx *ctx = file2ctx(file);
struct vb2_queue *vq;
struct dma2d_frame *frm;
@@ -379,7 +379,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
- struct dma2d_ctx *ctx = prv;
+ struct dma2d_ctx *ctx = file2ctx(file);
struct dma2d_fmt *fmt;
enum v4l2_field *field;
u32 fourcc = f->fmt.pix.pixelformat;
@@ -422,7 +422,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
{
- struct dma2d_ctx *ctx = prv;
+ struct dma2d_ctx *ctx = file2ctx(file);
struct vb2_queue *vq;
struct dma2d_frame *frm;
struct dma2d_fmt *fmt;
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (52 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 53/65] media: stm32: dma2d: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-04 21:59 ` Paul Kocialkowski
2025-08-02 9:23 ` [PATCH 55/65] media: omap3isp: Access v4l2_fh from file Jacopo Mondi
` (10 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To prepare for the introduction of video_device_state as second argument
of the v4l2_ioctl_ops handler, access the v4l2_fh from
file->private_data instead of using void *priv.
The file->private_data is initialized to point to the v4l2_fh
by the usage of v4l2_fh_init() in the v4l2_file_operations.open()
handler.
While at it remove the only left user of fh_to_ctx() and remove
the macro completely.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/verisilicon/hantro.h | 5 -----
drivers/media/platform/verisilicon/hantro_v4l2.c | 22 +++++++++++-----------
2 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
index 0f10714f1953945472e11d8c8ad87f8ec009b39f..e0fdc4535b2d73c5260057b0a89aee67a4732dd2 100644
--- a/drivers/media/platform/verisilicon/hantro.h
+++ b/drivers/media/platform/verisilicon/hantro.h
@@ -382,11 +382,6 @@ extern int hantro_debug;
pr_err("%s:%d: " fmt, __func__, __LINE__, ##args)
/* Structure access helpers. */
-static __always_inline struct hantro_ctx *fh_to_ctx(struct v4l2_fh *fh)
-{
- return container_of(fh, struct hantro_ctx, fh);
-}
-
static __always_inline struct hantro_ctx *file_to_ctx(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct hantro_ctx, fh);
diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
index 7c3515cf7d64a090adfb8d8aff368f9a617f8c8a..6bcd892e7bb49c654aae5841664d68c1692064bd 100644
--- a/drivers/media/platform/verisilicon/hantro_v4l2.c
+++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
@@ -185,7 +185,7 @@ static int vidioc_querycap(struct file *file, void *priv,
static int vidioc_enum_framesizes(struct file *file, void *priv,
struct v4l2_frmsizeenum *fsize)
{
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
const struct hantro_fmt *fmt;
fmt = hantro_find_format(ctx, fsize->pixel_format);
@@ -217,7 +217,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f, bool capture)
{
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
const struct hantro_fmt *fmt, *formats;
unsigned int num_fmts, i, j = 0;
bool skip_mode_none, enum_all_formats;
@@ -297,7 +297,7 @@ static int vidioc_g_fmt_out_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
vpu_debug(4, "f->type = %d\n", f->type);
@@ -310,7 +310,7 @@ static int vidioc_g_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
vpu_debug(4, "f->type = %d\n", f->type);
@@ -398,13 +398,13 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
static int vidioc_try_fmt_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
- return hantro_try_fmt(fh_to_ctx(priv), &f->fmt.pix_mp, f->type);
+ return hantro_try_fmt(file_to_ctx(file), &f->fmt.pix_mp, f->type);
}
static int vidioc_try_fmt_out_mplane(struct file *file, void *priv,
struct v4l2_format *f)
{
- return hantro_try_fmt(fh_to_ctx(priv), &f->fmt.pix_mp, f->type);
+ return hantro_try_fmt(file_to_ctx(file), &f->fmt.pix_mp, f->type);
}
static void
@@ -648,19 +648,19 @@ static int hantro_set_fmt_cap(struct hantro_ctx *ctx,
static int
vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f)
{
- return hantro_set_fmt_out(fh_to_ctx(priv), &f->fmt.pix_mp, HANTRO_AUTO_POSTPROC);
+ return hantro_set_fmt_out(file_to_ctx(file), &f->fmt.pix_mp, HANTRO_AUTO_POSTPROC);
}
static int
vidioc_s_fmt_cap_mplane(struct file *file, void *priv, struct v4l2_format *f)
{
- return hantro_set_fmt_cap(fh_to_ctx(priv), &f->fmt.pix_mp);
+ return hantro_set_fmt_cap(file_to_ctx(file), &f->fmt.pix_mp);
}
static int vidioc_g_selection(struct file *file, void *priv,
struct v4l2_selection *sel)
{
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
/* Crop only supported on source. */
if (!ctx->is_encoder ||
@@ -691,7 +691,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
static int vidioc_s_selection(struct file *file, void *priv,
struct v4l2_selection *sel)
{
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
struct v4l2_rect *rect = &sel->r;
struct vb2_queue *vq;
@@ -738,7 +738,7 @@ static const struct v4l2_event hantro_eos_event = {
static int vidioc_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *ec)
{
- struct hantro_ctx *ctx = fh_to_ctx(priv);
+ struct hantro_ctx *ctx = file_to_ctx(file);
int ret;
ret = v4l2_m2m_ioctl_try_encoder_cmd(file, priv, ec);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 55/65] media: omap3isp: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (53 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 56/65] media: cx18: " Jacopo Mondi
` (9 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it remove the only left user of to_isp_video_fh() and remove
the macro completely.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/platform/ti/omap3isp/ispvideo.c | 22 +++++++++++-----------
drivers/media/platform/ti/omap3isp/ispvideo.h | 2 --
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.c b/drivers/media/platform/ti/omap3isp/ispvideo.c
index 2c0008444b7e2b532c9af061760e7399cdf3e45d..0e7f0bf2b3463b7ef6678f7bd836a952e0b707a7 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.c
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.c
@@ -657,7 +657,7 @@ isp_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
static int
isp_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
if (format->type != video->type)
@@ -673,7 +673,7 @@ isp_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
static int
isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
struct v4l2_mbus_framefmt fmt;
@@ -858,7 +858,7 @@ isp_video_set_selection(struct file *file, void *fh, struct v4l2_selection *sel)
static int
isp_video_get_param(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
@@ -876,7 +876,7 @@ isp_video_get_param(struct file *file, void *fh, struct v4l2_streamparm *a)
static int
isp_video_set_param(struct file *file, void *fh, struct v4l2_streamparm *a)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
@@ -894,7 +894,7 @@ isp_video_set_param(struct file *file, void *fh, struct v4l2_streamparm *a)
static int
isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
int ret;
@@ -908,7 +908,7 @@ isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb)
static int
isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
int ret;
@@ -922,7 +922,7 @@ isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
static int
isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
int ret;
@@ -936,7 +936,7 @@ isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
static int
isp_video_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
int ret;
@@ -1074,7 +1074,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
static int
isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
enum isp_pipeline_state state;
struct isp_pipeline *pipe;
@@ -1180,7 +1180,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
static int
isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
{
- struct isp_video_fh *vfh = to_isp_video_fh(fh);
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
enum isp_pipeline_state state;
@@ -1348,7 +1348,7 @@ static int isp_video_release(struct file *file)
{
struct isp_video *video = video_drvdata(file);
struct v4l2_fh *vfh = file_to_v4l2_fh(file);
- struct isp_video_fh *handle = to_isp_video_fh(vfh);
+ struct isp_video_fh *handle = file_to_isp_video_fh(file);
/* Disable streaming and free the buffers queue resources. */
isp_video_streamoff(file, vfh, video->type);
diff --git a/drivers/media/platform/ti/omap3isp/ispvideo.h b/drivers/media/platform/ti/omap3isp/ispvideo.h
index 355812770e18ef5353ac68e65426a3180a6d91ab..537da59cff6258cb66ff4eac6ad2739c3f9465c4 100644
--- a/drivers/media/platform/ti/omap3isp/ispvideo.h
+++ b/drivers/media/platform/ti/omap3isp/ispvideo.h
@@ -194,8 +194,6 @@ struct isp_video_fh {
struct v4l2_fract timeperframe;
};
-#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
-
static inline struct isp_video_fh *file_to_isp_video_fh(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct isp_video_fh, vfh);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 56/65] media: cx18: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (54 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 55/65] media: omap3isp: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 57/65] media: ivtv: " Jacopo Mondi
` (8 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/cx18/cx18-ioctl.c | 64 ++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index 9a1512b1ccaafd991c0422616a0d7b3e6c7c49cc..bf16d36448f888d9326b5f4a8f9c8f0e13d0c3a1 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -52,7 +52,7 @@ static const struct v4l2_fmtdesc cx18_formats_mpeg[] = {
static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
struct cx18_stream *s = &cx->streams[id->type];
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
@@ -76,7 +76,7 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
int w = pixfmt->width;
@@ -121,7 +121,7 @@ static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
@@ -261,7 +261,7 @@ u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
vbifmt->sampling_rate = 27000000;
@@ -280,7 +280,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
/* sane, V4L2 spec compliant, defaults */
@@ -311,7 +311,7 @@ static int cx18_try_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
@@ -330,7 +330,7 @@ static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
int ret;
@@ -360,7 +360,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
int ret;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
@@ -392,7 +392,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
static int cx18_g_register(struct file *file, void *fh,
struct v4l2_dbg_register *reg)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (reg->reg & 0x3)
return -EINVAL;
@@ -406,7 +406,7 @@ static int cx18_g_register(struct file *file, void *fh,
static int cx18_s_register(struct file *file, void *fh,
const struct v4l2_dbg_register *reg)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (reg->reg & 0x3)
return -EINVAL;
@@ -420,7 +420,7 @@ static int cx18_s_register(struct file *file, void *fh,
static int cx18_querycap(struct file *file, void *fh,
struct v4l2_capability *vcap)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
@@ -431,14 +431,14 @@ static int cx18_querycap(struct file *file, void *fh,
static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
return cx18_get_audio_input(cx, vin->index, vin);
}
static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
vin->index = cx->audio_input;
return cx18_get_audio_input(cx, vin->index, vin);
@@ -446,7 +446,7 @@ static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
static int cx18_s_audio(struct file *file, void *fh, const struct v4l2_audio *vout)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (vout->index >= cx->nof_audio_inputs)
return -EINVAL;
@@ -457,7 +457,7 @@ static int cx18_s_audio(struct file *file, void *fh, const struct v4l2_audio *vo
static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
/* set it to defaults from our table */
return cx18_get_input(cx, vin->index, vin);
@@ -466,7 +466,7 @@ static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
static int cx18_g_pixelaspect(struct file *file, void *fh,
int type, struct v4l2_fract *f)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -479,7 +479,7 @@ static int cx18_g_pixelaspect(struct file *file, void *fh,
static int cx18_g_selection(struct file *file, void *fh,
struct v4l2_selection *sel)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
@@ -499,7 +499,7 @@ static int cx18_g_selection(struct file *file, void *fh,
static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_fmtdesc *fmt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
if (fmt->index >= ARRAY_SIZE(cx18_formats_yuv))
@@ -515,7 +515,7 @@ static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
*i = cx->active_input;
return 0;
@@ -523,7 +523,7 @@ static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
int cx18_s_input(struct file *file, void *fh, unsigned int inp)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
v4l2_std_id std = V4L2_STD_ALL;
const struct cx18_card_video_input *card_input =
@@ -561,7 +561,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
static int cx18_g_frequency(struct file *file, void *fh,
struct v4l2_frequency *vf)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (vf->tuner != 0)
return -EINVAL;
@@ -572,7 +572,7 @@ static int cx18_g_frequency(struct file *file, void *fh,
int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
if (vf->tuner != 0)
@@ -587,7 +587,7 @@ int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *v
static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
*std = cx->std;
return 0;
@@ -595,7 +595,7 @@ static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
if ((std & V4L2_STD_ALL) == 0)
@@ -644,7 +644,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
if (vt->index != 0)
@@ -656,7 +656,7 @@ static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt
static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
if (vt->index != 0)
return -EINVAL;
@@ -673,7 +673,7 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
static int cx18_g_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_sliced_vbi_cap *cap)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
int f, l;
@@ -794,7 +794,7 @@ static int cx18_process_idx_data(struct cx18_stream *s, struct cx18_mdl *mdl,
static int cx18_g_enc_index(struct file *file, void *fh,
struct v4l2_enc_idx *idx)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
s32 tmp;
struct cx18_mdl *mdl;
@@ -841,7 +841,7 @@ static int cx18_g_enc_index(struct file *file, void *fh,
static int cx18_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *enc)
{
- struct cx18_open_id *id = fh2id(fh);
+ struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
u32 h;
@@ -900,7 +900,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
static int cx18_try_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *enc)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
switch (enc->cmd) {
case V4L2_ENC_CMD_START:
@@ -932,7 +932,7 @@ static int cx18_try_encoder_cmd(struct file *file, void *fh,
static int cx18_log_status(struct file *file, void *fh)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
struct v4l2_input vidin;
struct v4l2_audio audin;
int i;
@@ -976,7 +976,7 @@ static int cx18_log_status(struct file *file, void *fh)
static long cx18_default(struct file *file, void *fh, bool valid_prio,
unsigned int cmd, void *arg)
{
- struct cx18 *cx = fh2id(fh)->cx;
+ struct cx18 *cx = file2id(file)->cx;
switch (cmd) {
case VIDIOC_INT_RESET: {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 57/65] media: ivtv: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (55 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 56/65] media: cx18: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 58/65] media: zoran: Remove access to __fh Jacopo Mondi
` (7 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
While at it remove the only left user of fh2id() and remove
the macro completely.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/ivtv/ivtv-driver.h | 5 --
drivers/media/pci/ivtv/ivtv-fileops.c | 2 +-
drivers/media/pci/ivtv/ivtv-ioctl.c | 124 +++++++++++++++++-----------------
3 files changed, 63 insertions(+), 68 deletions(-)
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index 38c4ceb04cf834906ed877b57c20fcbdb390da13..69c37f450c21f91abb4e4f73823097bd61d5abc2 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -384,11 +384,6 @@ struct ivtv_open_id {
struct ivtv *itv;
};
-static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
-{
- return container_of(fh, struct ivtv_open_id, fh);
-}
-
static inline struct ivtv_open_id *file2id(struct file *filp)
{
return container_of(file_to_v4l2_fh(filp), struct ivtv_open_id, fh);
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
index 0040a5e7f654149eb429400dd1db7197a9a3b54e..814fe7989cdc11ed225f03a9168be50c6b9ba595 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -878,7 +878,7 @@ static void ivtv_stop_decoding(struct ivtv_open_id *id, int flags, u64 pts)
int ivtv_v4l2_close(struct file *filp)
{
struct v4l2_fh *fh = file_to_v4l2_fh(filp);
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index d888435b71fb6f6873d9d884248a67364576bf33..8077a71d4850ec773caa20c3fca08f92f3117d69 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -308,7 +308,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
static int ivtv_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
vbifmt->reserved[0] = 0;
@@ -330,7 +330,7 @@ static int ivtv_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_fo
static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
@@ -353,7 +353,7 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
vbifmt->sampling_rate = 27000000;
@@ -372,7 +372,7 @@ static int ivtv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
vbifmt->reserved[0] = 0;
@@ -394,7 +394,7 @@ static int ivtv_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
@@ -434,8 +434,8 @@ static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_g_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
struct v4l2_window *winfmt = &fmt->fmt.win;
if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
@@ -461,7 +461,7 @@ static int ivtv_try_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_
static int ivtv_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
int w = fmt->fmt.pix.width;
int h = fmt->fmt.pix.height;
@@ -490,7 +490,7 @@ static int ivtv_try_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format
static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
if (id->type == IVTV_DEC_STREAM_TYPE_VBI)
@@ -510,7 +510,7 @@ static int ivtv_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_
static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
s32 w = fmt->fmt.pix.width;
s32 h = fmt->fmt.pix.height;
int field = fmt->fmt.pix.field;
@@ -544,8 +544,8 @@ static int ivtv_try_fmt_vid_out(struct file *file, void *fh, struct v4l2_format
static int ivtv_try_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
u32 chromakey = fmt->fmt.win.chromakey;
u8 global_alpha = fmt->fmt.win.global_alpha;
@@ -566,7 +566,7 @@ static int ivtv_s_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_fo
static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
@@ -597,7 +597,7 @@ static int ivtv_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (!ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0)
return -EBUSY;
@@ -610,7 +610,7 @@ static int ivtv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt)
{
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
int ret = ivtv_try_fmt_sliced_vbi_cap(file, fh, fmt);
@@ -628,7 +628,7 @@ static int ivtv_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_fo
static int ivtv_s_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct yuv_playback_info *yi = &itv->yuv_info;
int ret = ivtv_try_fmt_vid_out(file, fh, fmt);
@@ -673,7 +673,7 @@ static int ivtv_s_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f
static int ivtv_s_fmt_vid_out_overlay(struct file *file, void *fh, struct v4l2_format *fmt)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
int ret = ivtv_try_fmt_vid_out_overlay(file, fh, fmt);
if (ret == 0) {
@@ -710,7 +710,7 @@ static int ivtv_itvc(struct ivtv *itv, bool get, u64 reg, u64 *val)
static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
reg->size = 4;
return ivtv_itvc(itv, true, reg->reg, ®->val);
@@ -718,7 +718,7 @@ static int ivtv_g_register(struct file *file, void *fh, struct v4l2_dbg_register
static int ivtv_s_register(struct file *file, void *fh, const struct v4l2_dbg_register *reg)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
u64 val = reg->val;
return ivtv_itvc(itv, false, reg->reg, &val);
@@ -727,7 +727,7 @@ static int ivtv_s_register(struct file *file, void *fh, const struct v4l2_dbg_re
static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
{
- struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
@@ -738,14 +738,14 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc
static int ivtv_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
return ivtv_get_audio_input(itv, vin->index, vin);
}
static int ivtv_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
vin->index = itv->audio_input;
return ivtv_get_audio_input(itv, vin->index, vin);
@@ -753,7 +753,7 @@ static int ivtv_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
static int ivtv_s_audio(struct file *file, void *fh, const struct v4l2_audio *vout)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (vout->index >= itv->nof_audio_inputs)
return -EINVAL;
@@ -766,7 +766,7 @@ static int ivtv_s_audio(struct file *file, void *fh, const struct v4l2_audio *vo
static int ivtv_enumaudout(struct file *file, void *fh, struct v4l2_audioout *vin)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
/* set it to defaults from our table */
return ivtv_get_audio_output(itv, vin->index, vin);
@@ -774,7 +774,7 @@ static int ivtv_enumaudout(struct file *file, void *fh, struct v4l2_audioout *vi
static int ivtv_g_audout(struct file *file, void *fh, struct v4l2_audioout *vin)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
vin->index = 0;
return ivtv_get_audio_output(itv, vin->index, vin);
@@ -782,7 +782,7 @@ static int ivtv_g_audout(struct file *file, void *fh, struct v4l2_audioout *vin)
static int ivtv_s_audout(struct file *file, void *fh, const struct v4l2_audioout *vout)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (itv->card->video_outputs == NULL || vout->index != 0)
return -EINVAL;
@@ -791,7 +791,7 @@ static int ivtv_s_audout(struct file *file, void *fh, const struct v4l2_audioout
static int ivtv_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
/* set it to defaults from our table */
return ivtv_get_input(itv, vin->index, vin);
@@ -799,7 +799,7 @@ static int ivtv_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
static int ivtv_enum_output(struct file *file, void *fh, struct v4l2_output *vout)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
return ivtv_get_output(itv, vout->index, vout);
}
@@ -807,7 +807,7 @@ static int ivtv_enum_output(struct file *file, void *fh, struct v4l2_output *vou
static int ivtv_g_pixelaspect(struct file *file, void *fh,
int type, struct v4l2_fract *f)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
@@ -825,7 +825,7 @@ static int ivtv_g_pixelaspect(struct file *file, void *fh,
static int ivtv_s_selection(struct file *file, void *fh,
struct v4l2_selection *sel)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct yuv_playback_info *yi = &itv->yuv_info;
struct v4l2_rect r = { 0, 0, 720, 0 };
@@ -868,7 +868,7 @@ static int ivtv_s_selection(struct file *file, void *fh,
static int ivtv_g_selection(struct file *file, void *fh,
struct v4l2_selection *sel)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
struct yuv_playback_info *yi = &itv->yuv_info;
struct v4l2_rect r = { 0, 0, 720, 0 };
@@ -924,8 +924,8 @@ static int ivtv_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdes
.description = "MPEG",
.pixelformat = V4L2_PIX_FMT_MPEG,
};
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
if (fmt->index)
return -EINVAL;
@@ -951,8 +951,8 @@ static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdes
.description = "MPEG",
.pixelformat = V4L2_PIX_FMT_MPEG,
};
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
if (fmt->index)
return -EINVAL;
@@ -967,7 +967,7 @@ static int ivtv_enum_fmt_vid_out(struct file *file, void *fh, struct v4l2_fmtdes
static int ivtv_g_input(struct file *file, void *fh, unsigned int *i)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
*i = itv->active_input;
@@ -976,7 +976,7 @@ static int ivtv_g_input(struct file *file, void *fh, unsigned int *i)
int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
v4l2_std_id std;
int i;
@@ -1019,7 +1019,7 @@ int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
static int ivtv_g_output(struct file *file, void *fh, unsigned int *i)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
return -EINVAL;
@@ -1031,7 +1031,7 @@ static int ivtv_g_output(struct file *file, void *fh, unsigned int *i)
static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (outp >= itv->card->nof_outputs)
return -EINVAL;
@@ -1053,8 +1053,8 @@ static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
{
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
if (s->vdev.vfl_dir)
return -ENOTTY;
@@ -1067,8 +1067,8 @@ static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *
int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
{
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
if (s->vdev.vfl_dir)
return -ENOTTY;
@@ -1084,7 +1084,7 @@ int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *v
static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
*std = itv->std;
return 0;
@@ -1157,7 +1157,7 @@ void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id std)
static int ivtv_s_std(struct file *file, void *fh, v4l2_std_id std)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if ((std & V4L2_STD_ALL) == 0)
return -EINVAL;
@@ -1185,7 +1185,7 @@ static int ivtv_s_std(struct file *file, void *fh, v4l2_std_id std)
static int ivtv_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
if (vt->index != 0)
@@ -1198,7 +1198,7 @@ static int ivtv_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt
static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (vt->index != 0)
return -EINVAL;
@@ -1214,7 +1214,7 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
int f, l;
@@ -1249,7 +1249,7 @@ static int ivtv_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced
static int ivtv_g_enc_index(struct file *file, void *fh, struct v4l2_enc_idx *idx)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
struct v4l2_enc_idx_entry *e = idx->entry;
int entries;
int i;
@@ -1275,7 +1275,7 @@ static int ivtv_g_enc_index(struct file *file, void *fh, struct v4l2_enc_idx *id
static int ivtv_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
@@ -1327,7 +1327,7 @@ static int ivtv_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd
static int ivtv_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
switch (enc->cmd) {
case V4L2_ENC_CMD_START:
@@ -1357,8 +1357,8 @@ static int ivtv_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder
static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
{
- struct ivtv *itv = fh2id(fh)->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv *itv = file2id(file)->itv;
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
u32 data[CX2341X_MBOX_MAX_DATA];
struct yuv_playback_info *yi = &itv->yuv_info;
@@ -1444,9 +1444,9 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
static int ivtv_s_fbuf(struct file *file, void *fh, const struct v4l2_framebuffer *fb)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
struct yuv_playback_info *yi = &itv->yuv_info;
if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
@@ -1465,9 +1465,9 @@ static int ivtv_s_fbuf(struct file *file, void *fh, const struct v4l2_framebuffe
static int ivtv_overlay(struct file *file, void *fh, unsigned int on)
{
- struct ivtv_open_id *id = fh2id(fh);
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
- struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
+ struct ivtv_stream *s = &itv->streams[file2id(file)->type];
if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY))
return -ENOTTY;
@@ -1492,7 +1492,7 @@ static int ivtv_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subs
static int ivtv_log_status(struct file *file, void *fh)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
u32 data[CX2341X_MBOX_MAX_DATA];
int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT;
@@ -1584,7 +1584,7 @@ static int ivtv_log_status(struct file *file, void *fh)
static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
{
- struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd);
@@ -1593,7 +1593,7 @@ static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd
static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
{
- struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
+ struct ivtv_open_id *id = file2id(file);
struct ivtv *itv = id->itv;
IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd);
@@ -1602,7 +1602,7 @@ static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder
static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
{
- struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(filp));
+ struct ivtv_open_id *id = file2id(filp);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
@@ -1645,7 +1645,7 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
static long ivtv_default(struct file *file, void *fh, bool valid_prio,
unsigned int cmd, void *arg)
{
- struct ivtv *itv = fh2id(fh)->itv;
+ struct ivtv *itv = file2id(file)->itv;
if (!valid_prio) {
switch (cmd) {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 58/65] media: zoran: Remove access to __fh
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (56 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 57/65] media: ivtv: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-07 6:58 ` Hans Verkuil
2025-08-02 9:23 ` [PATCH 59/65] media: usb: hdpvr: Access v4l2_fh from file Jacopo Mondi
` (6 subsequent siblings)
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The __fh parameter is assigned to an unsued variable. Remove it
and remove the unused struct zoran_fh type.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/zoran/zoran.h | 6 ------
drivers/media/pci/zoran/zoran_driver.c | 3 +--
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/media/pci/zoran/zoran.h b/drivers/media/pci/zoran/zoran.h
index 1cd990468d3de9db8b14b72483972041c57bfee2..d05e222b392156bf1b3b4c83c6591db642c3c377 100644
--- a/drivers/media/pci/zoran/zoran.h
+++ b/drivers/media/pci/zoran/zoran.h
@@ -154,12 +154,6 @@ struct zoran_jpg_settings {
struct zoran;
-/* zoran_fh contains per-open() settings */
-struct zoran_fh {
- struct v4l2_fh fh;
- struct zoran *zr;
-};
-
struct card_info {
enum card_type type;
char name[32];
diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
index f42f596d3e6295e31e3b33cd83c5f7243911bd30..ec7fc1da4cc02f5a344cb49bb9a783c41c758195 100644
--- a/drivers/media/pci/zoran/zoran_driver.c
+++ b/drivers/media/pci/zoran/zoran_driver.c
@@ -511,12 +511,11 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
struct v4l2_format *fmt)
{
struct zoran *zr = video_drvdata(file);
- struct zoran_fh *fh = __fh;
int i;
int res = 0;
if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
- return zoran_s_fmt_vid_out(file, fh, fmt);
+ return zoran_s_fmt_vid_out(file, __fh, fmt);
for (i = 0; i < NUM_FORMATS; i++)
if (fmt->fmt.pix.pixelformat == zoran_formats[i].fourcc)
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 59/65] media: usb: hdpvr: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (57 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 58/65] media: zoran: Remove access to __fh Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 60/65] media: usb: uvc: " Jacopo Mondi
` (5 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/usb/hdpvr/hdpvr-video.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 6c6e467f85549e86598e73d29352a84de7df2f4d..8a5c2c5227ebe6f64bf44fff50dd4918f4f5394e 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -52,6 +52,11 @@ struct hdpvr_fh {
bool legacy_mode;
};
+static inline struct hdpvr_fh *file_to_hdpvr_fh(struct file *file)
+{
+ return container_of(file_to_v4l2_fh(file), struct hdpvr_fh, fh);
+}
+
static uint list_size(struct list_head *list)
{
struct list_head *tmp;
@@ -589,7 +594,7 @@ static int vidioc_s_std(struct file *file, void *_fh,
v4l2_std_id std)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
u8 std_type = 1;
if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT)
@@ -609,7 +614,8 @@ static int vidioc_g_std(struct file *file, void *_fh,
v4l2_std_id *std)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
+
if (!fh->legacy_mode && dev->options.video_input == HDPVR_COMPONENT)
return -ENODATA;
@@ -620,8 +626,8 @@ static int vidioc_g_std(struct file *file, void *_fh,
static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a)
{
struct hdpvr_device *dev = video_drvdata(file);
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
struct hdpvr_video_info vid_info;
- struct hdpvr_fh *fh = _fh;
int ret;
*a = V4L2_STD_UNKNOWN;
@@ -640,7 +646,7 @@ static int vidioc_s_dv_timings(struct file *file, void *_fh,
struct v4l2_dv_timings *timings)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
int i;
fh->legacy_mode = false;
@@ -663,7 +669,7 @@ static int vidioc_g_dv_timings(struct file *file, void *_fh,
struct v4l2_dv_timings *timings)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
fh->legacy_mode = false;
if (dev->options.video_input)
@@ -676,7 +682,7 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh,
struct v4l2_dv_timings *timings)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
struct hdpvr_video_info vid_info;
bool interlaced;
int ret = 0;
@@ -718,7 +724,7 @@ static int vidioc_enum_dv_timings(struct file *file, void *_fh,
struct v4l2_enum_dv_timings *timings)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
fh->legacy_mode = false;
memset(timings->reserved, 0, sizeof(timings->reserved));
@@ -734,7 +740,7 @@ static int vidioc_dv_timings_cap(struct file *file, void *_fh,
struct v4l2_dv_timings_cap *cap)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
fh->legacy_mode = false;
if (dev->options.video_input)
@@ -994,7 +1000,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh,
struct v4l2_format *f)
{
struct hdpvr_device *dev = video_drvdata(file);
- struct hdpvr_fh *fh = _fh;
+ struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
int ret;
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 60/65] media: usb: uvc: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (58 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 59/65] media: usb: hdpvr: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 61/65] media: staging: imx: " Jacopo Mondi
` (4 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/usb/uvc/uvc_v4l2.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 09677ed639ae9252a57ce09cdbcfd567ad7aabc2..10196d62f287502b0dd472ac68ec6914ca4eb06b 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -391,7 +391,7 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
static int uvc_ioctl_g_fmt(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
const struct uvc_format *format;
const struct uvc_frame *frame;
@@ -427,7 +427,7 @@ static int uvc_ioctl_g_fmt(struct file *file, void *fh,
static int uvc_ioctl_s_fmt(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
struct uvc_streaming_control probe;
const struct uvc_format *format;
@@ -460,7 +460,7 @@ static int uvc_ioctl_g_parm(struct file *file, void *fh,
struct v4l2_streamparm *parm)
{
u32 numerator, denominator;
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
if (parm->type != stream->type)
@@ -496,7 +496,7 @@ static int uvc_ioctl_g_parm(struct file *file, void *fh,
static int uvc_ioctl_s_parm(struct file *file, void *fh,
struct v4l2_streamparm *parm)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
struct uvc_streaming_control probe;
struct v4l2_fract timeperframe;
@@ -641,7 +641,7 @@ static int uvc_ioctl_querycap(struct file *file, void *fh,
static int uvc_ioctl_enum_fmt(struct file *file, void *fh,
struct v4l2_fmtdesc *fmt)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
enum v4l2_buf_type type = fmt->type;
const struct uvc_format *format;
@@ -665,7 +665,7 @@ static int uvc_ioctl_enum_fmt(struct file *file, void *fh,
static int uvc_ioctl_try_fmt(struct file *file, void *fh,
struct v4l2_format *fmt)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
struct uvc_streaming_control probe;
@@ -675,7 +675,7 @@ static int uvc_ioctl_try_fmt(struct file *file, void *fh,
static int uvc_ioctl_enum_input(struct file *file, void *fh,
struct v4l2_input *input)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
const struct uvc_entity *selector = chain->selector;
struct uvc_entity *iterm = NULL;
@@ -717,7 +717,7 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
u8 *buf;
int ret;
@@ -745,7 +745,7 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
struct uvc_video_chain *chain = handle->chain;
u8 *buf;
@@ -780,7 +780,7 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
struct v4l2_query_ext_ctrl *qec)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
return uvc_query_v4l2_ctrl(chain, qec);
@@ -808,7 +808,7 @@ static int uvc_ctrl_check_access(struct uvc_video_chain *chain,
static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
struct v4l2_ext_controls *ctrls)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
struct v4l2_ext_control *ctrl = ctrls->controls;
unsigned int i;
@@ -892,7 +892,7 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh,
struct v4l2_ext_controls *ctrls)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, VIDIOC_S_EXT_CTRLS);
}
@@ -900,7 +900,7 @@ static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh,
static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
struct v4l2_ext_controls *ctrls)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, VIDIOC_TRY_EXT_CTRLS);
}
@@ -908,7 +908,7 @@ static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
static int uvc_ioctl_querymenu(struct file *file, void *fh,
struct v4l2_querymenu *qm)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
return uvc_query_v4l2_menu(chain, qm);
@@ -917,7 +917,7 @@ static int uvc_ioctl_querymenu(struct file *file, void *fh,
static int uvc_ioctl_g_selection(struct file *file, void *fh,
struct v4l2_selection *sel)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
if (sel->type != stream->type)
@@ -951,7 +951,7 @@ static int uvc_ioctl_g_selection(struct file *file, void *fh,
static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *fsize)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
const struct uvc_format *format = NULL;
const struct uvc_frame *frame = NULL;
@@ -991,7 +991,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *fival)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_streaming *stream = handle->stream;
const struct uvc_format *format = NULL;
const struct uvc_frame *frame = NULL;
@@ -1063,7 +1063,7 @@ static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh,
static long uvc_ioctl_default(struct file *file, void *fh, bool valid_prio,
unsigned int cmd, void *arg)
{
- struct uvc_fh *handle = fh;
+ struct uvc_fh *handle = to_uvc_fh(file);
struct uvc_video_chain *chain = handle->chain;
switch (cmd) {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 61/65] media: staging: imx: Access v4l2_fh from file
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (59 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 60/65] media: usb: uvc: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 62/65] media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check Jacopo Mondi
` (3 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
The v4l2_fh associated with an open file handle is now guaranteed
to be available in file->private_data, initialised by v4l2_fh_add().
Access the v4l2_fh, and from there the driver-specific structure,
from the file * in all ioctl handlers.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/staging/media/imx/imx-media-csc-scaler.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index c4ee0eebb3730e709c3d4a95935d0047a645e411..1869c5792ecb46682491ecbf33674c6044915261 100644
--- a/drivers/staging/media/imx/imx-media-csc-scaler.c
+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c
@@ -23,8 +23,6 @@
#include "imx-media.h"
-#define fh_to_ctx(__fh) container_of(__fh, struct ipu_csc_scaler_ctx, fh)
-
#define IMX_CSC_SCALER_NAME "imx-csc-scaler"
enum {
@@ -184,7 +182,7 @@ static int ipu_csc_scaler_enum_fmt(struct file *file, void *fh,
static int ipu_csc_scaler_g_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(priv);
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
struct ipu_csc_scaler_q_data *q_data;
q_data = get_q_data(ctx, f->type);
@@ -197,7 +195,7 @@ static int ipu_csc_scaler_g_fmt(struct file *file, void *priv,
static int ipu_csc_scaler_try_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(priv);
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
struct ipu_csc_scaler_q_data *q_data = get_q_data(ctx, f->type);
struct ipu_image test_in, test_out;
enum v4l2_field field;
@@ -245,8 +243,8 @@ static int ipu_csc_scaler_try_fmt(struct file *file, void *priv,
static int ipu_csc_scaler_s_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
struct ipu_csc_scaler_q_data *q_data;
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(priv);
struct vb2_queue *vq;
int ret;
@@ -301,7 +299,7 @@ static int ipu_csc_scaler_s_fmt(struct file *file, void *priv,
static int ipu_csc_scaler_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(priv);
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
struct ipu_csc_scaler_q_data *q_data;
switch (s->target) {
@@ -339,7 +337,7 @@ static int ipu_csc_scaler_g_selection(struct file *file, void *priv,
static int ipu_csc_scaler_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(priv);
+ struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
struct ipu_csc_scaler_q_data *q_data;
switch (s->target) {
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 62/65] media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (60 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 61/65] media: staging: imx: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
` (2 subsequent siblings)
64 siblings, 0 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The v4l2_ctrl_log_status() function retrieves the v4l2_fh from the file
with file_to_v4l2_fh() before checking the V4L2_FL_USES_V4L2_FH to see
if the device makes use of v4l2_fh. While this doesn't cause any
practical issue given the current implementation of file_to_v4l2_fh(),
it is cleaner to retrieve the v4l2_fh after checking the flag. This
could prevent future issues if the implementation of file_to_v4l2_fh()
changes.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/v4l2-core/v4l2-ctrls-api.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-ctrls-api.c b/drivers/media/v4l2-core/v4l2-ctrls-api.c
index d46b2c8f3d23596293210125b148c3da99c52cac..b0bba8eec143968b127368ee7de8bca76b427dbd 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls-api.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls-api.c
@@ -1253,11 +1253,14 @@ EXPORT_SYMBOL(v4l2_querymenu);
int v4l2_ctrl_log_status(struct file *file, void *fh)
{
struct video_device *vfd = video_devdata(file);
- struct v4l2_fh *vfh = file_to_v4l2_fh(file);
- if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev)
+ if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) && vfd->v4l2_dev) {
+ struct v4l2_fh *vfh = file_to_v4l2_fh(file);
+
v4l2_ctrl_handler_log_status(vfh->ctrl_handler,
vfd->v4l2_dev->name);
+ }
+
return 0;
}
EXPORT_SYMBOL(v4l2_ctrl_log_status);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (61 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 62/65] media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-08 1:01 ` Cao, Bingbu
2025-08-08 7:22 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 64/65] media: staging: ipu7: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers Jacopo Mondi
64 siblings, 2 replies; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
to be set manually by drivers. Drop it from the ipu6-isys driver.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
index 24a2ef93474cc400f64eb1d50bc760ee66124d1b..f3f3bc0615e5dc698be5c479dfed8ef2eb49cbfb 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
@@ -1306,7 +1306,6 @@ int ipu6_isys_video_init(struct ipu6_isys_video *av)
__ipu6_isys_vidioc_try_fmt_meta_cap(av, &format_meta);
av->meta_fmt = format_meta.fmt.meta;
- set_bit(V4L2_FL_USES_V4L2_FH, &av->vdev.flags);
video_set_drvdata(&av->vdev, av);
ret = video_register_device(&av->vdev, VFL_TYPE_VIDEO, -1);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 64/65] media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (62 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-07 9:07 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers Jacopo Mondi
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
to be set manually by drivers. Drop it from the ipu7-isys driver.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/staging/media/ipu7/ipu7-isys-video.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/staging/media/ipu7/ipu7-isys-video.c b/drivers/staging/media/ipu7/ipu7-isys-video.c
index 8756da3a8fb0bfaf88da199b4608c7850888e6a2..6b31c766bc5835f8b6e28ad75efead918934349b 100644
--- a/drivers/staging/media/ipu7/ipu7-isys-video.c
+++ b/drivers/staging/media/ipu7/ipu7-isys-video.c
@@ -1082,7 +1082,6 @@ int ipu7_isys_video_init(struct ipu7_isys_video *av)
__ipu_isys_vidioc_try_fmt_vid_cap(av, &format);
av->pix_fmt = format.fmt.pix;
- set_bit(V4L2_FL_USES_V4L2_FH, &av->vdev.flags);
video_set_drvdata(&av->vdev, av);
ret = video_register_device(&av->vdev, VFL_TYPE_VIDEO, -1);
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
` (63 preceding siblings ...)
2025-08-02 9:23 ` [PATCH 64/65] media: staging: ipu7: " Jacopo Mondi
@ 2025-08-02 9:23 ` Jacopo Mondi
2025-08-07 7:26 ` Hans Verkuil
64 siblings, 1 reply; 101+ messages in thread
From: Jacopo Mondi @ 2025-08-02 9:23 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Now that all drivers access the v4l2_fh from the file structure, there
is no need to pass it as an explicit argument to ioctl handlers. Set the
argument to NULL in the w__video_do_ioctl(), and drop the name of the
void *fh argument in the ioctl handler declarations to indicate it is
not used.
The argument could be removed altogether with a mechanical change
(probably using coccinelle), but there are plans to pass a new argument
to the ioctl handlers in the near future. The tree-wide change to remove
the argument, only to add another one soon after, would be too much
churn.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
2 files changed, 120 insertions(+), 121 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
bool write_only = false;
struct v4l2_ioctl_info default_info;
const struct v4l2_ioctl_info *info;
- void *fh = file_to_v4l2_fh(file);
struct v4l2_fh *vfh = NULL;
int dev_debug = vfd->dev_debug;
long ret = -ENOTTY;
@@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
write_only = _IOC_DIR(cmd) == _IOC_WRITE;
if (info != &default_info) {
- ret = info->func(ops, file, fh, arg);
+ ret = info->func(ops, file, NULL, arg);
} else if (!ops->vidioc_default) {
ret = -ENOTTY;
} else {
- ret = ops->vidioc_default(file, fh,
+ ret = ops->vidioc_default(file, NULL,
vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
cmd, arg);
}
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
/* ioctl callbacks */
/* VIDIOC_QUERYCAP handler */
- int (*vidioc_querycap)(struct file *file, void *fh,
+ int (*vidioc_querycap)(struct file *file, void *,
struct v4l2_capability *cap);
/* VIDIOC_ENUM_FMT handlers */
- int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
struct v4l2_fmtdesc *f);
- int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
+ int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
struct v4l2_fmtdesc *f);
/* VIDIOC_G_FMT handlers */
- int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
+ int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
struct v4l2_format *f);
/* VIDIOC_S_FMT handlers */
- int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
+ int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
struct v4l2_format *f);
/* VIDIOC_TRY_FMT handlers */
- int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
struct v4l2_format *f);
- int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
+ int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
struct v4l2_format *f);
/* Buffer handlers */
- int (*vidioc_reqbufs)(struct file *file, void *fh,
+ int (*vidioc_reqbufs)(struct file *file, void *,
struct v4l2_requestbuffers *b);
- int (*vidioc_querybuf)(struct file *file, void *fh,
+ int (*vidioc_querybuf)(struct file *file, void *,
struct v4l2_buffer *b);
- int (*vidioc_qbuf)(struct file *file, void *fh,
+ int (*vidioc_qbuf)(struct file *file, void *,
struct v4l2_buffer *b);
- int (*vidioc_expbuf)(struct file *file, void *fh,
+ int (*vidioc_expbuf)(struct file *file, void *,
struct v4l2_exportbuffer *e);
- int (*vidioc_dqbuf)(struct file *file, void *fh,
+ int (*vidioc_dqbuf)(struct file *file, void *,
struct v4l2_buffer *b);
- int (*vidioc_create_bufs)(struct file *file, void *fh,
+ int (*vidioc_create_bufs)(struct file *file, void *,
struct v4l2_create_buffers *b);
- int (*vidioc_prepare_buf)(struct file *file, void *fh,
+ int (*vidioc_prepare_buf)(struct file *file, void *,
struct v4l2_buffer *b);
- int (*vidioc_remove_bufs)(struct file *file, void *fh,
+ int (*vidioc_remove_bufs)(struct file *file, void *,
struct v4l2_remove_buffers *d);
- int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
- int (*vidioc_g_fbuf)(struct file *file, void *fh,
+ int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
+ int (*vidioc_g_fbuf)(struct file *file, void *,
struct v4l2_framebuffer *a);
- int (*vidioc_s_fbuf)(struct file *file, void *fh,
+ int (*vidioc_s_fbuf)(struct file *file, void *,
const struct v4l2_framebuffer *a);
/* Stream on/off */
- int (*vidioc_streamon)(struct file *file, void *fh,
+ int (*vidioc_streamon)(struct file *file, void *,
enum v4l2_buf_type i);
- int (*vidioc_streamoff)(struct file *file, void *fh,
+ int (*vidioc_streamoff)(struct file *file, void *,
enum v4l2_buf_type i);
/*
@@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
*
* Note: ENUMSTD is handled by videodev.c
*/
- int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
- int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
- int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
+ int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
+ int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
+ int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
/* Input handling */
- int (*vidioc_enum_input)(struct file *file, void *fh,
+ int (*vidioc_enum_input)(struct file *file, void *,
struct v4l2_input *inp);
- int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
- int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
+ int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
+ int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
/* Output handling */
- int (*vidioc_enum_output)(struct file *file, void *fh,
+ int (*vidioc_enum_output)(struct file *file, void *,
struct v4l2_output *a);
- int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
- int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
+ int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
+ int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
/* Control handling */
- int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
+ int (*vidioc_query_ext_ctrl)(struct file *file, void *,
struct v4l2_query_ext_ctrl *a);
- int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
+ int (*vidioc_g_ext_ctrls)(struct file *file, void *,
struct v4l2_ext_controls *a);
- int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
+ int (*vidioc_s_ext_ctrls)(struct file *file, void *,
struct v4l2_ext_controls *a);
- int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
+ int (*vidioc_try_ext_ctrls)(struct file *file, void *,
struct v4l2_ext_controls *a);
- int (*vidioc_querymenu)(struct file *file, void *fh,
+ int (*vidioc_querymenu)(struct file *file, void *,
struct v4l2_querymenu *a);
/* Audio ioctls */
- int (*vidioc_enumaudio)(struct file *file, void *fh,
+ int (*vidioc_enumaudio)(struct file *file, void *,
struct v4l2_audio *a);
- int (*vidioc_g_audio)(struct file *file, void *fh,
+ int (*vidioc_g_audio)(struct file *file, void *,
struct v4l2_audio *a);
- int (*vidioc_s_audio)(struct file *file, void *fh,
+ int (*vidioc_s_audio)(struct file *file, void *,
const struct v4l2_audio *a);
/* Audio out ioctls */
- int (*vidioc_enumaudout)(struct file *file, void *fh,
+ int (*vidioc_enumaudout)(struct file *file, void *,
struct v4l2_audioout *a);
- int (*vidioc_g_audout)(struct file *file, void *fh,
+ int (*vidioc_g_audout)(struct file *file, void *,
struct v4l2_audioout *a);
- int (*vidioc_s_audout)(struct file *file, void *fh,
+ int (*vidioc_s_audout)(struct file *file, void *,
const struct v4l2_audioout *a);
- int (*vidioc_g_modulator)(struct file *file, void *fh,
+ int (*vidioc_g_modulator)(struct file *file, void *,
struct v4l2_modulator *a);
- int (*vidioc_s_modulator)(struct file *file, void *fh,
+ int (*vidioc_s_modulator)(struct file *file, void *,
const struct v4l2_modulator *a);
/* Crop ioctls */
- int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
+ int (*vidioc_g_pixelaspect)(struct file *file, void *,
int buf_type, struct v4l2_fract *aspect);
- int (*vidioc_g_selection)(struct file *file, void *fh,
+ int (*vidioc_g_selection)(struct file *file, void *,
struct v4l2_selection *s);
- int (*vidioc_s_selection)(struct file *file, void *fh,
+ int (*vidioc_s_selection)(struct file *file, void *,
struct v4l2_selection *s);
/* Compression ioctls */
- int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
+ int (*vidioc_g_jpegcomp)(struct file *file, void *,
struct v4l2_jpegcompression *a);
- int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
+ int (*vidioc_s_jpegcomp)(struct file *file, void *,
const struct v4l2_jpegcompression *a);
- int (*vidioc_g_enc_index)(struct file *file, void *fh,
+ int (*vidioc_g_enc_index)(struct file *file, void *,
struct v4l2_enc_idx *a);
- int (*vidioc_encoder_cmd)(struct file *file, void *fh,
+ int (*vidioc_encoder_cmd)(struct file *file, void *,
struct v4l2_encoder_cmd *a);
- int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
+ int (*vidioc_try_encoder_cmd)(struct file *file, void *,
struct v4l2_encoder_cmd *a);
- int (*vidioc_decoder_cmd)(struct file *file, void *fh,
+ int (*vidioc_decoder_cmd)(struct file *file, void *,
struct v4l2_decoder_cmd *a);
- int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
+ int (*vidioc_try_decoder_cmd)(struct file *file, void *,
struct v4l2_decoder_cmd *a);
/* Stream type-dependent parameter ioctls */
- int (*vidioc_g_parm)(struct file *file, void *fh,
+ int (*vidioc_g_parm)(struct file *file, void *,
struct v4l2_streamparm *a);
- int (*vidioc_s_parm)(struct file *file, void *fh,
+ int (*vidioc_s_parm)(struct file *file, void *,
struct v4l2_streamparm *a);
/* Tuner ioctls */
- int (*vidioc_g_tuner)(struct file *file, void *fh,
+ int (*vidioc_g_tuner)(struct file *file, void *,
struct v4l2_tuner *a);
- int (*vidioc_s_tuner)(struct file *file, void *fh,
+ int (*vidioc_s_tuner)(struct file *file, void *,
const struct v4l2_tuner *a);
- int (*vidioc_g_frequency)(struct file *file, void *fh,
+ int (*vidioc_g_frequency)(struct file *file, void *,
struct v4l2_frequency *a);
- int (*vidioc_s_frequency)(struct file *file, void *fh,
+ int (*vidioc_s_frequency)(struct file *file, void *,
const struct v4l2_frequency *a);
- int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
+ int (*vidioc_enum_freq_bands)(struct file *file, void *,
struct v4l2_frequency_band *band);
/* Sliced VBI cap */
- int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
+ int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
struct v4l2_sliced_vbi_cap *a);
/* Log status ioctl */
- int (*vidioc_log_status)(struct file *file, void *fh);
+ int (*vidioc_log_status)(struct file *file, void *);
- int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
+ int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
const struct v4l2_hw_freq_seek *a);
/* Debugging ioctls */
#ifdef CONFIG_VIDEO_ADV_DEBUG
- int (*vidioc_g_register)(struct file *file, void *fh,
+ int (*vidioc_g_register)(struct file *file, void *,
struct v4l2_dbg_register *reg);
- int (*vidioc_s_register)(struct file *file, void *fh,
+ int (*vidioc_s_register)(struct file *file, void *,
const struct v4l2_dbg_register *reg);
- int (*vidioc_g_chip_info)(struct file *file, void *fh,
+ int (*vidioc_g_chip_info)(struct file *file, void *,
struct v4l2_dbg_chip_info *chip);
#endif
- int (*vidioc_enum_framesizes)(struct file *file, void *fh,
+ int (*vidioc_enum_framesizes)(struct file *file, void *,
struct v4l2_frmsizeenum *fsize);
- int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
+ int (*vidioc_enum_frameintervals)(struct file *file, void *,
struct v4l2_frmivalenum *fival);
/* DV Timings IOCTLs */
- int (*vidioc_s_dv_timings)(struct file *file, void *fh,
+ int (*vidioc_s_dv_timings)(struct file *file, void *,
struct v4l2_dv_timings *timings);
- int (*vidioc_g_dv_timings)(struct file *file, void *fh,
+ int (*vidioc_g_dv_timings)(struct file *file, void *,
struct v4l2_dv_timings *timings);
- int (*vidioc_query_dv_timings)(struct file *file, void *fh,
+ int (*vidioc_query_dv_timings)(struct file *file, void *,
struct v4l2_dv_timings *timings);
- int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
+ int (*vidioc_enum_dv_timings)(struct file *file, void *,
struct v4l2_enum_dv_timings *timings);
- int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
+ int (*vidioc_dv_timings_cap)(struct file *file, void *,
struct v4l2_dv_timings_cap *cap);
- int (*vidioc_g_edid)(struct file *file, void *fh,
+ int (*vidioc_g_edid)(struct file *file, void *,
struct v4l2_edid *edid);
- int (*vidioc_s_edid)(struct file *file, void *fh,
+ int (*vidioc_s_edid)(struct file *file, void *,
struct v4l2_edid *edid);
int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
@@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
const struct v4l2_event_subscription *sub);
/* For other private ioctls */
- long (*vidioc_default)(struct file *file, void *fh,
+ long (*vidioc_default)(struct file *file, void *,
bool valid_prio, unsigned int cmd, void *arg);
};
--
2.49.0
^ permalink raw reply related [flat|nested] 101+ messages in thread
* Re: [PATCH 17/65] media: rcar-vin: Do not set file->private_data
2025-08-02 9:22 ` [PATCH 17/65] media: rcar-vin: Do not set file->private_data Jacopo Mondi
@ 2025-08-02 13:26 ` Niklas Söderlund
0 siblings, 0 replies; 101+ messages in thread
From: Niklas Söderlund @ 2025-08-02 13:26 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Robert Foss, Todor Tomov,
Vladimir Zapolskiy, Corentin Labbe, Sakari Ailus, Bingbu Cao,
Tianshu Qiu, Stanislaw Gruszka, linux-media, linux-kernel,
linux-staging, linux-doc, linux-arm-kernel, linux-mediatek,
linux-tegra, imx, linux-renesas-soc, linux-arm-msm,
linux-samsung-soc, linux-sunxi, linux-usb, linux-amlogic,
linux-rockchip, linux-stm32, mjpeg-users
Hi Jacopo,
Thanks for your effort tidying things up!
On 2025-08-02 11:22:39 +0200, Jacopo Mondi wrote:
> The R-Car VIN driver sets file->private_data to the driver-specific
> structure, but the following call to v4l2_fh_open() overwrites it
> with a pointer to the just allocated v4l2_fh.
>
> Remove the mis-leading assignment in the driver.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> index 62eddf3a35fc91434cb2e584a01819380a7a6dd8..079dbaf016c25139e2ac82be63d8fce0d11fd208 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> @@ -588,8 +588,6 @@ static int rvin_open(struct file *file)
> if (ret)
> goto err_pm;
>
> - file->private_data = vin;
> -
> ret = v4l2_fh_open(file);
> if (ret)
> goto err_unlock;
>
> --
> 2.49.0
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 44/65] media: rockchip: rkvdec: Access v4l2_fh from file
2025-08-02 9:23 ` [PATCH 44/65] media: rockchip: rkvdec: " Jacopo Mondi
@ 2025-08-02 16:02 ` Detlev Casanova
0 siblings, 0 replies; 101+ messages in thread
From: Detlev Casanova @ 2025-08-02 16:02 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
Jacopo Mondi
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users, Jacopo Mondi
Hi Jacopo,
Thanks for the cleanup !
On Saturday, 2 August 2025 05:23:06 EDT Jacopo Mondi wrote:
> The v4l2_fh associated with an open file handle is now guaranteed
> to be available in file->private_data, initialised by v4l2_fh_add().
>
> Access the v4l2_fh, and from there the driver-specific structure,
> from the file * in all ioctl handlers.
>
> While at it, remove the now unused fh_to_rkvdec_ctx() macro.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Detlev Casanova <detlev.casanova@collabora.com>
> ---
> drivers/media/platform/rockchip/rkvdec/rkvdec.c | 14 +++++++-------
> drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 -----
> 2 files changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> b/drivers/media/platform/rockchip/rkvdec/rkvdec.c index
> 481c2488f9ac64e70869ed21e5053cfbc4ed6e0e..9fa80ab3c62b7753e6c992aefd106ee99
> ed375e4 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
> @@ -354,7 +354,7 @@ static int rkvdec_try_capture_fmt(struct file *file,
> void *priv, struct v4l2_format *f)
> {
> struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
> const struct rkvdec_coded_fmt_desc *coded_desc;
>
> /*
> @@ -387,7 +387,7 @@ static int rkvdec_try_output_fmt(struct file *file, void
> *priv, struct v4l2_format *f)
> {
> struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
> const struct rkvdec_coded_fmt_desc *desc;
>
> desc = rkvdec_find_coded_fmt_desc(pix_mp->pixelformat);
> @@ -418,7 +418,7 @@ static int rkvdec_try_output_fmt(struct file *file, void
> *priv, static int rkvdec_s_capture_fmt(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
> struct vb2_queue *vq;
> int ret;
>
> @@ -439,7 +439,7 @@ static int rkvdec_s_capture_fmt(struct file *file, void
> *priv, static int rkvdec_s_output_fmt(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
> struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
> const struct rkvdec_coded_fmt_desc *desc;
> struct v4l2_format *cap_fmt;
> @@ -504,7 +504,7 @@ static int rkvdec_s_output_fmt(struct file *file, void
> *priv, static int rkvdec_g_output_fmt(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
>
> *f = ctx->coded_fmt;
> return 0;
> @@ -513,7 +513,7 @@ static int rkvdec_g_output_fmt(struct file *file, void
> *priv, static int rkvdec_g_capture_fmt(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
>
> *f = ctx->decoded_fmt;
> return 0;
> @@ -532,7 +532,7 @@ static int rkvdec_enum_output_fmt(struct file *file,
> void *priv, static int rkvdec_enum_capture_fmt(struct file *file, void
> *priv, struct v4l2_fmtdesc *f)
> {
> - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv);
> + struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(file);
> u32 fourcc;
>
> fourcc = rkvdec_enum_decoded_fmt(ctx, f->index, ctx->image_fmt);
> diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
> b/drivers/media/platform/rockchip/rkvdec/rkvdec.h index
> 35effe9467845fdfc4ffea432211d1d2e75a08b0..481aaa4bffe975fa106fb22e78bef90ad
> e86a6cf 100644 --- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
> +++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
> @@ -124,11 +124,6 @@ struct rkvdec_ctx {
> void *priv;
> };
>
> -static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct rkvdec_ctx, fh);
> -}
> -
> static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh);
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 18/65] media: rzg2l-cru: Do not set file->private_data
2025-08-02 9:22 ` [PATCH 18/65] media: rzg2l-cru: " Jacopo Mondi
@ 2025-08-04 10:01 ` Tommaso Merciai
0 siblings, 0 replies; 101+ messages in thread
From: Tommaso Merciai @ 2025-08-04 10:01 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Jacopo,
Thank you for the patch!
On Sat, Aug 02, 2025 at 11:22:40AM +0200, Jacopo Mondi wrote:
> The RZ G2/L CRU driver sets file->private_data to the driver-specific
The RZ/G2L
> structure, but the following call to v4l2_fh_open() overwrites it
> with a pointer to the just allocated v4l2_fh.
>
> Remove the mis-leading assignment in the driver.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Apart from that:
Tested-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> ---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> index a8817a7066b22f8a8dd1fdab50efabc486e4dfdb..941badc90ff55c5225644f88de1d70239eb3a247 100644
> --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-video.c
> @@ -1078,7 +1078,6 @@ static int rzg2l_cru_open(struct file *file)
> if (ret)
> return ret;
>
> - file->private_data = cru;
> ret = v4l2_fh_open(file);
> if (ret)
> goto err_unlock;
>
> --
> 2.49.0
>
Thanks & Regards,
Tommaso
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data
2025-08-02 9:23 ` [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data Jacopo Mondi
@ 2025-08-04 21:59 ` Paul Kocialkowski
0 siblings, 0 replies; 101+ messages in thread
From: Paul Kocialkowski @ 2025-08-04 21:59 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Niklas Söderlund, Robert Foss, Todor Tomov,
Vladimir Zapolskiy, Corentin Labbe, Sakari Ailus, Bingbu Cao,
Tianshu Qiu, Stanislaw Gruszka, linux-media, linux-kernel,
linux-staging, linux-doc, linux-arm-kernel, linux-mediatek,
linux-tegra, imx, linux-renesas-soc, linux-arm-msm,
linux-samsung-soc, linux-sunxi, linux-usb, linux-amlogic,
linux-rockchip, linux-stm32, mjpeg-users
[-- Attachment #1: Type: text/plain, Size: 6069 bytes --]
Hi,
Very nice cleanup, glad to see this abstracted away from drivers!
Reviewed-by: Paul Kocialkowski <paulk@sys-base.io>
All the best,
Paul
On Sat 02 Aug 25, 11:23, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> To prepare for the introduction of video_device_state as second argument
> of the v4l2_ioctl_ops handler, access the v4l2_fh from
> file->private_data instead of using void *priv.
>
> The file->private_data is initialized to point to the v4l2_fh
> by the usage of v4l2_fh_init() in the v4l2_file_operations.open()
> handler.
>
> While at it remove the only left user of fh_to_ctx() and remove
> the macro completely.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> drivers/media/platform/verisilicon/hantro.h | 5 -----
> drivers/media/platform/verisilicon/hantro_v4l2.c | 22 +++++++++++-----------
> 2 files changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro.h b/drivers/media/platform/verisilicon/hantro.h
> index 0f10714f1953945472e11d8c8ad87f8ec009b39f..e0fdc4535b2d73c5260057b0a89aee67a4732dd2 100644
> --- a/drivers/media/platform/verisilicon/hantro.h
> +++ b/drivers/media/platform/verisilicon/hantro.h
> @@ -382,11 +382,6 @@ extern int hantro_debug;
> pr_err("%s:%d: " fmt, __func__, __LINE__, ##args)
>
> /* Structure access helpers. */
> -static __always_inline struct hantro_ctx *fh_to_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct hantro_ctx, fh);
> -}
> -
> static __always_inline struct hantro_ctx *file_to_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct hantro_ctx, fh);
> diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/media/platform/verisilicon/hantro_v4l2.c
> index 7c3515cf7d64a090adfb8d8aff368f9a617f8c8a..6bcd892e7bb49c654aae5841664d68c1692064bd 100644
> --- a/drivers/media/platform/verisilicon/hantro_v4l2.c
> +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c
> @@ -185,7 +185,7 @@ static int vidioc_querycap(struct file *file, void *priv,
> static int vidioc_enum_framesizes(struct file *file, void *priv,
> struct v4l2_frmsizeenum *fsize)
> {
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
> const struct hantro_fmt *fmt;
>
> fmt = hantro_find_format(ctx, fsize->pixel_format);
> @@ -217,7 +217,7 @@ static int vidioc_enum_fmt(struct file *file, void *priv,
> struct v4l2_fmtdesc *f, bool capture)
>
> {
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
> const struct hantro_fmt *fmt, *formats;
> unsigned int num_fmts, i, j = 0;
> bool skip_mode_none, enum_all_formats;
> @@ -297,7 +297,7 @@ static int vidioc_g_fmt_out_mplane(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
>
> vpu_debug(4, "f->type = %d\n", f->type);
>
> @@ -310,7 +310,7 @@ static int vidioc_g_fmt_cap_mplane(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
>
> vpu_debug(4, "f->type = %d\n", f->type);
>
> @@ -398,13 +398,13 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx,
> static int vidioc_try_fmt_cap_mplane(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - return hantro_try_fmt(fh_to_ctx(priv), &f->fmt.pix_mp, f->type);
> + return hantro_try_fmt(file_to_ctx(file), &f->fmt.pix_mp, f->type);
> }
>
> static int vidioc_try_fmt_out_mplane(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> - return hantro_try_fmt(fh_to_ctx(priv), &f->fmt.pix_mp, f->type);
> + return hantro_try_fmt(file_to_ctx(file), &f->fmt.pix_mp, f->type);
> }
>
> static void
> @@ -648,19 +648,19 @@ static int hantro_set_fmt_cap(struct hantro_ctx *ctx,
> static int
> vidioc_s_fmt_out_mplane(struct file *file, void *priv, struct v4l2_format *f)
> {
> - return hantro_set_fmt_out(fh_to_ctx(priv), &f->fmt.pix_mp, HANTRO_AUTO_POSTPROC);
> + return hantro_set_fmt_out(file_to_ctx(file), &f->fmt.pix_mp, HANTRO_AUTO_POSTPROC);
> }
>
> static int
> vidioc_s_fmt_cap_mplane(struct file *file, void *priv, struct v4l2_format *f)
> {
> - return hantro_set_fmt_cap(fh_to_ctx(priv), &f->fmt.pix_mp);
> + return hantro_set_fmt_cap(file_to_ctx(file), &f->fmt.pix_mp);
> }
>
> static int vidioc_g_selection(struct file *file, void *priv,
> struct v4l2_selection *sel)
> {
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
>
> /* Crop only supported on source. */
> if (!ctx->is_encoder ||
> @@ -691,7 +691,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
> static int vidioc_s_selection(struct file *file, void *priv,
> struct v4l2_selection *sel)
> {
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
> struct v4l2_rect *rect = &sel->r;
> struct vb2_queue *vq;
>
> @@ -738,7 +738,7 @@ static const struct v4l2_event hantro_eos_event = {
> static int vidioc_encoder_cmd(struct file *file, void *priv,
> struct v4l2_encoder_cmd *ec)
> {
> - struct hantro_ctx *ctx = fh_to_ctx(priv);
> + struct hantro_ctx *ctx = file_to_ctx(file);
> int ret;
>
> ret = v4l2_m2m_ioctl_try_encoder_cmd(file, priv, ec);
>
> --
> 2.49.0
>
--
Paul Kocialkowski,
Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/
Expert in multimedia, graphics and embedded hardware support with Linux.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 101+ messages in thread
* RE: [EXT] [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static
2025-08-02 9:22 ` [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static Jacopo Mondi
@ 2025-08-05 1:34 ` Ming Qian
0 siblings, 0 replies; 101+ messages in thread
From: Ming Qian @ 2025-08-05 1:34 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Eagle Zhou, Xavier Roumegue (OSS), Philipp Zabel, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
Sylwester Nawrocki, Jernej Skrabec, Chen-Yu Tsai, Samuel Holland,
Daniel Almeida, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Nas Chung, Jackson Lee, Minghsiu Tsai,
Houlong Wei, Andrew-CT Chen, Tiffany Lin, Yunfei Dong,
Geert Uytterhoeven, Magnus Damm, Mikhail Ulyanov, Jacob Chen,
Ezequiel Garcia, Heiko Stuebner, Detlev Casanova,
Krzysztof Kozlowski, Alim Akhtar, Sylwester Nawrocki,
Łukasz Stelmach, Andrzej Pietrasiewicz, Jacek Anaszewski,
Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-sunxi@lists.linux.dev, linux-usb@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
mjpeg-users@lists.sourceforge.net
>-----Original Message-----
>From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Sent: Saturday, August 2, 2025 5:23 PM
>To: Mauro Carvalho Chehab <mchehab@kernel.org>; Devarsh Thakkar
><devarsht@ti.com>; Benoit Parrot <bparrot@ti.com>; Hans Verkuil
><hverkuil@kernel.org>; Mike Isely <isely@pobox.com>; Laurent Pinchart
><laurent.pinchart@ideasonboard.com>; Hans de Goede <hansg@kernel.org>;
>Parthiban Veerasooran <parthiban.veerasooran@microchip.com>; Christian
>Gromm <christian.gromm@microchip.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Alex Shi <alexs@kernel.org>; Yanteng Si
><si.yanteng@linux.dev>; Dongliang Mu <dzm91@hust.edu.cn>; Jonathan
>Corbet <corbet@lwn.net>; Tomasz Figa <tfiga@chromium.org>; Marek
>Szyprowski <m.szyprowski@samsung.com>; Andy Walls
><awalls@md.metrocast.net>; Michael Tretter <m.tretter@pengutronix.de>;
>Pengutronix Kernel Team <kernel@pengutronix.de>; Bin Liu
><bin.liu@mediatek.com>; Matthias Brugger <matthias.bgg@gmail.com>;
>AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>;
>Dmitry Osipenko <digetx@gmail.com>; Thierry Reding
><thierry.reding@gmail.com>; Jonathan Hunter <jonathanh@nvidia.com>;
>Mirela Rabulea <mirela.rabulea@nxp.com>; Shawn Guo
><shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Fabio
>Estevam <festevam@gmail.com>; Kieran Bingham
><kieran.bingham+renesas@ideasonboard.com>; Michal Simek
><michal.simek@amd.com>; Ming Qian <ming.qian@nxp.com>; Eagle Zhou
><eagle.zhou@nxp.com>; Xavier Roumegue (OSS)
><xavier.roumegue@oss.nxp.com>; Philipp Zabel <p.zabel@pengutronix.de>;
>Vikash Garodia <quic_vgarodia@quicinc.com>; Dikshita Agarwal
><quic_dikshita@quicinc.com>; Abhinav Kumar <abhinav.kumar@linux.dev>;
>Bryan O'Donoghue <bryan.odonoghue@linaro.org>; Sylwester Nawrocki
><sylvester.nawrocki@gmail.com>; Jernej Skrabec <jernej.skrabec@gmail.com>;
>Chen-Yu Tsai <wens@csie.org>; Samuel Holland <samuel@sholland.org>;
>Daniel Almeida <daniel.almeida@collabora.com>; Neil Armstrong
><neil.armstrong@linaro.org>; Kevin Hilman <khilman@baylibre.com>; Jerome
>Brunet <jbrunet@baylibre.com>; Martin Blumenstingl
><martin.blumenstingl@googlemail.com>; Nas Chung
><nas.chung@chipsnmedia.com>; Jackson Lee
><jackson.lee@chipsnmedia.com>; Minghsiu Tsai
><minghsiu.tsai@mediatek.com>; Houlong Wei <houlong.wei@mediatek.com>;
>Andrew-CT Chen <andrew-ct.chen@mediatek.com>; Tiffany Lin
><tiffany.lin@mediatek.com>; Yunfei Dong <yunfei.dong@mediatek.com>;
>Geert Uytterhoeven <geert+renesas@glider.be>; Magnus Damm
><magnus.damm@gmail.com>; Mikhail Ulyanov
><mikhail.ulyanov@cogentembedded.com>; Jacob Chen <jacob-
>chen@iotwrt.com>; Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>; Heiko
>Stuebner <heiko@sntech.de>; Detlev Casanova
><detlev.casanova@collabora.com>; Krzysztof Kozlowski <krzk@kernel.org>;
>Alim Akhtar <alim.akhtar@samsung.com>; Sylwester Nawrocki
><s.nawrocki@samsung.com>; Łukasz Stelmach <l.stelmach@samsung.com>;
>Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>; Jacek Anaszewski
><jacek.anaszewski@gmail.com>; Andrzej Hajda <andrzej.hajda@intel.com>;
>Fabien Dessenne <fabien.dessenne@foss.st.com>; Hugues Fruchet
><hugues.fruchet@foss.st.com>; Jean-Christophe Trotin <jean-
>christophe.trotin@foss.st.com>; Maxime Coquelin
><mcoquelin.stm32@gmail.com>; Alexandre Torgue
><alexandre.torgue@foss.st.com>; Nicolas Dufresne
><nicolas.dufresne@collabora.com>; Benjamin Gaignard
><benjamin.gaignard@collabora.com>; Steve Longerbeam
><slongerbeam@gmail.com>; Maxime Ripard <mripard@kernel.org>; Paul
>Kocialkowski <paulk@sys-base.io>; Niklas Söderlund
><niklas.soderlund@ragnatech.se>; Robert Foss <rfoss@kernel.org>; Todor
>Tomov <todor.too@gmail.com>; Vladimir Zapolskiy
><vladimir.zapolskiy@linaro.org>; Corentin Labbe <clabbe@baylibre.com>;
>Sakari Ailus <sakari.ailus@linux.intel.com>; Bingbu Cao
><bingbu.cao@intel.com>; Tianshu Qiu <tian.shu.qiu@intel.com>; Stanislaw
>Gruszka <stanislaw.gruszka@linux.intel.com>
>Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>staging@lists.linux.dev; linux-doc@vger.kernel.org; linux-arm-
>kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; linux-
>tegra@vger.kernel.org; imx@lists.linux.dev; linux-renesas-soc@vger.kernel.org;
>linux-arm-msm@vger.kernel.org; linux-samsung-soc@vger.kernel.org; linux-
>sunxi@lists.linux.dev; linux-usb@vger.kernel.org; linux-
>amlogic@lists.infradead.org; linux-rockchip@lists.infradead.org; linux-
>stm32@st-md-mailman.stormreply.com; mjpeg-users@lists.sourceforge.net;
>Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Subject: [EXT] [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions
>static
>
>Caution: This is an external email. Please take care when clicking links or
>opening attachments. When in doubt, report the message using the 'Report
>this email' button
>
>
>From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>Some functions defined in vpu_v4l2.c are never used outside of that
>compilation unit. Make them static.
>
>Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Ming Qian <ming.qian@oss.nxp.com>
>---
> drivers/media/platform/amphion/vpu_v4l2.c | 12 +++++++++---
>drivers/media/platform/amphion/vpu_v4l2.h | 8 --------
> 2 files changed, 9 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/media/platform/amphion/vpu_v4l2.c
>b/drivers/media/platform/amphion/vpu_v4l2.c
>index
>74668fa362e24fd34829b500e99c8455a9413fc1..306d94e0f8e79faaacfa35b28e
>5786860f7bd1ca 100644
>--- a/drivers/media/platform/amphion/vpu_v4l2.c
>+++ b/drivers/media/platform/amphion/vpu_v4l2.c
>@@ -24,6 +24,11 @@
> #include "vpu_msgs.h"
> #include "vpu_helpers.h"
>
>+static char *vpu_type_name(u32 type)
>+{
>+ return V4L2_TYPE_IS_OUTPUT(type) ? "output" : "capture"; }
>+
> void vpu_inst_lock(struct vpu_inst *inst) {
> mutex_lock(&inst->lock);
>@@ -42,7 +47,7 @@ dma_addr_t vpu_get_vb_phy_addr(struct vb2_buffer
>*vb, u32 plane_no)
> vb->planes[plane_no].data_offset; }
>
>-unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no)
>+static unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32
>+plane_no)
> {
> if (plane_no >= vb->num_planes)
> return 0;
>@@ -81,7 +86,7 @@ void vpu_v4l2_set_error(struct vpu_inst *inst)
> vpu_inst_unlock(inst);
> }
>
>-int vpu_notify_eos(struct vpu_inst *inst)
>+static int vpu_notify_eos(struct vpu_inst *inst)
> {
> static const struct v4l2_event ev = {
> .id = 0,
>@@ -573,7 +578,8 @@ static void vpu_vb2_buf_finish(struct vb2_buffer *vb)
> call_void_vop(inst, on_queue_empty, q->type); }
>
>-void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type, enum
>vb2_buffer_state state)
>+static void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type,
>+ enum vb2_buffer_state state)
> {
> struct vb2_v4l2_buffer *buf;
>
>diff --git a/drivers/media/platform/amphion/vpu_v4l2.h
>b/drivers/media/platform/amphion/vpu_v4l2.h
>index
>56f2939fa84d07b7ea07e889ab5ad3bb7ca9ab5c..4a87b06ae520306ede356b6f
>3309d8b4a67c204a 100644
>--- a/drivers/media/platform/amphion/vpu_v4l2.h
>+++ b/drivers/media/platform/amphion/vpu_v4l2.h
>@@ -26,15 +26,12 @@ void vpu_skip_frame(struct vpu_inst *inst, int count);
>struct vb2_v4l2_buffer *vpu_find_buf_by_sequence(struct vpu_inst *inst, u32
>type, u32 sequence); struct vb2_v4l2_buffer *vpu_find_buf_by_idx(struct
>vpu_inst *inst, u32 type, u32 idx); void vpu_v4l2_set_error(struct vpu_inst
>*inst); -int vpu_notify_eos(struct vpu_inst *inst); int
>vpu_notify_source_change(struct vpu_inst *inst); int
>vpu_set_last_buffer_dequeued(struct vpu_inst *inst, bool eos); -void
>vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type, enum
>vb2_buffer_state state); int vpu_get_num_buffers(struct vpu_inst *inst, u32
>type); bool vpu_is_source_empty(struct vpu_inst *inst);
>
> dma_addr_t vpu_get_vb_phy_addr(struct vb2_buffer *vb, u32 plane_no); -
>unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no); static
>inline struct vpu_format *vpu_get_format(struct vpu_inst *inst, u32 type) {
> if (V4L2_TYPE_IS_OUTPUT(type))
>@@ -43,11 +40,6 @@ static inline struct vpu_format *vpu_get_format(struct
>vpu_inst *inst, u32 type)
> return &inst->cap_format; }
>
>-static inline char *vpu_type_name(u32 type) -{
>- return V4L2_TYPE_IS_OUTPUT(type) ? "output" : "capture";
>-}
>-
> static inline int vpu_vb_is_codecconfig(struct vb2_v4l2_buffer *vbuf) { #ifdef
>V4L2_BUF_FLAG_CODECCONFIG
>
>--
>2.49.0
^ permalink raw reply [flat|nested] 101+ messages in thread
* RE: [EXT] [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release()
2025-08-02 9:22 ` [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release() Jacopo Mondi
@ 2025-08-05 1:43 ` Ming Qian
0 siblings, 0 replies; 101+ messages in thread
From: Ming Qian @ 2025-08-05 1:43 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Eagle Zhou, Xavier Roumegue (OSS), Philipp Zabel, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
Sylwester Nawrocki, Jernej Skrabec, Chen-Yu Tsai, Samuel Holland,
Daniel Almeida, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Nas Chung, Jackson Lee, Minghsiu Tsai,
Houlong Wei, Andrew-CT Chen, Tiffany Lin, Yunfei Dong,
Geert Uytterhoeven, Magnus Damm, Mikhail Ulyanov, Jacob Chen,
Ezequiel Garcia, Heiko Stuebner, Detlev Casanova,
Krzysztof Kozlowski, Alim Akhtar, Sylwester Nawrocki,
Łukasz Stelmach, Andrzej Pietrasiewicz, Jacek Anaszewski,
Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-sunxi@lists.linux.dev, linux-usb@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
mjpeg-users@lists.sourceforge.net
>-----Original Message-----
>From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Sent: Saturday, August 2, 2025 5:23 PM
>To: Mauro Carvalho Chehab <mchehab@kernel.org>; Devarsh Thakkar
><devarsht@ti.com>; Benoit Parrot <bparrot@ti.com>; Hans Verkuil
><hverkuil@kernel.org>; Mike Isely <isely@pobox.com>; Laurent Pinchart
><laurent.pinchart@ideasonboard.com>; Hans de Goede <hansg@kernel.org>;
>Parthiban Veerasooran <parthiban.veerasooran@microchip.com>; Christian
>Gromm <christian.gromm@microchip.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Alex Shi <alexs@kernel.org>; Yanteng Si
><si.yanteng@linux.dev>; Dongliang Mu <dzm91@hust.edu.cn>; Jonathan
>Corbet <corbet@lwn.net>; Tomasz Figa <tfiga@chromium.org>; Marek
>Szyprowski <m.szyprowski@samsung.com>; Andy Walls
><awalls@md.metrocast.net>; Michael Tretter <m.tretter@pengutronix.de>;
>Pengutronix Kernel Team <kernel@pengutronix.de>; Bin Liu
><bin.liu@mediatek.com>; Matthias Brugger <matthias.bgg@gmail.com>;
>AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>;
>Dmitry Osipenko <digetx@gmail.com>; Thierry Reding
><thierry.reding@gmail.com>; Jonathan Hunter <jonathanh@nvidia.com>;
>Mirela Rabulea <mirela.rabulea@nxp.com>; Shawn Guo
><shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Fabio
>Estevam <festevam@gmail.com>; Kieran Bingham
><kieran.bingham+renesas@ideasonboard.com>; Michal Simek
><michal.simek@amd.com>; Ming Qian <ming.qian@nxp.com>; Eagle Zhou
><eagle.zhou@nxp.com>; Xavier Roumegue (OSS)
><xavier.roumegue@oss.nxp.com>; Philipp Zabel <p.zabel@pengutronix.de>;
>Vikash Garodia <quic_vgarodia@quicinc.com>; Dikshita Agarwal
><quic_dikshita@quicinc.com>; Abhinav Kumar <abhinav.kumar@linux.dev>;
>Bryan O'Donoghue <bryan.odonoghue@linaro.org>; Sylwester Nawrocki
><sylvester.nawrocki@gmail.com>; Jernej Skrabec <jernej.skrabec@gmail.com>;
>Chen-Yu Tsai <wens@csie.org>; Samuel Holland <samuel@sholland.org>;
>Daniel Almeida <daniel.almeida@collabora.com>; Neil Armstrong
><neil.armstrong@linaro.org>; Kevin Hilman <khilman@baylibre.com>; Jerome
>Brunet <jbrunet@baylibre.com>; Martin Blumenstingl
><martin.blumenstingl@googlemail.com>; Nas Chung
><nas.chung@chipsnmedia.com>; Jackson Lee
><jackson.lee@chipsnmedia.com>; Minghsiu Tsai
><minghsiu.tsai@mediatek.com>; Houlong Wei <houlong.wei@mediatek.com>;
>Andrew-CT Chen <andrew-ct.chen@mediatek.com>; Tiffany Lin
><tiffany.lin@mediatek.com>; Yunfei Dong <yunfei.dong@mediatek.com>;
>Geert Uytterhoeven <geert+renesas@glider.be>; Magnus Damm
><magnus.damm@gmail.com>; Mikhail Ulyanov
><mikhail.ulyanov@cogentembedded.com>; Jacob Chen <jacob-
>chen@iotwrt.com>; Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>; Heiko
>Stuebner <heiko@sntech.de>; Detlev Casanova
><detlev.casanova@collabora.com>; Krzysztof Kozlowski <krzk@kernel.org>;
>Alim Akhtar <alim.akhtar@samsung.com>; Sylwester Nawrocki
><s.nawrocki@samsung.com>; Łukasz Stelmach <l.stelmach@samsung.com>;
>Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>; Jacek Anaszewski
><jacek.anaszewski@gmail.com>; Andrzej Hajda <andrzej.hajda@intel.com>;
>Fabien Dessenne <fabien.dessenne@foss.st.com>; Hugues Fruchet
><hugues.fruchet@foss.st.com>; Jean-Christophe Trotin <jean-
>christophe.trotin@foss.st.com>; Maxime Coquelin
><mcoquelin.stm32@gmail.com>; Alexandre Torgue
><alexandre.torgue@foss.st.com>; Nicolas Dufresne
><nicolas.dufresne@collabora.com>; Benjamin Gaignard
><benjamin.gaignard@collabora.com>; Steve Longerbeam
><slongerbeam@gmail.com>; Maxime Ripard <mripard@kernel.org>; Paul
>Kocialkowski <paulk@sys-base.io>; Niklas Söderlund
><niklas.soderlund@ragnatech.se>; Robert Foss <rfoss@kernel.org>; Todor
>Tomov <todor.too@gmail.com>; Vladimir Zapolskiy
><vladimir.zapolskiy@linaro.org>; Corentin Labbe <clabbe@baylibre.com>;
>Sakari Ailus <sakari.ailus@linux.intel.com>; Bingbu Cao
><bingbu.cao@intel.com>; Tianshu Qiu <tian.shu.qiu@intel.com>; Stanislaw
>Gruszka <stanislaw.gruszka@linux.intel.com>
>Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>staging@lists.linux.dev; linux-doc@vger.kernel.org; linux-arm-
>kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; linux-
>tegra@vger.kernel.org; imx@lists.linux.dev; linux-renesas-soc@vger.kernel.org;
>linux-arm-msm@vger.kernel.org; linux-samsung-soc@vger.kernel.org; linux-
>sunxi@lists.linux.dev; linux-usb@vger.kernel.org; linux-
>amlogic@lists.infradead.org; linux-rockchip@lists.infradead.org; linux-
>stm32@st-md-mailman.stormreply.com; mjpeg-users@lists.sourceforge.net;
>Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Subject: [EXT] [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously
>in .release()
>
>Caution: This is an external email. Please take care when clicking links or
>opening attachments. When in doubt, report the message using the 'Report
>this email' button
>
>
>From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>The v4l2_fh initialized and added in vpu_v4l2_open() is delete and cleaned up
>when the last reference to the vpu_inst is released. This may happen later than
>at vpu_v4l2_close() time.
>
>Not deleting and cleaning up the v4l2_fh when closing the file handle to the
>video device is not ideal, as the v4l2_fh will still be present in the video device's
>fh_list, and will store a copy of events queued to the video device. There may
>also be other side effects of keeping alive an object that represents an open file
>handle after the file handle is closed.
>
>The v4l2_fh instance is embedded in the vpu_inst structure, and is accessed in
>two different ways:
>
>- in vpu_notify_eos() and vpu_notify_source_change(), to queue V4L2
> events to the file handle ; and
>
>- through the driver to access the v4l2_fh.m2m_ctx pointer.
>
>The v4l2_fh.m2m_ctx pointer is not touched by v4l2_fh_del() and
>v4l2_fh_exit(). It is set to NULL by the driver when closing the file handle, in
>vpu_v4l2_close().
>
>The vpu_notify_eos() and vpu_notify_source_change() functions are called in
>vpu_set_last_buffer_dequeued() and vdec_handle_resolution_change()
>respectively, only if the v4l2_fh.m2m_ctx pointer is not NULL. There is therefore
>a guarantee that no new event will be queued to the v4l2_fh after
>vpu_v4l2_close() destroys the m2m_ctx.
>
>The vpu_notify_eos() function is also called from vpu_vb2_buf_finish(), which
>is guaranteed to be called for all queued buffers when
>vpu_v4l2_close() calls v4l2_m2m_ctx_release(), and will not be called later.
>
>It is therefore safe to assume that the driver will not touch the v4l2_fh, except
>to check the m2m_ctx pointer, after vpu_v4l2_close() destroys the m2m_ctx.
>We can safely delete and cleanup the v4l2_fh synchronously in
>vpu_v4l2_close().
>
>Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Ming Qian <ming.qian@oss.nxp.com>
>---
> drivers/media/platform/amphion/vpu_v4l2.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/media/platform/amphion/vpu_v4l2.c
>b/drivers/media/platform/amphion/vpu_v4l2.c
>index
>306d94e0f8e79faaacfa35b28e5786860f7bd1ca..57ca6262bb04b356a85e217ef
>51cfb13cb9a0a36 100644
>--- a/drivers/media/platform/amphion/vpu_v4l2.c
>+++ b/drivers/media/platform/amphion/vpu_v4l2.c
>@@ -724,8 +724,6 @@ static int vpu_v4l2_release(struct vpu_inst *inst)
>
> v4l2_ctrl_handler_free(&inst->ctrl_handler);
> mutex_destroy(&inst->lock);
>- v4l2_fh_del(&inst->fh);
>- v4l2_fh_exit(&inst->fh);
>
> call_void_vop(inst, cleanup);
>
>@@ -794,6 +792,8 @@ int vpu_v4l2_open(struct file *file, struct vpu_inst
>*inst)
>
> return 0;
> error:
>+ v4l2_fh_del(&inst->fh);
>+ v4l2_fh_exit(&inst->fh);
> vpu_inst_put(inst);
> return ret;
> }
>@@ -813,6 +813,9 @@ int vpu_v4l2_close(struct file *file)
> call_void_vop(inst, release);
> vpu_inst_unlock(inst);
>
>+ v4l2_fh_del(&inst->fh);
>+ v4l2_fh_exit(&inst->fh);
>+
> vpu_inst_unregister(inst);
> vpu_inst_put(inst);
>
>
>--
>2.49.0
^ permalink raw reply [flat|nested] 101+ messages in thread
* RE: [EXT] [PATCH 39/65] media: imx-jpeg: Access v4l2_fh from file
2025-08-02 9:23 ` [PATCH 39/65] media: imx-jpeg: " Jacopo Mondi
@ 2025-08-05 1:58 ` Ming Qian
0 siblings, 0 replies; 101+ messages in thread
From: Ming Qian @ 2025-08-05 1:58 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Eagle Zhou, Xavier Roumegue (OSS), Philipp Zabel, Vikash Garodia,
Dikshita Agarwal, Abhinav Kumar, Bryan O'Donoghue,
Sylwester Nawrocki, Jernej Skrabec, Chen-Yu Tsai, Samuel Holland,
Daniel Almeida, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, Nas Chung, Jackson Lee, Minghsiu Tsai,
Houlong Wei, Andrew-CT Chen, Tiffany Lin, Yunfei Dong,
Geert Uytterhoeven, Magnus Damm, Mikhail Ulyanov, Jacob Chen,
Ezequiel Garcia, Heiko Stuebner, Detlev Casanova,
Krzysztof Kozlowski, Alim Akhtar, Sylwester Nawrocki,
Łukasz Stelmach, Andrzej Pietrasiewicz, Jacek Anaszewski,
Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-sunxi@lists.linux.dev, linux-usb@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
mjpeg-users@lists.sourceforge.net
>-----Original Message-----
>From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Sent: Saturday, August 2, 2025 5:23 PM
>To: Mauro Carvalho Chehab <mchehab@kernel.org>; Devarsh Thakkar
><devarsht@ti.com>; Benoit Parrot <bparrot@ti.com>; Hans Verkuil
><hverkuil@kernel.org>; Mike Isely <isely@pobox.com>; Laurent Pinchart
><laurent.pinchart@ideasonboard.com>; Hans de Goede <hansg@kernel.org>;
>Parthiban Veerasooran <parthiban.veerasooran@microchip.com>; Christian
>Gromm <christian.gromm@microchip.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Alex Shi <alexs@kernel.org>; Yanteng Si
><si.yanteng@linux.dev>; Dongliang Mu <dzm91@hust.edu.cn>; Jonathan
>Corbet <corbet@lwn.net>; Tomasz Figa <tfiga@chromium.org>; Marek
>Szyprowski <m.szyprowski@samsung.com>; Andy Walls
><awalls@md.metrocast.net>; Michael Tretter <m.tretter@pengutronix.de>;
>Pengutronix Kernel Team <kernel@pengutronix.de>; Bin Liu
><bin.liu@mediatek.com>; Matthias Brugger <matthias.bgg@gmail.com>;
>AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>;
>Dmitry Osipenko <digetx@gmail.com>; Thierry Reding
><thierry.reding@gmail.com>; Jonathan Hunter <jonathanh@nvidia.com>;
>Mirela Rabulea <mirela.rabulea@nxp.com>; Shawn Guo
><shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Fabio
>Estevam <festevam@gmail.com>; Kieran Bingham
><kieran.bingham+renesas@ideasonboard.com>; Michal Simek
><michal.simek@amd.com>; Ming Qian <ming.qian@nxp.com>; Eagle Zhou
><eagle.zhou@nxp.com>; Xavier Roumegue (OSS)
><xavier.roumegue@oss.nxp.com>; Philipp Zabel <p.zabel@pengutronix.de>;
>Vikash Garodia <quic_vgarodia@quicinc.com>; Dikshita Agarwal
><quic_dikshita@quicinc.com>; Abhinav Kumar <abhinav.kumar@linux.dev>;
>Bryan O'Donoghue <bryan.odonoghue@linaro.org>; Sylwester Nawrocki
><sylvester.nawrocki@gmail.com>; Jernej Skrabec <jernej.skrabec@gmail.com>;
>Chen-Yu Tsai <wens@csie.org>; Samuel Holland <samuel@sholland.org>;
>Daniel Almeida <daniel.almeida@collabora.com>; Neil Armstrong
><neil.armstrong@linaro.org>; Kevin Hilman <khilman@baylibre.com>; Jerome
>Brunet <jbrunet@baylibre.com>; Martin Blumenstingl
><martin.blumenstingl@googlemail.com>; Nas Chung
><nas.chung@chipsnmedia.com>; Jackson Lee
><jackson.lee@chipsnmedia.com>; Minghsiu Tsai
><minghsiu.tsai@mediatek.com>; Houlong Wei <houlong.wei@mediatek.com>;
>Andrew-CT Chen <andrew-ct.chen@mediatek.com>; Tiffany Lin
><tiffany.lin@mediatek.com>; Yunfei Dong <yunfei.dong@mediatek.com>;
>Geert Uytterhoeven <geert+renesas@glider.be>; Magnus Damm
><magnus.damm@gmail.com>; Mikhail Ulyanov
><mikhail.ulyanov@cogentembedded.com>; Jacob Chen <jacob-
>chen@iotwrt.com>; Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>; Heiko
>Stuebner <heiko@sntech.de>; Detlev Casanova
><detlev.casanova@collabora.com>; Krzysztof Kozlowski <krzk@kernel.org>;
>Alim Akhtar <alim.akhtar@samsung.com>; Sylwester Nawrocki
><s.nawrocki@samsung.com>; Łukasz Stelmach <l.stelmach@samsung.com>;
>Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>; Jacek Anaszewski
><jacek.anaszewski@gmail.com>; Andrzej Hajda <andrzej.hajda@intel.com>;
>Fabien Dessenne <fabien.dessenne@foss.st.com>; Hugues Fruchet
><hugues.fruchet@foss.st.com>; Jean-Christophe Trotin <jean-
>christophe.trotin@foss.st.com>; Maxime Coquelin
><mcoquelin.stm32@gmail.com>; Alexandre Torgue
><alexandre.torgue@foss.st.com>; Nicolas Dufresne
><nicolas.dufresne@collabora.com>; Benjamin Gaignard
><benjamin.gaignard@collabora.com>; Steve Longerbeam
><slongerbeam@gmail.com>; Maxime Ripard <mripard@kernel.org>; Paul
>Kocialkowski <paulk@sys-base.io>; Niklas Söderlund
><niklas.soderlund@ragnatech.se>; Robert Foss <rfoss@kernel.org>; Todor
>Tomov <todor.too@gmail.com>; Vladimir Zapolskiy
><vladimir.zapolskiy@linaro.org>; Corentin Labbe <clabbe@baylibre.com>;
>Sakari Ailus <sakari.ailus@linux.intel.com>; Bingbu Cao
><bingbu.cao@intel.com>; Tianshu Qiu <tian.shu.qiu@intel.com>; Stanislaw
>Gruszka <stanislaw.gruszka@linux.intel.com>
>Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>staging@lists.linux.dev; linux-doc@vger.kernel.org; linux-arm-
>kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; linux-
>tegra@vger.kernel.org; imx@lists.linux.dev; linux-renesas-soc@vger.kernel.org;
>linux-arm-msm@vger.kernel.org; linux-samsung-soc@vger.kernel.org; linux-
>sunxi@lists.linux.dev; linux-usb@vger.kernel.org; linux-
>amlogic@lists.infradead.org; linux-rockchip@lists.infradead.org; linux-
>stm32@st-md-mailman.stormreply.com; mjpeg-users@lists.sourceforge.net;
>Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Subject: [EXT] [PATCH 39/65] media: imx-jpeg: Access v4l2_fh from file
>
>Caution: This is an external email. Please take care when clicking links or
>opening attachments. When in doubt, report the message using the 'Report
>this email' button
>
>
>The v4l2_fh associated with an open file handle is now guaranteed to be
>available in file->private_data, initialised by v4l2_fh_add().
>
>Access the v4l2_fh, and from there the driver-specific structure, from the file *
>in all ioctl handlers.
>
>While at it, remove the now unused mxc_jpeg_fh_to_ctx() macro.
>
>Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Ming Qian <ming.qian@oss.nxp.com>
>---
> drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 33 +++++++++++--------------
>-
> 1 file changed, 14 insertions(+), 19 deletions(-)
>
>diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
>b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
>index
>fa7d74d8c1aabd3bf74482e214165d8c1a7e89da..df3ccdf767baf0bf6687808e2c
>017063181a7220 100644
>--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
>+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
>@@ -644,11 +644,6 @@ static void print_mxc_buf(struct mxc_jpeg_dev *jpeg,
>struct vb2_buffer *buf,
> }
> }
>
>-static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh) -{
>- return container_of(fh, struct mxc_jpeg_ctx, fh);
>-}
>-
> static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp) {
> return container_of(file_to_v4l2_fh(filp), struct mxc_jpeg_ctx, fh); @@ -
>1610,7 +1605,7 @@ static int mxc_jpeg_decoder_cmd(struct file *file, void
>*priv,
> struct v4l2_decoder_cmd *cmd) {
> struct v4l2_fh *fh = file_to_v4l2_fh(file);
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> unsigned long flags;
> int ret;
>
>@@ -1643,7 +1638,7 @@ static int mxc_jpeg_encoder_cmd(struct file *file,
>void *priv,
> struct v4l2_encoder_cmd *cmd) {
> struct v4l2_fh *fh = file_to_v4l2_fh(file);
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> unsigned long flags;
> int ret;
>
>@@ -2260,7 +2255,7 @@ static int mxc_jpeg_querycap(struct file *file, void
>*priv, static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv,
> struct v4l2_fmtdesc *f) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_q_data *q_data = mxc_jpeg_get_q_data(ctx, f->type);
>
> if (ctx->mxc_jpeg->mode == MXC_JPEG_ENCODE) { @@ -2300,7 +2295,7
>@@ static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, static
>int mxc_jpeg_enum_fmt_vid_out(struct file *file, void *priv,
> struct v4l2_fmtdesc *f) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> u32 type = ctx->mxc_jpeg->mode == MXC_JPEG_DECODE ?
>MXC_JPEG_FMT_TYPE_ENC :
> MXC_JPEG_FMT_TYPE_RAW;
> int ret;
>@@ -2441,7 +2436,7 @@ static int mxc_jpeg_try_fmt(struct v4l2_format *f,
>static int mxc_jpeg_try_fmt_vid_cap(struct file *file, void *priv,
> struct v4l2_format *f) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
> struct device *dev = jpeg->dev;
> struct mxc_jpeg_q_data tmp_q;
>@@ -2460,7 +2455,7 @@ static int mxc_jpeg_try_fmt_vid_cap(struct file *file,
>void *priv, static int mxc_jpeg_try_fmt_vid_out(struct file *file, void *priv,
> struct v4l2_format *f) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
> struct device *dev = jpeg->dev;
> struct mxc_jpeg_q_data tmp_q;
>@@ -2512,20 +2507,20 @@ static int mxc_jpeg_s_fmt(struct mxc_jpeg_ctx
>*ctx, static int mxc_jpeg_s_fmt_vid_cap(struct file *file, void *priv,
> struct v4l2_format *f) {
>- return mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
>+ return mxc_jpeg_s_fmt(mxc_jpeg_file_to_ctx(file), f);
> }
>
> static int mxc_jpeg_s_fmt_vid_out(struct file *file, void *priv,
> struct v4l2_format *f) {
> int ret;
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct vb2_queue *dst_vq;
> struct mxc_jpeg_q_data *q_data_cap;
> enum v4l2_buf_type cap_type =
>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
> struct v4l2_format fc;
>
>- ret = mxc_jpeg_s_fmt(mxc_jpeg_fh_to_ctx(priv), f);
>+ ret = mxc_jpeg_s_fmt(ctx, f);
> if (ret)
> return ret;
>
>@@ -2554,7 +2549,7 @@ static int mxc_jpeg_s_fmt_vid_out(struct file *file,
>void *priv, static int mxc_jpeg_g_fmt_vid(struct file *file, void *priv,
> struct v4l2_format *f) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(priv);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_dev *jpeg = ctx->mxc_jpeg;
> struct device *dev = jpeg->dev;
> struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
>@@ -2592,7 +2587,7 @@ static int mxc_jpeg_g_fmt_vid(struct file *file, void
>*priv,
>
> static int mxc_jpeg_dec_g_selection(struct file *file, void *fh, struct
>v4l2_selection *s) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_q_data *q_data_cap;
>
> if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && s->type !=
>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
>@@ -2621,7 +2616,7 @@ static int mxc_jpeg_dec_g_selection(struct file *file,
>void *fh, struct v4l2_sel
>
> static int mxc_jpeg_enc_g_selection(struct file *file, void *fh, struct
>v4l2_selection *s) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_q_data *q_data_out;
>
> if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && s->type !=
>V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
>@@ -2649,7 +2644,7 @@ static int mxc_jpeg_enc_g_selection(struct file *file,
>void *fh, struct v4l2_sel
>
> static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selection
>*s) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
>
> if (ctx->mxc_jpeg->mode == MXC_JPEG_DECODE)
> return mxc_jpeg_dec_g_selection(file, fh, s); @@ -2659,7 +2654,7 @@
>static int mxc_jpeg_g_selection(struct file *file, void *fh, struct v4l2_selecti
>
> static int mxc_jpeg_s_selection(struct file *file, void *fh, struct v4l2_selection
>*s) {
>- struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(fh);
>+ struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
> struct mxc_jpeg_q_data *q_data_out;
>
> if (ctx->mxc_jpeg->mode != MXC_JPEG_ENCODE)
>
>--
>2.49.0
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 29/65] media: allegro: Access v4l2_fh from file
2025-08-02 9:22 ` [PATCH 29/65] media: allegro: Access v4l2_fh from file Jacopo Mondi
@ 2025-08-05 7:39 ` Michael Tretter
0 siblings, 0 replies; 101+ messages in thread
From: Michael Tretter @ 2025-08-05 7:39 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Jacopo,
On Sat, 02 Aug 2025 11:22:51 +0200, Jacopo Mondi wrote:
> The v4l2_fh associated with an open file handle is now guaranteed
> to be available in file->private_data, initialised by v4l2_fh_add().
>
> Access the v4l2_fh, and from there the driver-specific structure,
> from the file * in all ioctl handlers.
>
> While at it remove the only left user of fh_to_channel() and remove
> the macro completely.
Thanks for the cleanup!
Minor suggestion below, but even without it
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
> drivers/media/platform/allegro-dvt/allegro-core.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
> index 5e3b1f5d7206d84b8ccb9ea3b3f3f1fe75becf99..81c6afcf2d06f9e39015e49d355346238c5033d8 100644
> --- a/drivers/media/platform/allegro-dvt/allegro-core.c
> +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
> @@ -197,8 +197,6 @@ static const struct regmap_config allegro_sram_config = {
> .cache_type = REGCACHE_NONE,
> };
>
> -#define fh_to_channel(__fh) container_of(__fh, struct allegro_channel, fh)
> -
> struct allegro_channel {
> struct allegro_dev *dev;
> struct v4l2_fh fh;
> @@ -3284,7 +3282,7 @@ static int allegro_enum_fmt_vid(struct file *file, void *fh,
> static int allegro_g_fmt_vid_cap(struct file *file, void *fh,
> struct v4l2_format *f)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
>
> f->fmt.pix.field = V4L2_FIELD_NONE;
> f->fmt.pix.width = channel->width;
> @@ -3326,7 +3324,7 @@ static int allegro_try_fmt_vid_cap(struct file *file, void *fh,
> static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
> struct v4l2_format *f)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
> struct vb2_queue *vq;
> int err;
>
> @@ -3350,7 +3348,7 @@ static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
> static int allegro_g_fmt_vid_out(struct file *file, void *fh,
> struct v4l2_format *f)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
>
> f->fmt.pix.field = V4L2_FIELD_NONE;
>
> @@ -3397,7 +3395,7 @@ static int allegro_try_fmt_vid_out(struct file *file, void *fh,
> static int allegro_s_fmt_vid_out(struct file *file, void *fh,
> struct v4l2_format *f)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
> int err;
>
> err = allegro_try_fmt_vid_out(file, fh, f);
> @@ -3438,7 +3436,7 @@ static int allegro_channel_cmd_start(struct allegro_channel *channel)
> static int allegro_encoder_cmd(struct file *file, void *fh,
> struct v4l2_encoder_cmd *cmd)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
> int err;
>
> err = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, cmd);
> @@ -3488,7 +3486,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
> enum v4l2_buf_type type)
> {
> struct v4l2_fh *fh = file_to_v4l2_fh(file);
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
You could remove the local fh entirely, if you change
return v4l2_m2m_streamon(file, fh->m2m_ctx, type);
to
return v4l2_m2m_streamon(file, channel->fh.m2m_ctx, type);
in the allegro_ioctl_streamon() function.
Michael
> int err;
>
> if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> @@ -3503,7 +3501,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
> static int allegro_g_parm(struct file *file, void *fh,
> struct v4l2_streamparm *a)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
> struct v4l2_fract *timeperframe;
>
> if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
> @@ -3520,7 +3518,7 @@ static int allegro_g_parm(struct file *file, void *fh,
> static int allegro_s_parm(struct file *file, void *fh,
> struct v4l2_streamparm *a)
> {
> - struct allegro_channel *channel = fh_to_channel(fh);
> + struct allegro_channel *channel = file_to_channel(file);
> struct v4l2_fract *timeperframe;
> int div;
>
>
> --
> 2.49.0
>
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 42/65] media: renesas: Access v4l2_fh from file
2025-08-02 9:23 ` [PATCH 42/65] media: renesas: " Jacopo Mondi
@ 2025-08-05 9:59 ` Kieran Bingham
0 siblings, 0 replies; 101+ messages in thread
From: Kieran Bingham @ 2025-08-05 9:59 UTC (permalink / raw)
To: Jacopo Mondi
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Quoting Jacopo Mondi (2025-08-02 10:23:04)
> The v4l2_fh associated with an open file handle is now guaranteed
> to be available in file->private_data, initialised by v4l2_fh_add().
>
> Access the v4l2_fh, and from there the driver-specific structure,
> from the file * in all ioctl handlers.
>
> While at it, remove the now unused fh_to_ctx() macro.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rcar_fdp1.c | 11 +++--------
> drivers/media/platform/renesas/rcar_jpu.c | 21 ++++++++-------------
> 2 files changed, 11 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
> index e78d8fb104e9544d27c8ace38888995ca170483f..84c3901a2e5dc3e7ccfb3b44062e839f8f19ee02 100644
> --- a/drivers/media/platform/renesas/rcar_fdp1.c
> +++ b/drivers/media/platform/renesas/rcar_fdp1.c
> @@ -630,11 +630,6 @@ struct fdp1_ctx {
> struct fdp1_field_buffer *previous;
> };
>
> -static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct fdp1_ctx, fh);
> -}
> -
> static inline struct fdp1_ctx *file_to_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct fdp1_ctx, fh);
> @@ -1411,8 +1406,8 @@ static int fdp1_enum_fmt_vid_out(struct file *file, void *priv,
>
> static int fdp1_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> + struct fdp1_ctx *ctx = file_to_ctx(file);
> struct fdp1_q_data *q_data;
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -1589,7 +1584,7 @@ static void fdp1_try_fmt_capture(struct fdp1_ctx *ctx,
>
> static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
> + struct fdp1_ctx *ctx = file_to_ctx(file);
>
> if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> fdp1_try_fmt_output(ctx, NULL, &f->fmt.pix_mp);
> @@ -1660,7 +1655,7 @@ static void fdp1_set_format(struct fdp1_ctx *ctx,
>
> static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
> + struct fdp1_ctx *ctx = file_to_ctx(file);
> struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
> struct vb2_queue *vq = v4l2_m2m_get_vq(m2m_ctx, f->type);
>
> diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
> index 058fcfb967bd98440f33272db42f0d973299d572..9c70a74a2969fce6446b0f26e0637a68eade3942 100644
> --- a/drivers/media/platform/renesas/rcar_jpu.c
> +++ b/drivers/media/platform/renesas/rcar_jpu.c
> @@ -480,11 +480,6 @@ static struct jpu_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
> return container_of(c->handler, struct jpu_ctx, ctrl_handler);
> }
>
> -static struct jpu_ctx *fh_to_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct jpu_ctx, fh);
> -}
> -
> static struct jpu_ctx *file_to_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct jpu_ctx, fh);
> @@ -661,7 +656,7 @@ static u8 jpu_parse_hdr(void *buffer, unsigned long size, unsigned int *width,
> static int jpu_querycap(struct file *file, void *priv,
> struct v4l2_capability *cap)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> if (ctx->encoder)
> strscpy(cap->card, DRV_NAME " encoder", sizeof(cap->card));
> @@ -719,7 +714,7 @@ static int jpu_enum_fmt(struct v4l2_fmtdesc *f, u32 type)
> static int jpu_enum_fmt_cap(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_CAPTURE :
> JPU_DEC_CAPTURE);
> @@ -728,7 +723,7 @@ static int jpu_enum_fmt_cap(struct file *file, void *priv,
> static int jpu_enum_fmt_out(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_OUTPUT : JPU_DEC_OUTPUT);
> }
> @@ -828,7 +823,7 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>
> static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -839,7 +834,7 @@ static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> struct vb2_queue *vq;
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
> struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
> struct jpu_fmt *fmtinfo;
> struct jpu_q_data *q_data;
> @@ -868,8 +863,8 @@ static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>
> static int jpu_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> + struct jpu_ctx *ctx = file_to_ctx(file);
> struct jpu_q_data *q_data;
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -902,8 +897,8 @@ static const struct v4l2_ctrl_ops jpu_ctrl_ops = {
>
> static int jpu_streamon(struct file *file, void *priv, enum v4l2_buf_type type)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> struct jpu_q_data *src_q_data, *dst_q_data, *orig, adj, *ref;
> + struct jpu_ctx *ctx = file_to_ctx(file);
> enum v4l2_buf_type adj_type;
>
> src_q_data = jpu_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
> @@ -1284,8 +1279,8 @@ static int jpu_open(struct file *file)
>
> static int jpu_release(struct file *file)
> {
> - struct jpu *jpu = video_drvdata(file);
> struct jpu_ctx *ctx = file_to_ctx(file);
> + struct jpu *jpu = video_drvdata(file);
>
> v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> v4l2_ctrl_handler_free(&ctx->ctrl_handler);
>
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 11/65] media: Replace file->private_data access with custom functions
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
@ 2025-08-06 8:16 ` Hans Verkuil
2025-08-06 9:48 ` Laurent Pinchart
2025-08-18 14:10 ` Lukasz Stelmach
1 sibling, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-06 8:16 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 02/08/2025 11:22, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> 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 and cast it to driver-specific file handle
> structures with driver-specific functions that use file_to_v4l2_fh() and
> perform the same cast.
>
> 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@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> drivers/media/pci/ivtv/ivtv-driver.h | 5 ++++
> drivers/media/pci/ivtv/ivtv-fileops.c | 10 +++----
> drivers/media/pci/ivtv/ivtv-ioctl.c | 8 +++---
> drivers/media/platform/allegro-dvt/allegro-core.c | 7 ++++-
> drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 8 ++++--
> .../media/platform/chips-media/coda/coda-common.c | 7 ++++-
> .../platform/chips-media/wave5/wave5-helper.c | 2 +-
> .../media/platform/chips-media/wave5/wave5-vpu.h | 5 ++++
> drivers/media/platform/m2m-deinterlace.c | 7 ++++-
> .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 ++++-
> drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 7 ++++-
> .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 7 ++++-
> .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 2 +-
> .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 5 ++++
> .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 2 +-
> .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 5 ++++
> drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 7 ++++-
> drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 7 ++++-
> drivers/media/platform/nxp/mx2_emmaprp.c | 7 ++++-
> drivers/media/platform/renesas/rcar_fdp1.c | 7 ++++-
> drivers/media/platform/renesas/rcar_jpu.c | 7 ++++-
> drivers/media/platform/rockchip/rga/rga.c | 3 +--
> drivers/media/platform/rockchip/rga/rga.h | 5 ++++
> drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
> drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 ++++
> .../media/platform/samsung/exynos-gsc/gsc-core.h | 6 +++++
> .../media/platform/samsung/exynos-gsc/gsc-m2m.c | 6 ++---
> .../media/platform/samsung/exynos4-is/fimc-core.h | 5 ++++
> .../media/platform/samsung/exynos4-is/fimc-m2m.c | 2 +-
> drivers/media/platform/samsung/s5p-g2d/g2d.c | 7 +++--
> .../media/platform/samsung/s5p-jpeg/jpeg-core.c | 9 +++++--
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 6 ++---
> .../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +++++
> drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 7 ++++-
> drivers/media/platform/st/sti/delta/delta-v4l2.c | 26 +++++++++++-------
> drivers/media/platform/st/sti/hva/hva-v4l2.c | 31 ++++++++++++----------
> drivers/media/platform/st/sti/hva/hva.h | 2 --
> drivers/media/platform/st/stm32/dma2d/dma2d.c | 7 +++--
> drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +--
> .../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +--
> drivers/media/platform/ti/omap3isp/ispvideo.c | 4 +--
> drivers/media/platform/ti/omap3isp/ispvideo.h | 6 +++++
> drivers/media/platform/verisilicon/hantro.h | 5 ++++
> drivers/media/platform/verisilicon/hantro_drv.c | 3 +--
> drivers/staging/media/imx/imx-media-csc-scaler.c | 7 ++++-
> drivers/staging/media/meson/vdec/vdec.c | 24 ++++++-----------
> drivers/staging/media/meson/vdec/vdec.h | 5 ++++
> drivers/staging/media/sunxi/cedrus/cedrus.c | 3 +--
> drivers/staging/media/sunxi/cedrus/cedrus.h | 5 ++++
> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 ----
> 50 files changed, 237 insertions(+), 100 deletions(-)
>
> diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
> index a6ffa99e16bc64a5b7d3e48c1ab32b49a7989242..cad548b28e360ecfe2bcb9fcb5d12cd8823c3727 100644
> --- a/drivers/media/pci/ivtv/ivtv-driver.h
> +++ b/drivers/media/pci/ivtv/ivtv-driver.h
> @@ -388,6 +388,11 @@ static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
> return container_of(fh, struct ivtv_open_id, fh);
> }
>
> +static inline struct ivtv_open_id *file2id(struct file *filp)
> +{
> + return container_of(file_to_v4l2_fh(filp), struct ivtv_open_id, fh);
Why not write:
return fh2id(file_to_v4l2_fh(filp));
Same for all other drivers that do this. I prefer to have the contained_of()
in just one place.
> +}
> +
> struct yuv_frame_info
> {
> u32 update;
<snip>
> diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
> index 1f134e08923a528cc676f825da68951c97ac2f25..74977f3ae4844022c04de877f31b4fc6aaac0749 100644
> --- a/drivers/media/platform/allegro-dvt/allegro-core.c
> +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
> @@ -302,6 +302,11 @@ struct allegro_channel {
> unsigned int error;
> };
>
> +static inline struct allegro_channel *file_to_channel(struct file *filp)
> +{
> + return container_of(file_to_v4l2_fh(filp), struct allegro_channel, fh);
> +}
> +
> static inline int
> allegro_channel_get_i_frame_qp(struct allegro_channel *channel)
> {
> @@ -3229,7 +3234,7 @@ static int allegro_open(struct file *file)
>
> static int allegro_release(struct file *file)
> {
> - struct allegro_channel *channel = fh_to_channel(file->private_data);
> + struct allegro_channel *channel = file_to_channel(file);
So a file_to_channel inline function was added, but it is used in just one
place.
I would prefer to just drop the inline function and instead write:
struct allegro_channel *channel = fh_to_channel(file_to_v4l2_fh(file));
If this is needed in two or more places, then the extra inline makes sense,
but it is a fairly common pattern that it is only needed in the release function.
Adding a new inline just for that seems overkill to me.
>
> v4l2_m2m_ctx_release(channel->fh.m2m_ctx);
>
Regards,
Hans
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 11/65] media: Replace file->private_data access with custom functions
2025-08-06 8:16 ` Hans Verkuil
@ 2025-08-06 9:48 ` Laurent Pinchart
2025-08-06 10:23 ` Hans Verkuil
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-06 9:48 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Hans,
On Wed, Aug 06, 2025 at 10:16:37AM +0200, Hans Verkuil wrote:
> On 02/08/2025 11:22, Jacopo Mondi wrote:
> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > 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 and cast it to driver-specific file handle
> > structures with driver-specific functions that use file_to_v4l2_fh() and
> > perform the same cast.
> >
> > 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@ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > ---
> > drivers/media/pci/ivtv/ivtv-driver.h | 5 ++++
> > drivers/media/pci/ivtv/ivtv-fileops.c | 10 +++----
> > drivers/media/pci/ivtv/ivtv-ioctl.c | 8 +++---
> > drivers/media/platform/allegro-dvt/allegro-core.c | 7 ++++-
> > drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 8 ++++--
> > .../media/platform/chips-media/coda/coda-common.c | 7 ++++-
> > .../platform/chips-media/wave5/wave5-helper.c | 2 +-
> > .../media/platform/chips-media/wave5/wave5-vpu.h | 5 ++++
> > drivers/media/platform/m2m-deinterlace.c | 7 ++++-
> > .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 ++++-
> > drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 7 ++++-
> > .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 7 ++++-
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 2 +-
> > .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 5 ++++
> > .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 2 +-
> > .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 5 ++++
> > drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 7 ++++-
> > drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 7 ++++-
> > drivers/media/platform/nxp/mx2_emmaprp.c | 7 ++++-
> > drivers/media/platform/renesas/rcar_fdp1.c | 7 ++++-
> > drivers/media/platform/renesas/rcar_jpu.c | 7 ++++-
> > drivers/media/platform/rockchip/rga/rga.c | 3 +--
> > drivers/media/platform/rockchip/rga/rga.h | 5 ++++
> > drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
> > drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 ++++
> > .../media/platform/samsung/exynos-gsc/gsc-core.h | 6 +++++
> > .../media/platform/samsung/exynos-gsc/gsc-m2m.c | 6 ++---
> > .../media/platform/samsung/exynos4-is/fimc-core.h | 5 ++++
> > .../media/platform/samsung/exynos4-is/fimc-m2m.c | 2 +-
> > drivers/media/platform/samsung/s5p-g2d/g2d.c | 7 +++--
> > .../media/platform/samsung/s5p-jpeg/jpeg-core.c | 9 +++++--
> > drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 6 ++---
> > .../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +++++
> > drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 7 ++++-
> > drivers/media/platform/st/sti/delta/delta-v4l2.c | 26 +++++++++++-------
> > drivers/media/platform/st/sti/hva/hva-v4l2.c | 31 ++++++++++++----------
> > drivers/media/platform/st/sti/hva/hva.h | 2 --
> > drivers/media/platform/st/stm32/dma2d/dma2d.c | 7 +++--
> > drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +--
> > .../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +--
> > drivers/media/platform/ti/omap3isp/ispvideo.c | 4 +--
> > drivers/media/platform/ti/omap3isp/ispvideo.h | 6 +++++
> > drivers/media/platform/verisilicon/hantro.h | 5 ++++
> > drivers/media/platform/verisilicon/hantro_drv.c | 3 +--
> > drivers/staging/media/imx/imx-media-csc-scaler.c | 7 ++++-
> > drivers/staging/media/meson/vdec/vdec.c | 24 ++++++-----------
> > drivers/staging/media/meson/vdec/vdec.h | 5 ++++
> > drivers/staging/media/sunxi/cedrus/cedrus.c | 3 +--
> > drivers/staging/media/sunxi/cedrus/cedrus.h | 5 ++++
> > drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 ----
> > 50 files changed, 237 insertions(+), 100 deletions(-)
> >
> > diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
> > index a6ffa99e16bc64a5b7d3e48c1ab32b49a7989242..cad548b28e360ecfe2bcb9fcb5d12cd8823c3727 100644
> > --- a/drivers/media/pci/ivtv/ivtv-driver.h
> > +++ b/drivers/media/pci/ivtv/ivtv-driver.h
> > @@ -388,6 +388,11 @@ static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
> > return container_of(fh, struct ivtv_open_id, fh);
> > }
> >
> > +static inline struct ivtv_open_id *file2id(struct file *filp)
> > +{
> > + return container_of(file_to_v4l2_fh(filp), struct ivtv_open_id, fh);
>
> Why not write:
>
> return fh2id(file_to_v4l2_fh(filp));
>
> Same for all other drivers that do this. I prefer to have the contained_of()
> in just one place.
Because fh2id gets removed in "[PATCH 57/65] media: ivtv: Access v4l2_fh
from file". I can use it in this patch and drop it later, would you
prefer that ?
> > +}
> > +
> > struct yuv_frame_info
> > {
> > u32 update;
>
> <snip>
>
> > diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
> > index 1f134e08923a528cc676f825da68951c97ac2f25..74977f3ae4844022c04de877f31b4fc6aaac0749 100644
> > --- a/drivers/media/platform/allegro-dvt/allegro-core.c
> > +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
> > @@ -302,6 +302,11 @@ struct allegro_channel {
> > unsigned int error;
> > };
> >
> > +static inline struct allegro_channel *file_to_channel(struct file *filp)
> > +{
> > + return container_of(file_to_v4l2_fh(filp), struct allegro_channel, fh);
> > +}
> > +
> > static inline int
> > allegro_channel_get_i_frame_qp(struct allegro_channel *channel)
> > {
> > @@ -3229,7 +3234,7 @@ static int allegro_open(struct file *file)
> >
> > static int allegro_release(struct file *file)
> > {
> > - struct allegro_channel *channel = fh_to_channel(file->private_data);
> > + struct allegro_channel *channel = file_to_channel(file);
>
> So a file_to_channel inline function was added, but it is used in just one
> place.
>
> I would prefer to just drop the inline function and instead write:
>
> struct allegro_channel *channel = fh_to_channel(file_to_v4l2_fh(file));
>
> If this is needed in two or more places, then the extra inline makes sense,
> but it is a fairly common pattern that it is only needed in the release function.
>
> Adding a new inline just for that seems overkill to me.
file_to_channel() gets used in more places in "[PATCH 29/65] media:
allegro: Access v4l2_fh from file", where fh_to_channel() is dropped.
I'd rather keep it in this patch instead of having to modify the
allegro_release() function in patch 29/65.
> >
> > v4l2_m2m_ctx_release(channel->fh.m2m_ctx);
> >
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 11/65] media: Replace file->private_data access with custom functions
2025-08-06 9:48 ` Laurent Pinchart
@ 2025-08-06 10:23 ` Hans Verkuil
0 siblings, 0 replies; 101+ messages in thread
From: Hans Verkuil @ 2025-08-06 10:23 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 06/08/2025 11:48, Laurent Pinchart wrote:
> Hi Hans,
>
> On Wed, Aug 06, 2025 at 10:16:37AM +0200, Hans Verkuil wrote:
>> On 02/08/2025 11:22, Jacopo Mondi wrote:
>>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>
>>> 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 and cast it to driver-specific file handle
>>> structures with driver-specific functions that use file_to_v4l2_fh() and
>>> perform the same cast.
>>>
>>> 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@ideasonboard.com>
>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>>> ---
>>> drivers/media/pci/ivtv/ivtv-driver.h | 5 ++++
>>> drivers/media/pci/ivtv/ivtv-fileops.c | 10 +++----
>>> drivers/media/pci/ivtv/ivtv-ioctl.c | 8 +++---
>>> drivers/media/platform/allegro-dvt/allegro-core.c | 7 ++++-
>>> drivers/media/platform/amlogic/meson-ge2d/ge2d.c | 8 ++++--
>>> .../media/platform/chips-media/coda/coda-common.c | 7 ++++-
>>> .../platform/chips-media/wave5/wave5-helper.c | 2 +-
>>> .../media/platform/chips-media/wave5/wave5-vpu.h | 5 ++++
>>> drivers/media/platform/m2m-deinterlace.c | 7 ++++-
>>> .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 ++++-
>>> drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c | 7 ++++-
>>> .../media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 7 ++++-
>>> .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 2 +-
>>> .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 5 ++++
>>> .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.c | 2 +-
>>> .../mediatek/vcodec/encoder/mtk_vcodec_enc_drv.h | 5 ++++
>>> drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 7 ++++-
>>> drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c | 7 ++++-
>>> drivers/media/platform/nxp/mx2_emmaprp.c | 7 ++++-
>>> drivers/media/platform/renesas/rcar_fdp1.c | 7 ++++-
>>> drivers/media/platform/renesas/rcar_jpu.c | 7 ++++-
>>> drivers/media/platform/rockchip/rga/rga.c | 3 +--
>>> drivers/media/platform/rockchip/rga/rga.h | 5 ++++
>>> drivers/media/platform/rockchip/rkvdec/rkvdec.c | 2 +-
>>> drivers/media/platform/rockchip/rkvdec/rkvdec.h | 5 ++++
>>> .../media/platform/samsung/exynos-gsc/gsc-core.h | 6 +++++
>>> .../media/platform/samsung/exynos-gsc/gsc-m2m.c | 6 ++---
>>> .../media/platform/samsung/exynos4-is/fimc-core.h | 5 ++++
>>> .../media/platform/samsung/exynos4-is/fimc-m2m.c | 2 +-
>>> drivers/media/platform/samsung/s5p-g2d/g2d.c | 7 +++--
>>> .../media/platform/samsung/s5p-jpeg/jpeg-core.c | 9 +++++--
>>> drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 6 ++---
>>> .../platform/samsung/s5p-mfc/s5p_mfc_common.h | 6 +++++
>>> drivers/media/platform/st/sti/bdisp/bdisp-v4l2.c | 7 ++++-
>>> drivers/media/platform/st/sti/delta/delta-v4l2.c | 26 +++++++++++-------
>>> drivers/media/platform/st/sti/hva/hva-v4l2.c | 31 ++++++++++++----------
>>> drivers/media/platform/st/sti/hva/hva.h | 2 --
>>> drivers/media/platform/st/stm32/dma2d/dma2d.c | 7 +++--
>>> drivers/media/platform/sunxi/sun8i-di/sun8i-di.c | 3 +--
>>> .../platform/sunxi/sun8i-rotate/sun8i_rotate.c | 3 +--
>>> drivers/media/platform/ti/omap3isp/ispvideo.c | 4 +--
>>> drivers/media/platform/ti/omap3isp/ispvideo.h | 6 +++++
>>> drivers/media/platform/verisilicon/hantro.h | 5 ++++
>>> drivers/media/platform/verisilicon/hantro_drv.c | 3 +--
>>> drivers/staging/media/imx/imx-media-csc-scaler.c | 7 ++++-
>>> drivers/staging/media/meson/vdec/vdec.c | 24 ++++++-----------
>>> drivers/staging/media/meson/vdec/vdec.h | 5 ++++
>>> drivers/staging/media/sunxi/cedrus/cedrus.c | 3 +--
>>> drivers/staging/media/sunxi/cedrus/cedrus.h | 5 ++++
>>> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 5 ----
>>> 50 files changed, 237 insertions(+), 100 deletions(-)
>>>
>>> diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
>>> index a6ffa99e16bc64a5b7d3e48c1ab32b49a7989242..cad548b28e360ecfe2bcb9fcb5d12cd8823c3727 100644
>>> --- a/drivers/media/pci/ivtv/ivtv-driver.h
>>> +++ b/drivers/media/pci/ivtv/ivtv-driver.h
>>> @@ -388,6 +388,11 @@ static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
>>> return container_of(fh, struct ivtv_open_id, fh);
>>> }
>>>
>>> +static inline struct ivtv_open_id *file2id(struct file *filp)
>>> +{
>>> + return container_of(file_to_v4l2_fh(filp), struct ivtv_open_id, fh);
>>
>> Why not write:
>>
>> return fh2id(file_to_v4l2_fh(filp));
>>
>> Same for all other drivers that do this. I prefer to have the contained_of()
>> in just one place.
>
> Because fh2id gets removed in "[PATCH 57/65] media: ivtv: Access v4l2_fh
> from file". I can use it in this patch and drop it later, would you
> prefer that ?
Based on the irc discussion some drivers need both, so yes, I prefer that the
file2foo inline calls the fh2foo inline.
Regards,
Hans
>
>>> +}
>>> +
>>> struct yuv_frame_info
>>> {
>>> u32 update;
>>
>> <snip>
>>
>>> diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
>>> index 1f134e08923a528cc676f825da68951c97ac2f25..74977f3ae4844022c04de877f31b4fc6aaac0749 100644
>>> --- a/drivers/media/platform/allegro-dvt/allegro-core.c
>>> +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
>>> @@ -302,6 +302,11 @@ struct allegro_channel {
>>> unsigned int error;
>>> };
>>>
>>> +static inline struct allegro_channel *file_to_channel(struct file *filp)
>>> +{
>>> + return container_of(file_to_v4l2_fh(filp), struct allegro_channel, fh);
>>> +}
>>> +
>>> static inline int
>>> allegro_channel_get_i_frame_qp(struct allegro_channel *channel)
>>> {
>>> @@ -3229,7 +3234,7 @@ static int allegro_open(struct file *file)
>>>
>>> static int allegro_release(struct file *file)
>>> {
>>> - struct allegro_channel *channel = fh_to_channel(file->private_data);
>>> + struct allegro_channel *channel = file_to_channel(file);
>>
>> So a file_to_channel inline function was added, but it is used in just one
>> place.
>>
>> I would prefer to just drop the inline function and instead write:
>>
>> struct allegro_channel *channel = fh_to_channel(file_to_v4l2_fh(file));
>>
>> If this is needed in two or more places, then the extra inline makes sense,
>> but it is a fairly common pattern that it is only needed in the release function.
>>
>> Adding a new inline just for that seems overkill to me.
>
> file_to_channel() gets used in more places in "[PATCH 29/65] media:
> allegro: Access v4l2_fh from file", where fh_to_channel() is dropped.
> I'd rather keep it in this patch instead of having to modify the
> allegro_release() function in patch 29/65.
>
>>>
>>> v4l2_m2m_ctx_release(channel->fh.m2m_ctx);
>>>
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
@ 2025-08-06 12:45 ` Hans Verkuil
2025-08-07 8:50 ` Laurent Pinchart
2025-08-18 14:12 ` Lukasz Stelmach
1 sibling, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-06 12:45 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 02/08/2025 11:22, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> 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@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
> Documentation/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 ++--
> .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
> .../media/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(-)
>
<snip>
> diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
Instead of adding a second argument, perhaps it is better to
just provide the filp pointer. After all, you can get the v4l2_fh
from filp->private_data.
It simplifies the code a bit.
Regards,
Hans
> {
> 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;
> }
<snip>
> diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
> index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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.
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 58/65] media: zoran: Remove access to __fh
2025-08-02 9:23 ` [PATCH 58/65] media: zoran: Remove access to __fh Jacopo Mondi
@ 2025-08-07 6:58 ` Hans Verkuil
2025-08-07 12:31 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 6:58 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 02/08/2025 11:23, Jacopo Mondi wrote:
> The __fh parameter is assigned to an unsued variable. Remove it
> and remove the unused struct zoran_fh type.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> drivers/media/pci/zoran/zoran.h | 6 ------
> drivers/media/pci/zoran/zoran_driver.c | 3 +--
> 2 files changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/media/pci/zoran/zoran.h b/drivers/media/pci/zoran/zoran.h
> index 1cd990468d3de9db8b14b72483972041c57bfee2..d05e222b392156bf1b3b4c83c6591db642c3c377 100644
> --- a/drivers/media/pci/zoran/zoran.h
> +++ b/drivers/media/pci/zoran/zoran.h
> @@ -154,12 +154,6 @@ struct zoran_jpg_settings {
>
> struct zoran;
>
> -/* zoran_fh contains per-open() settings */
> -struct zoran_fh {
> - struct v4l2_fh fh;
> - struct zoran *zr;
> -};
> -
> struct card_info {
> enum card_type type;
> char name[32];
> diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
> index f42f596d3e6295e31e3b33cd83c5f7243911bd30..ec7fc1da4cc02f5a344cb49bb9a783c41c758195 100644
> --- a/drivers/media/pci/zoran/zoran_driver.c
> +++ b/drivers/media/pci/zoran/zoran_driver.c
> @@ -511,12 +511,11 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
This driver uses __fh as the name for the second argument of the ioctl
callbacks. Can you take this opportunity to rename it to either 'fh' or 'priv'?
Generally it's not a good idea to prefix variables with __ for no good reason.
Grepping for __fh also shows two other drivers:
drivers/media/platform/chips-media/coda/coda-common.c:#define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh)
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h:#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
I think it is a good idea to rename __fh to fh there as well.
Regards,
Hans
> struct v4l2_format *fmt)
> {
> struct zoran *zr = video_drvdata(file);
> - struct zoran_fh *fh = __fh;
> int i;
> int res = 0;
>
> if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
> - return zoran_s_fmt_vid_out(file, fh, fmt);
> + return zoran_s_fmt_vid_out(file, __fh, fmt);
>
> for (i = 0; i < NUM_FORMATS; i++)
> if (fmt->fmt.pix.pixelformat == zoran_formats[i].fourcc)
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-02 9:23 ` [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers Jacopo Mondi
@ 2025-08-07 7:26 ` Hans Verkuil
2025-08-07 7:58 ` Hans Verkuil
0 siblings, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 7:26 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 02/08/2025 11:23, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> Now that all drivers access the v4l2_fh from the file structure, there
> is no need to pass it as an explicit argument to ioctl handlers. Set the
> argument to NULL in the w__video_do_ioctl(), and drop the name of the
> void *fh argument in the ioctl handler declarations to indicate it is
> not used.
>
> The argument could be removed altogether with a mechanical change
> (probably using coccinelle), but there are plans to pass a new argument
> to the ioctl handlers in the near future. The tree-wide change to remove
> the argument, only to add another one soon after, would be too much
> churn.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
> drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
> include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
> 2 files changed, 120 insertions(+), 121 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
> bool write_only = false;
> struct v4l2_ioctl_info default_info;
> const struct v4l2_ioctl_info *info;
> - void *fh = file_to_v4l2_fh(file);
> struct v4l2_fh *vfh = NULL;
> int dev_debug = vfd->dev_debug;
> long ret = -ENOTTY;
> @@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
>
> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
> if (info != &default_info) {
> - ret = info->func(ops, file, fh, arg);
> + ret = info->func(ops, file, NULL, arg);
> } else if (!ops->vidioc_default) {
> ret = -ENOTTY;
> } else {
> - ret = ops->vidioc_default(file, fh,
> + ret = ops->vidioc_default(file, NULL,
> vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
> cmd, arg);
> }
drivers/media/v4l2-core/v4l2-compat-ioctl32.c also calls ops->vidioc_query_ext_ctrl
directly, but still passes the fh as second argument: that needs to be replaced by
a NULL pointer as well. That should be fixed in this patch as well.
Regarding v4l2-ioctl.c: I would like a follow-up patch that pushes the NULL pointer
down into each ioctl helper function. I.e. drop the 'void *fh' argument in the
struct v4l2_ioctl_info 'func' callback, and all callbacks like v4l_g_fmt() just
replace 'fh' by 'NULL' when they call the vidioc op.
Part of it is that the core functions currently suggest that the second argument is
a filehandle (since it's still named 'fh'), which is obviously wrong. And I also think
that the core framework shouldn't use a dummy second argument at all. I admit that
changing all vidioc callbacks in the whole subsystem to drop the second argument is
too much churn, but for this core file I think it is something that should be done.
Regards,
Hans
> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
> index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
> --- a/include/media/v4l2-ioctl.h
> +++ b/include/media/v4l2-ioctl.h
> @@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
> /* ioctl callbacks */
>
> /* VIDIOC_QUERYCAP handler */
> - int (*vidioc_querycap)(struct file *file, void *fh,
> + int (*vidioc_querycap)(struct file *file, void *,
> struct v4l2_capability *cap);
>
> /* VIDIOC_ENUM_FMT handlers */
> - int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
> - int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
> + int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
> struct v4l2_fmtdesc *f);
>
> /* VIDIOC_G_FMT handlers */
> - int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
> + int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
> struct v4l2_format *f);
>
> /* VIDIOC_S_FMT handlers */
> - int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
> + int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
> struct v4l2_format *f);
>
> /* VIDIOC_TRY_FMT handlers */
> - int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
> struct v4l2_format *f);
> - int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
> + int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
> struct v4l2_format *f);
>
> /* Buffer handlers */
> - int (*vidioc_reqbufs)(struct file *file, void *fh,
> + int (*vidioc_reqbufs)(struct file *file, void *,
> struct v4l2_requestbuffers *b);
> - int (*vidioc_querybuf)(struct file *file, void *fh,
> + int (*vidioc_querybuf)(struct file *file, void *,
> struct v4l2_buffer *b);
> - int (*vidioc_qbuf)(struct file *file, void *fh,
> + int (*vidioc_qbuf)(struct file *file, void *,
> struct v4l2_buffer *b);
> - int (*vidioc_expbuf)(struct file *file, void *fh,
> + int (*vidioc_expbuf)(struct file *file, void *,
> struct v4l2_exportbuffer *e);
> - int (*vidioc_dqbuf)(struct file *file, void *fh,
> + int (*vidioc_dqbuf)(struct file *file, void *,
> struct v4l2_buffer *b);
>
> - int (*vidioc_create_bufs)(struct file *file, void *fh,
> + int (*vidioc_create_bufs)(struct file *file, void *,
> struct v4l2_create_buffers *b);
> - int (*vidioc_prepare_buf)(struct file *file, void *fh,
> + int (*vidioc_prepare_buf)(struct file *file, void *,
> struct v4l2_buffer *b);
> - int (*vidioc_remove_bufs)(struct file *file, void *fh,
> + int (*vidioc_remove_bufs)(struct file *file, void *,
> struct v4l2_remove_buffers *d);
>
> - int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
> - int (*vidioc_g_fbuf)(struct file *file, void *fh,
> + int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
> + int (*vidioc_g_fbuf)(struct file *file, void *,
> struct v4l2_framebuffer *a);
> - int (*vidioc_s_fbuf)(struct file *file, void *fh,
> + int (*vidioc_s_fbuf)(struct file *file, void *,
> const struct v4l2_framebuffer *a);
>
> /* Stream on/off */
> - int (*vidioc_streamon)(struct file *file, void *fh,
> + int (*vidioc_streamon)(struct file *file, void *,
> enum v4l2_buf_type i);
> - int (*vidioc_streamoff)(struct file *file, void *fh,
> + int (*vidioc_streamoff)(struct file *file, void *,
> enum v4l2_buf_type i);
>
> /*
> @@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
> *
> * Note: ENUMSTD is handled by videodev.c
> */
> - int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
> - int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
> - int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
> + int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
> + int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
> + int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
>
> /* Input handling */
> - int (*vidioc_enum_input)(struct file *file, void *fh,
> + int (*vidioc_enum_input)(struct file *file, void *,
> struct v4l2_input *inp);
> - int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
> - int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
> + int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
> + int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
>
> /* Output handling */
> - int (*vidioc_enum_output)(struct file *file, void *fh,
> + int (*vidioc_enum_output)(struct file *file, void *,
> struct v4l2_output *a);
> - int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
> - int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
> + int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
> + int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
>
> /* Control handling */
> - int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
> + int (*vidioc_query_ext_ctrl)(struct file *file, void *,
> struct v4l2_query_ext_ctrl *a);
> - int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
> + int (*vidioc_g_ext_ctrls)(struct file *file, void *,
> struct v4l2_ext_controls *a);
> - int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
> + int (*vidioc_s_ext_ctrls)(struct file *file, void *,
> struct v4l2_ext_controls *a);
> - int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
> + int (*vidioc_try_ext_ctrls)(struct file *file, void *,
> struct v4l2_ext_controls *a);
> - int (*vidioc_querymenu)(struct file *file, void *fh,
> + int (*vidioc_querymenu)(struct file *file, void *,
> struct v4l2_querymenu *a);
>
> /* Audio ioctls */
> - int (*vidioc_enumaudio)(struct file *file, void *fh,
> + int (*vidioc_enumaudio)(struct file *file, void *,
> struct v4l2_audio *a);
> - int (*vidioc_g_audio)(struct file *file, void *fh,
> + int (*vidioc_g_audio)(struct file *file, void *,
> struct v4l2_audio *a);
> - int (*vidioc_s_audio)(struct file *file, void *fh,
> + int (*vidioc_s_audio)(struct file *file, void *,
> const struct v4l2_audio *a);
>
> /* Audio out ioctls */
> - int (*vidioc_enumaudout)(struct file *file, void *fh,
> + int (*vidioc_enumaudout)(struct file *file, void *,
> struct v4l2_audioout *a);
> - int (*vidioc_g_audout)(struct file *file, void *fh,
> + int (*vidioc_g_audout)(struct file *file, void *,
> struct v4l2_audioout *a);
> - int (*vidioc_s_audout)(struct file *file, void *fh,
> + int (*vidioc_s_audout)(struct file *file, void *,
> const struct v4l2_audioout *a);
> - int (*vidioc_g_modulator)(struct file *file, void *fh,
> + int (*vidioc_g_modulator)(struct file *file, void *,
> struct v4l2_modulator *a);
> - int (*vidioc_s_modulator)(struct file *file, void *fh,
> + int (*vidioc_s_modulator)(struct file *file, void *,
> const struct v4l2_modulator *a);
> /* Crop ioctls */
> - int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
> + int (*vidioc_g_pixelaspect)(struct file *file, void *,
> int buf_type, struct v4l2_fract *aspect);
> - int (*vidioc_g_selection)(struct file *file, void *fh,
> + int (*vidioc_g_selection)(struct file *file, void *,
> struct v4l2_selection *s);
> - int (*vidioc_s_selection)(struct file *file, void *fh,
> + int (*vidioc_s_selection)(struct file *file, void *,
> struct v4l2_selection *s);
> /* Compression ioctls */
> - int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
> + int (*vidioc_g_jpegcomp)(struct file *file, void *,
> struct v4l2_jpegcompression *a);
> - int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
> + int (*vidioc_s_jpegcomp)(struct file *file, void *,
> const struct v4l2_jpegcompression *a);
> - int (*vidioc_g_enc_index)(struct file *file, void *fh,
> + int (*vidioc_g_enc_index)(struct file *file, void *,
> struct v4l2_enc_idx *a);
> - int (*vidioc_encoder_cmd)(struct file *file, void *fh,
> + int (*vidioc_encoder_cmd)(struct file *file, void *,
> struct v4l2_encoder_cmd *a);
> - int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
> + int (*vidioc_try_encoder_cmd)(struct file *file, void *,
> struct v4l2_encoder_cmd *a);
> - int (*vidioc_decoder_cmd)(struct file *file, void *fh,
> + int (*vidioc_decoder_cmd)(struct file *file, void *,
> struct v4l2_decoder_cmd *a);
> - int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
> + int (*vidioc_try_decoder_cmd)(struct file *file, void *,
> struct v4l2_decoder_cmd *a);
>
> /* Stream type-dependent parameter ioctls */
> - int (*vidioc_g_parm)(struct file *file, void *fh,
> + int (*vidioc_g_parm)(struct file *file, void *,
> struct v4l2_streamparm *a);
> - int (*vidioc_s_parm)(struct file *file, void *fh,
> + int (*vidioc_s_parm)(struct file *file, void *,
> struct v4l2_streamparm *a);
>
> /* Tuner ioctls */
> - int (*vidioc_g_tuner)(struct file *file, void *fh,
> + int (*vidioc_g_tuner)(struct file *file, void *,
> struct v4l2_tuner *a);
> - int (*vidioc_s_tuner)(struct file *file, void *fh,
> + int (*vidioc_s_tuner)(struct file *file, void *,
> const struct v4l2_tuner *a);
> - int (*vidioc_g_frequency)(struct file *file, void *fh,
> + int (*vidioc_g_frequency)(struct file *file, void *,
> struct v4l2_frequency *a);
> - int (*vidioc_s_frequency)(struct file *file, void *fh,
> + int (*vidioc_s_frequency)(struct file *file, void *,
> const struct v4l2_frequency *a);
> - int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
> + int (*vidioc_enum_freq_bands)(struct file *file, void *,
> struct v4l2_frequency_band *band);
>
> /* Sliced VBI cap */
> - int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
> + int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
> struct v4l2_sliced_vbi_cap *a);
>
> /* Log status ioctl */
> - int (*vidioc_log_status)(struct file *file, void *fh);
> + int (*vidioc_log_status)(struct file *file, void *);
>
> - int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
> + int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
> const struct v4l2_hw_freq_seek *a);
>
> /* Debugging ioctls */
> #ifdef CONFIG_VIDEO_ADV_DEBUG
> - int (*vidioc_g_register)(struct file *file, void *fh,
> + int (*vidioc_g_register)(struct file *file, void *,
> struct v4l2_dbg_register *reg);
> - int (*vidioc_s_register)(struct file *file, void *fh,
> + int (*vidioc_s_register)(struct file *file, void *,
> const struct v4l2_dbg_register *reg);
>
> - int (*vidioc_g_chip_info)(struct file *file, void *fh,
> + int (*vidioc_g_chip_info)(struct file *file, void *,
> struct v4l2_dbg_chip_info *chip);
> #endif
>
> - int (*vidioc_enum_framesizes)(struct file *file, void *fh,
> + int (*vidioc_enum_framesizes)(struct file *file, void *,
> struct v4l2_frmsizeenum *fsize);
>
> - int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
> + int (*vidioc_enum_frameintervals)(struct file *file, void *,
> struct v4l2_frmivalenum *fival);
>
> /* DV Timings IOCTLs */
> - int (*vidioc_s_dv_timings)(struct file *file, void *fh,
> + int (*vidioc_s_dv_timings)(struct file *file, void *,
> struct v4l2_dv_timings *timings);
> - int (*vidioc_g_dv_timings)(struct file *file, void *fh,
> + int (*vidioc_g_dv_timings)(struct file *file, void *,
> struct v4l2_dv_timings *timings);
> - int (*vidioc_query_dv_timings)(struct file *file, void *fh,
> + int (*vidioc_query_dv_timings)(struct file *file, void *,
> struct v4l2_dv_timings *timings);
> - int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
> + int (*vidioc_enum_dv_timings)(struct file *file, void *,
> struct v4l2_enum_dv_timings *timings);
> - int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
> + int (*vidioc_dv_timings_cap)(struct file *file, void *,
> struct v4l2_dv_timings_cap *cap);
> - int (*vidioc_g_edid)(struct file *file, void *fh,
> + int (*vidioc_g_edid)(struct file *file, void *,
> struct v4l2_edid *edid);
> - int (*vidioc_s_edid)(struct file *file, void *fh,
> + int (*vidioc_s_edid)(struct file *file, void *,
> struct v4l2_edid *edid);
>
> int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
> @@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
> const struct v4l2_event_subscription *sub);
>
> /* For other private ioctls */
> - long (*vidioc_default)(struct file *file, void *fh,
> + long (*vidioc_default)(struct file *file, void *,
> bool valid_prio, unsigned int cmd, void *arg);
> };
>
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-07 7:26 ` Hans Verkuil
@ 2025-08-07 7:58 ` Hans Verkuil
2025-08-07 20:33 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 7:58 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 07/08/2025 09:26, Hans Verkuil wrote:
> On 02/08/2025 11:23, Jacopo Mondi wrote:
>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>
>> Now that all drivers access the v4l2_fh from the file structure, there
>> is no need to pass it as an explicit argument to ioctl handlers. Set the
>> argument to NULL in the w__video_do_ioctl(), and drop the name of the
>> void *fh argument in the ioctl handler declarations to indicate it is
>> not used.
>>
>> The argument could be removed altogether with a mechanical change
>> (probably using coccinelle), but there are plans to pass a new argument
>> to the ioctl handlers in the near future. The tree-wide change to remove
>> the argument, only to add another one soon after, would be too much
>> churn.
>>
>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>> ---
>> drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
>> include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
>> 2 files changed, 120 insertions(+), 121 deletions(-)
>>
>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
>> index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>> @@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
>> bool write_only = false;
>> struct v4l2_ioctl_info default_info;
>> const struct v4l2_ioctl_info *info;
>> - void *fh = file_to_v4l2_fh(file);
>> struct v4l2_fh *vfh = NULL;
>> int dev_debug = vfd->dev_debug;
>> long ret = -ENOTTY;
>> @@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
>>
>> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
>> if (info != &default_info) {
>> - ret = info->func(ops, file, fh, arg);
>> + ret = info->func(ops, file, NULL, arg);
>> } else if (!ops->vidioc_default) {
>> ret = -ENOTTY;
>> } else {
>> - ret = ops->vidioc_default(file, fh,
>> + ret = ops->vidioc_default(file, NULL,
>> vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
>> cmd, arg);
>> }
>
> drivers/media/v4l2-core/v4l2-compat-ioctl32.c also calls ops->vidioc_query_ext_ctrl
> directly, but still passes the fh as second argument: that needs to be replaced by
> a NULL pointer as well. That should be fixed in this patch as well.
>
> Regarding v4l2-ioctl.c: I would like a follow-up patch that pushes the NULL pointer
> down into each ioctl helper function. I.e. drop the 'void *fh' argument in the
> struct v4l2_ioctl_info 'func' callback, and all callbacks like v4l_g_fmt() just
> replace 'fh' by 'NULL' when they call the vidioc op.
>
> Part of it is that the core functions currently suggest that the second argument is
> a filehandle (since it's still named 'fh'), which is obviously wrong. And I also think
> that the core framework shouldn't use a dummy second argument at all. I admit that
> changing all vidioc callbacks in the whole subsystem to drop the second argument is
> too much churn, but for this core file I think it is something that should be done.
A follow-up on this: I would not be against a large patch that drops the second priv
argument from all vidioc ops since it is now unused. If nothing else, it helps ensure
that it is really unused by all drivers :-)
But if you don't want to go there, then there is something that I think need to be addressed:
a lot of drivers name the second argument 'fh' or '_fh' or even 'fh0'. Can we add a patch that
renames the second arg to 'priv'?
At minimum I think this should be done for drivers/media/test-drivers and
samples/v4l/v4l2-pci-skeleton.c. These drivers are often used as reference drivers,
so they should be up-to-date.
I would also suggest to do this for uvc since it is by far the most widely used media
driver.
I also see the use of 'fh' in v4l2-mem2mem.c in a few places.
Regards,
Hans
>
> Regards,
>
> Hans
>
>> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
>> index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
>> --- a/include/media/v4l2-ioctl.h
>> +++ b/include/media/v4l2-ioctl.h
>> @@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
>> /* ioctl callbacks */
>>
>> /* VIDIOC_QUERYCAP handler */
>> - int (*vidioc_querycap)(struct file *file, void *fh,
>> + int (*vidioc_querycap)(struct file *file, void *,
>> struct v4l2_capability *cap);
>>
>> /* VIDIOC_ENUM_FMT handlers */
>> - int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>> - int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
>> + int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
>> struct v4l2_fmtdesc *f);
>>
>> /* VIDIOC_G_FMT handlers */
>> - int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
>> + int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
>> struct v4l2_format *f);
>>
>> /* VIDIOC_S_FMT handlers */
>> - int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
>> + int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
>> struct v4l2_format *f);
>>
>> /* VIDIOC_TRY_FMT handlers */
>> - int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
>> struct v4l2_format *f);
>> - int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
>> + int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
>> struct v4l2_format *f);
>>
>> /* Buffer handlers */
>> - int (*vidioc_reqbufs)(struct file *file, void *fh,
>> + int (*vidioc_reqbufs)(struct file *file, void *,
>> struct v4l2_requestbuffers *b);
>> - int (*vidioc_querybuf)(struct file *file, void *fh,
>> + int (*vidioc_querybuf)(struct file *file, void *,
>> struct v4l2_buffer *b);
>> - int (*vidioc_qbuf)(struct file *file, void *fh,
>> + int (*vidioc_qbuf)(struct file *file, void *,
>> struct v4l2_buffer *b);
>> - int (*vidioc_expbuf)(struct file *file, void *fh,
>> + int (*vidioc_expbuf)(struct file *file, void *,
>> struct v4l2_exportbuffer *e);
>> - int (*vidioc_dqbuf)(struct file *file, void *fh,
>> + int (*vidioc_dqbuf)(struct file *file, void *,
>> struct v4l2_buffer *b);
>>
>> - int (*vidioc_create_bufs)(struct file *file, void *fh,
>> + int (*vidioc_create_bufs)(struct file *file, void *,
>> struct v4l2_create_buffers *b);
>> - int (*vidioc_prepare_buf)(struct file *file, void *fh,
>> + int (*vidioc_prepare_buf)(struct file *file, void *,
>> struct v4l2_buffer *b);
>> - int (*vidioc_remove_bufs)(struct file *file, void *fh,
>> + int (*vidioc_remove_bufs)(struct file *file, void *,
>> struct v4l2_remove_buffers *d);
>>
>> - int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
>> - int (*vidioc_g_fbuf)(struct file *file, void *fh,
>> + int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
>> + int (*vidioc_g_fbuf)(struct file *file, void *,
>> struct v4l2_framebuffer *a);
>> - int (*vidioc_s_fbuf)(struct file *file, void *fh,
>> + int (*vidioc_s_fbuf)(struct file *file, void *,
>> const struct v4l2_framebuffer *a);
>>
>> /* Stream on/off */
>> - int (*vidioc_streamon)(struct file *file, void *fh,
>> + int (*vidioc_streamon)(struct file *file, void *,
>> enum v4l2_buf_type i);
>> - int (*vidioc_streamoff)(struct file *file, void *fh,
>> + int (*vidioc_streamoff)(struct file *file, void *,
>> enum v4l2_buf_type i);
>>
>> /*
>> @@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
>> *
>> * Note: ENUMSTD is handled by videodev.c
>> */
>> - int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
>> - int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
>> - int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
>> + int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
>> + int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
>> + int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
>>
>> /* Input handling */
>> - int (*vidioc_enum_input)(struct file *file, void *fh,
>> + int (*vidioc_enum_input)(struct file *file, void *,
>> struct v4l2_input *inp);
>> - int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
>> - int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
>> + int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
>> + int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
>>
>> /* Output handling */
>> - int (*vidioc_enum_output)(struct file *file, void *fh,
>> + int (*vidioc_enum_output)(struct file *file, void *,
>> struct v4l2_output *a);
>> - int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
>> - int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
>> + int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
>> + int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
>>
>> /* Control handling */
>> - int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
>> + int (*vidioc_query_ext_ctrl)(struct file *file, void *,
>> struct v4l2_query_ext_ctrl *a);
>> - int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
>> + int (*vidioc_g_ext_ctrls)(struct file *file, void *,
>> struct v4l2_ext_controls *a);
>> - int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
>> + int (*vidioc_s_ext_ctrls)(struct file *file, void *,
>> struct v4l2_ext_controls *a);
>> - int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
>> + int (*vidioc_try_ext_ctrls)(struct file *file, void *,
>> struct v4l2_ext_controls *a);
>> - int (*vidioc_querymenu)(struct file *file, void *fh,
>> + int (*vidioc_querymenu)(struct file *file, void *,
>> struct v4l2_querymenu *a);
>>
>> /* Audio ioctls */
>> - int (*vidioc_enumaudio)(struct file *file, void *fh,
>> + int (*vidioc_enumaudio)(struct file *file, void *,
>> struct v4l2_audio *a);
>> - int (*vidioc_g_audio)(struct file *file, void *fh,
>> + int (*vidioc_g_audio)(struct file *file, void *,
>> struct v4l2_audio *a);
>> - int (*vidioc_s_audio)(struct file *file, void *fh,
>> + int (*vidioc_s_audio)(struct file *file, void *,
>> const struct v4l2_audio *a);
>>
>> /* Audio out ioctls */
>> - int (*vidioc_enumaudout)(struct file *file, void *fh,
>> + int (*vidioc_enumaudout)(struct file *file, void *,
>> struct v4l2_audioout *a);
>> - int (*vidioc_g_audout)(struct file *file, void *fh,
>> + int (*vidioc_g_audout)(struct file *file, void *,
>> struct v4l2_audioout *a);
>> - int (*vidioc_s_audout)(struct file *file, void *fh,
>> + int (*vidioc_s_audout)(struct file *file, void *,
>> const struct v4l2_audioout *a);
>> - int (*vidioc_g_modulator)(struct file *file, void *fh,
>> + int (*vidioc_g_modulator)(struct file *file, void *,
>> struct v4l2_modulator *a);
>> - int (*vidioc_s_modulator)(struct file *file, void *fh,
>> + int (*vidioc_s_modulator)(struct file *file, void *,
>> const struct v4l2_modulator *a);
>> /* Crop ioctls */
>> - int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
>> + int (*vidioc_g_pixelaspect)(struct file *file, void *,
>> int buf_type, struct v4l2_fract *aspect);
>> - int (*vidioc_g_selection)(struct file *file, void *fh,
>> + int (*vidioc_g_selection)(struct file *file, void *,
>> struct v4l2_selection *s);
>> - int (*vidioc_s_selection)(struct file *file, void *fh,
>> + int (*vidioc_s_selection)(struct file *file, void *,
>> struct v4l2_selection *s);
>> /* Compression ioctls */
>> - int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
>> + int (*vidioc_g_jpegcomp)(struct file *file, void *,
>> struct v4l2_jpegcompression *a);
>> - int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
>> + int (*vidioc_s_jpegcomp)(struct file *file, void *,
>> const struct v4l2_jpegcompression *a);
>> - int (*vidioc_g_enc_index)(struct file *file, void *fh,
>> + int (*vidioc_g_enc_index)(struct file *file, void *,
>> struct v4l2_enc_idx *a);
>> - int (*vidioc_encoder_cmd)(struct file *file, void *fh,
>> + int (*vidioc_encoder_cmd)(struct file *file, void *,
>> struct v4l2_encoder_cmd *a);
>> - int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
>> + int (*vidioc_try_encoder_cmd)(struct file *file, void *,
>> struct v4l2_encoder_cmd *a);
>> - int (*vidioc_decoder_cmd)(struct file *file, void *fh,
>> + int (*vidioc_decoder_cmd)(struct file *file, void *,
>> struct v4l2_decoder_cmd *a);
>> - int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
>> + int (*vidioc_try_decoder_cmd)(struct file *file, void *,
>> struct v4l2_decoder_cmd *a);
>>
>> /* Stream type-dependent parameter ioctls */
>> - int (*vidioc_g_parm)(struct file *file, void *fh,
>> + int (*vidioc_g_parm)(struct file *file, void *,
>> struct v4l2_streamparm *a);
>> - int (*vidioc_s_parm)(struct file *file, void *fh,
>> + int (*vidioc_s_parm)(struct file *file, void *,
>> struct v4l2_streamparm *a);
>>
>> /* Tuner ioctls */
>> - int (*vidioc_g_tuner)(struct file *file, void *fh,
>> + int (*vidioc_g_tuner)(struct file *file, void *,
>> struct v4l2_tuner *a);
>> - int (*vidioc_s_tuner)(struct file *file, void *fh,
>> + int (*vidioc_s_tuner)(struct file *file, void *,
>> const struct v4l2_tuner *a);
>> - int (*vidioc_g_frequency)(struct file *file, void *fh,
>> + int (*vidioc_g_frequency)(struct file *file, void *,
>> struct v4l2_frequency *a);
>> - int (*vidioc_s_frequency)(struct file *file, void *fh,
>> + int (*vidioc_s_frequency)(struct file *file, void *,
>> const struct v4l2_frequency *a);
>> - int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
>> + int (*vidioc_enum_freq_bands)(struct file *file, void *,
>> struct v4l2_frequency_band *band);
>>
>> /* Sliced VBI cap */
>> - int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
>> + int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
>> struct v4l2_sliced_vbi_cap *a);
>>
>> /* Log status ioctl */
>> - int (*vidioc_log_status)(struct file *file, void *fh);
>> + int (*vidioc_log_status)(struct file *file, void *);
>>
>> - int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
>> + int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
>> const struct v4l2_hw_freq_seek *a);
>>
>> /* Debugging ioctls */
>> #ifdef CONFIG_VIDEO_ADV_DEBUG
>> - int (*vidioc_g_register)(struct file *file, void *fh,
>> + int (*vidioc_g_register)(struct file *file, void *,
>> struct v4l2_dbg_register *reg);
>> - int (*vidioc_s_register)(struct file *file, void *fh,
>> + int (*vidioc_s_register)(struct file *file, void *,
>> const struct v4l2_dbg_register *reg);
>>
>> - int (*vidioc_g_chip_info)(struct file *file, void *fh,
>> + int (*vidioc_g_chip_info)(struct file *file, void *,
>> struct v4l2_dbg_chip_info *chip);
>> #endif
>>
>> - int (*vidioc_enum_framesizes)(struct file *file, void *fh,
>> + int (*vidioc_enum_framesizes)(struct file *file, void *,
>> struct v4l2_frmsizeenum *fsize);
>>
>> - int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
>> + int (*vidioc_enum_frameintervals)(struct file *file, void *,
>> struct v4l2_frmivalenum *fival);
>>
>> /* DV Timings IOCTLs */
>> - int (*vidioc_s_dv_timings)(struct file *file, void *fh,
>> + int (*vidioc_s_dv_timings)(struct file *file, void *,
>> struct v4l2_dv_timings *timings);
>> - int (*vidioc_g_dv_timings)(struct file *file, void *fh,
>> + int (*vidioc_g_dv_timings)(struct file *file, void *,
>> struct v4l2_dv_timings *timings);
>> - int (*vidioc_query_dv_timings)(struct file *file, void *fh,
>> + int (*vidioc_query_dv_timings)(struct file *file, void *,
>> struct v4l2_dv_timings *timings);
>> - int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
>> + int (*vidioc_enum_dv_timings)(struct file *file, void *,
>> struct v4l2_enum_dv_timings *timings);
>> - int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
>> + int (*vidioc_dv_timings_cap)(struct file *file, void *,
>> struct v4l2_dv_timings_cap *cap);
>> - int (*vidioc_g_edid)(struct file *file, void *fh,
>> + int (*vidioc_g_edid)(struct file *file, void *,
>> struct v4l2_edid *edid);
>> - int (*vidioc_s_edid)(struct file *file, void *fh,
>> + int (*vidioc_s_edid)(struct file *file, void *,
>> struct v4l2_edid *edid);
>>
>> int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
>> @@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
>> const struct v4l2_event_subscription *sub);
>>
>> /* For other private ioctls */
>> - long (*vidioc_default)(struct file *file, void *fh,
>> + long (*vidioc_default)(struct file *file, void *,
>> bool valid_prio, unsigned int cmd, void *arg);
>> };
>>
>>
>
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-06 12:45 ` Hans Verkuil
@ 2025-08-07 8:50 ` Laurent Pinchart
2025-08-07 17:00 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 8:50 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Wed, Aug 06, 2025 at 02:45:14PM +0200, Hans Verkuil wrote:
> On 02/08/2025 11:22, Jacopo Mondi wrote:
> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > 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@ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > ---
> > Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
> > Documentation/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 ++--
> > .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
> > .../media/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(-)
> >
>
> <snip>
>
> > diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> > index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
>
> Instead of adding a second argument, perhaps it is better to
> just provide the filp pointer. After all, you can get the v4l2_fh
> from filp->private_data.
>
> It simplifies the code a bit.
That's an interesting idea. I'll give it a try.
> > {
> > 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;
> > }
>
> <snip>
>
> > diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
> > index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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 [flat|nested] 101+ messages in thread
* Re: [PATCH 64/65] media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-02 9:23 ` [PATCH 64/65] media: staging: ipu7: " Jacopo Mondi
@ 2025-08-07 9:07 ` Sakari Ailus
2025-08-07 17:01 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Sakari Ailus @ 2025-08-07 9:07 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka, linux-media,
linux-kernel, linux-staging, linux-doc, linux-arm-kernel,
linux-mediatek, linux-tegra, imx, linux-renesas-soc,
linux-arm-msm, linux-samsung-soc, linux-sunxi, linux-usb,
linux-amlogic, linux-rockchip, linux-stm32, mjpeg-users
On Sat, Aug 02, 2025 at 11:23:26AM +0200, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
> to be set manually by drivers. Drop it from the ipu7-isys driver.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Thanks, Jacopo!
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 58/65] media: zoran: Remove access to __fh
2025-08-07 6:58 ` Hans Verkuil
@ 2025-08-07 12:31 ` Laurent Pinchart
2025-08-07 13:18 ` Hans Verkuil
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 12:31 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Thu, Aug 07, 2025 at 08:58:01AM +0200, Hans Verkuil wrote:
> On 02/08/2025 11:23, Jacopo Mondi wrote:
> > The __fh parameter is assigned to an unsued variable. Remove it
> > and remove the unused struct zoran_fh type.
> >
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > ---
> > drivers/media/pci/zoran/zoran.h | 6 ------
> > drivers/media/pci/zoran/zoran_driver.c | 3 +--
> > 2 files changed, 1 insertion(+), 8 deletions(-)
> >
> > diff --git a/drivers/media/pci/zoran/zoran.h b/drivers/media/pci/zoran/zoran.h
> > index 1cd990468d3de9db8b14b72483972041c57bfee2..d05e222b392156bf1b3b4c83c6591db642c3c377 100644
> > --- a/drivers/media/pci/zoran/zoran.h
> > +++ b/drivers/media/pci/zoran/zoran.h
> > @@ -154,12 +154,6 @@ struct zoran_jpg_settings {
> >
> > struct zoran;
> >
> > -/* zoran_fh contains per-open() settings */
> > -struct zoran_fh {
> > - struct v4l2_fh fh;
> > - struct zoran *zr;
> > -};
> > -
> > struct card_info {
> > enum card_type type;
> > char name[32];
> > diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
> > index f42f596d3e6295e31e3b33cd83c5f7243911bd30..ec7fc1da4cc02f5a344cb49bb9a783c41c758195 100644
> > --- a/drivers/media/pci/zoran/zoran_driver.c
> > +++ b/drivers/media/pci/zoran/zoran_driver.c
> > @@ -511,12 +511,11 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
>
> This driver uses __fh as the name for the second argument of the ioctl
> callbacks. Can you take this opportunity to rename it to either 'fh' or 'priv'?
It's a bit of yak shaving, but not too difficult so it will be addressed
in the next version (Jacopo already wrote the patches, thanks).
> Generally it's not a good idea to prefix variables with __ for no good reason.
>
> Grepping for __fh also shows two other drivers:
>
> drivers/media/platform/chips-media/coda/coda-common.c:#define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh)
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h:#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
>
> I think it is a good idea to rename __fh to fh there as well.
That can't be done, otherwise things like
#define fh_to_ctx(fh) container_of(fh, struct coda_ctx, fh)
static inline struct coda_ctx *file_to_ctx(struct file *filp)
{
return fh_to_ctx(file_to_v4l2_fh(filp));
}
will expand in the file_to_ctx() function to
return container_of(file_to_v4l2_fh(filp), struct coda_ctx, file_to_v4l2_fh(filp))
We could rename the __fh argument to vfh or v4l2fh, but I think __fh is
equally good there. It's just the macro argument name.
> > struct v4l2_format *fmt)
> > {
> > struct zoran *zr = video_drvdata(file);
> > - struct zoran_fh *fh = __fh;
> > int i;
> > int res = 0;
> >
> > if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
> > - return zoran_s_fmt_vid_out(file, fh, fmt);
> > + return zoran_s_fmt_vid_out(file, __fh, fmt);
> >
> > for (i = 0; i < NUM_FORMATS; i++)
> > if (fmt->fmt.pix.pixelformat == zoran_formats[i].fourcc)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 58/65] media: zoran: Remove access to __fh
2025-08-07 12:31 ` Laurent Pinchart
@ 2025-08-07 13:18 ` Hans Verkuil
0 siblings, 0 replies; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 13:18 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 8/7/25 14:31, Laurent Pinchart wrote:
> On Thu, Aug 07, 2025 at 08:58:01AM +0200, Hans Verkuil wrote:
>> On 02/08/2025 11:23, Jacopo Mondi wrote:
>>> The __fh parameter is assigned to an unsued variable. Remove it
>>> and remove the unused struct zoran_fh type.
>>>
>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>>> ---
>>> drivers/media/pci/zoran/zoran.h | 6 ------
>>> drivers/media/pci/zoran/zoran_driver.c | 3 +--
>>> 2 files changed, 1 insertion(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/media/pci/zoran/zoran.h b/drivers/media/pci/zoran/zoran.h
>>> index 1cd990468d3de9db8b14b72483972041c57bfee2..d05e222b392156bf1b3b4c83c6591db642c3c377 100644
>>> --- a/drivers/media/pci/zoran/zoran.h
>>> +++ b/drivers/media/pci/zoran/zoran.h
>>> @@ -154,12 +154,6 @@ struct zoran_jpg_settings {
>>>
>>> struct zoran;
>>>
>>> -/* zoran_fh contains per-open() settings */
>>> -struct zoran_fh {
>>> - struct v4l2_fh fh;
>>> - struct zoran *zr;
>>> -};
>>> -
>>> struct card_info {
>>> enum card_type type;
>>> char name[32];
>>> diff --git a/drivers/media/pci/zoran/zoran_driver.c b/drivers/media/pci/zoran/zoran_driver.c
>>> index f42f596d3e6295e31e3b33cd83c5f7243911bd30..ec7fc1da4cc02f5a344cb49bb9a783c41c758195 100644
>>> --- a/drivers/media/pci/zoran/zoran_driver.c
>>> +++ b/drivers/media/pci/zoran/zoran_driver.c
>>> @@ -511,12 +511,11 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
>>
>> This driver uses __fh as the name for the second argument of the ioctl
>> callbacks. Can you take this opportunity to rename it to either 'fh' or 'priv'?
>
> It's a bit of yak shaving, but not too difficult so it will be addressed
> in the next version (Jacopo already wrote the patches, thanks).
>
>> Generally it's not a good idea to prefix variables with __ for no good reason.
>>
>> Grepping for __fh also shows two other drivers:
>>
>> drivers/media/platform/chips-media/coda/coda-common.c:#define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh)
>> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h:#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
>>
>> I think it is a good idea to rename __fh to fh there as well.
>
> That can't be done, otherwise things like
>
> #define fh_to_ctx(fh) container_of(fh, struct coda_ctx, fh)
>
> static inline struct coda_ctx *file_to_ctx(struct file *filp)
> {
> return fh_to_ctx(file_to_v4l2_fh(filp));
> }
>
> will expand in the file_to_ctx() function to
>
> return container_of(file_to_v4l2_fh(filp), struct coda_ctx, file_to_v4l2_fh(filp))
If the fh_to_ctx #define is changed to a static inline, then there is no problem.
That said, it is overkill.
Regards,
Hans
>
> We could rename the __fh argument to vfh or v4l2fh, but I think __fh is
> equally good there. It's just the macro argument name.
>
>>> struct v4l2_format *fmt)
>>> {
>>> struct zoran *zr = video_drvdata(file);
>>> - struct zoran_fh *fh = __fh;
>>> int i;
>>> int res = 0;
>>>
>>> if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
>>> - return zoran_s_fmt_vid_out(file, fh, fmt);
>>> + return zoran_s_fmt_vid_out(file, __fh, fmt);
>>>
>>> for (i = 0; i < NUM_FORMATS; i++)
>>> if (fmt->fmt.pix.pixelformat == zoran_formats[i].fourcc)
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-07 8:50 ` Laurent Pinchart
@ 2025-08-07 17:00 ` Laurent Pinchart
2025-08-07 20:25 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 17:00 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Thu, Aug 07, 2025 at 11:50:07AM +0300, Laurent Pinchart wrote:
> On Wed, Aug 06, 2025 at 02:45:14PM +0200, Hans Verkuil wrote:
> > On 02/08/2025 11:22, Jacopo Mondi wrote:
> > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > >
> > > 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@ideasonboard.com>
> > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > ---
> > > Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
> > > Documentation/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 ++--
> > > .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
> > > .../media/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(-)
> > >
> >
> > <snip>
> >
> > > diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> > > index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
> >
> > Instead of adding a second argument, perhaps it is better to
> > just provide the filp pointer. After all, you can get the v4l2_fh
> > from filp->private_data.
> >
> > It simplifies the code a bit.
>
> That's an interesting idea. I'll give it a try.
We end up with code like (e.g. in v4l2_fh_release(), with similar
constructs in lots of drivers)
if (fh) {
v4l2_fh_del(filp);
v4l2_fh_exit(fh);
kfree(fh);
}
compared to
if (fh) {
v4l2_fh_del(fh, filp);
v4l2_fh_exit(fh);
kfree(fh);
}
with the existing patch. I find the fact that v4l2_fh_del() takes a
different pointer than v4l2_fh_exit() a bit disturbing. If you think
it's better I'll drop the fh argument in v2.
> > > {
> > > 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;
> > > }
> >
> > <snip>
> >
> > > diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
> > > index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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 [flat|nested] 101+ messages in thread
* Re: [PATCH 64/65] media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-07 9:07 ` Sakari Ailus
@ 2025-08-07 17:01 ` Laurent Pinchart
2025-08-08 7:22 ` Sakari Ailus
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 17:01 UTC (permalink / raw)
To: Sakari Ailus
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka, linux-media,
linux-kernel, linux-staging, linux-doc, linux-arm-kernel,
linux-mediatek, linux-tegra, imx, linux-renesas-soc,
linux-arm-msm, linux-samsung-soc, linux-sunxi, linux-usb,
linux-amlogic, linux-rockchip, linux-stm32, mjpeg-users
Hi Sakari,
On Thu, Aug 07, 2025 at 09:07:13AM +0000, Sakari Ailus wrote:
> On Sat, Aug 02, 2025 at 11:23:26AM +0200, Jacopo Mondi wrote:
> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
> > to be set manually by drivers. Drop it from the ipu7-isys driver.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> Thanks, Jacopo!
>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Can we get you review on patch 63/65 too (for the IPU6 driver) too ?
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-07 17:00 ` Laurent Pinchart
@ 2025-08-07 20:25 ` Laurent Pinchart
2025-08-07 20:51 ` Hans Verkuil
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 20:25 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Thu, Aug 07, 2025 at 08:00:06PM +0300, Laurent Pinchart wrote:
> On Thu, Aug 07, 2025 at 11:50:07AM +0300, Laurent Pinchart wrote:
> > On Wed, Aug 06, 2025 at 02:45:14PM +0200, Hans Verkuil wrote:
> > > On 02/08/2025 11:22, Jacopo Mondi wrote:
> > > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > >
> > > > 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@ideasonboard.com>
> > > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > > ---
> > > > Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
> > > > Documentation/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 ++--
> > > > .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
> > > > .../media/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(-)
> > > >
> > >
> > > <snip>
> > >
> > > > diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> > > > index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
> > >
> > > Instead of adding a second argument, perhaps it is better to
> > > just provide the filp pointer. After all, you can get the v4l2_fh
> > > from filp->private_data.
> > >
> > > It simplifies the code a bit.
> >
> > That's an interesting idea. I'll give it a try.
>
> We end up with code like (e.g. in v4l2_fh_release(), with similar
> constructs in lots of drivers)
>
> if (fh) {
> v4l2_fh_del(filp);
> v4l2_fh_exit(fh);
> kfree(fh);
> }
>
> compared to
>
> if (fh) {
> v4l2_fh_del(fh, filp);
> v4l2_fh_exit(fh);
> kfree(fh);
> }
>
> with the existing patch. I find the fact that v4l2_fh_del() takes a
> different pointer than v4l2_fh_exit() a bit disturbing. If you think
> it's better I'll drop the fh argument in v2.
I gave it a try, and looking at the function prototype, its
documentation, the imbalance with v4l2_fh_add(), and the code in the
callers, I think keeping both arguments would look cleaner. Please tell
me if you feel strongly about this, I can still submit a patch to drop
the argument. It can very easily be scripted with coccinelle and doesn't
conflict with the rest of the series, so it could also be done later.
> > > > {
> > > > 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;
> > > > }
> > >
> > > <snip>
> > >
> > > > diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
> > > > index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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 [flat|nested] 101+ messages in thread
* Re: [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-07 7:58 ` Hans Verkuil
@ 2025-08-07 20:33 ` Laurent Pinchart
2025-08-07 20:55 ` Hans Verkuil
0 siblings, 1 reply; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-07 20:33 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Hans,
On Thu, Aug 07, 2025 at 09:58:34AM +0200, Hans Verkuil wrote:
> On 07/08/2025 09:26, Hans Verkuil wrote:
> > On 02/08/2025 11:23, Jacopo Mondi wrote:
> >> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>
> >> Now that all drivers access the v4l2_fh from the file structure, there
> >> is no need to pass it as an explicit argument to ioctl handlers. Set the
> >> argument to NULL in the w__video_do_ioctl(), and drop the name of the
> >> void *fh argument in the ioctl handler declarations to indicate it is
> >> not used.
> >>
> >> The argument could be removed altogether with a mechanical change
> >> (probably using coccinelle), but there are plans to pass a new argument
> >> to the ioctl handlers in the near future. The tree-wide change to remove
> >> the argument, only to add another one soon after, would be too much
> >> churn.
> >>
> >> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >> ---
> >> drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
> >> include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
> >> 2 files changed, 120 insertions(+), 121 deletions(-)
> >>
> >> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> >> index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
> >> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> >> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> >> @@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
> >> bool write_only = false;
> >> struct v4l2_ioctl_info default_info;
> >> const struct v4l2_ioctl_info *info;
> >> - void *fh = file_to_v4l2_fh(file);
> >> struct v4l2_fh *vfh = NULL;
> >> int dev_debug = vfd->dev_debug;
> >> long ret = -ENOTTY;
> >> @@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
> >>
> >> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
> >> if (info != &default_info) {
> >> - ret = info->func(ops, file, fh, arg);
> >> + ret = info->func(ops, file, NULL, arg);
> >> } else if (!ops->vidioc_default) {
> >> ret = -ENOTTY;
> >> } else {
> >> - ret = ops->vidioc_default(file, fh,
> >> + ret = ops->vidioc_default(file, NULL,
> >> vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
> >> cmd, arg);
> >> }
> >
> > drivers/media/v4l2-core/v4l2-compat-ioctl32.c also calls ops->vidioc_query_ext_ctrl
> > directly, but still passes the fh as second argument: that needs to be replaced by
> > a NULL pointer as well. That should be fixed in this patch as well.
Oops, I missed it. Will be fixed in v2.
> > Regarding v4l2-ioctl.c: I would like a follow-up patch that pushes the NULL pointer
> > down into each ioctl helper function. I.e. drop the 'void *fh' argument in the
> > struct v4l2_ioctl_info 'func' callback, and all callbacks like v4l_g_fmt() just
> > replace 'fh' by 'NULL' when they call the vidioc op.
I'll add a patch in v2.
> > Part of it is that the core functions currently suggest that the second argument is
> > a filehandle (since it's still named 'fh'), which is obviously wrong. And I also think
> > that the core framework shouldn't use a dummy second argument at all. I admit that
> > changing all vidioc callbacks in the whole subsystem to drop the second argument is
> > too much churn, but for this core file I think it is something that should be done.
>
> A follow-up on this: I would not be against a large patch that drops the second priv
> argument from all vidioc ops since it is now unused. If nothing else, it helps ensure
> that it is really unused by all drivers :-)
I've considered that. We're working on introducing a video_device_state
that will likely be passed as an argument to the ioctl handlers, and we
thought that not removing the void *priv argument yet could mean less
churn in drivers when we add the new argument, taking over the void
*priv. However, the state should be passed through an explicitly typed
pointer, so we'll have to patch all drivers anyway. I suppose we could
drop the void pointer now, and add a new pointer later. What do you
think ?
> But if you don't want to go there, then there is something that I think need to be addressed:
> a lot of drivers name the second argument 'fh' or '_fh' or even 'fh0'. Can we add a patch that
> renames the second arg to 'priv'?
>
> At minimum I think this should be done for drivers/media/test-drivers and
> samples/v4l/v4l2-pci-skeleton.c. These drivers are often used as reference drivers,
> so they should be up-to-date.
>
> I would also suggest to do this for uvc since it is by far the most widely used media
> driver.
>
> I also see the use of 'fh' in v4l2-mem2mem.c in a few places.
>
> >> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
> >> index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
> >> --- a/include/media/v4l2-ioctl.h
> >> +++ b/include/media/v4l2-ioctl.h
> >> @@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
> >> /* ioctl callbacks */
> >>
> >> /* VIDIOC_QUERYCAP handler */
> >> - int (*vidioc_querycap)(struct file *file, void *fh,
> >> + int (*vidioc_querycap)(struct file *file, void *,
> >> struct v4l2_capability *cap);
> >>
> >> /* VIDIOC_ENUM_FMT handlers */
> >> - int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >> - int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
> >> + int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
> >> struct v4l2_fmtdesc *f);
> >>
> >> /* VIDIOC_G_FMT handlers */
> >> - int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
> >> + int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >>
> >> /* VIDIOC_S_FMT handlers */
> >> - int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
> >> + int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >>
> >> /* VIDIOC_TRY_FMT handlers */
> >> - int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
> >> struct v4l2_format *f);
> >> - int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
> >> + int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
> >> struct v4l2_format *f);
> >>
> >> /* Buffer handlers */
> >> - int (*vidioc_reqbufs)(struct file *file, void *fh,
> >> + int (*vidioc_reqbufs)(struct file *file, void *,
> >> struct v4l2_requestbuffers *b);
> >> - int (*vidioc_querybuf)(struct file *file, void *fh,
> >> + int (*vidioc_querybuf)(struct file *file, void *,
> >> struct v4l2_buffer *b);
> >> - int (*vidioc_qbuf)(struct file *file, void *fh,
> >> + int (*vidioc_qbuf)(struct file *file, void *,
> >> struct v4l2_buffer *b);
> >> - int (*vidioc_expbuf)(struct file *file, void *fh,
> >> + int (*vidioc_expbuf)(struct file *file, void *,
> >> struct v4l2_exportbuffer *e);
> >> - int (*vidioc_dqbuf)(struct file *file, void *fh,
> >> + int (*vidioc_dqbuf)(struct file *file, void *,
> >> struct v4l2_buffer *b);
> >>
> >> - int (*vidioc_create_bufs)(struct file *file, void *fh,
> >> + int (*vidioc_create_bufs)(struct file *file, void *,
> >> struct v4l2_create_buffers *b);
> >> - int (*vidioc_prepare_buf)(struct file *file, void *fh,
> >> + int (*vidioc_prepare_buf)(struct file *file, void *,
> >> struct v4l2_buffer *b);
> >> - int (*vidioc_remove_bufs)(struct file *file, void *fh,
> >> + int (*vidioc_remove_bufs)(struct file *file, void *,
> >> struct v4l2_remove_buffers *d);
> >>
> >> - int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
> >> - int (*vidioc_g_fbuf)(struct file *file, void *fh,
> >> + int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
> >> + int (*vidioc_g_fbuf)(struct file *file, void *,
> >> struct v4l2_framebuffer *a);
> >> - int (*vidioc_s_fbuf)(struct file *file, void *fh,
> >> + int (*vidioc_s_fbuf)(struct file *file, void *,
> >> const struct v4l2_framebuffer *a);
> >>
> >> /* Stream on/off */
> >> - int (*vidioc_streamon)(struct file *file, void *fh,
> >> + int (*vidioc_streamon)(struct file *file, void *,
> >> enum v4l2_buf_type i);
> >> - int (*vidioc_streamoff)(struct file *file, void *fh,
> >> + int (*vidioc_streamoff)(struct file *file, void *,
> >> enum v4l2_buf_type i);
> >>
> >> /*
> >> @@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
> >> *
> >> * Note: ENUMSTD is handled by videodev.c
> >> */
> >> - int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
> >> - int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
> >> - int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
> >> + int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
> >> + int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
> >> + int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
> >>
> >> /* Input handling */
> >> - int (*vidioc_enum_input)(struct file *file, void *fh,
> >> + int (*vidioc_enum_input)(struct file *file, void *,
> >> struct v4l2_input *inp);
> >> - int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
> >> - int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
> >> + int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
> >> + int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
> >>
> >> /* Output handling */
> >> - int (*vidioc_enum_output)(struct file *file, void *fh,
> >> + int (*vidioc_enum_output)(struct file *file, void *,
> >> struct v4l2_output *a);
> >> - int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
> >> - int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
> >> + int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
> >> + int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
> >>
> >> /* Control handling */
> >> - int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
> >> + int (*vidioc_query_ext_ctrl)(struct file *file, void *,
> >> struct v4l2_query_ext_ctrl *a);
> >> - int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
> >> + int (*vidioc_g_ext_ctrls)(struct file *file, void *,
> >> struct v4l2_ext_controls *a);
> >> - int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
> >> + int (*vidioc_s_ext_ctrls)(struct file *file, void *,
> >> struct v4l2_ext_controls *a);
> >> - int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
> >> + int (*vidioc_try_ext_ctrls)(struct file *file, void *,
> >> struct v4l2_ext_controls *a);
> >> - int (*vidioc_querymenu)(struct file *file, void *fh,
> >> + int (*vidioc_querymenu)(struct file *file, void *,
> >> struct v4l2_querymenu *a);
> >>
> >> /* Audio ioctls */
> >> - int (*vidioc_enumaudio)(struct file *file, void *fh,
> >> + int (*vidioc_enumaudio)(struct file *file, void *,
> >> struct v4l2_audio *a);
> >> - int (*vidioc_g_audio)(struct file *file, void *fh,
> >> + int (*vidioc_g_audio)(struct file *file, void *,
> >> struct v4l2_audio *a);
> >> - int (*vidioc_s_audio)(struct file *file, void *fh,
> >> + int (*vidioc_s_audio)(struct file *file, void *,
> >> const struct v4l2_audio *a);
> >>
> >> /* Audio out ioctls */
> >> - int (*vidioc_enumaudout)(struct file *file, void *fh,
> >> + int (*vidioc_enumaudout)(struct file *file, void *,
> >> struct v4l2_audioout *a);
> >> - int (*vidioc_g_audout)(struct file *file, void *fh,
> >> + int (*vidioc_g_audout)(struct file *file, void *,
> >> struct v4l2_audioout *a);
> >> - int (*vidioc_s_audout)(struct file *file, void *fh,
> >> + int (*vidioc_s_audout)(struct file *file, void *,
> >> const struct v4l2_audioout *a);
> >> - int (*vidioc_g_modulator)(struct file *file, void *fh,
> >> + int (*vidioc_g_modulator)(struct file *file, void *,
> >> struct v4l2_modulator *a);
> >> - int (*vidioc_s_modulator)(struct file *file, void *fh,
> >> + int (*vidioc_s_modulator)(struct file *file, void *,
> >> const struct v4l2_modulator *a);
> >> /* Crop ioctls */
> >> - int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
> >> + int (*vidioc_g_pixelaspect)(struct file *file, void *,
> >> int buf_type, struct v4l2_fract *aspect);
> >> - int (*vidioc_g_selection)(struct file *file, void *fh,
> >> + int (*vidioc_g_selection)(struct file *file, void *,
> >> struct v4l2_selection *s);
> >> - int (*vidioc_s_selection)(struct file *file, void *fh,
> >> + int (*vidioc_s_selection)(struct file *file, void *,
> >> struct v4l2_selection *s);
> >> /* Compression ioctls */
> >> - int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
> >> + int (*vidioc_g_jpegcomp)(struct file *file, void *,
> >> struct v4l2_jpegcompression *a);
> >> - int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
> >> + int (*vidioc_s_jpegcomp)(struct file *file, void *,
> >> const struct v4l2_jpegcompression *a);
> >> - int (*vidioc_g_enc_index)(struct file *file, void *fh,
> >> + int (*vidioc_g_enc_index)(struct file *file, void *,
> >> struct v4l2_enc_idx *a);
> >> - int (*vidioc_encoder_cmd)(struct file *file, void *fh,
> >> + int (*vidioc_encoder_cmd)(struct file *file, void *,
> >> struct v4l2_encoder_cmd *a);
> >> - int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
> >> + int (*vidioc_try_encoder_cmd)(struct file *file, void *,
> >> struct v4l2_encoder_cmd *a);
> >> - int (*vidioc_decoder_cmd)(struct file *file, void *fh,
> >> + int (*vidioc_decoder_cmd)(struct file *file, void *,
> >> struct v4l2_decoder_cmd *a);
> >> - int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
> >> + int (*vidioc_try_decoder_cmd)(struct file *file, void *,
> >> struct v4l2_decoder_cmd *a);
> >>
> >> /* Stream type-dependent parameter ioctls */
> >> - int (*vidioc_g_parm)(struct file *file, void *fh,
> >> + int (*vidioc_g_parm)(struct file *file, void *,
> >> struct v4l2_streamparm *a);
> >> - int (*vidioc_s_parm)(struct file *file, void *fh,
> >> + int (*vidioc_s_parm)(struct file *file, void *,
> >> struct v4l2_streamparm *a);
> >>
> >> /* Tuner ioctls */
> >> - int (*vidioc_g_tuner)(struct file *file, void *fh,
> >> + int (*vidioc_g_tuner)(struct file *file, void *,
> >> struct v4l2_tuner *a);
> >> - int (*vidioc_s_tuner)(struct file *file, void *fh,
> >> + int (*vidioc_s_tuner)(struct file *file, void *,
> >> const struct v4l2_tuner *a);
> >> - int (*vidioc_g_frequency)(struct file *file, void *fh,
> >> + int (*vidioc_g_frequency)(struct file *file, void *,
> >> struct v4l2_frequency *a);
> >> - int (*vidioc_s_frequency)(struct file *file, void *fh,
> >> + int (*vidioc_s_frequency)(struct file *file, void *,
> >> const struct v4l2_frequency *a);
> >> - int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
> >> + int (*vidioc_enum_freq_bands)(struct file *file, void *,
> >> struct v4l2_frequency_band *band);
> >>
> >> /* Sliced VBI cap */
> >> - int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
> >> + int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
> >> struct v4l2_sliced_vbi_cap *a);
> >>
> >> /* Log status ioctl */
> >> - int (*vidioc_log_status)(struct file *file, void *fh);
> >> + int (*vidioc_log_status)(struct file *file, void *);
> >>
> >> - int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
> >> + int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
> >> const struct v4l2_hw_freq_seek *a);
> >>
> >> /* Debugging ioctls */
> >> #ifdef CONFIG_VIDEO_ADV_DEBUG
> >> - int (*vidioc_g_register)(struct file *file, void *fh,
> >> + int (*vidioc_g_register)(struct file *file, void *,
> >> struct v4l2_dbg_register *reg);
> >> - int (*vidioc_s_register)(struct file *file, void *fh,
> >> + int (*vidioc_s_register)(struct file *file, void *,
> >> const struct v4l2_dbg_register *reg);
> >>
> >> - int (*vidioc_g_chip_info)(struct file *file, void *fh,
> >> + int (*vidioc_g_chip_info)(struct file *file, void *,
> >> struct v4l2_dbg_chip_info *chip);
> >> #endif
> >>
> >> - int (*vidioc_enum_framesizes)(struct file *file, void *fh,
> >> + int (*vidioc_enum_framesizes)(struct file *file, void *,
> >> struct v4l2_frmsizeenum *fsize);
> >>
> >> - int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
> >> + int (*vidioc_enum_frameintervals)(struct file *file, void *,
> >> struct v4l2_frmivalenum *fival);
> >>
> >> /* DV Timings IOCTLs */
> >> - int (*vidioc_s_dv_timings)(struct file *file, void *fh,
> >> + int (*vidioc_s_dv_timings)(struct file *file, void *,
> >> struct v4l2_dv_timings *timings);
> >> - int (*vidioc_g_dv_timings)(struct file *file, void *fh,
> >> + int (*vidioc_g_dv_timings)(struct file *file, void *,
> >> struct v4l2_dv_timings *timings);
> >> - int (*vidioc_query_dv_timings)(struct file *file, void *fh,
> >> + int (*vidioc_query_dv_timings)(struct file *file, void *,
> >> struct v4l2_dv_timings *timings);
> >> - int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
> >> + int (*vidioc_enum_dv_timings)(struct file *file, void *,
> >> struct v4l2_enum_dv_timings *timings);
> >> - int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
> >> + int (*vidioc_dv_timings_cap)(struct file *file, void *,
> >> struct v4l2_dv_timings_cap *cap);
> >> - int (*vidioc_g_edid)(struct file *file, void *fh,
> >> + int (*vidioc_g_edid)(struct file *file, void *,
> >> struct v4l2_edid *edid);
> >> - int (*vidioc_s_edid)(struct file *file, void *fh,
> >> + int (*vidioc_s_edid)(struct file *file, void *,
> >> struct v4l2_edid *edid);
> >>
> >> int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
> >> @@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
> >> const struct v4l2_event_subscription *sub);
> >>
> >> /* For other private ioctls */
> >> - long (*vidioc_default)(struct file *file, void *fh,
> >> + long (*vidioc_default)(struct file *file, void *,
> >> bool valid_prio, unsigned int cmd, void *arg);
> >> };
> >>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-07 20:25 ` Laurent Pinchart
@ 2025-08-07 20:51 ` Hans Verkuil
2025-08-08 6:30 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 20:51 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 07/08/2025 22:25, Laurent Pinchart wrote:
> On Thu, Aug 07, 2025 at 08:00:06PM +0300, Laurent Pinchart wrote:
>> On Thu, Aug 07, 2025 at 11:50:07AM +0300, Laurent Pinchart wrote:
>>> On Wed, Aug 06, 2025 at 02:45:14PM +0200, Hans Verkuil wrote:
>>>> On 02/08/2025 11:22, Jacopo Mondi wrote:
>>>>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>>>
>>>>> 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@ideasonboard.com>
>>>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>>>>> ---
>>>>> Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
>>>>> Documentation/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 ++--
>>>>> .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
>>>>> .../media/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(-)
>>>>>
>>>>
>>>> <snip>
>>>>
>>>>> diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
>>>>> index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
>>>>
>>>> Instead of adding a second argument, perhaps it is better to
>>>> just provide the filp pointer. After all, you can get the v4l2_fh
>>>> from filp->private_data.
>>>>
>>>> It simplifies the code a bit.
>>>
>>> That's an interesting idea. I'll give it a try.
>>
>> We end up with code like (e.g. in v4l2_fh_release(), with similar
>> constructs in lots of drivers)
>>
>> if (fh) {
>> v4l2_fh_del(filp);
>> v4l2_fh_exit(fh);
>> kfree(fh);
>> }
>>
>> compared to
>>
>> if (fh) {
>> v4l2_fh_del(fh, filp);
>> v4l2_fh_exit(fh);
>> kfree(fh);
>> }
>>
>> with the existing patch. I find the fact that v4l2_fh_del() takes a
>> different pointer than v4l2_fh_exit() a bit disturbing. If you think
>> it's better I'll drop the fh argument in v2.
>
> I gave it a try, and looking at the function prototype, its
> documentation, the imbalance with v4l2_fh_add(), and the code in the
> callers, I think keeping both arguments would look cleaner. Please tell
> me if you feel strongly about this, I can still submit a patch to drop
> the argument. It can very easily be scripted with coccinelle and doesn't
> conflict with the rest of the series, so it could also be done later.
Looking at all the drivers that call v4l2_fh_del/exit I always see v4l2_fh_del()
directly followed by v4l2_fh_exit(). I think it would make a lot of sense to just
combine the two as a single function: v4l2_fh_del_exit(filp).
That simplifies the code and solves the imbalance.
Regards,
Hans
>
>>>>> {
>>>>> 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;
>>>>> }
>>>>
>>>> <snip>
>>>>
>>>>> diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
>>>>> index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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.
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-07 20:33 ` Laurent Pinchart
@ 2025-08-07 20:55 ` Hans Verkuil
2025-08-08 7:00 ` Laurent Pinchart
0 siblings, 1 reply; 101+ messages in thread
From: Hans Verkuil @ 2025-08-07 20:55 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On 07/08/2025 22:33, Laurent Pinchart wrote:
> Hi Hans,
>
> On Thu, Aug 07, 2025 at 09:58:34AM +0200, Hans Verkuil wrote:
>> On 07/08/2025 09:26, Hans Verkuil wrote:
>>> On 02/08/2025 11:23, Jacopo Mondi wrote:
>>>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>>
>>>> Now that all drivers access the v4l2_fh from the file structure, there
>>>> is no need to pass it as an explicit argument to ioctl handlers. Set the
>>>> argument to NULL in the w__video_do_ioctl(), and drop the name of the
>>>> void *fh argument in the ioctl handler declarations to indicate it is
>>>> not used.
>>>>
>>>> The argument could be removed altogether with a mechanical change
>>>> (probably using coccinelle), but there are plans to pass a new argument
>>>> to the ioctl handlers in the near future. The tree-wide change to remove
>>>> the argument, only to add another one soon after, would be too much
>>>> churn.
>>>>
>>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>>>> ---
>>>> drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
>>>> include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
>>>> 2 files changed, 120 insertions(+), 121 deletions(-)
>>>>
>>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
>>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
>>>> @@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
>>>> bool write_only = false;
>>>> struct v4l2_ioctl_info default_info;
>>>> const struct v4l2_ioctl_info *info;
>>>> - void *fh = file_to_v4l2_fh(file);
>>>> struct v4l2_fh *vfh = NULL;
>>>> int dev_debug = vfd->dev_debug;
>>>> long ret = -ENOTTY;
>>>> @@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
>>>>
>>>> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
>>>> if (info != &default_info) {
>>>> - ret = info->func(ops, file, fh, arg);
>>>> + ret = info->func(ops, file, NULL, arg);
>>>> } else if (!ops->vidioc_default) {
>>>> ret = -ENOTTY;
>>>> } else {
>>>> - ret = ops->vidioc_default(file, fh,
>>>> + ret = ops->vidioc_default(file, NULL,
>>>> vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
>>>> cmd, arg);
>>>> }
>>>
>>> drivers/media/v4l2-core/v4l2-compat-ioctl32.c also calls ops->vidioc_query_ext_ctrl
>>> directly, but still passes the fh as second argument: that needs to be replaced by
>>> a NULL pointer as well. That should be fixed in this patch as well.
>
> Oops, I missed it. Will be fixed in v2.
>
>>> Regarding v4l2-ioctl.c: I would like a follow-up patch that pushes the NULL pointer
>>> down into each ioctl helper function. I.e. drop the 'void *fh' argument in the
>>> struct v4l2_ioctl_info 'func' callback, and all callbacks like v4l_g_fmt() just
>>> replace 'fh' by 'NULL' when they call the vidioc op.
>
> I'll add a patch in v2.
>
>>> Part of it is that the core functions currently suggest that the second argument is
>>> a filehandle (since it's still named 'fh'), which is obviously wrong. And I also think
>>> that the core framework shouldn't use a dummy second argument at all. I admit that
>>> changing all vidioc callbacks in the whole subsystem to drop the second argument is
>>> too much churn, but for this core file I think it is something that should be done.
>>
>> A follow-up on this: I would not be against a large patch that drops the second priv
>> argument from all vidioc ops since it is now unused. If nothing else, it helps ensure
>> that it is really unused by all drivers :-)
>
> I've considered that. We're working on introducing a video_device_state
> that will likely be passed as an argument to the ioctl handlers, and we
> thought that not removing the void *priv argument yet could mean less
> churn in drivers when we add the new argument, taking over the void
> *priv. However, the state should be passed through an explicitly typed
> pointer, so we'll have to patch all drivers anyway. I suppose we could
> drop the void pointer now, and add a new pointer later. What do you
> think ?
It depends on how what you think is the ETA for the video_device_state :-)
I think we can shelve this for now, but as mentioned below, at least replace
'fh' by 'priv' for the test drivers, pci skeleton driver and (I think) uvc.
Regards,
Hans
>
>> But if you don't want to go there, then there is something that I think need to be addressed:
>> a lot of drivers name the second argument 'fh' or '_fh' or even 'fh0'. Can we add a patch that
>> renames the second arg to 'priv'?
>>
>> At minimum I think this should be done for drivers/media/test-drivers and
>> samples/v4l/v4l2-pci-skeleton.c. These drivers are often used as reference drivers,
>> so they should be up-to-date.
>>
>> I would also suggest to do this for uvc since it is by far the most widely used media
>> driver.
>>
>> I also see the use of 'fh' in v4l2-mem2mem.c in a few places.
>>
>>>> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
>>>> index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
>>>> --- a/include/media/v4l2-ioctl.h
>>>> +++ b/include/media/v4l2-ioctl.h
>>>> @@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
>>>> /* ioctl callbacks */
>>>>
>>>> /* VIDIOC_QUERYCAP handler */
>>>> - int (*vidioc_querycap)(struct file *file, void *fh,
>>>> + int (*vidioc_querycap)(struct file *file, void *,
>>>> struct v4l2_capability *cap);
>>>>
>>>> /* VIDIOC_ENUM_FMT handlers */
>>>> - int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>> - int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
>>>> struct v4l2_fmtdesc *f);
>>>>
>>>> /* VIDIOC_G_FMT handlers */
>>>> - int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
>>>> + int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>>
>>>> /* VIDIOC_S_FMT handlers */
>>>> - int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>>
>>>> /* VIDIOC_TRY_FMT handlers */
>>>> - int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>> - int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
>>>> + int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
>>>> struct v4l2_format *f);
>>>>
>>>> /* Buffer handlers */
>>>> - int (*vidioc_reqbufs)(struct file *file, void *fh,
>>>> + int (*vidioc_reqbufs)(struct file *file, void *,
>>>> struct v4l2_requestbuffers *b);
>>>> - int (*vidioc_querybuf)(struct file *file, void *fh,
>>>> + int (*vidioc_querybuf)(struct file *file, void *,
>>>> struct v4l2_buffer *b);
>>>> - int (*vidioc_qbuf)(struct file *file, void *fh,
>>>> + int (*vidioc_qbuf)(struct file *file, void *,
>>>> struct v4l2_buffer *b);
>>>> - int (*vidioc_expbuf)(struct file *file, void *fh,
>>>> + int (*vidioc_expbuf)(struct file *file, void *,
>>>> struct v4l2_exportbuffer *e);
>>>> - int (*vidioc_dqbuf)(struct file *file, void *fh,
>>>> + int (*vidioc_dqbuf)(struct file *file, void *,
>>>> struct v4l2_buffer *b);
>>>>
>>>> - int (*vidioc_create_bufs)(struct file *file, void *fh,
>>>> + int (*vidioc_create_bufs)(struct file *file, void *,
>>>> struct v4l2_create_buffers *b);
>>>> - int (*vidioc_prepare_buf)(struct file *file, void *fh,
>>>> + int (*vidioc_prepare_buf)(struct file *file, void *,
>>>> struct v4l2_buffer *b);
>>>> - int (*vidioc_remove_bufs)(struct file *file, void *fh,
>>>> + int (*vidioc_remove_bufs)(struct file *file, void *,
>>>> struct v4l2_remove_buffers *d);
>>>>
>>>> - int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
>>>> - int (*vidioc_g_fbuf)(struct file *file, void *fh,
>>>> + int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
>>>> + int (*vidioc_g_fbuf)(struct file *file, void *,
>>>> struct v4l2_framebuffer *a);
>>>> - int (*vidioc_s_fbuf)(struct file *file, void *fh,
>>>> + int (*vidioc_s_fbuf)(struct file *file, void *,
>>>> const struct v4l2_framebuffer *a);
>>>>
>>>> /* Stream on/off */
>>>> - int (*vidioc_streamon)(struct file *file, void *fh,
>>>> + int (*vidioc_streamon)(struct file *file, void *,
>>>> enum v4l2_buf_type i);
>>>> - int (*vidioc_streamoff)(struct file *file, void *fh,
>>>> + int (*vidioc_streamoff)(struct file *file, void *,
>>>> enum v4l2_buf_type i);
>>>>
>>>> /*
>>>> @@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
>>>> *
>>>> * Note: ENUMSTD is handled by videodev.c
>>>> */
>>>> - int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
>>>> - int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
>>>> - int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
>>>> + int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
>>>> + int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
>>>> + int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
>>>>
>>>> /* Input handling */
>>>> - int (*vidioc_enum_input)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_input)(struct file *file, void *,
>>>> struct v4l2_input *inp);
>>>> - int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
>>>> - int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
>>>> + int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
>>>> + int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
>>>>
>>>> /* Output handling */
>>>> - int (*vidioc_enum_output)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_output)(struct file *file, void *,
>>>> struct v4l2_output *a);
>>>> - int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
>>>> - int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
>>>> + int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
>>>> + int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
>>>>
>>>> /* Control handling */
>>>> - int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
>>>> + int (*vidioc_query_ext_ctrl)(struct file *file, void *,
>>>> struct v4l2_query_ext_ctrl *a);
>>>> - int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
>>>> + int (*vidioc_g_ext_ctrls)(struct file *file, void *,
>>>> struct v4l2_ext_controls *a);
>>>> - int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
>>>> + int (*vidioc_s_ext_ctrls)(struct file *file, void *,
>>>> struct v4l2_ext_controls *a);
>>>> - int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
>>>> + int (*vidioc_try_ext_ctrls)(struct file *file, void *,
>>>> struct v4l2_ext_controls *a);
>>>> - int (*vidioc_querymenu)(struct file *file, void *fh,
>>>> + int (*vidioc_querymenu)(struct file *file, void *,
>>>> struct v4l2_querymenu *a);
>>>>
>>>> /* Audio ioctls */
>>>> - int (*vidioc_enumaudio)(struct file *file, void *fh,
>>>> + int (*vidioc_enumaudio)(struct file *file, void *,
>>>> struct v4l2_audio *a);
>>>> - int (*vidioc_g_audio)(struct file *file, void *fh,
>>>> + int (*vidioc_g_audio)(struct file *file, void *,
>>>> struct v4l2_audio *a);
>>>> - int (*vidioc_s_audio)(struct file *file, void *fh,
>>>> + int (*vidioc_s_audio)(struct file *file, void *,
>>>> const struct v4l2_audio *a);
>>>>
>>>> /* Audio out ioctls */
>>>> - int (*vidioc_enumaudout)(struct file *file, void *fh,
>>>> + int (*vidioc_enumaudout)(struct file *file, void *,
>>>> struct v4l2_audioout *a);
>>>> - int (*vidioc_g_audout)(struct file *file, void *fh,
>>>> + int (*vidioc_g_audout)(struct file *file, void *,
>>>> struct v4l2_audioout *a);
>>>> - int (*vidioc_s_audout)(struct file *file, void *fh,
>>>> + int (*vidioc_s_audout)(struct file *file, void *,
>>>> const struct v4l2_audioout *a);
>>>> - int (*vidioc_g_modulator)(struct file *file, void *fh,
>>>> + int (*vidioc_g_modulator)(struct file *file, void *,
>>>> struct v4l2_modulator *a);
>>>> - int (*vidioc_s_modulator)(struct file *file, void *fh,
>>>> + int (*vidioc_s_modulator)(struct file *file, void *,
>>>> const struct v4l2_modulator *a);
>>>> /* Crop ioctls */
>>>> - int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
>>>> + int (*vidioc_g_pixelaspect)(struct file *file, void *,
>>>> int buf_type, struct v4l2_fract *aspect);
>>>> - int (*vidioc_g_selection)(struct file *file, void *fh,
>>>> + int (*vidioc_g_selection)(struct file *file, void *,
>>>> struct v4l2_selection *s);
>>>> - int (*vidioc_s_selection)(struct file *file, void *fh,
>>>> + int (*vidioc_s_selection)(struct file *file, void *,
>>>> struct v4l2_selection *s);
>>>> /* Compression ioctls */
>>>> - int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
>>>> + int (*vidioc_g_jpegcomp)(struct file *file, void *,
>>>> struct v4l2_jpegcompression *a);
>>>> - int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
>>>> + int (*vidioc_s_jpegcomp)(struct file *file, void *,
>>>> const struct v4l2_jpegcompression *a);
>>>> - int (*vidioc_g_enc_index)(struct file *file, void *fh,
>>>> + int (*vidioc_g_enc_index)(struct file *file, void *,
>>>> struct v4l2_enc_idx *a);
>>>> - int (*vidioc_encoder_cmd)(struct file *file, void *fh,
>>>> + int (*vidioc_encoder_cmd)(struct file *file, void *,
>>>> struct v4l2_encoder_cmd *a);
>>>> - int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
>>>> + int (*vidioc_try_encoder_cmd)(struct file *file, void *,
>>>> struct v4l2_encoder_cmd *a);
>>>> - int (*vidioc_decoder_cmd)(struct file *file, void *fh,
>>>> + int (*vidioc_decoder_cmd)(struct file *file, void *,
>>>> struct v4l2_decoder_cmd *a);
>>>> - int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
>>>> + int (*vidioc_try_decoder_cmd)(struct file *file, void *,
>>>> struct v4l2_decoder_cmd *a);
>>>>
>>>> /* Stream type-dependent parameter ioctls */
>>>> - int (*vidioc_g_parm)(struct file *file, void *fh,
>>>> + int (*vidioc_g_parm)(struct file *file, void *,
>>>> struct v4l2_streamparm *a);
>>>> - int (*vidioc_s_parm)(struct file *file, void *fh,
>>>> + int (*vidioc_s_parm)(struct file *file, void *,
>>>> struct v4l2_streamparm *a);
>>>>
>>>> /* Tuner ioctls */
>>>> - int (*vidioc_g_tuner)(struct file *file, void *fh,
>>>> + int (*vidioc_g_tuner)(struct file *file, void *,
>>>> struct v4l2_tuner *a);
>>>> - int (*vidioc_s_tuner)(struct file *file, void *fh,
>>>> + int (*vidioc_s_tuner)(struct file *file, void *,
>>>> const struct v4l2_tuner *a);
>>>> - int (*vidioc_g_frequency)(struct file *file, void *fh,
>>>> + int (*vidioc_g_frequency)(struct file *file, void *,
>>>> struct v4l2_frequency *a);
>>>> - int (*vidioc_s_frequency)(struct file *file, void *fh,
>>>> + int (*vidioc_s_frequency)(struct file *file, void *,
>>>> const struct v4l2_frequency *a);
>>>> - int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_freq_bands)(struct file *file, void *,
>>>> struct v4l2_frequency_band *band);
>>>>
>>>> /* Sliced VBI cap */
>>>> - int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
>>>> struct v4l2_sliced_vbi_cap *a);
>>>>
>>>> /* Log status ioctl */
>>>> - int (*vidioc_log_status)(struct file *file, void *fh);
>>>> + int (*vidioc_log_status)(struct file *file, void *);
>>>>
>>>> - int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
>>>> + int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
>>>> const struct v4l2_hw_freq_seek *a);
>>>>
>>>> /* Debugging ioctls */
>>>> #ifdef CONFIG_VIDEO_ADV_DEBUG
>>>> - int (*vidioc_g_register)(struct file *file, void *fh,
>>>> + int (*vidioc_g_register)(struct file *file, void *,
>>>> struct v4l2_dbg_register *reg);
>>>> - int (*vidioc_s_register)(struct file *file, void *fh,
>>>> + int (*vidioc_s_register)(struct file *file, void *,
>>>> const struct v4l2_dbg_register *reg);
>>>>
>>>> - int (*vidioc_g_chip_info)(struct file *file, void *fh,
>>>> + int (*vidioc_g_chip_info)(struct file *file, void *,
>>>> struct v4l2_dbg_chip_info *chip);
>>>> #endif
>>>>
>>>> - int (*vidioc_enum_framesizes)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_framesizes)(struct file *file, void *,
>>>> struct v4l2_frmsizeenum *fsize);
>>>>
>>>> - int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_frameintervals)(struct file *file, void *,
>>>> struct v4l2_frmivalenum *fival);
>>>>
>>>> /* DV Timings IOCTLs */
>>>> - int (*vidioc_s_dv_timings)(struct file *file, void *fh,
>>>> + int (*vidioc_s_dv_timings)(struct file *file, void *,
>>>> struct v4l2_dv_timings *timings);
>>>> - int (*vidioc_g_dv_timings)(struct file *file, void *fh,
>>>> + int (*vidioc_g_dv_timings)(struct file *file, void *,
>>>> struct v4l2_dv_timings *timings);
>>>> - int (*vidioc_query_dv_timings)(struct file *file, void *fh,
>>>> + int (*vidioc_query_dv_timings)(struct file *file, void *,
>>>> struct v4l2_dv_timings *timings);
>>>> - int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
>>>> + int (*vidioc_enum_dv_timings)(struct file *file, void *,
>>>> struct v4l2_enum_dv_timings *timings);
>>>> - int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
>>>> + int (*vidioc_dv_timings_cap)(struct file *file, void *,
>>>> struct v4l2_dv_timings_cap *cap);
>>>> - int (*vidioc_g_edid)(struct file *file, void *fh,
>>>> + int (*vidioc_g_edid)(struct file *file, void *,
>>>> struct v4l2_edid *edid);
>>>> - int (*vidioc_s_edid)(struct file *file, void *fh,
>>>> + int (*vidioc_s_edid)(struct file *file, void *,
>>>> struct v4l2_edid *edid);
>>>>
>>>> int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
>>>> @@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
>>>> const struct v4l2_event_subscription *sub);
>>>>
>>>> /* For other private ioctls */
>>>> - long (*vidioc_default)(struct file *file, void *fh,
>>>> + long (*vidioc_default)(struct file *file, void *,
>>>> bool valid_prio, unsigned int cmd, void *arg);
>>>> };
>>>>
>
^ permalink raw reply [flat|nested] 101+ messages in thread
* RE: [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
@ 2025-08-08 1:01 ` Cao, Bingbu
2025-08-08 7:22 ` Sakari Ailus
1 sibling, 0 replies; 101+ messages in thread
From: Cao, Bingbu @ 2025-08-08 1:01 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Laurent Pinchart,
Hans de Goede, Parthiban Veerasooran, Christian Gromm,
Greg Kroah-Hartman, Alex Shi, Yanteng Si, Dongliang Mu,
Jonathan Corbet, Tomasz Figa, Marek Szyprowski, Andy Walls,
Michael Tretter, Pengutronix Kernel Team, Bin Liu,
Matthias Brugger, AngeloGioacchino Del Regno, Dmitry Osipenko,
Thierry Reding, Jonathan Hunter, Mirela Rabulea, Shawn Guo,
Sascha Hauer, Fabio Estevam, Kieran Bingham, Michal Simek,
Ming Qian, Zhou Peng, Xavier Roumegue, Philipp Zabel,
Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
Chen-Yu Tsai, Samuel Holland, Daniel Almeida, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Nas Chung,
Jackson Lee, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen,
Tiffany Lin, Yunfei Dong, Geert Uytterhoeven, Magnus Damm,
Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Hajda, Andrzej, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Qiu, Tian Shu, Stanislaw Gruszka
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-sunxi@lists.linux.dev, linux-usb@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
mjpeg-users@lists.sourceforge.net
Jacopo,
>-----Original Message-----
>From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>Sent: Saturday, August 2, 2025 5:23 PM
>To: Mauro Carvalho Chehab <mchehab@kernel.org>; Devarsh Thakkar
><devarsht@ti.com>; Benoit Parrot <bparrot@ti.com>; Hans Verkuil
><hverkuil@kernel.org>; Mike Isely <isely@pobox.com>; Laurent Pinchart
><laurent.pinchart@ideasonboard.com>; Hans de Goede <hansg@kernel.org>;
>Parthiban Veerasooran <parthiban.veerasooran@microchip.com>; Christian
>Gromm <christian.gromm@microchip.com>; Greg Kroah-Hartman
><gregkh@linuxfoundation.org>; Alex Shi <alexs@kernel.org>; Yanteng Si
><si.yanteng@linux.dev>; Dongliang Mu <dzm91@hust.edu.cn>; Jonathan
>Corbet <corbet@lwn.net>; Tomasz Figa <tfiga@chromium.org>; Marek
>Szyprowski <m.szyprowski@samsung.com>; Andy Walls
><awalls@md.metrocast.net>; Michael Tretter <m.tretter@pengutronix.de>;
>Pengutronix Kernel Team <kernel@pengutronix.de>; Bin Liu
><bin.liu@mediatek.com>; Matthias Brugger <matthias.bgg@gmail.com>;
>AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>;
>Dmitry Osipenko <digetx@gmail.com>; Thierry Reding
><thierry.reding@gmail.com>; Jonathan Hunter <jonathanh@nvidia.com>;
>Mirela Rabulea <mirela.rabulea@nxp.com>; Shawn Guo
><shawnguo@kernel.org>; Sascha Hauer <s.hauer@pengutronix.de>; Fabio
>Estevam <festevam@gmail.com>; Kieran Bingham
><kieran.bingham+renesas@ideasonboard.com>; Michal Simek
><michal.simek@amd.com>; Ming Qian <ming.qian@nxp.com>; Zhou Peng
><eagle.zhou@nxp.com>; Xavier Roumegue <xavier.roumegue@oss.nxp.com>;
>Philipp Zabel <p.zabel@pengutronix.de>; Vikash Garodia
><quic_vgarodia@quicinc.com>; Dikshita Agarwal
><quic_dikshita@quicinc.com>; Abhinav Kumar <abhinav.kumar@linux.dev>;
>Bryan O'Donoghue <bryan.odonoghue@linaro.org>; Sylwester Nawrocki
><sylvester.nawrocki@gmail.com>; Jernej Skrabec
><jernej.skrabec@gmail.com>; Chen-Yu Tsai <wens@csie.org>; Samuel
>Holland <samuel@sholland.org>; Daniel Almeida
><daniel.almeida@collabora.com>; Neil Armstrong
><neil.armstrong@linaro.org>; Kevin Hilman <khilman@baylibre.com>;
>Jerome Brunet <jbrunet@baylibre.com>; Martin Blumenstingl
><martin.blumenstingl@googlemail.com>; Nas Chung
><nas.chung@chipsnmedia.com>; Jackson Lee <jackson.lee@chipsnmedia.com>;
>Minghsiu Tsai <minghsiu.tsai@mediatek.com>; Houlong Wei
><houlong.wei@mediatek.com>; Andrew-CT Chen <andrew-
>ct.chen@mediatek.com>; Tiffany Lin <tiffany.lin@mediatek.com>; Yunfei
>Dong <yunfei.dong@mediatek.com>; Geert Uytterhoeven
><geert+renesas@glider.be>; Magnus Damm <magnus.damm@gmail.com>; Mikhail
>Ulyanov <mikhail.ulyanov@cogentembedded.com>; Jacob Chen <jacob-
>chen@iotwrt.com>; Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>;
>Heiko Stuebner <heiko@sntech.de>; Detlev Casanova
><detlev.casanova@collabora.com>; Krzysztof Kozlowski <krzk@kernel.org>;
>Alim Akhtar <alim.akhtar@samsung.com>; Sylwester Nawrocki
><s.nawrocki@samsung.com>; Łukasz Stelmach <l.stelmach@samsung.com>;
>Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>; Jacek Anaszewski
><jacek.anaszewski@gmail.com>; Hajda, Andrzej <andrzej.hajda@intel.com>;
>Fabien Dessenne <fabien.dessenne@foss.st.com>; Hugues Fruchet
><hugues.fruchet@foss.st.com>; Jean-Christophe Trotin <jean-
>christophe.trotin@foss.st.com>; Maxime Coquelin
><mcoquelin.stm32@gmail.com>; Alexandre Torgue
><alexandre.torgue@foss.st.com>; Nicolas Dufresne
><nicolas.dufresne@collabora.com>; Benjamin Gaignard
><benjamin.gaignard@collabora.com>; Steve Longerbeam
><slongerbeam@gmail.com>; Maxime Ripard <mripard@kernel.org>; Paul
>Kocialkowski <paulk@sys-base.io>; Niklas Söderlund
><niklas.soderlund@ragnatech.se>; Robert Foss <rfoss@kernel.org>; Todor
>Tomov <todor.too@gmail.com>; Vladimir Zapolskiy
><vladimir.zapolskiy@linaro.org>; Corentin Labbe <clabbe@baylibre.com>;
>Sakari Ailus <sakari.ailus@linux.intel.com>; Cao, Bingbu
><bingbu.cao@intel.com>; Qiu, Tian Shu <tian.shu.qiu@intel.com>;
>Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
>Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
>staging@lists.linux.dev; linux-doc@vger.kernel.org; linux-arm-
>kernel@lists.infradead.org; linux-mediatek@lists.infradead.org; linux-
>tegra@vger.kernel.org; imx@lists.linux.dev; linux-renesas-
>soc@vger.kernel.org; linux-arm-msm@vger.kernel.org; linux-samsung-
>soc@vger.kernel.org; linux-sunxi@lists.linux.dev; linux-
>usb@vger.kernel.org; linux-amlogic@lists.infradead.org; linux-
>rockchip@lists.infradead.org; linux-stm32@st-md-mailman.stormreply.com;
>mjpeg-users@lists.sourceforge.net; Jacopo Mondi
><jacopo.mondi@ideasonboard.com>
>Subject: [PATCH 63/65] media: ipu6: isys: Don't set
>V4L2_FL_USES_V4L2_FH manually
>
>From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
>to be set manually by drivers. Drop it from the ipu6-isys driver.
>
>Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>---
> drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 1 -
> 1 file changed, 1 deletion(-)
>
>diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
>b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
>index
>24a2ef93474cc400f64eb1d50bc760ee66124d1b..f3f3bc0615e5dc698be5c479dfed8
>ef2eb49cbfb 100644
>--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
>+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c
>@@ -1306,7 +1306,6 @@ int ipu6_isys_video_init(struct ipu6_isys_video
>*av)
> __ipu6_isys_vidioc_try_fmt_meta_cap(av, &format_meta);
> av->meta_fmt = format_meta.fmt.meta;
>
>- set_bit(V4L2_FL_USES_V4L2_FH, &av->vdev.flags);
> video_set_drvdata(&av->vdev, av);
>
> ret = video_register_device(&av->vdev, VFL_TYPE_VIDEO, -1);
>
>--
>2.49.0
Thanks for the patch.
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com>
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-07 20:51 ` Hans Verkuil
@ 2025-08-08 6:30 ` Laurent Pinchart
0 siblings, 0 replies; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-08 6:30 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Thu, Aug 07, 2025 at 10:51:27PM +0200, Hans Verkuil wrote:
> On 07/08/2025 22:25, Laurent Pinchart wrote:
> > On Thu, Aug 07, 2025 at 08:00:06PM +0300, Laurent Pinchart wrote:
> >> On Thu, Aug 07, 2025 at 11:50:07AM +0300, Laurent Pinchart wrote:
> >>> On Wed, Aug 06, 2025 at 02:45:14PM +0200, Hans Verkuil wrote:
> >>>> On 02/08/2025 11:22, Jacopo Mondi wrote:
> >>>>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>>>
> >>>>> 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@ideasonboard.com>
> >>>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >>>>> ---
> >>>>> Documentation/driver-api/media/v4l2-fh.rst | 4 ++--
> >>>>> Documentation/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 ++--
> >>>>> .../media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.c | 4 ++--
> >>>>> .../media/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(-)
> >>>>>
> >>>>
> >>>> <snip>
> >>>>
> >>>>> diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
> >>>>> index b59b1084d8cdf1b62da12879e21dbe56c2109648..df3ba9d4674bd25626cfcddc2d0cb28c233e3cc3 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)
> >>>>
> >>>> Instead of adding a second argument, perhaps it is better to
> >>>> just provide the filp pointer. After all, you can get the v4l2_fh
> >>>> from filp->private_data.
> >>>>
> >>>> It simplifies the code a bit.
> >>>
> >>> That's an interesting idea. I'll give it a try.
> >>
> >> We end up with code like (e.g. in v4l2_fh_release(), with similar
> >> constructs in lots of drivers)
> >>
> >> if (fh) {
> >> v4l2_fh_del(filp);
> >> v4l2_fh_exit(fh);
> >> kfree(fh);
> >> }
> >>
> >> compared to
> >>
> >> if (fh) {
> >> v4l2_fh_del(fh, filp);
> >> v4l2_fh_exit(fh);
> >> kfree(fh);
> >> }
> >>
> >> with the existing patch. I find the fact that v4l2_fh_del() takes a
> >> different pointer than v4l2_fh_exit() a bit disturbing. If you think
> >> it's better I'll drop the fh argument in v2.
> >
> > I gave it a try, and looking at the function prototype, its
> > documentation, the imbalance with v4l2_fh_add(), and the code in the
> > callers, I think keeping both arguments would look cleaner. Please tell
> > me if you feel strongly about this, I can still submit a patch to drop
> > the argument. It can very easily be scripted with coccinelle and doesn't
> > conflict with the rest of the series, so it could also be done later.
>
> Looking at all the drivers that call v4l2_fh_del/exit I always see v4l2_fh_del()
> directly followed by v4l2_fh_exit(). I think it would make a lot of sense to just
> combine the two as a single function: v4l2_fh_del_exit(filp).
>
> That simplifies the code and solves the imbalance.
I'll try that as a separate patch on top of this one. Keeping the two
separate will ease review (both patches will be simpler, and will be
generated by coccinelle), and will also make it easier to drop the
second patch if we decide it's not the way to go.
> >>>>> {
> >>>>> 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;
> >>>>> }
> >>>>
> >>>> <snip>
> >>>>
> >>>>> diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
> >>>>> index d8fcf49f10e09452b73499f4a9bd1285bc2835a5..5e4c761635120608e0b588e0b0daf63e69588d38 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 [flat|nested] 101+ messages in thread
* Re: [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers
2025-08-07 20:55 ` Hans Verkuil
@ 2025-08-08 7:00 ` Laurent Pinchart
0 siblings, 0 replies; 101+ messages in thread
From: Laurent Pinchart @ 2025-08-08 7:00 UTC (permalink / raw)
To: Hans Verkuil
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Sakari Ailus, Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka,
linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
On Thu, Aug 07, 2025 at 10:55:59PM +0200, Hans Verkuil wrote:
> On 07/08/2025 22:33, Laurent Pinchart wrote:
> > On Thu, Aug 07, 2025 at 09:58:34AM +0200, Hans Verkuil wrote:
> >> On 07/08/2025 09:26, Hans Verkuil wrote:
> >>> On 02/08/2025 11:23, Jacopo Mondi wrote:
> >>>> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>>
> >>>> Now that all drivers access the v4l2_fh from the file structure, there
> >>>> is no need to pass it as an explicit argument to ioctl handlers. Set the
> >>>> argument to NULL in the w__video_do_ioctl(), and drop the name of the
> >>>> void *fh argument in the ioctl handler declarations to indicate it is
> >>>> not used.
> >>>>
> >>>> The argument could be removed altogether with a mechanical change
> >>>> (probably using coccinelle), but there are plans to pass a new argument
> >>>> to the ioctl handlers in the near future. The tree-wide change to remove
> >>>> the argument, only to add another one soon after, would be too much
> >>>> churn.
> >>>>
> >>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >>>> ---
> >>>> drivers/media/v4l2-core/v4l2-ioctl.c | 5 +-
> >>>> include/media/v4l2-ioctl.h | 236 +++++++++++++++++------------------
> >>>> 2 files changed, 120 insertions(+), 121 deletions(-)
> >>>>
> >>>> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> >>>> index 44c2f5ef3dae407d9786c5278d13efc982be2ff0..248a0b5b56ec7a09f2d4c61114f81aa5a9b8b041 100644
> >>>> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> >>>> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> >>>> @@ -3078,7 +3078,6 @@ static long __video_do_ioctl(struct file *file,
> >>>> bool write_only = false;
> >>>> struct v4l2_ioctl_info default_info;
> >>>> const struct v4l2_ioctl_info *info;
> >>>> - void *fh = file_to_v4l2_fh(file);
> >>>> struct v4l2_fh *vfh = NULL;
> >>>> int dev_debug = vfd->dev_debug;
> >>>> long ret = -ENOTTY;
> >>>> @@ -3140,11 +3139,11 @@ static long __video_do_ioctl(struct file *file,
> >>>>
> >>>> write_only = _IOC_DIR(cmd) == _IOC_WRITE;
> >>>> if (info != &default_info) {
> >>>> - ret = info->func(ops, file, fh, arg);
> >>>> + ret = info->func(ops, file, NULL, arg);
> >>>> } else if (!ops->vidioc_default) {
> >>>> ret = -ENOTTY;
> >>>> } else {
> >>>> - ret = ops->vidioc_default(file, fh,
> >>>> + ret = ops->vidioc_default(file, NULL,
> >>>> vfh ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
> >>>> cmd, arg);
> >>>> }
> >>>
> >>> drivers/media/v4l2-core/v4l2-compat-ioctl32.c also calls ops->vidioc_query_ext_ctrl
> >>> directly, but still passes the fh as second argument: that needs to be replaced by
> >>> a NULL pointer as well. That should be fixed in this patch as well.
> >
> > Oops, I missed it. Will be fixed in v2.
> >
> >>> Regarding v4l2-ioctl.c: I would like a follow-up patch that pushes the NULL pointer
> >>> down into each ioctl helper function. I.e. drop the 'void *fh' argument in the
> >>> struct v4l2_ioctl_info 'func' callback, and all callbacks like v4l_g_fmt() just
> >>> replace 'fh' by 'NULL' when they call the vidioc op.
> >
> > I'll add a patch in v2.
> >
> >>> Part of it is that the core functions currently suggest that the second argument is
> >>> a filehandle (since it's still named 'fh'), which is obviously wrong. And I also think
> >>> that the core framework shouldn't use a dummy second argument at all. I admit that
> >>> changing all vidioc callbacks in the whole subsystem to drop the second argument is
> >>> too much churn, but for this core file I think it is something that should be done.
> >>
> >> A follow-up on this: I would not be against a large patch that drops the second priv
> >> argument from all vidioc ops since it is now unused. If nothing else, it helps ensure
> >> that it is really unused by all drivers :-)
> >
> > I've considered that. We're working on introducing a video_device_state
> > that will likely be passed as an argument to the ioctl handlers, and we
> > thought that not removing the void *priv argument yet could mean less
> > churn in drivers when we add the new argument, taking over the void
> > *priv. However, the state should be passed through an explicitly typed
> > pointer, so we'll have to patch all drivers anyway. I suppose we could
> > drop the void pointer now, and add a new pointer later. What do you
> > think ?
>
> It depends on how what you think is the ETA for the video_device_state :-)
>
> I think we can shelve this for now, but as mentioned below, at least replace
> 'fh' by 'priv' for the test drivers, pci skeleton driver and (I think) uvc.
OK, I'll do that.
> >> But if you don't want to go there, then there is something that I think need to be addressed:
> >> a lot of drivers name the second argument 'fh' or '_fh' or even 'fh0'. Can we add a patch that
> >> renames the second arg to 'priv'?
> >>
> >> At minimum I think this should be done for drivers/media/test-drivers and
> >> samples/v4l/v4l2-pci-skeleton.c. These drivers are often used as reference drivers,
> >> so they should be up-to-date.
> >>
> >> I would also suggest to do this for uvc since it is by far the most widely used media
> >> driver.
> >>
> >> I also see the use of 'fh' in v4l2-mem2mem.c in a few places.
> >>
> >>>> diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
> >>>> index 82695c3a300a73219f262fb556ed61a8f09d273e..223e2c7a3516fc96fb486ab64226163e52f775a6 100644
> >>>> --- a/include/media/v4l2-ioctl.h
> >>>> +++ b/include/media/v4l2-ioctl.h
> >>>> @@ -293,144 +293,144 @@ struct v4l2_ioctl_ops {
> >>>> /* ioctl callbacks */
> >>>>
> >>>> /* VIDIOC_QUERYCAP handler */
> >>>> - int (*vidioc_querycap)(struct file *file, void *fh,
> >>>> + int (*vidioc_querycap)(struct file *file, void *,
> >>>> struct v4l2_capability *cap);
> >>>>
> >>>> /* VIDIOC_ENUM_FMT handlers */
> >>>> - int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_vid_overlay)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_vid_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_vid_out)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_sdr_cap)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_sdr_out)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_meta_cap)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>> - int (*vidioc_enum_fmt_meta_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_fmt_meta_out)(struct file *file, void *,
> >>>> struct v4l2_fmtdesc *f);
> >>>>
> >>>> /* VIDIOC_G_FMT handlers */
> >>>> - int (*vidioc_g_fmt_vid_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vid_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_sdr_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_sdr_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_sdr_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_meta_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_meta_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_g_fmt_meta_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_fmt_meta_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>>
> >>>> /* VIDIOC_S_FMT handlers */
> >>>> - int (*vidioc_s_fmt_vid_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vid_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_sdr_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_sdr_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_sdr_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_meta_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_meta_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_s_fmt_meta_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fmt_meta_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>>
> >>>> /* VIDIOC_TRY_FMT handlers */
> >>>> - int (*vidioc_try_fmt_vid_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vid_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_sdr_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_sdr_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_sdr_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_meta_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_meta_cap)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>> - int (*vidioc_try_fmt_meta_out)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_fmt_meta_out)(struct file *file, void *,
> >>>> struct v4l2_format *f);
> >>>>
> >>>> /* Buffer handlers */
> >>>> - int (*vidioc_reqbufs)(struct file *file, void *fh,
> >>>> + int (*vidioc_reqbufs)(struct file *file, void *,
> >>>> struct v4l2_requestbuffers *b);
> >>>> - int (*vidioc_querybuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_querybuf)(struct file *file, void *,
> >>>> struct v4l2_buffer *b);
> >>>> - int (*vidioc_qbuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_qbuf)(struct file *file, void *,
> >>>> struct v4l2_buffer *b);
> >>>> - int (*vidioc_expbuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_expbuf)(struct file *file, void *,
> >>>> struct v4l2_exportbuffer *e);
> >>>> - int (*vidioc_dqbuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_dqbuf)(struct file *file, void *,
> >>>> struct v4l2_buffer *b);
> >>>>
> >>>> - int (*vidioc_create_bufs)(struct file *file, void *fh,
> >>>> + int (*vidioc_create_bufs)(struct file *file, void *,
> >>>> struct v4l2_create_buffers *b);
> >>>> - int (*vidioc_prepare_buf)(struct file *file, void *fh,
> >>>> + int (*vidioc_prepare_buf)(struct file *file, void *,
> >>>> struct v4l2_buffer *b);
> >>>> - int (*vidioc_remove_bufs)(struct file *file, void *fh,
> >>>> + int (*vidioc_remove_bufs)(struct file *file, void *,
> >>>> struct v4l2_remove_buffers *d);
> >>>>
> >>>> - int (*vidioc_overlay)(struct file *file, void *fh, unsigned int i);
> >>>> - int (*vidioc_g_fbuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_overlay)(struct file *file, void *, unsigned int i);
> >>>> + int (*vidioc_g_fbuf)(struct file *file, void *,
> >>>> struct v4l2_framebuffer *a);
> >>>> - int (*vidioc_s_fbuf)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_fbuf)(struct file *file, void *,
> >>>> const struct v4l2_framebuffer *a);
> >>>>
> >>>> /* Stream on/off */
> >>>> - int (*vidioc_streamon)(struct file *file, void *fh,
> >>>> + int (*vidioc_streamon)(struct file *file, void *,
> >>>> enum v4l2_buf_type i);
> >>>> - int (*vidioc_streamoff)(struct file *file, void *fh,
> >>>> + int (*vidioc_streamoff)(struct file *file, void *,
> >>>> enum v4l2_buf_type i);
> >>>>
> >>>> /*
> >>>> @@ -438,135 +438,135 @@ struct v4l2_ioctl_ops {
> >>>> *
> >>>> * Note: ENUMSTD is handled by videodev.c
> >>>> */
> >>>> - int (*vidioc_g_std)(struct file *file, void *fh, v4l2_std_id *norm);
> >>>> - int (*vidioc_s_std)(struct file *file, void *fh, v4l2_std_id norm);
> >>>> - int (*vidioc_querystd)(struct file *file, void *fh, v4l2_std_id *a);
> >>>> + int (*vidioc_g_std)(struct file *file, void *, v4l2_std_id *norm);
> >>>> + int (*vidioc_s_std)(struct file *file, void *, v4l2_std_id norm);
> >>>> + int (*vidioc_querystd)(struct file *file, void *, v4l2_std_id *a);
> >>>>
> >>>> /* Input handling */
> >>>> - int (*vidioc_enum_input)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_input)(struct file *file, void *,
> >>>> struct v4l2_input *inp);
> >>>> - int (*vidioc_g_input)(struct file *file, void *fh, unsigned int *i);
> >>>> - int (*vidioc_s_input)(struct file *file, void *fh, unsigned int i);
> >>>> + int (*vidioc_g_input)(struct file *file, void *, unsigned int *i);
> >>>> + int (*vidioc_s_input)(struct file *file, void *, unsigned int i);
> >>>>
> >>>> /* Output handling */
> >>>> - int (*vidioc_enum_output)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_output)(struct file *file, void *,
> >>>> struct v4l2_output *a);
> >>>> - int (*vidioc_g_output)(struct file *file, void *fh, unsigned int *i);
> >>>> - int (*vidioc_s_output)(struct file *file, void *fh, unsigned int i);
> >>>> + int (*vidioc_g_output)(struct file *file, void *, unsigned int *i);
> >>>> + int (*vidioc_s_output)(struct file *file, void *, unsigned int i);
> >>>>
> >>>> /* Control handling */
> >>>> - int (*vidioc_query_ext_ctrl)(struct file *file, void *fh,
> >>>> + int (*vidioc_query_ext_ctrl)(struct file *file, void *,
> >>>> struct v4l2_query_ext_ctrl *a);
> >>>> - int (*vidioc_g_ext_ctrls)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_ext_ctrls)(struct file *file, void *,
> >>>> struct v4l2_ext_controls *a);
> >>>> - int (*vidioc_s_ext_ctrls)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_ext_ctrls)(struct file *file, void *,
> >>>> struct v4l2_ext_controls *a);
> >>>> - int (*vidioc_try_ext_ctrls)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_ext_ctrls)(struct file *file, void *,
> >>>> struct v4l2_ext_controls *a);
> >>>> - int (*vidioc_querymenu)(struct file *file, void *fh,
> >>>> + int (*vidioc_querymenu)(struct file *file, void *,
> >>>> struct v4l2_querymenu *a);
> >>>>
> >>>> /* Audio ioctls */
> >>>> - int (*vidioc_enumaudio)(struct file *file, void *fh,
> >>>> + int (*vidioc_enumaudio)(struct file *file, void *,
> >>>> struct v4l2_audio *a);
> >>>> - int (*vidioc_g_audio)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_audio)(struct file *file, void *,
> >>>> struct v4l2_audio *a);
> >>>> - int (*vidioc_s_audio)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_audio)(struct file *file, void *,
> >>>> const struct v4l2_audio *a);
> >>>>
> >>>> /* Audio out ioctls */
> >>>> - int (*vidioc_enumaudout)(struct file *file, void *fh,
> >>>> + int (*vidioc_enumaudout)(struct file *file, void *,
> >>>> struct v4l2_audioout *a);
> >>>> - int (*vidioc_g_audout)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_audout)(struct file *file, void *,
> >>>> struct v4l2_audioout *a);
> >>>> - int (*vidioc_s_audout)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_audout)(struct file *file, void *,
> >>>> const struct v4l2_audioout *a);
> >>>> - int (*vidioc_g_modulator)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_modulator)(struct file *file, void *,
> >>>> struct v4l2_modulator *a);
> >>>> - int (*vidioc_s_modulator)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_modulator)(struct file *file, void *,
> >>>> const struct v4l2_modulator *a);
> >>>> /* Crop ioctls */
> >>>> - int (*vidioc_g_pixelaspect)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_pixelaspect)(struct file *file, void *,
> >>>> int buf_type, struct v4l2_fract *aspect);
> >>>> - int (*vidioc_g_selection)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_selection)(struct file *file, void *,
> >>>> struct v4l2_selection *s);
> >>>> - int (*vidioc_s_selection)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_selection)(struct file *file, void *,
> >>>> struct v4l2_selection *s);
> >>>> /* Compression ioctls */
> >>>> - int (*vidioc_g_jpegcomp)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_jpegcomp)(struct file *file, void *,
> >>>> struct v4l2_jpegcompression *a);
> >>>> - int (*vidioc_s_jpegcomp)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_jpegcomp)(struct file *file, void *,
> >>>> const struct v4l2_jpegcompression *a);
> >>>> - int (*vidioc_g_enc_index)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_enc_index)(struct file *file, void *,
> >>>> struct v4l2_enc_idx *a);
> >>>> - int (*vidioc_encoder_cmd)(struct file *file, void *fh,
> >>>> + int (*vidioc_encoder_cmd)(struct file *file, void *,
> >>>> struct v4l2_encoder_cmd *a);
> >>>> - int (*vidioc_try_encoder_cmd)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_encoder_cmd)(struct file *file, void *,
> >>>> struct v4l2_encoder_cmd *a);
> >>>> - int (*vidioc_decoder_cmd)(struct file *file, void *fh,
> >>>> + int (*vidioc_decoder_cmd)(struct file *file, void *,
> >>>> struct v4l2_decoder_cmd *a);
> >>>> - int (*vidioc_try_decoder_cmd)(struct file *file, void *fh,
> >>>> + int (*vidioc_try_decoder_cmd)(struct file *file, void *,
> >>>> struct v4l2_decoder_cmd *a);
> >>>>
> >>>> /* Stream type-dependent parameter ioctls */
> >>>> - int (*vidioc_g_parm)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_parm)(struct file *file, void *,
> >>>> struct v4l2_streamparm *a);
> >>>> - int (*vidioc_s_parm)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_parm)(struct file *file, void *,
> >>>> struct v4l2_streamparm *a);
> >>>>
> >>>> /* Tuner ioctls */
> >>>> - int (*vidioc_g_tuner)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_tuner)(struct file *file, void *,
> >>>> struct v4l2_tuner *a);
> >>>> - int (*vidioc_s_tuner)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_tuner)(struct file *file, void *,
> >>>> const struct v4l2_tuner *a);
> >>>> - int (*vidioc_g_frequency)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_frequency)(struct file *file, void *,
> >>>> struct v4l2_frequency *a);
> >>>> - int (*vidioc_s_frequency)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_frequency)(struct file *file, void *,
> >>>> const struct v4l2_frequency *a);
> >>>> - int (*vidioc_enum_freq_bands)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_freq_bands)(struct file *file, void *,
> >>>> struct v4l2_frequency_band *band);
> >>>>
> >>>> /* Sliced VBI cap */
> >>>> - int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_sliced_vbi_cap)(struct file *file, void *,
> >>>> struct v4l2_sliced_vbi_cap *a);
> >>>>
> >>>> /* Log status ioctl */
> >>>> - int (*vidioc_log_status)(struct file *file, void *fh);
> >>>> + int (*vidioc_log_status)(struct file *file, void *);
> >>>>
> >>>> - int (*vidioc_s_hw_freq_seek)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_hw_freq_seek)(struct file *file, void *,
> >>>> const struct v4l2_hw_freq_seek *a);
> >>>>
> >>>> /* Debugging ioctls */
> >>>> #ifdef CONFIG_VIDEO_ADV_DEBUG
> >>>> - int (*vidioc_g_register)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_register)(struct file *file, void *,
> >>>> struct v4l2_dbg_register *reg);
> >>>> - int (*vidioc_s_register)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_register)(struct file *file, void *,
> >>>> const struct v4l2_dbg_register *reg);
> >>>>
> >>>> - int (*vidioc_g_chip_info)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_chip_info)(struct file *file, void *,
> >>>> struct v4l2_dbg_chip_info *chip);
> >>>> #endif
> >>>>
> >>>> - int (*vidioc_enum_framesizes)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_framesizes)(struct file *file, void *,
> >>>> struct v4l2_frmsizeenum *fsize);
> >>>>
> >>>> - int (*vidioc_enum_frameintervals)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_frameintervals)(struct file *file, void *,
> >>>> struct v4l2_frmivalenum *fival);
> >>>>
> >>>> /* DV Timings IOCTLs */
> >>>> - int (*vidioc_s_dv_timings)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_dv_timings)(struct file *file, void *,
> >>>> struct v4l2_dv_timings *timings);
> >>>> - int (*vidioc_g_dv_timings)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_dv_timings)(struct file *file, void *,
> >>>> struct v4l2_dv_timings *timings);
> >>>> - int (*vidioc_query_dv_timings)(struct file *file, void *fh,
> >>>> + int (*vidioc_query_dv_timings)(struct file *file, void *,
> >>>> struct v4l2_dv_timings *timings);
> >>>> - int (*vidioc_enum_dv_timings)(struct file *file, void *fh,
> >>>> + int (*vidioc_enum_dv_timings)(struct file *file, void *,
> >>>> struct v4l2_enum_dv_timings *timings);
> >>>> - int (*vidioc_dv_timings_cap)(struct file *file, void *fh,
> >>>> + int (*vidioc_dv_timings_cap)(struct file *file, void *,
> >>>> struct v4l2_dv_timings_cap *cap);
> >>>> - int (*vidioc_g_edid)(struct file *file, void *fh,
> >>>> + int (*vidioc_g_edid)(struct file *file, void *,
> >>>> struct v4l2_edid *edid);
> >>>> - int (*vidioc_s_edid)(struct file *file, void *fh,
> >>>> + int (*vidioc_s_edid)(struct file *file, void *,
> >>>> struct v4l2_edid *edid);
> >>>>
> >>>> int (*vidioc_subscribe_event)(struct v4l2_fh *fh,
> >>>> @@ -575,7 +575,7 @@ struct v4l2_ioctl_ops {
> >>>> const struct v4l2_event_subscription *sub);
> >>>>
> >>>> /* For other private ioctls */
> >>>> - long (*vidioc_default)(struct file *file, void *fh,
> >>>> + long (*vidioc_default)(struct file *file, void *,
> >>>> bool valid_prio, unsigned int cmd, void *arg);
> >>>> };
> >>>>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
2025-08-08 1:01 ` Cao, Bingbu
@ 2025-08-08 7:22 ` Sakari Ailus
1 sibling, 0 replies; 101+ messages in thread
From: Sakari Ailus @ 2025-08-08 7:22 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Devarsh Thakkar, Benoit Parrot,
Hans Verkuil, Mike Isely, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka, linux-media,
linux-kernel, linux-staging, linux-doc, linux-arm-kernel,
linux-mediatek, linux-tegra, imx, linux-renesas-soc,
linux-arm-msm, linux-samsung-soc, linux-sunxi, linux-usb,
linux-amlogic, linux-rockchip, linux-stm32, mjpeg-users
On Sat, Aug 02, 2025 at 11:23:25AM +0200, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
> to be set manually by drivers. Drop it from the ipu6-isys driver.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 64/65] media: staging: ipu7: isys: Don't set V4L2_FL_USES_V4L2_FH manually
2025-08-07 17:01 ` Laurent Pinchart
@ 2025-08-08 7:22 ` Sakari Ailus
0 siblings, 0 replies; 101+ messages in thread
From: Sakari Ailus @ 2025-08-08 7:22 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Mike Isely, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Dongliang Mu, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Jacob Chen, Ezequiel Garcia,
Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne, Hugues Fruchet,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Vladimir Zapolskiy, Corentin Labbe,
Bingbu Cao, Tianshu Qiu, Stanislaw Gruszka, linux-media,
linux-kernel, linux-staging, linux-doc, linux-arm-kernel,
linux-mediatek, linux-tegra, imx, linux-renesas-soc,
linux-arm-msm, linux-samsung-soc, linux-sunxi, linux-usb,
linux-amlogic, linux-rockchip, linux-stm32, mjpeg-users
On Thu, Aug 07, 2025 at 08:01:35PM +0300, Laurent Pinchart wrote:
> Hi Sakari,
>
> On Thu, Aug 07, 2025 at 09:07:13AM +0000, Sakari Ailus wrote:
> > On Sat, Aug 02, 2025 at 11:23:26AM +0200, Jacopo Mondi wrote:
> > > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > >
> > > The V4L2_FL_USES_V4L2_FH flag is set by v4l2_fh_init(). It is not meant
> > > to be set manually by drivers. Drop it from the ipu7-isys driver.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >
> > Thanks, Jacopo!
> >
> > Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> Can we get you review on patch 63/65 too (for the IPU6 driver) too ?
Done.
--
Sakari Ailus
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 11/65] media: Replace file->private_data access with custom functions
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
2025-08-06 8:16 ` Hans Verkuil
@ 2025-08-18 14:10 ` Lukasz Stelmach
1 sibling, 0 replies; 101+ messages in thread
From: Lukasz Stelmach @ 2025-08-18 14:10 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Laurent Pinchart, linux-media, linux-kernel, linux-staging,
linux-doc, linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
[-- Attachment #1: Type: text/plain, Size: 2037 bytes --]
It was <2025-08-02 sob 11:22>, when Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> 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 and cast it to driver-specific file handle
> structures with driver-specific functions that use file_to_v4l2_fh() and
> perform the same cast.
>
> 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@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> ---
[...]
> diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> index ffed16a34493be2edbdaee13619467417487c1e7..44fcedbbc90a9863827aacbcd5f56d850cb552ea 100644
> --- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> @@ -25,7 +25,10 @@
> #include "g2d.h"
> #include "g2d-regs.h"
>
> -#define fh2ctx(__fh) container_of(__fh, struct g2d_ctx, fh)
> +static inline struct g2d_ctx *file2ctx(struct file *filp)
> +{
> + return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh);
> +}
>
> static struct g2d_fmt formats[] = {
> {
> @@ -272,7 +275,7 @@ static int g2d_open(struct file *file)
> static int g2d_release(struct file *file)
> {
> struct g2d_dev *dev = video_drvdata(file);
> - struct g2d_ctx *ctx = fh2ctx(file->private_data);
> + struct g2d_ctx *ctx = file2ctx(file);
>
> mutex_lock(&dev->mutex);
> v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
Acked-by: Lukasz Stelmach <l.stelmach@samsung.com>
[...]
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del()
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
2025-08-06 12:45 ` Hans Verkuil
@ 2025-08-18 14:12 ` Lukasz Stelmach
1 sibling, 0 replies; 101+ messages in thread
From: Lukasz Stelmach @ 2025-08-18 14:12 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Laurent Pinchart, linux-media, linux-kernel, linux-staging,
linux-doc, linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]
It was <2025-08-02 sob 11:22>, when Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> 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.
[...]
> diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> index e34cae9c9cf65d3161822b68233d28472171f917..922262f61e7b53baf1b5840d35149bf5b4b2e7ad 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 c4ad0196ed8f1bf579365a0a21dd8c4a78bdaa10..2a57efd181540183e7d2b66d51f9f2f274ddd100 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);
Acked-by: Łukasz Stelmach <l.stelmach@samsung.com>
[...]
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open()
2025-08-02 9:22 ` [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open() Jacopo Mondi
@ 2025-08-24 19:04 ` Vladimir Zapolskiy
0 siblings, 0 replies; 101+ messages in thread
From: Vladimir Zapolskiy @ 2025-08-24 19:04 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Minghsiu Tsai, Houlong Wei, Andrew-CT Chen, Tiffany Lin,
Yunfei Dong, Geert Uytterhoeven, Magnus Damm, Mikhail Ulyanov,
Jacob Chen, Heiko Stuebner, Detlev Casanova, Krzysztof Kozlowski,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Paul Kocialkowski, Niklas Söderlund,
Robert Foss, Todor Tomov, Corentin Labbe, Sakari Ailus,
Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Jacopo, Laurent,
thank you for the nice clean-up.
On 8/2/25 12:22, Jacopo Mondi wrote:
> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> 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@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 101+ messages in thread
* Re: [PATCH 20/65] media: camss: Remove custom .release fop()
2025-08-02 9:22 ` [PATCH 20/65] media: camss: Remove custom .release fop() Jacopo Mondi
@ 2025-08-24 19:07 ` Vladimir Zapolskiy
0 siblings, 0 replies; 101+ messages in thread
From: Vladimir Zapolskiy @ 2025-08-24 19:07 UTC (permalink / raw)
To: Jacopo Mondi, Mauro Carvalho Chehab, Devarsh Thakkar,
Benoit Parrot, Hans Verkuil, Laurent Pinchart, Hans de Goede,
Parthiban Veerasooran, Christian Gromm, Greg Kroah-Hartman,
Alex Shi, Yanteng Si, Jonathan Corbet, Tomasz Figa,
Marek Szyprowski, Andy Walls, Michael Tretter,
Pengutronix Kernel Team, Bin Liu, Matthias Brugger,
AngeloGioacchino Del Regno, Dmitry Osipenko, Thierry Reding,
Jonathan Hunter, Mirela Rabulea, Shawn Guo, Sascha Hauer,
Fabio Estevam, Kieran Bingham, Michal Simek, Ming Qian, Zhou Peng,
Xavier Roumegue, Philipp Zabel, Vikash Garodia, Dikshita Agarwal,
Abhinav Kumar, Bryan O'Donoghue, Sylwester Nawrocki,
Jernej Skrabec, Chen-Yu Tsai, Samuel Holland, Daniel Almeida,
Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Nas Chung, Jackson Lee, Minghsiu Tsai, Houlong Wei,
Andrew-CT Chen, Tiffany Lin, Yunfei Dong, Geert Uytterhoeven,
Magnus Damm, Mikhail Ulyanov, Ezequiel Garcia, Heiko Stuebner,
Detlev Casanova, Krzysztof Kozlowski, Alim Akhtar,
Sylwester Nawrocki, Łukasz Stelmach, Andrzej Pietrasiewicz,
Jacek Anaszewski, Andrzej Hajda, Fabien Dessenne,
Jean-Christophe Trotin, Maxime Coquelin, Alexandre Torgue,
Nicolas Dufresne, Benjamin Gaignard, Steve Longerbeam,
Maxime Ripard, Niklas Söderlund, Robert Foss, Todor Tomov,
Corentin Labbe, Sakari Ailus, Bingbu Cao, Stanislaw Gruszka
Cc: linux-media, linux-kernel, linux-staging, linux-doc,
linux-arm-kernel, linux-mediatek, linux-tegra, imx,
linux-renesas-soc, linux-arm-msm, linux-samsung-soc, linux-sunxi,
linux-usb, linux-amlogic, linux-rockchip, linux-stm32,
mjpeg-users
Hi Jacopo,
thank you for the change!
On 8/2/25 12:22, Jacopo Mondi wrote:
> 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>
Tested-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 101+ messages in thread
end of thread, other threads:[~2025-08-24 19:07 UTC | newest]
Thread overview: 101+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 02/65] media: imagination: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 03/65] media: ti: vpe: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 04/65] media: usb: hdpvr: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 05/65] media: usb: pvrusb2: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 06/65] media: usb: uvcvideo: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 07/65] media: staging: most: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 08/65] media: Wrap file->private_data access with a helper function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 09/65] media: Replace file->private_data access with file_to_v4l2_fh() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access Jacopo Mondi
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
2025-08-06 8:16 ` Hans Verkuil
2025-08-06 9:48 ` Laurent Pinchart
2025-08-06 10:23 ` Hans Verkuil
2025-08-18 14:10 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 12/65] media: pci: ivtv: Don't create fake v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static Jacopo Mondi
2025-08-05 1:34 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release() Jacopo Mondi
2025-08-05 1:43 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 15/65] media: visl: Drop visl_v4l2fh_to_ctx() function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 16/65] media: v4l2-fh: Move piece of documentation to correct function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 17/65] media: rcar-vin: Do not set file->private_data Jacopo Mondi
2025-08-02 13:26 ` Niklas Söderlund
2025-08-02 9:22 ` [PATCH 18/65] media: rzg2l-cru: " Jacopo Mondi
2025-08-04 10:01 ` Tommaso Merciai
2025-08-02 9:22 ` [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open() Jacopo Mondi
2025-08-24 19:04 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 20/65] media: camss: Remove custom .release fop() Jacopo Mondi
2025-08-24 19:07 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 21/65] media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 22/65] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 23/65] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 24/65] media: qcom: iris: Drop unused argument to iris_get_inst() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 25/65] media: qcom: venus: Pass file pointer to venus_close_common() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 26/65] media: Set file->private_data in v4l2_fh_add() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
2025-08-06 12:45 ` Hans Verkuil
2025-08-07 8:50 ` Laurent Pinchart
2025-08-07 17:00 ` Laurent Pinchart
2025-08-07 20:25 ` Laurent Pinchart
2025-08-07 20:51 ` Hans Verkuil
2025-08-08 6:30 ` Laurent Pinchart
2025-08-18 14:12 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 28/65] media: v4l2-ioctl: Access v4l2_fh from private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 29/65] media: allegro: Access v4l2_fh from file Jacopo Mondi
2025-08-05 7:39 ` Michael Tretter
2025-08-02 9:22 ` [PATCH 30/65] media: meson-ge2d: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 31/65] media: coda: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 32/65] media: wave5: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 33/65] media: m2m-deinterlace: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 34/65] media: mtk: jpeg: Access v4l2_fh from file->private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 35/65] media: mtk_mdp_m2m: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:22 ` [PATCH 36/65] media: mtk: mdp3: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 37/65] media: mtk: vcodec: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 38/65] media: tegra-vde: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 39/65] media: imx-jpeg: " Jacopo Mondi
2025-08-05 1:58 ` [EXT] " Ming Qian
2025-08-02 9:23 ` [PATCH 40/65] media: imx-isi: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 41/65] media: nxp: mx2: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 42/65] media: renesas: " Jacopo Mondi
2025-08-05 9:59 ` Kieran Bingham
2025-08-02 9:23 ` [PATCH 43/65] media: rockhip: rga: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 44/65] media: rockchip: rkvdec: " Jacopo Mondi
2025-08-02 16:02 ` Detlev Casanova
2025-08-02 9:23 ` [PATCH 45/65] media: exynos-gsc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 46/65] media: exynos4-is: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 47/65] media: s3c-camif: Set queue owner using file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 48/65] media: s5p-g2d: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 49/65] media: s5p-jpeg: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 50/65] media: s5p-mfc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 51/65] media: bdisp: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 52/65] media: st: delta: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 53/65] media: stm32: dma2d: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data Jacopo Mondi
2025-08-04 21:59 ` Paul Kocialkowski
2025-08-02 9:23 ` [PATCH 55/65] media: omap3isp: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 56/65] media: cx18: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 57/65] media: ivtv: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 58/65] media: zoran: Remove access to __fh Jacopo Mondi
2025-08-07 6:58 ` Hans Verkuil
2025-08-07 12:31 ` Laurent Pinchart
2025-08-07 13:18 ` Hans Verkuil
2025-08-02 9:23 ` [PATCH 59/65] media: usb: hdpvr: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 60/65] media: usb: uvc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 61/65] media: staging: imx: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 62/65] media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check Jacopo Mondi
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
2025-08-08 1:01 ` Cao, Bingbu
2025-08-08 7:22 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 64/65] media: staging: ipu7: " Jacopo Mondi
2025-08-07 9:07 ` Sakari Ailus
2025-08-07 17:01 ` Laurent Pinchart
2025-08-08 7:22 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers Jacopo Mondi
2025-08-07 7:26 ` Hans Verkuil
2025-08-07 7:58 ` Hans Verkuil
2025-08-07 20:33 ` Laurent Pinchart
2025-08-07 20:55 ` Hans Verkuil
2025-08-08 7:00 ` 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).