public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v3 08/76] media: Wrap file->private_data access with a helper function
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
@ 2025-08-10  1:29 ` Laurent Pinchart
  2025-08-10  1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:29 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, 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, Hans de Goede,
	Sakari Ailus, Hans Verkuil, Ricardo Ribalda, Yunke Cao,
	Tomi Valkeinen, Lad Prabhakar, Tommaso Merciai, linux-doc,
	linux-arm-kernel, linux-mediatek, linux-tegra, imx,
	linux-renesas-soc

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+renesas@ideasonboard.com>
---
 Documentation/driver-api/media/v4l2-fh.rst    | 16 +++++----
 .../zh_CN/video4linux/v4l2-framework.txt      |  2 +-
 .../media/common/videobuf2/videobuf2-v4l2.c   |  2 +-
 drivers/media/pci/cx18/cx18-fileops.c         |  2 +-
 drivers/media/pci/ivtv/ivtv-fileops.c         |  2 +-
 .../media/platform/allegro-dvt/allegro-core.c |  2 +-
 .../platform/mediatek/jpeg/mtk_jpeg_core.c    |  2 +-
 .../media/platform/nvidia/tegra-vde/v4l2.c    |  2 +-
 .../media/platform/nxp/imx-jpeg/mxc-jpeg.c    |  4 +--
 .../media/platform/renesas/vsp1/vsp1_histo.c  |  6 ++--
 .../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 3eeaa8da0c9e..2c87b74578d9 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 9cc97ec75d7a..a9eb62fa1531 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 1cd26faee503..f29307e59be5 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 cefa91b37f89..af25628b11ba 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 cfa28d035586..230d498108b5 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 eb03df0d8652..1f134e08923a 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 7eb12449b63a..329e5787c2c2 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 e3726cab0c82..531a85e3fe49 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 8681dd193033..1b2148578cb6 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 c762202877ba..390ea50f1595 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 bc66fbdde3cc..656fb5e6cb30 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 78e30298c7ad..a777135c6a6c 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 18bfa6001909..fcfe0883aba5 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 229e08ff323e..4cbf6ce314fd 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 d49a68b36c28..d46b2c8f3d23 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 90eec79ee995..7a5f7aa5e253 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 eb22d6172462..e67e67f76f72 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 4fd25fea3b58..29d3b788b288 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 b5b3e00c8e6a..823fa8ebeb8f 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.
  *
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh()
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
  2025-08-10  1:29 ` [PATCH v3 08/76] media: Wrap file->private_data access with a helper function Laurent Pinchart
@ 2025-08-10  1:29 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 37/76] media: meson-ge2d: Access v4l2_fh from file Laurent Pinchart
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:29 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Andy Walls,
	Ming Qian, Zhou Peng, Devarsh Thakkar, Xavier Roumegue,
	Philipp Zabel, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, Vikash Garodia, Dikshita Agarwal, Abhinav Kumar,
	Bryan O'Donoghue, Sylwester Nawrocki, Jernej Skrabec,
	Chen-Yu Tsai, Samuel Holland, Benoit Parrot, Hans Verkuil,
	Daniel Almeida, Mike Isely, Hans de Goede, Parthiban Veerasooran,
	Christian Gromm, Greg Kroah-Hartman, Dr. David Alan Gilbert,
	Matthew Majewski, Uwe Kleine-König, Shuah Khan,
	Ricardo Ribalda, Michael Grzeschik, Akash Kumar, Abhishek Tamboli,
	imx, linux-arm-kernel, linux-arm-msm, linux-samsung-soc,
	linux-sunxi, linux-staging, linux-usb

Accessing file->private_data manually to retrieve the v4l2_fh pointer is
error-prone, as the field is a void * and will happily cast implicitly
to any pointer type.

Replace all remaining locations that read the v4l2_fh pointer directly
from file->private_data with usage of the file_to_v4l2_fh() function.
The change was generated manually.

No functional change is intended, this only paves the way to remove
direct accesses to file->private_data and make V4L2 drivers safer.
Other accesses to the field will be addressed separately.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/pci/cx18/cx18-driver.h                 |  2 +-
 drivers/media/pci/cx18/cx18-fileops.c                |  2 +-
 drivers/media/pci/saa7164/saa7164.h                  |  4 ++--
 drivers/media/platform/amphion/vpu.h                 |  2 +-
 drivers/media/platform/imagination/e5010-jpeg-enc.h  |  2 +-
 drivers/media/platform/nxp/dw100/dw100.c             |  2 +-
 drivers/media/platform/nxp/imx-pxp.c                 |  2 +-
 drivers/media/platform/qcom/iris/iris_vidc.c         |  2 +-
 drivers/media/platform/qcom/venus/core.h             |  2 +-
 .../media/platform/samsung/s3c-camif/camif-capture.c |  6 +++---
 drivers/media/platform/sunxi/sun8i-di/sun8i-di.c     |  2 +-
 .../media/platform/sunxi/sun8i-rotate/sun8i_rotate.c |  2 +-
 drivers/media/platform/ti/vpe/vpe.c                  |  2 +-
 drivers/media/test-drivers/vicodec/vicodec-core.c    |  2 +-
 drivers/media/test-drivers/vim2m.c                   |  2 +-
 drivers/media/test-drivers/visl/visl.h               |  2 +-
 drivers/media/test-drivers/vivid/vivid-core.c        |  4 ++--
 drivers/media/test-drivers/vivid/vivid-radio-rx.c    |  4 ++--
 drivers/media/test-drivers/vivid/vivid-radio-tx.c    |  4 ++--
 drivers/media/usb/hdpvr/hdpvr-video.c                | 12 ++++++------
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c             |  2 +-
 drivers/media/usb/uvc/uvcvideo.h                     |  2 +-
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c        |  2 +-
 drivers/media/v4l2-core/v4l2-ioctl.c                 |  4 ++--
 drivers/staging/most/video/video.c                   |  2 +-
 drivers/usb/gadget/function/uvc.h                    |  5 +++++
 drivers/usb/gadget/function/uvc_v4l2.c               |  2 +-
 27 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h
index 485ca9747c4c..92acd23a8c4d 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -414,7 +414,7 @@ static inline struct cx18_open_id *fh2id(struct v4l2_fh *fh)
 
 static inline struct cx18_open_id *file2id(struct file *file)
 {
-	return fh2id(file->private_data);
+	return fh2id(file_to_v4l2_fh(file));
 }
 
 /* forward declaration of struct defined in cx18-cards.h */
diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
index af25628b11ba..89e38b303630 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -709,7 +709,7 @@ int cx18_v4l2_close(struct file *filp)
 	}
 
 	if (id->type == CX18_ENC_STREAM_TYPE_YUV &&
-	    filp->private_data == vdev->queue->owner) {
+	    file_to_v4l2_fh(filp) == vdev->queue->owner) {
 		vb2_queue_release(vdev->queue);
 		vdev->queue->owner = NULL;
 	}
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h
index 7b511f7f1cfc..94e987e7b5e5 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -182,7 +182,7 @@ struct saa7164_encoder_fh {
 
 static inline struct saa7164_encoder_fh *to_saa7164_encoder_fh(struct file *filp)
 {
-	return container_of(filp->private_data, struct saa7164_encoder_fh, fh);
+	return container_of(file_to_v4l2_fh(filp), struct saa7164_encoder_fh, fh);
 }
 
 struct saa7164_vbi_fh {
@@ -193,7 +193,7 @@ struct saa7164_vbi_fh {
 
 static inline struct saa7164_vbi_fh *to_saa7164_vbi_fh(struct file *filp)
 {
-	return container_of(filp->private_data, struct saa7164_vbi_fh, fh);
+	return container_of(file_to_v4l2_fh(filp), struct saa7164_vbi_fh, fh);
 }
 
 struct saa7164_histogram_bucket {
diff --git a/drivers/media/platform/amphion/vpu.h b/drivers/media/platform/amphion/vpu.h
index cac0f1a64fea..bfd171a3ded4 100644
--- a/drivers/media/platform/amphion/vpu.h
+++ b/drivers/media/platform/amphion/vpu.h
@@ -328,7 +328,7 @@ static inline const char *vpu_core_type_desc(enum vpu_core_type type)
 
 static inline struct vpu_inst *to_inst(struct file *filp)
 {
-	return container_of(filp->private_data, struct vpu_inst, fh);
+	return container_of(file_to_v4l2_fh(filp), struct vpu_inst, fh);
 }
 
 #define ctrl_to_inst(ctrl)	\
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.h b/drivers/media/platform/imagination/e5010-jpeg-enc.h
index eefaf60489d3..da57bc1baa46 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.h
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.h
@@ -122,7 +122,7 @@ struct e5010_context {
 
 static inline struct e5010_context *to_e5010_context(struct file *filp)
 {
-	return container_of(filp->private_data, struct e5010_context, fh);
+	return container_of(file_to_v4l2_fh(filp), struct e5010_context, fh);
 }
 
 /*
diff --git a/drivers/media/platform/nxp/dw100/dw100.c b/drivers/media/platform/nxp/dw100/dw100.c
index 3d1db1121bf9..2460f09a6813 100644
--- a/drivers/media/platform/nxp/dw100/dw100.c
+++ b/drivers/media/platform/nxp/dw100/dw100.c
@@ -266,7 +266,7 @@ static inline int dw100_dump_regs(struct seq_file *m)
 
 static inline struct dw100_ctx *dw100_file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct dw100_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct dw100_ctx, fh);
 }
 
 static struct dw100_q_data *dw100_get_q_data(struct dw100_ctx *ctx,
diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index 7f8ffbac582f..879b1803a2b3 100644
--- a/drivers/media/platform/nxp/imx-pxp.c
+++ b/drivers/media/platform/nxp/imx-pxp.c
@@ -248,7 +248,7 @@ struct pxp_ctx {
 
 static inline struct pxp_ctx *file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct pxp_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct pxp_ctx, fh);
 }
 
 static struct pxp_q_data *get_q_data(struct pxp_ctx *ctx,
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index c417e8c31f80..0c3b47b9958a 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -69,7 +69,7 @@ static void iris_remove_session(struct iris_inst *inst)
 
 static inline struct iris_inst *iris_get_inst(struct file *filp, void *fh)
 {
-	return container_of(filp->private_data, struct iris_inst, fh);
+	return container_of(file_to_v4l2_fh(filp), struct iris_inst, fh);
 }
 
 static void iris_m2m_device_run(void *priv)
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 5b1ba1c69adb..3c0c5f9dbe7b 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -535,7 +535,7 @@ struct venus_inst {
 
 static inline struct venus_inst *to_inst(struct file *filp)
 {
-	return container_of(filp->private_data, struct venus_inst, fh);
+	return container_of(file_to_v4l2_fh(filp), struct venus_inst, fh);
 }
 
 static inline void *to_hfi_priv(struct venus_core *core)
diff --git a/drivers/media/platform/samsung/s3c-camif/camif-capture.c b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
index 3e566b65f417..cae15a4ce5fd 100644
--- a/drivers/media/platform/samsung/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
@@ -572,7 +572,7 @@ static int s3c_camif_close(struct file *file)
 
 	mutex_lock(&camif->lock);
 
-	if (vp->owner == file->private_data) {
+	if (vp->owner == file_to_v4l2_fh(file)) {
 		camif_stop_capture(vp);
 		vb2_queue_release(&vp->vb_queue);
 		vp->owner = NULL;
@@ -595,7 +595,7 @@ static __poll_t s3c_camif_poll(struct file *file,
 	__poll_t ret;
 
 	mutex_lock(&camif->lock);
-	if (vp->owner && vp->owner != file->private_data)
+	if (vp->owner && vp->owner != file_to_v4l2_fh(file))
 		ret = EPOLLERR;
 	else
 		ret = vb2_poll(&vp->vb_queue, file, wait);
@@ -609,7 +609,7 @@ static int s3c_camif_mmap(struct file *file, struct vm_area_struct *vma)
 	struct camif_vp *vp = video_drvdata(file);
 	int ret;
 
-	if (vp->owner && vp->owner != file->private_data)
+	if (vp->owner && vp->owner != file_to_v4l2_fh(file))
 		ret = -EBUSY;
 	else
 		ret = vb2_mmap(&vp->vb_queue, vma);
diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
index 3e7f2df70408..43755043e8af 100644
--- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
+++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c
@@ -309,7 +309,7 @@ static void deinterlace_init(struct deinterlace_dev *dev)
 
 static inline struct deinterlace_ctx *deinterlace_file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct deinterlace_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct deinterlace_ctx, fh);
 }
 
 static bool deinterlace_check_format(u32 pixelformat)
diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
index abd10b218aa1..d0608b5d900f 100644
--- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
+++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
@@ -170,7 +170,7 @@ static irqreturn_t rotate_irq(int irq, void *data)
 
 static inline struct rotate_ctx *rotate_file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct rotate_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct rotate_ctx, fh);
 }
 
 static void rotate_prepare_format(struct v4l2_pix_format *pix_fmt)
diff --git a/drivers/media/platform/ti/vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
index b76b5d18c963..4b9b2bec7377 100644
--- a/drivers/media/platform/ti/vpe/vpe.c
+++ b/drivers/media/platform/ti/vpe/vpe.c
@@ -424,7 +424,7 @@ struct vpe_ctx {
 
 static inline struct vpe_ctx *to_vpe_ctx(struct file *filp)
 {
-	return container_of(filp->private_data, struct vpe_ctx, fh);
+	return container_of(file_to_v4l2_fh(filp), struct vpe_ctx, fh);
 }
 
 /*
diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
index c45f5cf12ded..e27f6761cba1 100644
--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
+++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
@@ -144,7 +144,7 @@ static const struct v4l2_event vicodec_eos_event = {
 
 static inline struct vicodec_ctx *file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct vicodec_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct vicodec_ctx, fh);
 }
 
 static struct vicodec_q_data *get_q_data(struct vicodec_ctx *ctx,
diff --git a/drivers/media/test-drivers/vim2m.c b/drivers/media/test-drivers/vim2m.c
index 1d1a9e768505..55d885be5bcc 100644
--- a/drivers/media/test-drivers/vim2m.c
+++ b/drivers/media/test-drivers/vim2m.c
@@ -236,7 +236,7 @@ struct vim2m_ctx {
 
 static inline struct vim2m_ctx *file2ctx(struct file *file)
 {
-	return container_of(file->private_data, struct vim2m_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct vim2m_ctx, fh);
 }
 
 static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx,
diff --git a/drivers/media/test-drivers/visl/visl.h b/drivers/media/test-drivers/visl/visl.h
index 434e9efbf9b2..ad3d0ab791d6 100644
--- a/drivers/media/test-drivers/visl/visl.h
+++ b/drivers/media/test-drivers/visl/visl.h
@@ -163,7 +163,7 @@ struct visl_ctrl_desc {
 
 static inline struct visl_ctx *visl_file_to_ctx(struct file *file)
 {
-	return container_of(file->private_data, struct visl_ctx, fh);
+	return container_of(file_to_v4l2_fh(file), struct visl_ctx, fh);
 }
 
 static inline struct visl_ctx *visl_v4l2fh_to_ctx(struct v4l2_fh *v4l2_fh)
diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index 8d56168c72aa..9c9a93a3b540 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -654,11 +654,11 @@ static int vivid_fop_release(struct file *file)
 		v4l2_info(&dev->v4l2_dev, "reconnect\n");
 		vivid_reconnect(dev);
 	}
-	if (file->private_data == dev->radio_rx_rds_owner) {
+	if (file_to_v4l2_fh(file) == dev->radio_rx_rds_owner) {
 		dev->radio_rx_rds_last_block = 0;
 		dev->radio_rx_rds_owner = NULL;
 	}
-	if (file->private_data == dev->radio_tx_rds_owner) {
+	if (file_to_v4l2_fh(file) == dev->radio_tx_rds_owner) {
 		dev->radio_tx_rds_last_block = 0;
 		dev->radio_tx_rds_owner = NULL;
 	}
diff --git a/drivers/media/test-drivers/vivid/vivid-radio-rx.c b/drivers/media/test-drivers/vivid/vivid-radio-rx.c
index 79c1723bd84c..be711cae2d49 100644
--- a/drivers/media/test-drivers/vivid/vivid-radio-rx.c
+++ b/drivers/media/test-drivers/vivid/vivid-radio-rx.c
@@ -42,13 +42,13 @@ ssize_t vivid_radio_rx_read(struct file *file, char __user *buf,
 	if (mutex_lock_interruptible(&dev->mutex))
 		return -ERESTARTSYS;
 	if (dev->radio_rx_rds_owner &&
-	    file->private_data != dev->radio_rx_rds_owner) {
+	    file_to_v4l2_fh(file) != dev->radio_rx_rds_owner) {
 		mutex_unlock(&dev->mutex);
 		return -EBUSY;
 	}
 	if (dev->radio_rx_rds_owner == NULL) {
 		vivid_radio_rds_init(dev);
-		dev->radio_rx_rds_owner = file->private_data;
+		dev->radio_rx_rds_owner = file_to_v4l2_fh(file);
 	}
 
 retry:
diff --git a/drivers/media/test-drivers/vivid/vivid-radio-tx.c b/drivers/media/test-drivers/vivid/vivid-radio-tx.c
index 049d40b948bb..f6e80b8d00a6 100644
--- a/drivers/media/test-drivers/vivid/vivid-radio-tx.c
+++ b/drivers/media/test-drivers/vivid/vivid-radio-tx.c
@@ -39,11 +39,11 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf,
 	if (mutex_lock_interruptible(&dev->mutex))
 		return -ERESTARTSYS;
 	if (dev->radio_tx_rds_owner &&
-	    file->private_data != dev->radio_tx_rds_owner) {
+	    file_to_v4l2_fh(file) != dev->radio_tx_rds_owner) {
 		mutex_unlock(&dev->mutex);
 		return -EBUSY;
 	}
-	dev->radio_tx_rds_owner = file->private_data;
+	dev->radio_tx_rds_owner = file_to_v4l2_fh(file);
 
 retry:
 	timestamp = ktime_sub(ktime_get(), dev->radio_rds_init_time);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 4c431bd9b503..ea17f1a5f5b0 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -390,7 +390,7 @@ static int hdpvr_release(struct file *file)
 	struct hdpvr_device *dev = video_drvdata(file);
 
 	mutex_lock(&dev->io_mutex);
-	if (file->private_data == dev->owner) {
+	if (file_to_v4l2_fh(file) == dev->owner) {
 		hdpvr_stop_streaming(dev);
 		dev->owner = NULL;
 	}
@@ -426,7 +426,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
 			mutex_unlock(&dev->io_mutex);
 			goto err;
 		}
-		dev->owner = file->private_data;
+		dev->owner = file_to_v4l2_fh(file);
 		print_buffer_status();
 	}
 	mutex_unlock(&dev->io_mutex);
@@ -541,7 +541,7 @@ static __poll_t hdpvr_poll(struct file *filp, poll_table *wait)
 				 "start_streaming failed\n");
 			dev->status = STATUS_IDLE;
 		} else {
-			dev->owner = filp->private_data;
+			dev->owner = file_to_v4l2_fh(filp);
 		}
 
 		print_buffer_status();
@@ -1048,7 +1048,7 @@ static int vidioc_encoder_cmd(struct file *filp, void *priv,
 
 	switch (a->cmd) {
 	case V4L2_ENC_CMD_START:
-		if (dev->owner && filp->private_data != dev->owner) {
+		if (dev->owner && file_to_v4l2_fh(filp) != dev->owner) {
 			res = -EBUSY;
 			break;
 		}
@@ -1056,12 +1056,12 @@ static int vidioc_encoder_cmd(struct file *filp, void *priv,
 			break;
 		res = hdpvr_start_streaming(dev);
 		if (!res)
-			dev->owner = filp->private_data;
+			dev->owner = file_to_v4l2_fh(filp);
 		else
 			dev->status = STATUS_IDLE;
 		break;
 	case V4L2_ENC_CMD_STOP:
-		if (dev->owner && filp->private_data != dev->owner) {
+		if (dev->owner && file_to_v4l2_fh(filp) != dev->owner) {
 			res = -EBUSY;
 			break;
 		}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 7dc7c90ebf62..481b03bbecf8 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -48,7 +48,7 @@ struct pvr2_v4l2_fh {
 
 static inline struct pvr2_v4l2_fh *to_pvr2_v4l2_fh(struct file *filp)
 {
-	return container_of(filp->private_data, struct pvr2_v4l2_fh, fh);
+	return container_of(file_to_v4l2_fh(filp), struct pvr2_v4l2_fh, fh);
 }
 
 struct pvr2_v4l2 {
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 8b5625203048..70dc80e2b213 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -639,7 +639,7 @@ struct uvc_fh {
 
 static inline struct uvc_fh *to_uvc_fh(struct file *filp)
 {
-	return container_of(filp->private_data, struct uvc_fh, vfh);
+	return container_of(file_to_v4l2_fh(filp), struct uvc_fh, vfh);
 }
 
 /* ------------------------------------------------------------------------
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 8c07400bd280..8a5559225ff2 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -678,7 +678,7 @@ static inline bool ctrl_is_pointer(struct file *file, u32 id)
 	const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
 
 	if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags))
-		fh = file->private_data;
+		fh = file_to_v4l2_fh(file);
 
 	if (fh && fh->ctrl_handler)
 		hdl = fh->ctrl_handler;
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 46da373066f4..8c81852c3046 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1197,7 +1197,7 @@ static int v4l_s_priority(const struct v4l2_ioctl_ops *ops,
 	vfd = video_devdata(file);
 	if (!test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags))
 		return -ENOTTY;
-	vfh = file->private_data;
+	vfh = file_to_v4l2_fh(file);
 	return v4l2_prio_change(vfd->prio, &vfh->prio, *p);
 }
 
@@ -3084,7 +3084,7 @@ static long __video_do_ioctl(struct file *file,
 	}
 
 	if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags))
-		vfh = file->private_data;
+		vfh = file_to_v4l2_fh(file);
 
 	/*
 	 * We need to serialize streamon/off with queueing new requests.
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index bce7ffeac8fe..116331cead2a 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -54,7 +54,7 @@ struct comp_fh {
 
 static inline struct comp_fh *to_comp_fh(struct file *filp)
 {
-	return container_of(filp->private_data, struct comp_fh, fh);
+	return container_of(file_to_v4l2_fh(filp), struct comp_fh, fh);
 }
 
 static LIST_HEAD(video_devices);
diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
index 6f44dd732315..9e79cbe50715 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -196,6 +196,11 @@ struct uvc_file_handle {
 #define to_uvc_file_handle(handle) \
 	container_of(handle, struct uvc_file_handle, vfh)
 
+static inline struct uvc_file_handle *file_to_uvc_file_handle(struct file *filp)
+{
+	return container_of(file_to_v4l2_fh(filp), struct uvc_file_handle, vfh);
+}
+
 /* ------------------------------------------------------------------------
  * Functions
  */
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index fc9a8d31a1e9..886300a29b90 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -685,7 +685,7 @@ uvc_v4l2_release(struct file *file)
 {
 	struct video_device *vdev = video_devdata(file);
 	struct uvc_device *uvc = video_get_drvdata(vdev);
-	struct uvc_file_handle *handle = to_uvc_file_handle(file->private_data);
+	struct uvc_file_handle *handle = file_to_uvc_file_handle(file);
 	struct uvc_video *video = handle->device;
 
 	mutex_lock(&video->mutex);
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 37/76] media: meson-ge2d: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
  2025-08-10  1:29 ` [PATCH v3 08/76] media: Wrap file->private_data access with a helper function Laurent Pinchart
  2025-08-10  1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 41/76] media: mtk: jpeg: Access v4l2_fh from file->private_data Laurent Pinchart
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, linux-amlogic,
	linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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 b1b0b6535fb1..5744853a4003 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 41/76] media: mtk: jpeg: Access v4l2_fh from file->private_data
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (2 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 37/76] media: meson-ge2d: Access v4l2_fh from file Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 42/76] media: mtk_mdp_m2m: Access v4l2_fh from file Laurent Pinchart
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Bin Liu,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-arm-kernel,
	linux-mediatek

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../platform/mediatek/jpeg/mtk_jpeg_core.c    | 29 ++++++++-----------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
index de15d6f0b490..6268d651bdcf 100644
--- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
@@ -119,14 +119,9 @@ 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 mtk_jpeg_fh_to_ctx(file_to_v4l2_fh(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(
@@ -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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 42/76] media: mtk_mdp_m2m: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (3 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 41/76] media: mtk: jpeg: Access v4l2_fh from file->private_data Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 43/76] media: mtk: mdp3: " Laurent Pinchart
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Minghsiu Tsai,
	Houlong Wei, Andrew-CT Chen, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-arm-kernel, linux-mediatek

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../media/platform/mediatek/mdp/mtk_mdp_m2m.c | 23 ++++++++-----------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
index 7e89a8443707..03c07948dfdd 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_m2m.c
@@ -348,14 +348,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
@@ -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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 43/76] media: mtk: mdp3: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (4 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 42/76] media: mtk_mdp_m2m: Access v4l2_fh from file Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 44/76] media: mtk: vcodec: " Laurent Pinchart
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Matthias Brugger, AngeloGioacchino Del Regno, Hans Verkuil,
	Neil Armstrong, Andrzej Pietrasiewicz, linux-arm-kernel,
	linux-mediatek

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../platform/mediatek/mdp3/mtk-mdp3-m2m.c     | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
index e68ae19d71a9..9ef956b565a7 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
@@ -10,14 +10,9 @@
 #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 fh_to_ctx(file_to_v4l2_fh(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)
@@ -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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 44/76] media: mtk: vcodec: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (5 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 43/76] media: mtk: mdp3: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 46/76] media: imx-jpeg: " Laurent Pinchart
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Tiffany Lin,
	Andrew-CT Chen, Yunfei Dong, Matthias Brugger,
	AngeloGioacchino Del Regno, Andrzej Pietrasiewicz, Neil Armstrong,
	Hans Verkuil, linux-arm-kernel, linux-mediatek

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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 *.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../mediatek/vcodec/decoder/mtk_vcodec_dec.c  | 36 +++++++++---------
 .../mediatek/vcodec/encoder/mtk_vcodec_enc.c  | 37 +++++++++----------
 .../vcodec/encoder/mtk_vcodec_enc_drv.h       |  7 +---
 3 files changed, 37 insertions(+), 43 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 98838217b97d..d691bd533103 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 a01dc25a7699..d815e962ab89 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 a4fe2f453d8f..5b304a551236 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,14 +217,9 @@ 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 fh_to_enc_ctx(file_to_v4l2_fh(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)
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 46/76] media: imx-jpeg: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (6 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 44/76] media: mtk: vcodec: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-11 15:05   ` Frank Li
  2025-08-10  1:30 ` [PATCH v3 47/76] media: imx-isi: " Laurent Pinchart
                   ` (12 subsequent siblings)
  20 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Mirela Rabulea,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	imx, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Reviewed-by: Ming Qian <ming.qian@oss.nxp.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../media/platform/nxp/imx-jpeg/mxc-jpeg.c    | 35 ++++++++-----------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index a34e644b2cb1..df3ccdf767ba 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -644,14 +644,9 @@ 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 mxc_jpeg_fh_to_ctx(file_to_v4l2_fh(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,
@@ -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)
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 47/76] media: imx-isi: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (7 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 46/76] media: imx-jpeg: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-11 15:05   ` Frank Li
  2025-08-10  1:30 ` [PATCH v3 50/76] media: rockhip: rga: " Laurent Pinchart
                   ` (11 subsequent siblings)
  20 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, imx,
	linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../media/platform/nxp/imx8-isi/imx8-isi-m2m.c  | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 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 31298307c672..5501214cc6c0 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
@@ -74,14 +74,9 @@ 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 to_isi_m2m_ctx(file_to_v4l2_fh(filp));
+	return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
 }
 
 static inline struct mxc_isi_m2m_ctx_queue_data *
@@ -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;
 
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 50/76] media: rockhip: rga: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (8 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 47/76] media: imx-isi: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 51/76] media: rockchip: rkvdec: " Laurent Pinchart
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Jacob Chen,
	Ezequiel Garcia, Heiko Stuebner, linux-rockchip, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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 45c42c7ad846..7c657df623f2 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 51/76] media: rockchip: rkvdec: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (9 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 50/76] media: rockhip: rga: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 52/76] media: exynos-gsc: " Laurent Pinchart
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Detlev Casanova, Heiko Stuebner, linux-rockchip, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Reviewed-by: Detlev Casanova <detlev.casanova@collabora.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 drivers/media/platform/rockchip/rkvdec/rkvdec.c | 14 +++++++-------
 drivers/media/platform/rockchip/rkvdec/rkvdec.h |  7 +------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 481c2488f9ac..9fa80ab3c62b 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 3a6322d42b26..481aaa4bffe9 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.h
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.h
@@ -124,14 +124,9 @@ 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 fh_to_rkvdec_ctx(file_to_v4l2_fh(filp));
+	return container_of(file_to_v4l2_fh(filp), struct rkvdec_ctx, fh);
 }
 
 struct rkvdec_aux_buf {
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 52/76] media: exynos-gsc: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (10 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 51/76] media: rockchip: rkvdec: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 53/76] media: exynos4-is: " Laurent Pinchart
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Krzysztof Kozlowski, Alim Akhtar, Neil Armstrong,
	Andrzej Pietrasiewicz, Hans Verkuil, linux-arm-kernel,
	linux-samsung-soc

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../platform/samsung/exynos-gsc/gsc-core.h    |  4 +---
 .../platform/samsung/exynos-gsc/gsc-m2m.c     | 24 +++++++++----------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-core.h b/drivers/media/platform/samsung/exynos-gsc/gsc-core.h
index 56856e9f9baf..265221abf4dc 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))
@@ -384,7 +382,7 @@ struct gsc_ctx {
 
 static inline struct gsc_ctx *file_to_ctx(struct file *filp)
 {
-	return fh_to_ctx(file_to_v4l2_fh(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);
diff --git a/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c b/drivers/media/platform/samsung/exynos-gsc/gsc-m2m.c
index 2999fb2610f0..722e2531e23f 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 53/76] media: exynos4-is: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (11 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 52/76] media: exynos-gsc: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 55/76] media: s5p-g2d: " Laurent Pinchart
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	linux-arm-kernel, linux-samsung-soc

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 drivers/media/platform/samsung/exynos4-is/fimc-core.h |  4 +---
 drivers/media/platform/samsung/exynos4-is/fimc-m2m.c  | 10 +++++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-core.h b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
index 2b6c72d9442c..c23cbdee7afc 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-core.h
@@ -496,11 +496,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c b/drivers/media/platform/samsung/exynos4-is/fimc-m2m.c
index 609fd84f89d4..562c57f186c6 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 55/76] media: s5p-g2d: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (12 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 53/76] media: exynos4-is: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 56/76] media: s5p-jpeg: " Laurent Pinchart
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Łukasz Stelmach, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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 922262f61e7b..55f5130156b7 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;
 
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 56/76] media: s5p-jpeg: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (13 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 55/76] media: s5p-g2d: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-12  6:13   ` Andrzej Pietrasiewicz
  2025-08-10  1:30 ` [PATCH v3 57/76] media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv Laurent Pinchart
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Andrzej Pietrasiewicz, Jacek Anaszewski, Sylwester Nawrocki,
	linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Reviewed-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 .../platform/samsung/s5p-jpeg/jpeg-core.c     | 27 ++++++++-----------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
index 65f256db4c76..81792f7f8b16 100644
--- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
@@ -580,14 +580,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
@@ -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)
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 57/76] media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (14 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 56/76] media: s5p-jpeg: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 58/76] media: s5p-mfc: Access v4l2_fh from file Laurent Pinchart
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Marek Szyprowski, Andrzej Hajda, linux-arm-kernel

The driver stores a pointer to a v4l2_fh in the vb2_queue.drv_priv,
which it then has to cast to a s5p_mfc_ctx pointer in all vb2 queue
operations. Store the pointer to the s5p_mfc_ctx instead to avoid the
cast. While at it, use the vb2_get_drv_priv() helper to access the
field.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c     |  4 ++--
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 10 +++++-----
 drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 12 ++++++------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index a5e756049620..4948d734eb02 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -876,7 +876,7 @@ static int s5p_mfc_open(struct file *file)
 	/* Init videobuf2 queue for CAPTURE */
 	q = &ctx->vq_dst;
 	q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-	q->drv_priv = &ctx->fh;
+	q->drv_priv = ctx;
 	q->lock = &dev->mfc_mutex;
 	if (vdev == dev->vfd_dec) {
 		q->io_modes = VB2_MMAP;
@@ -903,7 +903,7 @@ static int s5p_mfc_open(struct file *file)
 	/* Init videobuf2 queue for OUTPUT */
 	q = &ctx->vq_src;
 	q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-	q->drv_priv = &ctx->fh;
+	q->drv_priv = ctx;
 	q->lock = &dev->mfc_mutex;
 	if (vdev == dev->vfd_dec) {
 		q->io_modes = VB2_MMAP;
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 3efbc3367906..aefa6da5c609 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -937,7 +937,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 			unsigned int *plane_count, unsigned int psize[],
 			struct device *alloc_devs[])
 {
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	struct s5p_mfc_dev *dev = ctx->dev;
 	const struct v4l2_format_info *format;
 
@@ -1006,7 +1006,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 {
 	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 	struct vb2_queue *vq = vb->vb2_queue;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	unsigned int i;
 
 	if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -1068,7 +1068,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 
 static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 {
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
 	struct s5p_mfc_dev *dev = ctx->dev;
 
 	v4l2_ctrl_handler_setup(&ctx->ctrl_handler);
@@ -1085,7 +1085,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 {
 	unsigned long flags;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
 	struct s5p_mfc_dev *dev = ctx->dev;
 	int aborted = 0;
 
@@ -1130,7 +1130,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
 {
 	struct vb2_queue *vq = vb->vb2_queue;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	struct s5p_mfc_dev *dev = ctx->dev;
 	unsigned long flags;
 	struct s5p_mfc_buf *mfc_buf;
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 6c603dcd5664..9b77dbd856e7 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -2418,7 +2418,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
 			unsigned int *buf_count, unsigned int *plane_count,
 			unsigned int psize[], struct device *alloc_devs[])
 {
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	struct s5p_mfc_dev *dev = ctx->dev;
 
 	if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -2477,7 +2477,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 {
 	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 	struct vb2_queue *vq = vb->vb2_queue;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	unsigned int i;
 	int ret;
 
@@ -2516,7 +2516,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
 {
 	struct vb2_queue *vq = vb->vb2_queue;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	int ret;
 
 	if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -2557,7 +2557,7 @@ static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
 
 static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 {
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
 	struct s5p_mfc_dev *dev = ctx->dev;
 
 	if (IS_MFCV6_PLUS(dev) &&
@@ -2588,7 +2588,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 {
 	unsigned long flags;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
 	struct s5p_mfc_dev *dev = ctx->dev;
 
 	if ((ctx->state == MFCINST_FINISHING ||
@@ -2617,7 +2617,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
 {
 	struct vb2_queue *vq = vb->vb2_queue;
-	struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+	struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
 	struct s5p_mfc_dev *dev = ctx->dev;
 	unsigned long flags;
 	struct s5p_mfc_buf *mfc_buf;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 58/76] media: s5p-mfc: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (15 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 57/76] media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 61/76] media: stm32: dma2d: " Laurent Pinchart
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Marek Szyprowski, Andrzej Hajda, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
---
Changes since v1:

- Drop fh_to_ctx() macro
---
 .../platform/samsung/s5p-mfc/s5p_mfc_common.h |  4 +---
 .../platform/samsung/s5p-mfc/s5p_mfc_dec.c    | 22 ++++++++---------
 .../platform/samsung/s5p-mfc/s5p_mfc_enc.c    | 24 +++++++++----------
 3 files changed, 24 insertions(+), 26 deletions(-)

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 a29228b4207f..58dc1768082c 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -767,11 +767,9 @@ struct mfc_control {
 #define s5p_mfc_hw_call(f, op, args...) \
 	((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 fh_to_ctx(file_to_v4l2_fh(filp));
+	return container_of(file_to_v4l2_fh(filp), struct s5p_mfc_ctx, fh);
 }
 
 #define ctrl_to_ctx(__ctrl) \
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 aefa6da5c609..606e1a7121b5 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 9b77dbd856e7..694b68788a95 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 61/76] media: stm32: dma2d: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (16 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 58/76] media: s5p-mfc: Access v4l2_fh from file Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 68/76] media: staging: imx: " Laurent Pinchart
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Maxime Coquelin, Alexandre Torgue, Hans Verkuil, Neil Armstrong,
	Andrzej Pietrasiewicz, Jiasheng Jiang, Uwe Kleine-König,
	linux-stm32, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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 bc0f81e78018..a22f587a5f83 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;
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 68/76] media: staging: imx: Access v4l2_fh from file
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (17 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 61/76] media: stm32: dma2d: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv' Laurent Pinchart
  2025-08-10  1:30 ` [PATCH v3 76/76] media: staging: " Laurent Pinchart
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Steve Longerbeam, Philipp Zabel, Greg Kroah-Hartman, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-staging, imx, linux-arm-kernel

From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

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>
Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
Changes since v1:

- Update file-to-ctx macro due to removal of fh-to-ctx macro
---
 drivers/staging/media/imx/imx-media-csc-scaler.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c
index dc7f9a77cbe6..1869c5792ecb 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 {
@@ -68,7 +66,7 @@ struct ipu_csc_scaler_ctx {
 
 static inline struct ipu_csc_scaler_ctx *file_to_ctx(struct file *filp)
 {
-	return fh_to_ctx(file_to_v4l2_fh(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,
@@ -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) {
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv'
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (18 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 68/76] media: staging: imx: " Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  2025-08-12  5:52   ` Jai Luthra
  2025-08-10  1:30 ` [PATCH v3 76/76] media: staging: " Laurent Pinchart
  20 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab, Hans Verkuil,
	Jacob Chen, Ezequiel Garcia, Heiko Stuebner, Łukasz Stelmach,
	Marek Szyprowski, Andrzej Hajda, Maxime Coquelin,
	Alexandre Torgue, Yong Deng, Paul Kocialkowski, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Jai Luthra, Eduardo Valentin,
	Thomas Gleixner, Ingo Molnar, Sakari Ailus, Neil Armstrong,
	Andrzej Pietrasiewicz, Uwe Kleine-König, Jiasheng Jiang,
	Ricardo Ribalda, linux-rockchip, linux-arm-kernel, linux-stm32,
	linux-sunxi, kernel

The second argument to the ioctl handlers is not a file handle any more.
The standard practice is to name it 'void *priv' in drivers. Many
drivers still name it 'void *fh', and a few use more exotic names.
Replace those more exotic names with 'void *priv' in all media drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../extron-da-hd-4k-plus.c                    |  4 +-
 drivers/media/pci/bt8xx/bttv-driver.c         | 14 ++---
 drivers/media/pci/bt8xx/bttv-vbi.c            |  6 +-
 drivers/media/pci/cobalt/cobalt-v4l2.c        | 60 +++++++++----------
 drivers/media/pci/saa7134/saa7134-video.c     |  4 +-
 drivers/media/platform/rockchip/rga/rga.c     | 14 ++---
 drivers/media/platform/samsung/s5p-g2d/g2d.c  | 18 +++---
 .../platform/samsung/s5p-mfc/s5p_mfc_dec.c    |  2 +-
 .../platform/samsung/s5p-mfc/s5p_mfc_enc.c    |  2 +-
 drivers/media/platform/st/stm32/dma2d/dma2d.c | 10 ++--
 .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 16 ++---
 .../platform/synopsys/hdmirx/snps_hdmirx.c    |  8 +--
 .../platform/ti/j721e-csi2rx/j721e-csi2rx.c   |  2 +-
 drivers/media/platform/ti/omap/omap_vout.c    |  6 +-
 .../radio/si4713/radio-platform-si4713.c      | 10 ++--
 drivers/media/usb/cx231xx/cx231xx-417.c       |  2 +-
 drivers/media/usb/gspca/gspca.c               | 18 +++---
 drivers/media/usb/hdpvr/hdpvr-video.c         | 30 +++++-----
 18 files changed, 113 insertions(+), 113 deletions(-)

diff --git a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
index 41d019b01ec0..c476e8d1279e 100644
--- a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
+++ b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
@@ -1252,7 +1252,7 @@ static int extron_s_output(struct file *file, void *priv, unsigned int o)
 	return o ? -EINVAL : 0;
 }
 
-static int extron_g_edid(struct file *file, void *_fh,
+static int extron_g_edid(struct file *file, void *priv,
 			 struct v4l2_edid *edid)
 {
 	struct extron_port *port = video_drvdata(file);
@@ -1280,7 +1280,7 @@ static int extron_g_edid(struct file *file, void *_fh,
 	return 0;
 }
 
-static int extron_s_edid(struct file *file, void *_fh, struct v4l2_edid *edid)
+static int extron_s_edid(struct file *file, void *priv, struct v4l2_edid *edid)
 {
 	struct extron_port *port = video_drvdata(file);
 
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 9ce67f515843..17e4529e537a 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1620,7 +1620,7 @@ static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
 	return 0;
 }
 
-static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
+static int bttv_querystd(struct file *file, void *priv, v4l2_std_id *id)
 {
 	struct bttv *btv = video_drvdata(file);
 
@@ -1750,7 +1750,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
 	return 0;
 }
 
-static int bttv_log_status(struct file *file, void *f)
+static int bttv_log_status(struct file *file, void *priv)
 {
 	struct video_device *vdev = video_devdata(file);
 	struct bttv *btv = video_drvdata(file);
@@ -1761,7 +1761,7 @@ static int bttv_log_status(struct file *file, void *f)
 }
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
-static int bttv_g_register(struct file *file, void *f,
+static int bttv_g_register(struct file *file, void *priv,
 					struct v4l2_dbg_register *reg)
 {
 	struct bttv *btv = video_drvdata(file);
@@ -1774,7 +1774,7 @@ static int bttv_g_register(struct file *file, void *f,
 	return 0;
 }
 
-static int bttv_s_register(struct file *file, void *f,
+static int bttv_s_register(struct file *file, void *priv,
 					const struct v4l2_dbg_register *reg)
 {
 	struct bttv *btv = video_drvdata(file);
@@ -2159,7 +2159,7 @@ static int bttv_enum_fmt_vid_cap(struct file *file, void  *priv,
 	return 0;
 }
 
-static int bttv_g_parm(struct file *file, void *f,
+static int bttv_g_parm(struct file *file, void *priv,
 				struct v4l2_streamparm *parm)
 {
 	struct bttv *btv = video_drvdata(file);
@@ -2208,7 +2208,7 @@ static int bttv_g_pixelaspect(struct file *file, void *priv,
 	return 0;
 }
 
-static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
+static int bttv_g_selection(struct file *file, void *priv, struct v4l2_selection *sel)
 {
 	struct bttv *btv = video_drvdata(file);
 
@@ -2232,7 +2232,7 @@ static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *s
 	return 0;
 }
 
-static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
+static int bttv_s_selection(struct file *file, void *priv, struct v4l2_selection *sel)
 {
 	struct bttv *btv = video_drvdata(file);
 	const struct v4l2_rect *b;
diff --git a/drivers/media/pci/bt8xx/bttv-vbi.c b/drivers/media/pci/bt8xx/bttv-vbi.c
index a71440611e46..0ca88a2400ee 100644
--- a/drivers/media/pci/bt8xx/bttv-vbi.c
+++ b/drivers/media/pci/bt8xx/bttv-vbi.c
@@ -241,7 +241,7 @@ static int try_fmt(struct v4l2_vbi_format *f, const struct bttv_tvnorm *tvnorm,
 	return 0;
 }
 
-int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
+int bttv_try_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
 {
 	struct bttv *btv = video_drvdata(file);
 	const struct bttv_tvnorm *tvnorm;
@@ -258,7 +258,7 @@ int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
 }
 
 
-int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
+int bttv_s_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
 {
 	struct bttv *btv = video_drvdata(file);
 	const struct bttv_tvnorm *tvnorm;
@@ -301,7 +301,7 @@ int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
 }
 
 
-int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
+int bttv_g_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
 {
 	const struct bttv_tvnorm *tvnorm;
 	struct bttv *btv = video_drvdata(file);
diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
index ae82427e3479..51fd9576c6c2 100644
--- a/drivers/media/pci/cobalt/cobalt-v4l2.c
+++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
@@ -447,7 +447,7 @@ static int cobalt_cobaltc(struct cobalt *cobalt, unsigned int cmd, void *arg)
 	return 0;
 }
 
-static int cobalt_g_register(struct file *file, void *priv_fh,
+static int cobalt_g_register(struct file *file, void *priv,
 		struct v4l2_dbg_register *reg)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -456,7 +456,7 @@ static int cobalt_g_register(struct file *file, void *priv_fh,
 	return cobalt_cobaltc(cobalt, VIDIOC_DBG_G_REGISTER, reg);
 }
 
-static int cobalt_s_register(struct file *file, void *priv_fh,
+static int cobalt_s_register(struct file *file, void *priv,
 		const struct v4l2_dbg_register *reg)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -467,7 +467,7 @@ static int cobalt_s_register(struct file *file, void *priv_fh,
 }
 #endif
 
-static int cobalt_querycap(struct file *file, void *priv_fh,
+static int cobalt_querycap(struct file *file, void *priv,
 				struct v4l2_capability *vcap)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -562,7 +562,7 @@ static void cobalt_video_input_status_show(struct cobalt_stream *s)
 	cobalt_info("rx%d: Packer: %x\n", rx, ioread32(&packer->control));
 }
 
-static int cobalt_log_status(struct file *file, void *priv_fh)
+static int cobalt_log_status(struct file *file, void *priv)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 	struct cobalt *cobalt = s->cobalt;
@@ -596,7 +596,7 @@ static int cobalt_log_status(struct file *file, void *priv_fh)
 	return 0;
 }
 
-static int cobalt_enum_dv_timings(struct file *file, void *priv_fh,
+static int cobalt_enum_dv_timings(struct file *file, void *priv,
 				    struct v4l2_enum_dv_timings *timings)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -613,7 +613,7 @@ static int cobalt_enum_dv_timings(struct file *file, void *priv_fh,
 			pad, enum_dv_timings, timings);
 }
 
-static int cobalt_s_dv_timings(struct file *file, void *priv_fh,
+static int cobalt_s_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -641,7 +641,7 @@ static int cobalt_s_dv_timings(struct file *file, void *priv_fh,
 	return err;
 }
 
-static int cobalt_g_dv_timings(struct file *file, void *priv_fh,
+static int cobalt_g_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -654,7 +654,7 @@ static int cobalt_g_dv_timings(struct file *file, void *priv_fh,
 			pad, g_dv_timings, 0, timings);
 }
 
-static int cobalt_query_dv_timings(struct file *file, void *priv_fh,
+static int cobalt_query_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -667,7 +667,7 @@ static int cobalt_query_dv_timings(struct file *file, void *priv_fh,
 			pad, query_dv_timings, 0, timings);
 }
 
-static int cobalt_dv_timings_cap(struct file *file, void *priv_fh,
+static int cobalt_dv_timings_cap(struct file *file, void *priv,
 				    struct v4l2_dv_timings_cap *cap)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -677,7 +677,7 @@ static int cobalt_dv_timings_cap(struct file *file, void *priv_fh,
 			pad, dv_timings_cap, cap);
 }
 
-static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh,
+static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv,
 		struct v4l2_fmtdesc *f)
 {
 	switch (f->index) {
@@ -697,7 +697,7 @@ static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh,
+static int cobalt_g_fmt_vid_cap(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -726,7 +726,7 @@ static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
+static int cobalt_try_fmt_vid_cap(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -787,7 +787,7 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
+static int cobalt_s_fmt_vid_cap(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -796,7 +796,7 @@ static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
 	if (vb2_is_busy(&s->q))
 		return -EBUSY;
 
-	if (cobalt_try_fmt_vid_cap(file, priv_fh, f))
+	if (cobalt_try_fmt_vid_cap(file, priv, f))
 		return -EINVAL;
 
 	s->width = pix->width;
@@ -821,7 +821,7 @@ static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_try_fmt_vid_out(struct file *file, void *priv_fh,
+static int cobalt_try_fmt_vid_out(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct v4l2_pix_format *pix = &f->fmt.pix;
@@ -862,7 +862,7 @@ static int cobalt_try_fmt_vid_out(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_g_fmt_vid_out(struct file *file, void *priv_fh,
+static int cobalt_g_fmt_vid_out(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -882,7 +882,7 @@ static int cobalt_g_fmt_vid_out(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh,
+static int cobalt_enum_fmt_vid_out(struct file *file, void *priv,
 		struct v4l2_fmtdesc *f)
 {
 	switch (f->index) {
@@ -899,7 +899,7 @@ static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
+static int cobalt_s_fmt_vid_out(struct file *file, void *priv,
 		struct v4l2_format *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -909,7 +909,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
 	};
 	u32 code;
 
-	if (cobalt_try_fmt_vid_out(file, priv_fh, f))
+	if (cobalt_try_fmt_vid_out(file, priv, f))
 		return -EINVAL;
 
 	if (vb2_is_busy(&s->q) && (pix->pixelformat != s->pixfmt ||
@@ -942,7 +942,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_enum_input(struct file *file, void *priv_fh,
+static int cobalt_enum_input(struct file *file, void *priv,
 				 struct v4l2_input *inp)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -963,7 +963,7 @@ static int cobalt_enum_input(struct file *file, void *priv_fh,
 			video, g_input_status, &inp->status);
 }
 
-static int cobalt_g_input(struct file *file, void *priv_fh, unsigned int *i)
+static int cobalt_g_input(struct file *file, void *priv, unsigned int *i)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 
@@ -971,7 +971,7 @@ static int cobalt_g_input(struct file *file, void *priv_fh, unsigned int *i)
 	return 0;
 }
 
-static int cobalt_s_input(struct file *file, void *priv_fh, unsigned int i)
+static int cobalt_s_input(struct file *file, void *priv, unsigned int i)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 
@@ -990,7 +990,7 @@ static int cobalt_s_input(struct file *file, void *priv_fh, unsigned int i)
 			ADV76XX_PAD_HDMI_PORT_A, 0, 0);
 }
 
-static int cobalt_enum_output(struct file *file, void *priv_fh,
+static int cobalt_enum_output(struct file *file, void *priv,
 				 struct v4l2_output *out)
 {
 	if (out->index)
@@ -1001,18 +1001,18 @@ static int cobalt_enum_output(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int cobalt_g_output(struct file *file, void *priv_fh, unsigned int *i)
+static int cobalt_g_output(struct file *file, void *priv, unsigned int *i)
 {
 	*i = 0;
 	return 0;
 }
 
-static int cobalt_s_output(struct file *file, void *priv_fh, unsigned int i)
+static int cobalt_s_output(struct file *file, void *priv, unsigned int i)
 {
 	return i ? -EINVAL : 0;
 }
 
-static int cobalt_g_edid(struct file *file, void *fh, struct v4l2_edid *edid)
+static int cobalt_g_edid(struct file *file, void *priv, struct v4l2_edid *edid)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 	u32 pad = edid->pad;
@@ -1026,7 +1026,7 @@ static int cobalt_g_edid(struct file *file, void *fh, struct v4l2_edid *edid)
 	return ret;
 }
 
-static int cobalt_s_edid(struct file *file, void *fh, struct v4l2_edid *edid)
+static int cobalt_s_edid(struct file *file, void *priv, struct v4l2_edid *edid)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 	u32 pad = edid->pad;
@@ -1050,7 +1050,7 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh,
 	return v4l2_ctrl_subscribe_event(fh, sub);
 }
 
-static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+static int cobalt_g_parm(struct file *file, void *priv, struct v4l2_streamparm *a)
 {
 	struct cobalt_stream *s = video_drvdata(file);
 	struct v4l2_fract fps;
@@ -1065,7 +1065,7 @@ static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
 	return 0;
 }
 
-static int cobalt_g_pixelaspect(struct file *file, void *fh,
+static int cobalt_g_pixelaspect(struct file *file, void *priv,
 				int type, struct v4l2_fract *f)
 {
 	struct cobalt_stream *s = video_drvdata(file);
@@ -1084,7 +1084,7 @@ static int cobalt_g_pixelaspect(struct file *file, void *fh,
 	return err;
 }
 
-static int cobalt_g_selection(struct file *file, void *fh,
+static int cobalt_g_selection(struct file *file, void *priv,
 			      struct v4l2_selection *sel)
 {
 	struct cobalt_stream *s = video_drvdata(file);
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index c88939bce56b..4a51b873e47a 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1302,7 +1302,7 @@ static int saa7134_g_pixelaspect(struct file *file, void *priv,
 	return 0;
 }
 
-static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
+static int saa7134_g_selection(struct file *file, void *priv, struct v4l2_selection *sel)
 {
 	struct saa7134_dev *dev = video_drvdata(file);
 
@@ -1325,7 +1325,7 @@ static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection
 	return 0;
 }
 
-static int saa7134_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
+static int saa7134_s_selection(struct file *file, void *priv, struct v4l2_selection *sel)
 {
 	struct saa7134_dev *dev = video_drvdata(file);
 	struct v4l2_rect *b = &dev->crop_bounds;
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 7c657df623f2..776046de979a 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -446,7 +446,7 @@ vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap)
 	return 0;
 }
 
-static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
+static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
 {
 	struct rga_fmt *fmt;
 
@@ -459,7 +459,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
 	return 0;
 }
 
-static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
 	struct rga_ctx *ctx = file_to_rga_ctx(file);
@@ -481,7 +481,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
 	struct rga_fmt *fmt;
@@ -501,7 +501,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
 	struct rga_ctx *ctx = file_to_rga_ctx(file);
@@ -514,7 +514,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	/* Adjust all values accordingly to the hardware capabilities
 	 * and chosen format.
 	 */
-	ret = vidioc_try_fmt(file, prv, f);
+	ret = vidioc_try_fmt(file, priv, f);
 	if (ret)
 		return ret;
 	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
@@ -558,7 +558,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_g_selection(struct file *file, void *prv,
+static int vidioc_g_selection(struct file *file, void *priv,
 			      struct v4l2_selection *s)
 {
 	struct rga_ctx *ctx = file_to_rga_ctx(file);
@@ -606,7 +606,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
 	return 0;
 }
 
-static int vidioc_s_selection(struct file *file, void *prv,
+static int vidioc_s_selection(struct file *file, void *priv,
 			      struct v4l2_selection *s)
 {
 	struct rga_ctx *ctx = file_to_rga_ctx(file);
diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
index 55f5130156b7..ffb9bee6cb9d 100644
--- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
+++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
@@ -297,7 +297,7 @@ static int vidioc_querycap(struct file *file, void *priv,
 	return 0;
 }
 
-static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
+static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
 {
 	if (f->index >= NUM_FORMATS)
 		return -EINVAL;
@@ -305,7 +305,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
 	return 0;
 }
 
-static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct g2d_ctx *ctx = file2ctx(file);
 	struct vb2_queue *vq;
@@ -327,7 +327,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct g2d_fmt *fmt;
 	enum v4l2_field *field;
@@ -357,7 +357,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct g2d_ctx *ctx = file2ctx(file);
 	struct g2d_dev *dev = ctx->dev;
@@ -368,7 +368,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 
 	/* Adjust all values accordingly to the hardware capabilities
 	 * and chosen format. */
-	ret = vidioc_try_fmt(file, prv, f);
+	ret = vidioc_try_fmt(file, priv, f);
 	if (ret)
 		return ret;
 	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
@@ -397,7 +397,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_g_selection(struct file *file, void *prv,
+static int vidioc_g_selection(struct file *file, void *priv,
 			      struct v4l2_selection *s)
 {
 	struct g2d_ctx *ctx = file2ctx(file);
@@ -447,7 +447,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
 	return 0;
 }
 
-static int vidioc_try_selection(struct file *file, void *prv,
+static int vidioc_try_selection(struct file *file, void *priv,
 				const struct v4l2_selection *s)
 {
 	struct g2d_ctx *ctx = file2ctx(file);
@@ -475,14 +475,14 @@ static int vidioc_try_selection(struct file *file, void *prv,
 	return 0;
 }
 
-static int vidioc_s_selection(struct file *file, void *prv,
+static int vidioc_s_selection(struct file *file, void *priv,
 			      struct v4l2_selection *s)
 {
 	struct g2d_ctx *ctx = file2ctx(file);
 	struct g2d_frame *f;
 	int ret;
 
-	ret = vidioc_try_selection(file, prv, s);
+	ret = vidioc_try_selection(file, priv, s);
 	if (ret)
 		return ret;
 	f = get_frame(ctx, s->type);
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 606e1a7121b5..afd28beabfde 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -330,7 +330,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
 	return 0;
 }
 
-static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
+static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
 				   struct v4l2_fmtdesc *f)
 {
 	return vidioc_enum_fmt(file, f, false);
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 694b68788a95..3f8701e5614f 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -1375,7 +1375,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
 	return -EINVAL;
 }
 
-static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
+static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
 				   struct v4l2_fmtdesc *f)
 {
 	return vidioc_enum_fmt(file, f, false);
diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
index a22f587a5f83..468c247ba328 100644
--- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
+++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
@@ -343,7 +343,7 @@ static int vidioc_querycap(struct file *file, void *priv,
 	return 0;
 }
 
-static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
+static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
 {
 	if (f->index >= NUM_FORMATS)
 		return -EINVAL;
@@ -352,7 +352,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
 	return 0;
 }
 
-static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct dma2d_ctx *ctx = file2ctx(file);
 	struct vb2_queue *vq;
@@ -377,7 +377,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct dma2d_ctx *ctx = file2ctx(file);
 	struct dma2d_fmt *fmt;
@@ -420,7 +420,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
+static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct dma2d_ctx *ctx = file2ctx(file);
 	struct vb2_queue *vq;
@@ -431,7 +431,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
 	/* Adjust all values accordingly to the hardware capabilities
 	 * and chosen format.
 	 */
-	ret = vidioc_try_fmt(file, prv, f);
+	ret = vidioc_try_fmt(file, priv, f);
 	if (ret)
 		return ret;
 
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
index 76356bc7f10e..65879f4802c0 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
@@ -711,7 +711,7 @@ static void sun6i_csi_capture_format_prepare(struct v4l2_format *format)
 	pix_format->xfer_func = V4L2_XFER_FUNC_DEFAULT;
 }
 
-static int sun6i_csi_capture_querycap(struct file *file, void *private,
+static int sun6i_csi_capture_querycap(struct file *file, void *priv,
 				      struct v4l2_capability *capability)
 {
 	struct sun6i_csi_device *csi_dev = video_drvdata(file);
@@ -725,7 +725,7 @@ static int sun6i_csi_capture_querycap(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_enum_fmt(struct file *file, void *private,
+static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv,
 				      struct v4l2_fmtdesc *fmtdesc)
 {
 	u32 index = fmtdesc->index;
@@ -738,7 +738,7 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_g_fmt(struct file *file, void *private,
+static int sun6i_csi_capture_g_fmt(struct file *file, void *priv,
 				   struct v4l2_format *format)
 {
 	struct sun6i_csi_device *csi_dev = video_drvdata(file);
@@ -748,7 +748,7 @@ static int sun6i_csi_capture_g_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_s_fmt(struct file *file, void *private,
+static int sun6i_csi_capture_s_fmt(struct file *file, void *priv,
 				   struct v4l2_format *format)
 {
 	struct sun6i_csi_device *csi_dev = video_drvdata(file);
@@ -764,7 +764,7 @@ static int sun6i_csi_capture_s_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_try_fmt(struct file *file, void *private,
+static int sun6i_csi_capture_try_fmt(struct file *file, void *priv,
 				     struct v4l2_format *format)
 {
 	sun6i_csi_capture_format_prepare(format);
@@ -772,7 +772,7 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_enum_input(struct file *file, void *private,
+static int sun6i_csi_capture_enum_input(struct file *file, void *priv,
 					struct v4l2_input *input)
 {
 	if (input->index != 0)
@@ -784,7 +784,7 @@ static int sun6i_csi_capture_enum_input(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_g_input(struct file *file, void *private,
+static int sun6i_csi_capture_g_input(struct file *file, void *priv,
 				     unsigned int *index)
 {
 	*index = 0;
@@ -792,7 +792,7 @@ static int sun6i_csi_capture_g_input(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_csi_capture_s_input(struct file *file, void *private,
+static int sun6i_csi_capture_s_input(struct file *file, void *priv,
 				     unsigned int index)
 {
 	if (index != 0)
diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
index 7af6765532e3..b7d278b3889f 100644
--- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
+++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
@@ -459,7 +459,7 @@ static bool port_no_link(struct snps_hdmirx_dev *hdmirx_dev)
 	return !tx_5v_power_present(hdmirx_dev);
 }
 
-static int hdmirx_query_dv_timings(struct file *file, void *_fh,
+static int hdmirx_query_dv_timings(struct file *file, void *priv,
 				   struct v4l2_dv_timings *timings)
 {
 	struct hdmirx_stream *stream = video_drvdata(file);
@@ -751,7 +751,7 @@ static int hdmirx_dv_timings_cap(struct file *file, void *fh,
 	return 0;
 }
 
-static int hdmirx_enum_dv_timings(struct file *file, void *_fh,
+static int hdmirx_enum_dv_timings(struct file *file, void *priv,
 				  struct v4l2_enum_dv_timings *timings)
 {
 	return v4l2_enum_dv_timings_cap(timings, &hdmirx_timings_cap, NULL, NULL);
@@ -1323,7 +1323,7 @@ static int hdmirx_g_fmt_vid_cap_mplane(struct file *file, void *fh,
 	return 0;
 }
 
-static int hdmirx_g_dv_timings(struct file *file, void *_fh,
+static int hdmirx_g_dv_timings(struct file *file, void *priv,
 			       struct v4l2_dv_timings *timings)
 {
 	struct hdmirx_stream *stream = video_drvdata(file);
@@ -1339,7 +1339,7 @@ static int hdmirx_g_dv_timings(struct file *file, void *_fh,
 	return 0;
 }
 
-static int hdmirx_s_dv_timings(struct file *file, void *_fh,
+static int hdmirx_s_dv_timings(struct file *file, void *priv,
 			       struct v4l2_dv_timings *timings)
 {
 	struct hdmirx_stream *stream = video_drvdata(file);
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index b628d6e081db..7fb565ebbe62 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -299,7 +299,7 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file, void *priv,
 	return 0;
 }
 
-static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov,
+static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *priv,
 				   struct v4l2_format *f)
 {
 	struct ti_csi2rx_dev *csi = video_drvdata(file);
diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/ti/omap/omap_vout.c
index a87d5030ac35..22782e9f1f4e 100644
--- a/drivers/media/platform/ti/omap/omap_vout.c
+++ b/drivers/media/platform/ti/omap/omap_vout.c
@@ -1236,7 +1236,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh,
 	return 0;
 }
 
-static int vidioc_enum_output(struct file *file, void *priv_fh,
+static int vidioc_enum_output(struct file *file, void *priv,
 			      struct v4l2_output *out)
 {
 	if (out->index)
@@ -1246,13 +1246,13 @@ static int vidioc_enum_output(struct file *file, void *priv_fh,
 	return 0;
 }
 
-static int vidioc_g_output(struct file *file, void *priv_fh, unsigned int *i)
+static int vidioc_g_output(struct file *file, void *priv, unsigned int *i)
 {
 	*i = 0;
 	return 0;
 }
 
-static int vidioc_s_output(struct file *file, void *priv_fh, unsigned int i)
+static int vidioc_s_output(struct file *file, void *priv, unsigned int i)
 {
 	return i ? -EINVAL : 0;
 }
diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c
index 67b4afadc95a..4132968110e3 100644
--- a/drivers/media/radio/si4713/radio-platform-si4713.c
+++ b/drivers/media/radio/si4713/radio-platform-si4713.c
@@ -75,35 +75,35 @@ static inline struct v4l2_device *get_v4l2_dev(struct file *file)
 	return &((struct radio_si4713_device *)video_drvdata(file))->v4l2_dev;
 }
 
-static int radio_si4713_g_modulator(struct file *file, void *p,
+static int radio_si4713_g_modulator(struct file *file, void *priv,
 				    struct v4l2_modulator *vm)
 {
 	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
 					  g_modulator, vm);
 }
 
-static int radio_si4713_s_modulator(struct file *file, void *p,
+static int radio_si4713_s_modulator(struct file *file, void *priv,
 				    const struct v4l2_modulator *vm)
 {
 	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
 					  s_modulator, vm);
 }
 
-static int radio_si4713_g_frequency(struct file *file, void *p,
+static int radio_si4713_g_frequency(struct file *file, void *priv,
 				    struct v4l2_frequency *vf)
 {
 	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
 					  g_frequency, vf);
 }
 
-static int radio_si4713_s_frequency(struct file *file, void *p,
+static int radio_si4713_s_frequency(struct file *file, void *priv,
 				    const struct v4l2_frequency *vf)
 {
 	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
 					  s_frequency, vf);
 }
 
-static long radio_si4713_default(struct file *file, void *p,
+static long radio_si4713_default(struct file *file, void *priv,
 				 bool valid_prio, unsigned int cmd, void *arg)
 {
 	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index e585c8f6e4c5..c695a97e202b 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1499,7 +1499,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
 	return 0;
 }
 
-static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm)
+static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
 {
 	struct cx231xx *dev = video_drvdata(file);
 
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 25edd2189654..3fc15d16df8e 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1029,15 +1029,15 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
 	return 0;
 }
 
-static int vidioc_g_fmt_vid_cap(struct file *file, void *_priv,
+static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *fmt)
 {
 	struct gspca_dev *gspca_dev = video_drvdata(file);
-	u32 priv = fmt->fmt.pix.priv;
+	u32 fmt_priv = fmt->fmt.pix.priv;
 
 	fmt->fmt.pix = gspca_dev->pixfmt;
 	/* some drivers use priv internally, so keep the original value */
-	fmt->fmt.pix.priv = priv;
+	fmt->fmt.pix.priv = fmt_priv;
 	return 0;
 }
 
@@ -1075,24 +1075,24 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
 	return mode;			/* used when s_fmt */
 }
 
-static int vidioc_try_fmt_vid_cap(struct file *file, void *_priv,
+static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
 				  struct v4l2_format *fmt)
 {
 	struct gspca_dev *gspca_dev = video_drvdata(file);
-	u32 priv = fmt->fmt.pix.priv;
+	u32 fmt_priv = fmt->fmt.pix.priv;
 
 	if (try_fmt_vid_cap(gspca_dev, fmt) < 0)
 		return -EINVAL;
 	/* some drivers use priv internally, so keep the original value */
-	fmt->fmt.pix.priv = priv;
+	fmt->fmt.pix.priv = fmt_priv;
 	return 0;
 }
 
-static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
+static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *fmt)
 {
 	struct gspca_dev *gspca_dev = video_drvdata(file);
-	u32 priv = fmt->fmt.pix.priv;
+	u32 fmt_priv = fmt->fmt.pix.priv;
 	int mode;
 
 	if (vb2_is_busy(&gspca_dev->queue))
@@ -1109,7 +1109,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
 	else
 		gspca_dev->pixfmt = gspca_dev->cam.cam_mode[mode];
 	/* some drivers use priv internally, so keep the original value */
-	fmt->fmt.pix.priv = priv;
+	fmt->fmt.pix.priv = fmt_priv;
 	return 0;
 }
 
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 8a5c2c5227eb..8c7ae362d992 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -590,7 +590,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
 	return 0;
 }
 
-static int vidioc_s_std(struct file *file, void *_fh,
+static int vidioc_s_std(struct file *file, void *priv,
 			v4l2_std_id std)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -610,7 +610,7 @@ static int vidioc_s_std(struct file *file, void *_fh,
 	return hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, std_type);
 }
 
-static int vidioc_g_std(struct file *file, void *_fh,
+static int vidioc_g_std(struct file *file, void *priv,
 			v4l2_std_id *std)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -623,7 +623,7 @@ static int vidioc_g_std(struct file *file, void *_fh,
 	return 0;
 }
 
-static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a)
+static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *a)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
 	struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
@@ -642,7 +642,7 @@ static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a)
 	return ret;
 }
 
-static int vidioc_s_dv_timings(struct file *file, void *_fh,
+static int vidioc_s_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -665,7 +665,7 @@ static int vidioc_s_dv_timings(struct file *file, void *_fh,
 	return 0;
 }
 
-static int vidioc_g_dv_timings(struct file *file, void *_fh,
+static int vidioc_g_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -678,7 +678,7 @@ static int vidioc_g_dv_timings(struct file *file, void *_fh,
 	return 0;
 }
 
-static int vidioc_query_dv_timings(struct file *file, void *_fh,
+static int vidioc_query_dv_timings(struct file *file, void *priv,
 				    struct v4l2_dv_timings *timings)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -720,7 +720,7 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh,
 	return ret;
 }
 
-static int vidioc_enum_dv_timings(struct file *file, void *_fh,
+static int vidioc_enum_dv_timings(struct file *file, void *priv,
 				    struct v4l2_enum_dv_timings *timings)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -736,7 +736,7 @@ static int vidioc_enum_dv_timings(struct file *file, void *_fh,
 	return 0;
 }
 
-static int vidioc_dv_timings_cap(struct file *file, void *_fh,
+static int vidioc_dv_timings_cap(struct file *file, void *priv,
 				    struct v4l2_dv_timings_cap *cap)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -763,7 +763,7 @@ static const char *iname[] = {
 	[HDPVR_COMPOSITE] = "Composite",
 };
 
-static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)
+static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i)
 {
 	unsigned int n;
 
@@ -783,7 +783,7 @@ static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)
 	return 0;
 }
 
-static int vidioc_s_input(struct file *file, void *_fh,
+static int vidioc_s_input(struct file *file, void *priv,
 			  unsigned int index)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -817,7 +817,7 @@ static int vidioc_s_input(struct file *file, void *_fh,
 	return retval;
 }
 
-static int vidioc_g_input(struct file *file, void *private_data,
+static int vidioc_g_input(struct file *file, void *priv,
 			  unsigned int *index)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -849,7 +849,7 @@ static int vidioc_enumaudio(struct file *file, void *priv,
 	return 0;
 }
 
-static int vidioc_s_audio(struct file *file, void *private_data,
+static int vidioc_s_audio(struct file *file, void *priv,
 			  const struct v4l2_audio *audio)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -868,7 +868,7 @@ static int vidioc_s_audio(struct file *file, void *private_data,
 	return retval;
 }
 
-static int vidioc_g_audio(struct file *file, void *private_data,
+static int vidioc_g_audio(struct file *file, void *priv,
 			  struct v4l2_audio *audio)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
@@ -985,7 +985,7 @@ static int hdpvr_s_ctrl(struct v4l2_ctrl *ctrl)
 	return ret;
 }
 
-static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
+static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
 				    struct v4l2_fmtdesc *f)
 {
 	if (f->index != 0)
@@ -996,7 +996,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
 	return 0;
 }
 
-static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh,
+static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
 	struct hdpvr_device *dev = video_drvdata(file);
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v3 76/76] media: staging: Rename second ioctl handlers argument to 'void *priv'
       [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
                   ` (19 preceding siblings ...)
  2025-08-10  1:30 ` [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv' Laurent Pinchart
@ 2025-08-10  1:30 ` Laurent Pinchart
  20 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-10  1:30 UTC (permalink / raw)
  To: linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Paul Kocialkowski, Greg Kroah-Hartman, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, linux-staging, linux-arm-kernel,
	linux-sunxi

The second argument to the ioctl handlers is not a file handle any more.
The standard practice is to name it 'void *priv' in drivers. Many
drivers still name it 'void *fh', and a few use more exotic names.
Replace those more exotic names with 'void *priv' in all media staging
drivers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 .../media/sunxi/sun6i-isp/sun6i_isp_capture.c    | 16 ++++++++--------
 .../media/sunxi/sun6i-isp/sun6i_isp_params.c     |  6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
index 24899f41dc1c..e7b99cee63d6 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c
@@ -419,7 +419,7 @@ static void sun6i_isp_capture_format_prepare(struct v4l2_format *format)
 	pix_format->xfer_func = V4L2_XFER_FUNC_DEFAULT;
 }
 
-static int sun6i_isp_capture_querycap(struct file *file, void *private,
+static int sun6i_isp_capture_querycap(struct file *file, void *priv,
 				      struct v4l2_capability *capability)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
@@ -433,7 +433,7 @@ static int sun6i_isp_capture_querycap(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_enum_fmt(struct file *file, void *private,
+static int sun6i_isp_capture_enum_fmt(struct file *file, void *priv,
 				      struct v4l2_fmtdesc *fmtdesc)
 {
 	u32 index = fmtdesc->index;
@@ -446,7 +446,7 @@ static int sun6i_isp_capture_enum_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_g_fmt(struct file *file, void *private,
+static int sun6i_isp_capture_g_fmt(struct file *file, void *priv,
 				   struct v4l2_format *format)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
@@ -456,7 +456,7 @@ static int sun6i_isp_capture_g_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_s_fmt(struct file *file, void *private,
+static int sun6i_isp_capture_s_fmt(struct file *file, void *priv,
 				   struct v4l2_format *format)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
@@ -471,7 +471,7 @@ static int sun6i_isp_capture_s_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_try_fmt(struct file *file, void *private,
+static int sun6i_isp_capture_try_fmt(struct file *file, void *priv,
 				     struct v4l2_format *format)
 {
 	sun6i_isp_capture_format_prepare(format);
@@ -479,7 +479,7 @@ static int sun6i_isp_capture_try_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_enum_input(struct file *file, void *private,
+static int sun6i_isp_capture_enum_input(struct file *file, void *priv,
 					struct v4l2_input *input)
 {
 	if (input->index != 0)
@@ -491,7 +491,7 @@ static int sun6i_isp_capture_enum_input(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_g_input(struct file *file, void *private,
+static int sun6i_isp_capture_g_input(struct file *file, void *priv,
 				     unsigned int *index)
 {
 	*index = 0;
@@ -499,7 +499,7 @@ static int sun6i_isp_capture_g_input(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_capture_s_input(struct file *file, void *private,
+static int sun6i_isp_capture_s_input(struct file *file, void *priv,
 				     unsigned int index)
 {
 	if (index != 0)
diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
index 3d95ed0b023e..77c2d06c0436 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c
@@ -383,7 +383,7 @@ static const struct vb2_ops sun6i_isp_params_queue_ops = {
 
 /* Video Device */
 
-static int sun6i_isp_params_querycap(struct file *file, void *private,
+static int sun6i_isp_params_querycap(struct file *file, void *priv,
 				     struct v4l2_capability *capability)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
@@ -397,7 +397,7 @@ static int sun6i_isp_params_querycap(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_params_enum_fmt(struct file *file, void *private,
+static int sun6i_isp_params_enum_fmt(struct file *file, void *priv,
 				     struct v4l2_fmtdesc *fmtdesc)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
@@ -412,7 +412,7 @@ static int sun6i_isp_params_enum_fmt(struct file *file, void *private,
 	return 0;
 }
 
-static int sun6i_isp_params_g_fmt(struct file *file, void *private,
+static int sun6i_isp_params_g_fmt(struct file *file, void *priv,
 				  struct v4l2_format *format)
 {
 	struct sun6i_isp_device *isp_dev = video_drvdata(file);
-- 
Regards,

Laurent Pinchart



^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 47/76] media: imx-isi: Access v4l2_fh from file
  2025-08-10  1:30 ` [PATCH v3 47/76] media: imx-isi: " Laurent Pinchart
@ 2025-08-11 15:05   ` Frank Li
  0 siblings, 0 replies; 27+ messages in thread
From: Frank Li @ 2025-08-11 15:05 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	imx, linux-arm-kernel

On Sun, Aug 10, 2025 at 04:30:29AM +0300, Laurent Pinchart wrote:
> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> 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>
> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes since v1:
>
> - Update file-to-ctx macro due to removal of fh-to-ctx macro
> ---
>  .../media/platform/nxp/imx8-isi/imx8-isi-m2m.c  | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 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 31298307c672..5501214cc6c0 100644
> --- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> +++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c
> @@ -74,14 +74,9 @@ 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 to_isi_m2m_ctx(file_to_v4l2_fh(filp));
> +	return container_of(file_to_v4l2_fh(filp), struct mxc_isi_m2m_ctx, fh);
>  }
>
>  static inline struct mxc_isi_m2m_ctx_queue_data *
> @@ -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;
>
> --
> Regards,
>
> Laurent Pinchart
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 46/76] media: imx-jpeg: Access v4l2_fh from file
  2025-08-10  1:30 ` [PATCH v3 46/76] media: imx-jpeg: " Laurent Pinchart
@ 2025-08-11 15:05   ` Frank Li
  0 siblings, 0 replies; 27+ messages in thread
From: Frank Li @ 2025-08-11 15:05 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Mirela Rabulea, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, imx, linux-arm-kernel

On Sun, Aug 10, 2025 at 04:30:28AM +0300, Laurent Pinchart wrote:
> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> 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>
> Reviewed-by: Ming Qian <ming.qian@oss.nxp.com>
> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes since v1:
>
> - Update file-to-ctx macro due to removal of fh-to-ctx macro
> ---
>  .../media/platform/nxp/imx-jpeg/mxc-jpeg.c    | 35 ++++++++-----------
>  1 file changed, 15 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> index a34e644b2cb1..df3ccdf767ba 100644
> --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> @@ -644,14 +644,9 @@ 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 mxc_jpeg_fh_to_ctx(file_to_v4l2_fh(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,
> @@ -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)
> --
> Regards,
>
> Laurent Pinchart
>


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv'
  2025-08-10  1:30 ` [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv' Laurent Pinchart
@ 2025-08-12  5:52   ` Jai Luthra
  0 siblings, 0 replies; 27+ messages in thread
From: Jai Luthra @ 2025-08-12  5:52 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Hans Verkuil, Jacob Chen, Ezequiel Garcia, Heiko Stuebner,
	Łukasz Stelmach, Marek Szyprowski, Andrzej Hajda,
	Maxime Coquelin, Alexandre Torgue, Yong Deng, Paul Kocialkowski,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Eduardo Valentin,
	Thomas Gleixner, Ingo Molnar, Sakari Ailus, Neil Armstrong,
	Andrzej Pietrasiewicz, Uwe Kleine-König, Jiasheng Jiang,
	Ricardo Ribalda, linux-rockchip, linux-arm-kernel, linux-stm32,
	linux-sunxi, kernel

[-- Attachment #1: Type: text/plain, Size: 44402 bytes --]

On Sun, Aug 10, 2025 at 04:30:57AM +0300, Laurent Pinchart wrote:
> The second argument to the ioctl handlers is not a file handle any more.
> The standard practice is to name it 'void *priv' in drivers. Many
> drivers still name it 'void *fh', and a few use more exotic names.
> Replace those more exotic names with 'void *priv' in all media drivers.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Acked-by: Jai Luthra <jai.luthra@linux.dev>

> ---
>  .../extron-da-hd-4k-plus.c                    |  4 +-
>  drivers/media/pci/bt8xx/bttv-driver.c         | 14 ++---
>  drivers/media/pci/bt8xx/bttv-vbi.c            |  6 +-
>  drivers/media/pci/cobalt/cobalt-v4l2.c        | 60 +++++++++----------
>  drivers/media/pci/saa7134/saa7134-video.c     |  4 +-
>  drivers/media/platform/rockchip/rga/rga.c     | 14 ++---
>  drivers/media/platform/samsung/s5p-g2d/g2d.c  | 18 +++---
>  .../platform/samsung/s5p-mfc/s5p_mfc_dec.c    |  2 +-
>  .../platform/samsung/s5p-mfc/s5p_mfc_enc.c    |  2 +-
>  drivers/media/platform/st/stm32/dma2d/dma2d.c | 10 ++--
>  .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 16 ++---
>  .../platform/synopsys/hdmirx/snps_hdmirx.c    |  8 +--
>  .../platform/ti/j721e-csi2rx/j721e-csi2rx.c   |  2 +-
>  drivers/media/platform/ti/omap/omap_vout.c    |  6 +-
>  .../radio/si4713/radio-platform-si4713.c      | 10 ++--
>  drivers/media/usb/cx231xx/cx231xx-417.c       |  2 +-
>  drivers/media/usb/gspca/gspca.c               | 18 +++---
>  drivers/media/usb/hdpvr/hdpvr-video.c         | 30 +++++-----
>  18 files changed, 113 insertions(+), 113 deletions(-)
> 
> diff --git a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
> index 41d019b01ec0..c476e8d1279e 100644
> --- a/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
> +++ b/drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
> @@ -1252,7 +1252,7 @@ static int extron_s_output(struct file *file, void *priv, unsigned int o)
>  	return o ? -EINVAL : 0;
>  }
>  
> -static int extron_g_edid(struct file *file, void *_fh,
> +static int extron_g_edid(struct file *file, void *priv,
>  			 struct v4l2_edid *edid)
>  {
>  	struct extron_port *port = video_drvdata(file);
> @@ -1280,7 +1280,7 @@ static int extron_g_edid(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int extron_s_edid(struct file *file, void *_fh, struct v4l2_edid *edid)
> +static int extron_s_edid(struct file *file, void *priv, struct v4l2_edid *edid)
>  {
>  	struct extron_port *port = video_drvdata(file);
>  
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 9ce67f515843..17e4529e537a 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -1620,7 +1620,7 @@ static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
>  	return 0;
>  }
>  
> -static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
> +static int bttv_querystd(struct file *file, void *priv, v4l2_std_id *id)
>  {
>  	struct bttv *btv = video_drvdata(file);
>  
> @@ -1750,7 +1750,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int bttv_log_status(struct file *file, void *f)
> +static int bttv_log_status(struct file *file, void *priv)
>  {
>  	struct video_device *vdev = video_devdata(file);
>  	struct bttv *btv = video_drvdata(file);
> @@ -1761,7 +1761,7 @@ static int bttv_log_status(struct file *file, void *f)
>  }
>  
>  #ifdef CONFIG_VIDEO_ADV_DEBUG
> -static int bttv_g_register(struct file *file, void *f,
> +static int bttv_g_register(struct file *file, void *priv,
>  					struct v4l2_dbg_register *reg)
>  {
>  	struct bttv *btv = video_drvdata(file);
> @@ -1774,7 +1774,7 @@ static int bttv_g_register(struct file *file, void *f,
>  	return 0;
>  }
>  
> -static int bttv_s_register(struct file *file, void *f,
> +static int bttv_s_register(struct file *file, void *priv,
>  					const struct v4l2_dbg_register *reg)
>  {
>  	struct bttv *btv = video_drvdata(file);
> @@ -2159,7 +2159,7 @@ static int bttv_enum_fmt_vid_cap(struct file *file, void  *priv,
>  	return 0;
>  }
>  
> -static int bttv_g_parm(struct file *file, void *f,
> +static int bttv_g_parm(struct file *file, void *priv,
>  				struct v4l2_streamparm *parm)
>  {
>  	struct bttv *btv = video_drvdata(file);
> @@ -2208,7 +2208,7 @@ static int bttv_g_pixelaspect(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
> +static int bttv_g_selection(struct file *file, void *priv, struct v4l2_selection *sel)
>  {
>  	struct bttv *btv = video_drvdata(file);
>  
> @@ -2232,7 +2232,7 @@ static int bttv_g_selection(struct file *file, void *f, struct v4l2_selection *s
>  	return 0;
>  }
>  
> -static int bttv_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
> +static int bttv_s_selection(struct file *file, void *priv, struct v4l2_selection *sel)
>  {
>  	struct bttv *btv = video_drvdata(file);
>  	const struct v4l2_rect *b;
> diff --git a/drivers/media/pci/bt8xx/bttv-vbi.c b/drivers/media/pci/bt8xx/bttv-vbi.c
> index a71440611e46..0ca88a2400ee 100644
> --- a/drivers/media/pci/bt8xx/bttv-vbi.c
> +++ b/drivers/media/pci/bt8xx/bttv-vbi.c
> @@ -241,7 +241,7 @@ static int try_fmt(struct v4l2_vbi_format *f, const struct bttv_tvnorm *tvnorm,
>  	return 0;
>  }
>  
> -int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
> +int bttv_try_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
>  {
>  	struct bttv *btv = video_drvdata(file);
>  	const struct bttv_tvnorm *tvnorm;
> @@ -258,7 +258,7 @@ int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
>  }
>  
>  
> -int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
> +int bttv_s_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
>  {
>  	struct bttv *btv = video_drvdata(file);
>  	const struct bttv_tvnorm *tvnorm;
> @@ -301,7 +301,7 @@ int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
>  }
>  
>  
> -int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt)
> +int bttv_g_fmt_vbi_cap(struct file *file, void *priv, struct v4l2_format *frt)
>  {
>  	const struct bttv_tvnorm *tvnorm;
>  	struct bttv *btv = video_drvdata(file);
> diff --git a/drivers/media/pci/cobalt/cobalt-v4l2.c b/drivers/media/pci/cobalt/cobalt-v4l2.c
> index ae82427e3479..51fd9576c6c2 100644
> --- a/drivers/media/pci/cobalt/cobalt-v4l2.c
> +++ b/drivers/media/pci/cobalt/cobalt-v4l2.c
> @@ -447,7 +447,7 @@ static int cobalt_cobaltc(struct cobalt *cobalt, unsigned int cmd, void *arg)
>  	return 0;
>  }
>  
> -static int cobalt_g_register(struct file *file, void *priv_fh,
> +static int cobalt_g_register(struct file *file, void *priv,
>  		struct v4l2_dbg_register *reg)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -456,7 +456,7 @@ static int cobalt_g_register(struct file *file, void *priv_fh,
>  	return cobalt_cobaltc(cobalt, VIDIOC_DBG_G_REGISTER, reg);
>  }
>  
> -static int cobalt_s_register(struct file *file, void *priv_fh,
> +static int cobalt_s_register(struct file *file, void *priv,
>  		const struct v4l2_dbg_register *reg)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -467,7 +467,7 @@ static int cobalt_s_register(struct file *file, void *priv_fh,
>  }
>  #endif
>  
> -static int cobalt_querycap(struct file *file, void *priv_fh,
> +static int cobalt_querycap(struct file *file, void *priv,
>  				struct v4l2_capability *vcap)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -562,7 +562,7 @@ static void cobalt_video_input_status_show(struct cobalt_stream *s)
>  	cobalt_info("rx%d: Packer: %x\n", rx, ioread32(&packer->control));
>  }
>  
> -static int cobalt_log_status(struct file *file, void *priv_fh)
> +static int cobalt_log_status(struct file *file, void *priv)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  	struct cobalt *cobalt = s->cobalt;
> @@ -596,7 +596,7 @@ static int cobalt_log_status(struct file *file, void *priv_fh)
>  	return 0;
>  }
>  
> -static int cobalt_enum_dv_timings(struct file *file, void *priv_fh,
> +static int cobalt_enum_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_enum_dv_timings *timings)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -613,7 +613,7 @@ static int cobalt_enum_dv_timings(struct file *file, void *priv_fh,
>  			pad, enum_dv_timings, timings);
>  }
>  
> -static int cobalt_s_dv_timings(struct file *file, void *priv_fh,
> +static int cobalt_s_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -641,7 +641,7 @@ static int cobalt_s_dv_timings(struct file *file, void *priv_fh,
>  	return err;
>  }
>  
> -static int cobalt_g_dv_timings(struct file *file, void *priv_fh,
> +static int cobalt_g_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -654,7 +654,7 @@ static int cobalt_g_dv_timings(struct file *file, void *priv_fh,
>  			pad, g_dv_timings, 0, timings);
>  }
>  
> -static int cobalt_query_dv_timings(struct file *file, void *priv_fh,
> +static int cobalt_query_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -667,7 +667,7 @@ static int cobalt_query_dv_timings(struct file *file, void *priv_fh,
>  			pad, query_dv_timings, 0, timings);
>  }
>  
> -static int cobalt_dv_timings_cap(struct file *file, void *priv_fh,
> +static int cobalt_dv_timings_cap(struct file *file, void *priv,
>  				    struct v4l2_dv_timings_cap *cap)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -677,7 +677,7 @@ static int cobalt_dv_timings_cap(struct file *file, void *priv_fh,
>  			pad, dv_timings_cap, cap);
>  }
>  
> -static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh,
> +static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv,
>  		struct v4l2_fmtdesc *f)
>  {
>  	switch (f->index) {
> @@ -697,7 +697,7 @@ static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh,
> +static int cobalt_g_fmt_vid_cap(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -726,7 +726,7 @@ static int cobalt_g_fmt_vid_cap(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
> +static int cobalt_try_fmt_vid_cap(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -787,7 +787,7 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
> +static int cobalt_s_fmt_vid_cap(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -796,7 +796,7 @@ static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
>  	if (vb2_is_busy(&s->q))
>  		return -EBUSY;
>  
> -	if (cobalt_try_fmt_vid_cap(file, priv_fh, f))
> +	if (cobalt_try_fmt_vid_cap(file, priv, f))
>  		return -EINVAL;
>  
>  	s->width = pix->width;
> @@ -821,7 +821,7 @@ static int cobalt_s_fmt_vid_cap(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_try_fmt_vid_out(struct file *file, void *priv_fh,
> +static int cobalt_try_fmt_vid_out(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct v4l2_pix_format *pix = &f->fmt.pix;
> @@ -862,7 +862,7 @@ static int cobalt_try_fmt_vid_out(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_g_fmt_vid_out(struct file *file, void *priv_fh,
> +static int cobalt_g_fmt_vid_out(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -882,7 +882,7 @@ static int cobalt_g_fmt_vid_out(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh,
> +static int cobalt_enum_fmt_vid_out(struct file *file, void *priv,
>  		struct v4l2_fmtdesc *f)
>  {
>  	switch (f->index) {
> @@ -899,7 +899,7 @@ static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
> +static int cobalt_s_fmt_vid_out(struct file *file, void *priv,
>  		struct v4l2_format *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -909,7 +909,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
>  	};
>  	u32 code;
>  
> -	if (cobalt_try_fmt_vid_out(file, priv_fh, f))
> +	if (cobalt_try_fmt_vid_out(file, priv, f))
>  		return -EINVAL;
>  
>  	if (vb2_is_busy(&s->q) && (pix->pixelformat != s->pixfmt ||
> @@ -942,7 +942,7 @@ static int cobalt_s_fmt_vid_out(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_enum_input(struct file *file, void *priv_fh,
> +static int cobalt_enum_input(struct file *file, void *priv,
>  				 struct v4l2_input *inp)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -963,7 +963,7 @@ static int cobalt_enum_input(struct file *file, void *priv_fh,
>  			video, g_input_status, &inp->status);
>  }
>  
> -static int cobalt_g_input(struct file *file, void *priv_fh, unsigned int *i)
> +static int cobalt_g_input(struct file *file, void *priv, unsigned int *i)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  
> @@ -971,7 +971,7 @@ static int cobalt_g_input(struct file *file, void *priv_fh, unsigned int *i)
>  	return 0;
>  }
>  
> -static int cobalt_s_input(struct file *file, void *priv_fh, unsigned int i)
> +static int cobalt_s_input(struct file *file, void *priv, unsigned int i)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  
> @@ -990,7 +990,7 @@ static int cobalt_s_input(struct file *file, void *priv_fh, unsigned int i)
>  			ADV76XX_PAD_HDMI_PORT_A, 0, 0);
>  }
>  
> -static int cobalt_enum_output(struct file *file, void *priv_fh,
> +static int cobalt_enum_output(struct file *file, void *priv,
>  				 struct v4l2_output *out)
>  {
>  	if (out->index)
> @@ -1001,18 +1001,18 @@ static int cobalt_enum_output(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int cobalt_g_output(struct file *file, void *priv_fh, unsigned int *i)
> +static int cobalt_g_output(struct file *file, void *priv, unsigned int *i)
>  {
>  	*i = 0;
>  	return 0;
>  }
>  
> -static int cobalt_s_output(struct file *file, void *priv_fh, unsigned int i)
> +static int cobalt_s_output(struct file *file, void *priv, unsigned int i)
>  {
>  	return i ? -EINVAL : 0;
>  }
>  
> -static int cobalt_g_edid(struct file *file, void *fh, struct v4l2_edid *edid)
> +static int cobalt_g_edid(struct file *file, void *priv, struct v4l2_edid *edid)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  	u32 pad = edid->pad;
> @@ -1026,7 +1026,7 @@ static int cobalt_g_edid(struct file *file, void *fh, struct v4l2_edid *edid)
>  	return ret;
>  }
>  
> -static int cobalt_s_edid(struct file *file, void *fh, struct v4l2_edid *edid)
> +static int cobalt_s_edid(struct file *file, void *priv, struct v4l2_edid *edid)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  	u32 pad = edid->pad;
> @@ -1050,7 +1050,7 @@ static int cobalt_subscribe_event(struct v4l2_fh *fh,
>  	return v4l2_ctrl_subscribe_event(fh, sub);
>  }
>  
> -static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
> +static int cobalt_g_parm(struct file *file, void *priv, struct v4l2_streamparm *a)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
>  	struct v4l2_fract fps;
> @@ -1065,7 +1065,7 @@ static int cobalt_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
>  	return 0;
>  }
>  
> -static int cobalt_g_pixelaspect(struct file *file, void *fh,
> +static int cobalt_g_pixelaspect(struct file *file, void *priv,
>  				int type, struct v4l2_fract *f)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> @@ -1084,7 +1084,7 @@ static int cobalt_g_pixelaspect(struct file *file, void *fh,
>  	return err;
>  }
>  
> -static int cobalt_g_selection(struct file *file, void *fh,
> +static int cobalt_g_selection(struct file *file, void *priv,
>  			      struct v4l2_selection *sel)
>  {
>  	struct cobalt_stream *s = video_drvdata(file);
> diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
> index c88939bce56b..4a51b873e47a 100644
> --- a/drivers/media/pci/saa7134/saa7134-video.c
> +++ b/drivers/media/pci/saa7134/saa7134-video.c
> @@ -1302,7 +1302,7 @@ static int saa7134_g_pixelaspect(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
> +static int saa7134_g_selection(struct file *file, void *priv, struct v4l2_selection *sel)
>  {
>  	struct saa7134_dev *dev = video_drvdata(file);
>  
> @@ -1325,7 +1325,7 @@ static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection
>  	return 0;
>  }
>  
> -static int saa7134_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
> +static int saa7134_s_selection(struct file *file, void *priv, struct v4l2_selection *sel)
>  {
>  	struct saa7134_dev *dev = video_drvdata(file);
>  	struct v4l2_rect *b = &dev->crop_bounds;
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index 7c657df623f2..776046de979a 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -446,7 +446,7 @@ vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *cap)
>  	return 0;
>  }
>  
> -static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
> +static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
>  {
>  	struct rga_fmt *fmt;
>  
> @@ -459,7 +459,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
>  	struct rga_ctx *ctx = file_to_rga_ctx(file);
> @@ -481,7 +481,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
>  	struct rga_fmt *fmt;
> @@ -501,7 +501,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
>  	struct rga_ctx *ctx = file_to_rga_ctx(file);
> @@ -514,7 +514,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	/* Adjust all values accordingly to the hardware capabilities
>  	 * and chosen format.
>  	 */
> -	ret = vidioc_try_fmt(file, prv, f);
> +	ret = vidioc_try_fmt(file, priv, f);
>  	if (ret)
>  		return ret;
>  	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
> @@ -558,7 +558,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_g_selection(struct file *file, void *prv,
> +static int vidioc_g_selection(struct file *file, void *priv,
>  			      struct v4l2_selection *s)
>  {
>  	struct rga_ctx *ctx = file_to_rga_ctx(file);
> @@ -606,7 +606,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
>  	return 0;
>  }
>  
> -static int vidioc_s_selection(struct file *file, void *prv,
> +static int vidioc_s_selection(struct file *file, void *priv,
>  			      struct v4l2_selection *s)
>  {
>  	struct rga_ctx *ctx = file_to_rga_ctx(file);
> diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> index 55f5130156b7..ffb9bee6cb9d 100644
> --- a/drivers/media/platform/samsung/s5p-g2d/g2d.c
> +++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c
> @@ -297,7 +297,7 @@ static int vidioc_querycap(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
> +static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
>  {
>  	if (f->index >= NUM_FORMATS)
>  		return -EINVAL;
> @@ -305,7 +305,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct g2d_ctx *ctx = file2ctx(file);
>  	struct vb2_queue *vq;
> @@ -327,7 +327,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct g2d_fmt *fmt;
>  	enum v4l2_field *field;
> @@ -357,7 +357,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct g2d_ctx *ctx = file2ctx(file);
>  	struct g2d_dev *dev = ctx->dev;
> @@ -368,7 +368,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  
>  	/* Adjust all values accordingly to the hardware capabilities
>  	 * and chosen format. */
> -	ret = vidioc_try_fmt(file, prv, f);
> +	ret = vidioc_try_fmt(file, priv, f);
>  	if (ret)
>  		return ret;
>  	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
> @@ -397,7 +397,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_g_selection(struct file *file, void *prv,
> +static int vidioc_g_selection(struct file *file, void *priv,
>  			      struct v4l2_selection *s)
>  {
>  	struct g2d_ctx *ctx = file2ctx(file);
> @@ -447,7 +447,7 @@ static int vidioc_g_selection(struct file *file, void *prv,
>  	return 0;
>  }
>  
> -static int vidioc_try_selection(struct file *file, void *prv,
> +static int vidioc_try_selection(struct file *file, void *priv,
>  				const struct v4l2_selection *s)
>  {
>  	struct g2d_ctx *ctx = file2ctx(file);
> @@ -475,14 +475,14 @@ static int vidioc_try_selection(struct file *file, void *prv,
>  	return 0;
>  }
>  
> -static int vidioc_s_selection(struct file *file, void *prv,
> +static int vidioc_s_selection(struct file *file, void *priv,
>  			      struct v4l2_selection *s)
>  {
>  	struct g2d_ctx *ctx = file2ctx(file);
>  	struct g2d_frame *f;
>  	int ret;
>  
> -	ret = vidioc_try_selection(file, prv, s);
> +	ret = vidioc_try_selection(file, priv, s);
>  	if (ret)
>  		return ret;
>  	f = get_frame(ctx, s->type);
> 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 606e1a7121b5..afd28beabfde 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> @@ -330,7 +330,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
>  	return 0;
>  }
>  
> -static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
> +static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
>  				   struct v4l2_fmtdesc *f)
>  {
>  	return vidioc_enum_fmt(file, f, false);
> 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 694b68788a95..3f8701e5614f 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> @@ -1375,7 +1375,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
>  	return -EINVAL;
>  }
>  
> -static int vidioc_enum_fmt_vid_cap(struct file *file, void *pirv,
> +static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
>  				   struct v4l2_fmtdesc *f)
>  {
>  	return vidioc_enum_fmt(file, f, false);
> diff --git a/drivers/media/platform/st/stm32/dma2d/dma2d.c b/drivers/media/platform/st/stm32/dma2d/dma2d.c
> index a22f587a5f83..468c247ba328 100644
> --- a/drivers/media/platform/st/stm32/dma2d/dma2d.c
> +++ b/drivers/media/platform/st/stm32/dma2d/dma2d.c
> @@ -343,7 +343,7 @@ static int vidioc_querycap(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
> +static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f)
>  {
>  	if (f->index >= NUM_FORMATS)
>  		return -EINVAL;
> @@ -352,7 +352,7 @@ static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct dma2d_ctx *ctx = file2ctx(file);
>  	struct vb2_queue *vq;
> @@ -377,7 +377,7 @@ static int vidioc_g_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct dma2d_ctx *ctx = file2ctx(file);
>  	struct dma2d_fmt *fmt;
> @@ -420,7 +420,7 @@ static int vidioc_try_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
> +static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>  {
>  	struct dma2d_ctx *ctx = file2ctx(file);
>  	struct vb2_queue *vq;
> @@ -431,7 +431,7 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
>  	/* Adjust all values accordingly to the hardware capabilities
>  	 * and chosen format.
>  	 */
> -	ret = vidioc_try_fmt(file, prv, f);
> +	ret = vidioc_try_fmt(file, priv, f);
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> index 76356bc7f10e..65879f4802c0 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> @@ -711,7 +711,7 @@ static void sun6i_csi_capture_format_prepare(struct v4l2_format *format)
>  	pix_format->xfer_func = V4L2_XFER_FUNC_DEFAULT;
>  }
>  
> -static int sun6i_csi_capture_querycap(struct file *file, void *private,
> +static int sun6i_csi_capture_querycap(struct file *file, void *priv,
>  				      struct v4l2_capability *capability)
>  {
>  	struct sun6i_csi_device *csi_dev = video_drvdata(file);
> @@ -725,7 +725,7 @@ static int sun6i_csi_capture_querycap(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_enum_fmt(struct file *file, void *private,
> +static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv,
>  				      struct v4l2_fmtdesc *fmtdesc)
>  {
>  	u32 index = fmtdesc->index;
> @@ -738,7 +738,7 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_g_fmt(struct file *file, void *private,
> +static int sun6i_csi_capture_g_fmt(struct file *file, void *priv,
>  				   struct v4l2_format *format)
>  {
>  	struct sun6i_csi_device *csi_dev = video_drvdata(file);
> @@ -748,7 +748,7 @@ static int sun6i_csi_capture_g_fmt(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_s_fmt(struct file *file, void *private,
> +static int sun6i_csi_capture_s_fmt(struct file *file, void *priv,
>  				   struct v4l2_format *format)
>  {
>  	struct sun6i_csi_device *csi_dev = video_drvdata(file);
> @@ -764,7 +764,7 @@ static int sun6i_csi_capture_s_fmt(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_try_fmt(struct file *file, void *private,
> +static int sun6i_csi_capture_try_fmt(struct file *file, void *priv,
>  				     struct v4l2_format *format)
>  {
>  	sun6i_csi_capture_format_prepare(format);
> @@ -772,7 +772,7 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_enum_input(struct file *file, void *private,
> +static int sun6i_csi_capture_enum_input(struct file *file, void *priv,
>  					struct v4l2_input *input)
>  {
>  	if (input->index != 0)
> @@ -784,7 +784,7 @@ static int sun6i_csi_capture_enum_input(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_g_input(struct file *file, void *private,
> +static int sun6i_csi_capture_g_input(struct file *file, void *priv,
>  				     unsigned int *index)
>  {
>  	*index = 0;
> @@ -792,7 +792,7 @@ static int sun6i_csi_capture_g_input(struct file *file, void *private,
>  	return 0;
>  }
>  
> -static int sun6i_csi_capture_s_input(struct file *file, void *private,
> +static int sun6i_csi_capture_s_input(struct file *file, void *priv,
>  				     unsigned int index)
>  {
>  	if (index != 0)
> diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> index 7af6765532e3..b7d278b3889f 100644
> --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
> @@ -459,7 +459,7 @@ static bool port_no_link(struct snps_hdmirx_dev *hdmirx_dev)
>  	return !tx_5v_power_present(hdmirx_dev);
>  }
>  
> -static int hdmirx_query_dv_timings(struct file *file, void *_fh,
> +static int hdmirx_query_dv_timings(struct file *file, void *priv,
>  				   struct v4l2_dv_timings *timings)
>  {
>  	struct hdmirx_stream *stream = video_drvdata(file);
> @@ -751,7 +751,7 @@ static int hdmirx_dv_timings_cap(struct file *file, void *fh,
>  	return 0;
>  }
>  
> -static int hdmirx_enum_dv_timings(struct file *file, void *_fh,
> +static int hdmirx_enum_dv_timings(struct file *file, void *priv,
>  				  struct v4l2_enum_dv_timings *timings)
>  {
>  	return v4l2_enum_dv_timings_cap(timings, &hdmirx_timings_cap, NULL, NULL);
> @@ -1323,7 +1323,7 @@ static int hdmirx_g_fmt_vid_cap_mplane(struct file *file, void *fh,
>  	return 0;
>  }
>  
> -static int hdmirx_g_dv_timings(struct file *file, void *_fh,
> +static int hdmirx_g_dv_timings(struct file *file, void *priv,
>  			       struct v4l2_dv_timings *timings)
>  {
>  	struct hdmirx_stream *stream = video_drvdata(file);
> @@ -1339,7 +1339,7 @@ static int hdmirx_g_dv_timings(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int hdmirx_s_dv_timings(struct file *file, void *_fh,
> +static int hdmirx_s_dv_timings(struct file *file, void *priv,
>  			       struct v4l2_dv_timings *timings)
>  {
>  	struct hdmirx_stream *stream = video_drvdata(file);
> diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> index b628d6e081db..7fb565ebbe62 100644
> --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
> @@ -299,7 +299,7 @@ static int ti_csi2rx_enum_fmt_vid_cap(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov,
> +static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *priv,
>  				   struct v4l2_format *f)
>  {
>  	struct ti_csi2rx_dev *csi = video_drvdata(file);
> diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/platform/ti/omap/omap_vout.c
> index a87d5030ac35..22782e9f1f4e 100644
> --- a/drivers/media/platform/ti/omap/omap_vout.c
> +++ b/drivers/media/platform/ti/omap/omap_vout.c
> @@ -1236,7 +1236,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh,
>  	return 0;
>  }
>  
> -static int vidioc_enum_output(struct file *file, void *priv_fh,
> +static int vidioc_enum_output(struct file *file, void *priv,
>  			      struct v4l2_output *out)
>  {
>  	if (out->index)
> @@ -1246,13 +1246,13 @@ static int vidioc_enum_output(struct file *file, void *priv_fh,
>  	return 0;
>  }
>  
> -static int vidioc_g_output(struct file *file, void *priv_fh, unsigned int *i)
> +static int vidioc_g_output(struct file *file, void *priv, unsigned int *i)
>  {
>  	*i = 0;
>  	return 0;
>  }
>  
> -static int vidioc_s_output(struct file *file, void *priv_fh, unsigned int i)
> +static int vidioc_s_output(struct file *file, void *priv, unsigned int i)
>  {
>  	return i ? -EINVAL : 0;
>  }
> diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c
> index 67b4afadc95a..4132968110e3 100644
> --- a/drivers/media/radio/si4713/radio-platform-si4713.c
> +++ b/drivers/media/radio/si4713/radio-platform-si4713.c
> @@ -75,35 +75,35 @@ static inline struct v4l2_device *get_v4l2_dev(struct file *file)
>  	return &((struct radio_si4713_device *)video_drvdata(file))->v4l2_dev;
>  }
>  
> -static int radio_si4713_g_modulator(struct file *file, void *p,
> +static int radio_si4713_g_modulator(struct file *file, void *priv,
>  				    struct v4l2_modulator *vm)
>  {
>  	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
>  					  g_modulator, vm);
>  }
>  
> -static int radio_si4713_s_modulator(struct file *file, void *p,
> +static int radio_si4713_s_modulator(struct file *file, void *priv,
>  				    const struct v4l2_modulator *vm)
>  {
>  	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
>  					  s_modulator, vm);
>  }
>  
> -static int radio_si4713_g_frequency(struct file *file, void *p,
> +static int radio_si4713_g_frequency(struct file *file, void *priv,
>  				    struct v4l2_frequency *vf)
>  {
>  	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
>  					  g_frequency, vf);
>  }
>  
> -static int radio_si4713_s_frequency(struct file *file, void *p,
> +static int radio_si4713_s_frequency(struct file *file, void *priv,
>  				    const struct v4l2_frequency *vf)
>  {
>  	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
>  					  s_frequency, vf);
>  }
>  
> -static long radio_si4713_default(struct file *file, void *p,
> +static long radio_si4713_default(struct file *file, void *priv,
>  				 bool valid_prio, unsigned int cmd, void *arg)
>  {
>  	return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
> diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
> index e585c8f6e4c5..c695a97e202b 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-417.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-417.c
> @@ -1499,7 +1499,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm)
> +static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
>  {
>  	struct cx231xx *dev = video_drvdata(file);
>  
> diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
> index 25edd2189654..3fc15d16df8e 100644
> --- a/drivers/media/usb/gspca/gspca.c
> +++ b/drivers/media/usb/gspca/gspca.c
> @@ -1029,15 +1029,15 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt_vid_cap(struct file *file, void *_priv,
> +static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
>  				struct v4l2_format *fmt)
>  {
>  	struct gspca_dev *gspca_dev = video_drvdata(file);
> -	u32 priv = fmt->fmt.pix.priv;
> +	u32 fmt_priv = fmt->fmt.pix.priv;
>  
>  	fmt->fmt.pix = gspca_dev->pixfmt;
>  	/* some drivers use priv internally, so keep the original value */
> -	fmt->fmt.pix.priv = priv;
> +	fmt->fmt.pix.priv = fmt_priv;
>  	return 0;
>  }
>  
> @@ -1075,24 +1075,24 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
>  	return mode;			/* used when s_fmt */
>  }
>  
> -static int vidioc_try_fmt_vid_cap(struct file *file, void *_priv,
> +static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
>  				  struct v4l2_format *fmt)
>  {
>  	struct gspca_dev *gspca_dev = video_drvdata(file);
> -	u32 priv = fmt->fmt.pix.priv;
> +	u32 fmt_priv = fmt->fmt.pix.priv;
>  
>  	if (try_fmt_vid_cap(gspca_dev, fmt) < 0)
>  		return -EINVAL;
>  	/* some drivers use priv internally, so keep the original value */
> -	fmt->fmt.pix.priv = priv;
> +	fmt->fmt.pix.priv = fmt_priv;
>  	return 0;
>  }
>  
> -static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
> +static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
>  				struct v4l2_format *fmt)
>  {
>  	struct gspca_dev *gspca_dev = video_drvdata(file);
> -	u32 priv = fmt->fmt.pix.priv;
> +	u32 fmt_priv = fmt->fmt.pix.priv;
>  	int mode;
>  
>  	if (vb2_is_busy(&gspca_dev->queue))
> @@ -1109,7 +1109,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
>  	else
>  		gspca_dev->pixfmt = gspca_dev->cam.cam_mode[mode];
>  	/* some drivers use priv internally, so keep the original value */
> -	fmt->fmt.pix.priv = priv;
> +	fmt->fmt.pix.priv = fmt_priv;
>  	return 0;
>  }
>  
> diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
> index 8a5c2c5227eb..8c7ae362d992 100644
> --- a/drivers/media/usb/hdpvr/hdpvr-video.c
> +++ b/drivers/media/usb/hdpvr/hdpvr-video.c
> @@ -590,7 +590,7 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	return 0;
>  }
>  
> -static int vidioc_s_std(struct file *file, void *_fh,
> +static int vidioc_s_std(struct file *file, void *priv,
>  			v4l2_std_id std)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -610,7 +610,7 @@ static int vidioc_s_std(struct file *file, void *_fh,
>  	return hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, std_type);
>  }
>  
> -static int vidioc_g_std(struct file *file, void *_fh,
> +static int vidioc_g_std(struct file *file, void *priv,
>  			v4l2_std_id *std)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -623,7 +623,7 @@ static int vidioc_g_std(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a)
> +static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *a)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
>  	struct hdpvr_fh *fh = file_to_hdpvr_fh(file);
> @@ -642,7 +642,7 @@ static int vidioc_querystd(struct file *file, void *_fh, v4l2_std_id *a)
>  	return ret;
>  }
>  
> -static int vidioc_s_dv_timings(struct file *file, void *_fh,
> +static int vidioc_s_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -665,7 +665,7 @@ static int vidioc_s_dv_timings(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int vidioc_g_dv_timings(struct file *file, void *_fh,
> +static int vidioc_g_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -678,7 +678,7 @@ static int vidioc_g_dv_timings(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int vidioc_query_dv_timings(struct file *file, void *_fh,
> +static int vidioc_query_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_dv_timings *timings)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -720,7 +720,7 @@ static int vidioc_query_dv_timings(struct file *file, void *_fh,
>  	return ret;
>  }
>  
> -static int vidioc_enum_dv_timings(struct file *file, void *_fh,
> +static int vidioc_enum_dv_timings(struct file *file, void *priv,
>  				    struct v4l2_enum_dv_timings *timings)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -736,7 +736,7 @@ static int vidioc_enum_dv_timings(struct file *file, void *_fh,
>  	return 0;
>  }
>  
> -static int vidioc_dv_timings_cap(struct file *file, void *_fh,
> +static int vidioc_dv_timings_cap(struct file *file, void *priv,
>  				    struct v4l2_dv_timings_cap *cap)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -763,7 +763,7 @@ static const char *iname[] = {
>  	[HDPVR_COMPOSITE] = "Composite",
>  };
>  
> -static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)
> +static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *i)
>  {
>  	unsigned int n;
>  
> @@ -783,7 +783,7 @@ static int vidioc_enum_input(struct file *file, void *_fh, struct v4l2_input *i)
>  	return 0;
>  }
>  
> -static int vidioc_s_input(struct file *file, void *_fh,
> +static int vidioc_s_input(struct file *file, void *priv,
>  			  unsigned int index)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -817,7 +817,7 @@ static int vidioc_s_input(struct file *file, void *_fh,
>  	return retval;
>  }
>  
> -static int vidioc_g_input(struct file *file, void *private_data,
> +static int vidioc_g_input(struct file *file, void *priv,
>  			  unsigned int *index)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -849,7 +849,7 @@ static int vidioc_enumaudio(struct file *file, void *priv,
>  	return 0;
>  }
>  
> -static int vidioc_s_audio(struct file *file, void *private_data,
> +static int vidioc_s_audio(struct file *file, void *priv,
>  			  const struct v4l2_audio *audio)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -868,7 +868,7 @@ static int vidioc_s_audio(struct file *file, void *private_data,
>  	return retval;
>  }
>  
> -static int vidioc_g_audio(struct file *file, void *private_data,
> +static int vidioc_g_audio(struct file *file, void *priv,
>  			  struct v4l2_audio *audio)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> @@ -985,7 +985,7 @@ static int hdpvr_s_ctrl(struct v4l2_ctrl *ctrl)
>  	return ret;
>  }
>  
> -static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
> +static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
>  				    struct v4l2_fmtdesc *f)
>  {
>  	if (f->index != 0)
> @@ -996,7 +996,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
>  	return 0;
>  }
>  
> -static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh,
> +static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
>  				struct v4l2_format *f)
>  {
>  	struct hdpvr_device *dev = video_drvdata(file);
> -- 
> Regards,
> 
> Laurent Pinchart
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 56/76] media: s5p-jpeg: Access v4l2_fh from file
  2025-08-10  1:30 ` [PATCH v3 56/76] media: s5p-jpeg: " Laurent Pinchart
@ 2025-08-12  6:13   ` Andrzej Pietrasiewicz
  2025-08-12  7:51     ` Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Andrzej Pietrasiewicz @ 2025-08-12  6:13 UTC (permalink / raw)
  To: Laurent Pinchart, linux-media
  Cc: Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Jacek Anaszewski, Sylwester Nawrocki, linux-arm-kernel

Hi Laurent & Jacopo,

Thanks for taking care of this, this generally looks good to me,
but please see inline.

W dniu 10.08.2025 o 03:30, Laurent Pinchart pisze:
> From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> 
> 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>
> Reviewed-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
> Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> Changes since v1:
> 
> - Update file-to-ctx macro due to removal of fh-to-ctx macro
> ---
>   .../platform/samsung/s5p-jpeg/jpeg-core.c     | 27 ++++++++-----------
>   1 file changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> index 65f256db4c76..81792f7f8b16 100644
> --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> @@ -580,14 +580,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
> @@ -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);

What is the purpose of this change?

Regards,

Andrzej

>   
>   	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)



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 56/76] media: s5p-jpeg: Access v4l2_fh from file
  2025-08-12  6:13   ` Andrzej Pietrasiewicz
@ 2025-08-12  7:51     ` Laurent Pinchart
  2025-08-13 10:45       ` Laurent Pinchart
  0 siblings, 1 reply; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-12  7:51 UTC (permalink / raw)
  To: Andrzej Pietrasiewicz
  Cc: linux-media, Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Jacek Anaszewski, Sylwester Nawrocki, linux-arm-kernel

Hi Andrzej,

On Tue, Aug 12, 2025 at 08:13:39AM +0200, Andrzej Pietrasiewicz wrote:
> Hi Laurent & Jacopo,
> 
> Thanks for taking care of this, this generally looks good to me,
> but please see inline.
> 
> W dniu 10.08.2025 o 03:30, Laurent Pinchart pisze:
> > From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > 
> > 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>
> > Reviewed-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
> > Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > Changes since v1:
> > 
> > - Update file-to-ctx macro due to removal of fh-to-ctx macro
> > ---
> >   .../platform/samsung/s5p-jpeg/jpeg-core.c     | 27 ++++++++-----------
> >   1 file changed, 11 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > index 65f256db4c76..81792f7f8b16 100644
> > --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > @@ -580,14 +580,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
> > @@ -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);
> 
> What is the purpose of this change?

I don't think this is needed, I believe it can be dropped.

I'll send a new version (of this patch only, I don't want to respin the
whole series and spam everybody).

> >   
> >   	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)

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v3 56/76] media: s5p-jpeg: Access v4l2_fh from file
  2025-08-12  7:51     ` Laurent Pinchart
@ 2025-08-13 10:45       ` Laurent Pinchart
  0 siblings, 0 replies; 27+ messages in thread
From: Laurent Pinchart @ 2025-08-13 10:45 UTC (permalink / raw)
  To: Andrzej Pietrasiewicz
  Cc: linux-media, Jacopo Mondi, Hans Verkuil, Mauro Carvalho Chehab,
	Jacek Anaszewski, Sylwester Nawrocki, linux-arm-kernel

On Tue, Aug 12, 2025 at 10:51:57AM +0300, Laurent Pinchart wrote:
> On Tue, Aug 12, 2025 at 08:13:39AM +0200, Andrzej Pietrasiewicz wrote:
> > Hi Laurent & Jacopo,
> > 
> > Thanks for taking care of this, this generally looks good to me,
> > but please see inline.
> > 
> > W dniu 10.08.2025 o 03:30, Laurent Pinchart pisze:
> > > From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > 
> > > 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>
> > > Reviewed-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
> > > Co-developed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > Changes since v1:
> > > 
> > > - Update file-to-ctx macro due to removal of fh-to-ctx macro
> > > ---
> > >   .../platform/samsung/s5p-jpeg/jpeg-core.c     | 27 ++++++++-----------
> > >   1 file changed, 11 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > > index 65f256db4c76..81792f7f8b16 100644
> > > --- a/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > > +++ b/drivers/media/platform/samsung/s5p-jpeg/jpeg-core.c
> > > @@ -580,14 +580,9 @@ 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 fh_to_ctx(file_to_v4l2_fh(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)
> > > @@ -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);
> > 
> > What is the purpose of this change?
> 
> I don't think this is needed, I believe it can be dropped.
> 
> I'll send a new version (of this patch only, I don't want to respin the
> whole series and spam everybody).

The series got merged before I could send a new version of this patch.
Sorry about that. The new order of the variables doesn't really make a
difference as far as I can see, so I won't send a patch to revert it. If
there's an issue I'm missing that requires a fix, please let me know.

> > >   
> > >   	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)

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2025-08-13 11:28 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250810013100.29776-1-laurent.pinchart+renesas@ideasonboard.com>
2025-08-10  1:29 ` [PATCH v3 08/76] media: Wrap file->private_data access with a helper function Laurent Pinchart
2025-08-10  1:29 ` [PATCH v3 09/76] media: Replace file->private_data access with file_to_v4l2_fh() Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 37/76] media: meson-ge2d: Access v4l2_fh from file Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 41/76] media: mtk: jpeg: Access v4l2_fh from file->private_data Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 42/76] media: mtk_mdp_m2m: Access v4l2_fh from file Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 43/76] media: mtk: mdp3: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 44/76] media: mtk: vcodec: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 46/76] media: imx-jpeg: " Laurent Pinchart
2025-08-11 15:05   ` Frank Li
2025-08-10  1:30 ` [PATCH v3 47/76] media: imx-isi: " Laurent Pinchart
2025-08-11 15:05   ` Frank Li
2025-08-10  1:30 ` [PATCH v3 50/76] media: rockhip: rga: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 51/76] media: rockchip: rkvdec: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 52/76] media: exynos-gsc: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 53/76] media: exynos4-is: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 55/76] media: s5p-g2d: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 56/76] media: s5p-jpeg: " Laurent Pinchart
2025-08-12  6:13   ` Andrzej Pietrasiewicz
2025-08-12  7:51     ` Laurent Pinchart
2025-08-13 10:45       ` Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 57/76] media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 58/76] media: s5p-mfc: Access v4l2_fh from file Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 61/76] media: stm32: dma2d: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 68/76] media: staging: imx: " Laurent Pinchart
2025-08-10  1:30 ` [PATCH v3 75/76] media: v4l2: Rename second ioctl handlers argument to 'void *priv' Laurent Pinchart
2025-08-12  5:52   ` Jai Luthra
2025-08-10  1:30 ` [PATCH v3 76/76] media: staging: " Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox