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

index 385b26d2140854c4bae11db8f88283f9b33e9452..6c1a53c771f746813a6062cb3ffc139250ff7146 100644 (file)
 
 #define DELTA_PREFIX "[---:----]"
 
-#define to_ctx(__fh) container_of(__fh, struct delta_ctx, fh)
-
 static inline struct delta_ctx *file_to_ctx(struct file *filp)
 {
-       return to_ctx(file_to_v4l2_fh(filp));
+       return container_of(file_to_v4l2_fh(filp), struct delta_ctx, fh);
 }
 
 #define to_au(__vbuf) container_of(__vbuf, struct delta_au, vbuf)
@@ -727,7 +725,7 @@ static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
 static int delta_g_selection(struct file *file, void *fh,
                             struct v4l2_selection *s)
 {
-       struct delta_ctx *ctx = to_ctx(fh);
+       struct delta_ctx *ctx = file_to_ctx(file);
        struct delta_frameinfo *frameinfo = &ctx->frameinfo;
        struct v4l2_rect crop;
 
@@ -809,7 +807,7 @@ static int delta_try_decoder_cmd(struct file *file, void *fh,
        return 0;
 }
 
-static int delta_decoder_stop_cmd(struct delta_ctx *ctx, void *fh)
+static int delta_decoder_stop_cmd(struct delta_ctx *ctx)
 {
        const struct delta_dec *dec = ctx->dec;
        struct delta_dev *delta = ctx->dev;
@@ -872,14 +870,14 @@ delay_eos:
 static int delta_decoder_cmd(struct file *file, void *fh,
                             struct v4l2_decoder_cmd *cmd)
 {
-       struct delta_ctx *ctx = to_ctx(fh);
+       struct delta_ctx *ctx = file_to_ctx(file);
        int ret = 0;
 
        ret = delta_try_decoder_cmd(file, fh, cmd);
        if (ret)
                return ret;
 
-       return delta_decoder_stop_cmd(ctx, fh);
+       return delta_decoder_stop_cmd(ctx);
 }
 
 static int delta_subscribe_event(struct v4l2_fh *fh,