diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2025-08-10 04:29:50 +0300 |
|---|---|---|
| committer | Hans Verkuil <hverkuil+cisco@kernel.org> | 2025-08-13 09:33:23 +0300 |
| commit | 618882c92681de18e9bd99d2a88bb21c897283f3 (patch) | |
| tree | 06572425dc09a2ac4d133ed31cbfa419ab94bdba /drivers/media/v4l2-core/v4l2-ctrls-api.c | |
| parent | 0fd7155307bebb7daf946abae0ee8e50d20819ed (diff) | |
| download | linux-618882c92681de18e9bd99d2a88bb21c897283f3.tar.xz | |
media: Wrap file->private_data access with a helper function
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>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-ctrls-api.c')
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-ctrls-api.c | 4 |
1 files changed, 2 insertions, 2 deletions
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)) |
