[PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access

Jacopo Mondi <jacopo.mondi-ryLnwIuWjnjg/[email protected]> Sat, 02 Aug 2025 11:22:32 +0200
Newsgroups gmane.linux.ports.tegra,gmane.linux.drivers.video-input-infrastructure,gmane.linux.kernel,gmane.linux.documentation,gmane.linux.ports.arm.kernel,gmane.linux.ports.arm.mediatek,gmane.linux.kernel.renesas-soc,gmane.linux.ports.arm.msm,gmane.linux.kernel.samsung-soc,gmane.linux.usb.general,gmane.linux.ports.arm.rockchip,gmane.comp.video.mjpeg.user
Message-ID <[email protected]>
From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]>

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

The tegra-vde driver accesses file->private_data in the tegra_open()
function, right after setting the field to &ctx->fh. Replace the
accesses with usage of &ctx->fh.

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

Signed-off-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]>
Signed-off-by: Jacopo Mondi <jacopo.mondi-ryLnwIuWjnjg/[email protected]>
---
 drivers/media/platform/nvidia/tegra-vde/v4l2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/nvidia/tegra-vde/v4l2.c b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
index 531a85e3fe49ad0aa94fb96cbc7a84d474faae94..393dc3f07d5c78ff5ab0ae7b6368914859564458 100644
--- a/drivers/media/platform/nvidia/tegra-vde/v4l2.c
+++ b/drivers/media/platform/nvidia/tegra-vde/v4l2.c
@@ -836,10 +836,10 @@ static int tegra_open(struct file *file)
 	v4l2_fh_add(&ctx->fh);
 
 	tegra_reset_coded_fmt(ctx);
-	tegra_try_coded_fmt(file, file->private_data, &ctx->coded_fmt);
+	tegra_try_coded_fmt(file, &ctx->fh, &ctx->coded_fmt);
 
 	tegra_reset_decoded_fmt(ctx);
-	tegra_try_decoded_fmt(file, file->private_data, &ctx->decoded_fmt);
+	tegra_try_decoded_fmt(file, &ctx->fh, &ctx->decoded_fmt);
 
 	return 0;
 

-- 
2.49.0