]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: usb: uvc: Access v4l2_fh from file
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Sun, 10 Aug 2025 01:30:49 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:55 +0000 (08:33 +0200)
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>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/uvc/uvc_v4l2.c

index 09677ed639ae9252a57ce09cdbcfd567ad7aabc2..10196d62f287502b0dd472ac68ec6914ca4eb06b 100644 (file)
@@ -391,7 +391,7 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
 static int uvc_ioctl_g_fmt(struct file *file, void *fh,
                           struct v4l2_format *fmt)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        const struct uvc_format *format;
        const struct uvc_frame *frame;
@@ -427,7 +427,7 @@ done:
 static int uvc_ioctl_s_fmt(struct file *file, void *fh,
                           struct v4l2_format *fmt)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        struct uvc_streaming_control probe;
        const struct uvc_format *format;
@@ -460,7 +460,7 @@ static int uvc_ioctl_g_parm(struct file *file, void *fh,
                            struct v4l2_streamparm *parm)
 {
        u32 numerator, denominator;
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
 
        if (parm->type != stream->type)
@@ -496,7 +496,7 @@ static int uvc_ioctl_g_parm(struct file *file, void *fh,
 static int uvc_ioctl_s_parm(struct file *file, void *fh,
                            struct v4l2_streamparm *parm)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        struct uvc_streaming_control probe;
        struct v4l2_fract timeperframe;
@@ -641,7 +641,7 @@ static int uvc_ioctl_querycap(struct file *file, void *fh,
 static int uvc_ioctl_enum_fmt(struct file *file, void *fh,
                              struct v4l2_fmtdesc *fmt)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        enum v4l2_buf_type type = fmt->type;
        const struct uvc_format *format;
@@ -665,7 +665,7 @@ static int uvc_ioctl_enum_fmt(struct file *file, void *fh,
 static int uvc_ioctl_try_fmt(struct file *file, void *fh,
                             struct v4l2_format *fmt)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        struct uvc_streaming_control probe;
 
@@ -675,7 +675,7 @@ static int uvc_ioctl_try_fmt(struct file *file, void *fh,
 static int uvc_ioctl_enum_input(struct file *file, void *fh,
                                struct v4l2_input *input)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
        const struct uvc_entity *selector = chain->selector;
        struct uvc_entity *iterm = NULL;
@@ -717,7 +717,7 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
 
 static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
        u8 *buf;
        int ret;
@@ -745,7 +745,7 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
 
 static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        struct uvc_video_chain *chain = handle->chain;
        u8 *buf;
@@ -780,7 +780,7 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
 static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,
                                    struct v4l2_query_ext_ctrl *qec)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
 
        return uvc_query_v4l2_ctrl(chain, qec);
@@ -808,7 +808,7 @@ static int uvc_ctrl_check_access(struct uvc_video_chain *chain,
 static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,
                                 struct v4l2_ext_controls *ctrls)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
        struct v4l2_ext_control *ctrl = ctrls->controls;
        unsigned int i;
@@ -892,7 +892,7 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
 static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh,
                                 struct v4l2_ext_controls *ctrls)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
 
        return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, VIDIOC_S_EXT_CTRLS);
 }
@@ -900,7 +900,7 @@ static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh,
 static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
                                   struct v4l2_ext_controls *ctrls)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
 
        return uvc_ioctl_s_try_ext_ctrls(handle, ctrls, VIDIOC_TRY_EXT_CTRLS);
 }
@@ -908,7 +908,7 @@ static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
 static int uvc_ioctl_querymenu(struct file *file, void *fh,
                               struct v4l2_querymenu *qm)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
 
        return uvc_query_v4l2_menu(chain, qm);
@@ -917,7 +917,7 @@ static int uvc_ioctl_querymenu(struct file *file, void *fh,
 static int uvc_ioctl_g_selection(struct file *file, void *fh,
                                 struct v4l2_selection *sel)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
 
        if (sel->type != stream->type)
@@ -951,7 +951,7 @@ static int uvc_ioctl_g_selection(struct file *file, void *fh,
 static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
                                     struct v4l2_frmsizeenum *fsize)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        const struct uvc_format *format = NULL;
        const struct uvc_frame *frame = NULL;
@@ -991,7 +991,7 @@ static int uvc_ioctl_enum_framesizes(struct file *file, void *fh,
 static int uvc_ioctl_enum_frameintervals(struct file *file, void *fh,
                                         struct v4l2_frmivalenum *fival)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_streaming *stream = handle->stream;
        const struct uvc_format *format = NULL;
        const struct uvc_frame *frame = NULL;
@@ -1063,7 +1063,7 @@ static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh,
 static long uvc_ioctl_default(struct file *file, void *fh, bool valid_prio,
                              unsigned int cmd, void *arg)
 {
-       struct uvc_fh *handle = fh;
+       struct uvc_fh *handle = to_uvc_fh(file);
        struct uvc_video_chain *chain = handle->chain;
 
        switch (cmd) {