]> www.infradead.org Git - users/hch/misc.git/commitdiff
media: imx-isi: Access v4l2_fh from file
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Sun, 10 Aug 2025 01:30:29 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:50 +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>
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>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/nxp/imx8-isi/imx8-isi-m2m.c

index 31298307c672d4b7fbb23d77d8c7199f111c771b..5501214cc6c0ce3e0188ae6d4ff4ae277b975911 100644 (file)
@@ -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 @@ unlock:
 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;