From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org,
imx@lists.linux.dev, linux-renesas-soc@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-sunxi@lists.linux.dev, linux-usb@vger.kernel.org,
linux-amlogic@lists.infradead.org,
linux-rockchip@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
mjpeg-users@lists.sourceforge.net
Subject: Re: [PATCH 42/65] media: renesas: Access v4l2_fh from file
Date: Tue, 05 Aug 2025 10:59:19 +0100 [thread overview]
Message-ID: <175438795943.1641235.15440393062572657340@ping.linuxembedded.co.uk> (raw)
In-Reply-To: <20250802-media-private-data-v1-42-eb140ddd6a9d@ideasonboard.com>
Quoting Jacopo Mondi (2025-08-02 10:23:04)
> 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.
>
> While at it, remove the now unused fh_to_ctx() macro.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
> drivers/media/platform/renesas/rcar_fdp1.c | 11 +++--------
> drivers/media/platform/renesas/rcar_jpu.c | 21 ++++++++-------------
> 2 files changed, 11 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar_fdp1.c b/drivers/media/platform/renesas/rcar_fdp1.c
> index e78d8fb104e9544d27c8ace38888995ca170483f..84c3901a2e5dc3e7ccfb3b44062e839f8f19ee02 100644
> --- a/drivers/media/platform/renesas/rcar_fdp1.c
> +++ b/drivers/media/platform/renesas/rcar_fdp1.c
> @@ -630,11 +630,6 @@ struct fdp1_ctx {
> struct fdp1_field_buffer *previous;
> };
>
> -static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct fdp1_ctx, fh);
> -}
> -
> static inline struct fdp1_ctx *file_to_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct fdp1_ctx, fh);
> @@ -1411,8 +1406,8 @@ static int fdp1_enum_fmt_vid_out(struct file *file, void *priv,
>
> static int fdp1_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> + struct fdp1_ctx *ctx = file_to_ctx(file);
> struct fdp1_q_data *q_data;
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -1589,7 +1584,7 @@ static void fdp1_try_fmt_capture(struct fdp1_ctx *ctx,
>
> static int fdp1_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
> + struct fdp1_ctx *ctx = file_to_ctx(file);
>
> if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> fdp1_try_fmt_output(ctx, NULL, &f->fmt.pix_mp);
> @@ -1660,7 +1655,7 @@ static void fdp1_set_format(struct fdp1_ctx *ctx,
>
> static int fdp1_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct fdp1_ctx *ctx = fh_to_ctx(priv);
> + struct fdp1_ctx *ctx = file_to_ctx(file);
> struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
> struct vb2_queue *vq = v4l2_m2m_get_vq(m2m_ctx, f->type);
>
> diff --git a/drivers/media/platform/renesas/rcar_jpu.c b/drivers/media/platform/renesas/rcar_jpu.c
> index 058fcfb967bd98440f33272db42f0d973299d572..9c70a74a2969fce6446b0f26e0637a68eade3942 100644
> --- a/drivers/media/platform/renesas/rcar_jpu.c
> +++ b/drivers/media/platform/renesas/rcar_jpu.c
> @@ -480,11 +480,6 @@ static struct jpu_ctx *ctrl_to_ctx(struct v4l2_ctrl *c)
> return container_of(c->handler, struct jpu_ctx, ctrl_handler);
> }
>
> -static struct jpu_ctx *fh_to_ctx(struct v4l2_fh *fh)
> -{
> - return container_of(fh, struct jpu_ctx, fh);
> -}
> -
> static struct jpu_ctx *file_to_ctx(struct file *filp)
> {
> return container_of(file_to_v4l2_fh(filp), struct jpu_ctx, fh);
> @@ -661,7 +656,7 @@ static u8 jpu_parse_hdr(void *buffer, unsigned long size, unsigned int *width,
> static int jpu_querycap(struct file *file, void *priv,
> struct v4l2_capability *cap)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> if (ctx->encoder)
> strscpy(cap->card, DRV_NAME " encoder", sizeof(cap->card));
> @@ -719,7 +714,7 @@ static int jpu_enum_fmt(struct v4l2_fmtdesc *f, u32 type)
> static int jpu_enum_fmt_cap(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_CAPTURE :
> JPU_DEC_CAPTURE);
> @@ -728,7 +723,7 @@ static int jpu_enum_fmt_cap(struct file *file, void *priv,
> static int jpu_enum_fmt_out(struct file *file, void *priv,
> struct v4l2_fmtdesc *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> return jpu_enum_fmt(f, ctx->encoder ? JPU_ENC_OUTPUT : JPU_DEC_OUTPUT);
> }
> @@ -828,7 +823,7 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>
> static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -839,7 +834,7 @@ static int jpu_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> struct vb2_queue *vq;
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> + struct jpu_ctx *ctx = file_to_ctx(file);
> struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx;
> struct jpu_fmt *fmtinfo;
> struct jpu_q_data *q_data;
> @@ -868,8 +863,8 @@ static int jpu_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
>
> static int jpu_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> + struct jpu_ctx *ctx = file_to_ctx(file);
> struct jpu_q_data *q_data;
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
>
> if (!v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type))
> return -EINVAL;
> @@ -902,8 +897,8 @@ static const struct v4l2_ctrl_ops jpu_ctrl_ops = {
>
> static int jpu_streamon(struct file *file, void *priv, enum v4l2_buf_type type)
> {
> - struct jpu_ctx *ctx = fh_to_ctx(priv);
> struct jpu_q_data *src_q_data, *dst_q_data, *orig, adj, *ref;
> + struct jpu_ctx *ctx = file_to_ctx(file);
> enum v4l2_buf_type adj_type;
>
> src_q_data = jpu_get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
> @@ -1284,8 +1279,8 @@ static int jpu_open(struct file *file)
>
> static int jpu_release(struct file *file)
> {
> - struct jpu *jpu = video_drvdata(file);
> struct jpu_ctx *ctx = file_to_ctx(file);
> + struct jpu *jpu = video_drvdata(file);
>
> v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
> v4l2_ctrl_handler_free(&ctx->ctrl_handler);
>
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-08-05 9:59 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-02 9:22 [PATCH 00/65] media: Rationalise usage of v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 01/65] media: pci: saa7164: Store v4l2_fh pointer in file->private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 02/65] media: imagination: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 03/65] media: ti: vpe: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 04/65] media: usb: hdpvr: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 05/65] media: usb: pvrusb2: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 06/65] media: usb: uvcvideo: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 07/65] media: staging: most: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 08/65] media: Wrap file->private_data access with a helper function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 09/65] media: Replace file->private_data access with file_to_v4l2_fh() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 10/65] media: nvidia: tegra-vde: Replace file->private_data access Jacopo Mondi
2025-08-02 9:22 ` [PATCH 11/65] media: Replace file->private_data access with custom functions Jacopo Mondi
2025-08-06 8:16 ` Hans Verkuil
2025-08-06 9:48 ` Laurent Pinchart
2025-08-06 10:23 ` Hans Verkuil
2025-08-18 14:10 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 12/65] media: pci: ivtv: Don't create fake v4l2_fh Jacopo Mondi
2025-08-02 9:22 ` [PATCH 13/65] media: amphion: Make some vpu_v4l2 functions static Jacopo Mondi
2025-08-05 1:34 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 14/65] media: amphion: Delete v4l2_fh synchronously in .release() Jacopo Mondi
2025-08-05 1:43 ` [EXT] " Ming Qian
2025-08-02 9:22 ` [PATCH 15/65] media: visl: Drop visl_v4l2fh_to_ctx() function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 16/65] media: v4l2-fh: Move piece of documentation to correct function Jacopo Mondi
2025-08-02 9:22 ` [PATCH 17/65] media: rcar-vin: Do not set file->private_data Jacopo Mondi
2025-08-02 13:26 ` Niklas Söderlund
2025-08-02 9:22 ` [PATCH 18/65] media: rzg2l-cru: " Jacopo Mondi
2025-08-04 10:01 ` Tommaso Merciai
2025-08-02 9:22 ` [PATCH 19/65] media: camss: Replace .open() file operation with v4l2_fh_open() Jacopo Mondi
2025-08-24 19:04 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 20/65] media: camss: Remove custom .release fop() Jacopo Mondi
2025-08-24 19:07 ` Vladimir Zapolskiy
2025-08-02 9:22 ` [PATCH 21/65] media: chips-media: wave5: Pass file pointer to wave5_cleanup_instance() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 22/65] media: qcom: iris: Pass file pointer to iris_v4l2_fh_(de)init() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 23/65] media: qcom: iris: Set file->private_data in iris_v4l2_fh_(de)init() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 24/65] media: qcom: iris: Drop unused argument to iris_get_inst() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 25/65] media: qcom: venus: Pass file pointer to venus_close_common() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 26/65] media: Set file->private_data in v4l2_fh_add() Jacopo Mondi
2025-08-02 9:22 ` [PATCH 27/65] media: Reset file->private_data to NULL in v4l2_fh_del() Jacopo Mondi
2025-08-06 12:45 ` Hans Verkuil
2025-08-07 8:50 ` Laurent Pinchart
2025-08-07 17:00 ` Laurent Pinchart
2025-08-07 20:25 ` Laurent Pinchart
2025-08-07 20:51 ` Hans Verkuil
2025-08-08 6:30 ` Laurent Pinchart
2025-08-18 14:12 ` Lukasz Stelmach
2025-08-02 9:22 ` [PATCH 28/65] media: v4l2-ioctl: Access v4l2_fh from private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 29/65] media: allegro: Access v4l2_fh from file Jacopo Mondi
2025-08-05 7:39 ` Michael Tretter
2025-08-02 9:22 ` [PATCH 30/65] media: meson-ge2d: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 31/65] media: coda: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 32/65] media: wave5: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 33/65] media: m2m-deinterlace: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 34/65] media: mtk: jpeg: Access v4l2_fh from file->private_data Jacopo Mondi
2025-08-02 9:22 ` [PATCH 35/65] media: mtk_mdp_m2m: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:22 ` [PATCH 36/65] media: mtk: mdp3: " Jacopo Mondi
2025-08-02 9:22 ` [PATCH 37/65] media: mtk: vcodec: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 38/65] media: tegra-vde: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 39/65] media: imx-jpeg: " Jacopo Mondi
2025-08-05 1:58 ` [EXT] " Ming Qian
2025-08-02 9:23 ` [PATCH 40/65] media: imx-isi: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 41/65] media: nxp: mx2: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 42/65] media: renesas: " Jacopo Mondi
2025-08-05 9:59 ` Kieran Bingham [this message]
2025-08-02 9:23 ` [PATCH 43/65] media: rockhip: rga: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 44/65] media: rockchip: rkvdec: " Jacopo Mondi
2025-08-02 16:02 ` Detlev Casanova
2025-08-02 9:23 ` [PATCH 45/65] media: exynos-gsc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 46/65] media: exynos4-is: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 47/65] media: s3c-camif: Set queue owner using file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 48/65] media: s5p-g2d: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 49/65] media: s5p-jpeg: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 50/65] media: s5p-mfc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 51/65] media: bdisp: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 52/65] media: st: delta: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 53/65] media: stm32: dma2d: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 54/65] media: hantro: Access v4l2_fh from file->private_data Jacopo Mondi
2025-08-04 21:59 ` Paul Kocialkowski
2025-08-02 9:23 ` [PATCH 55/65] media: omap3isp: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 56/65] media: cx18: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 57/65] media: ivtv: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 58/65] media: zoran: Remove access to __fh Jacopo Mondi
2025-08-07 6:58 ` Hans Verkuil
2025-08-07 12:31 ` Laurent Pinchart
2025-08-07 13:18 ` Hans Verkuil
2025-08-02 9:23 ` [PATCH 59/65] media: usb: hdpvr: Access v4l2_fh from file Jacopo Mondi
2025-08-02 9:23 ` [PATCH 60/65] media: usb: uvc: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 61/65] media: staging: imx: " Jacopo Mondi
2025-08-02 9:23 ` [PATCH 62/65] media: v4l2-ctrls: Move v4l2_fh retrieval after V4L2_FL_USES_V4L2_FH check Jacopo Mondi
2025-08-02 9:23 ` [PATCH 63/65] media: ipu6: isys: Don't set V4L2_FL_USES_V4L2_FH manually Jacopo Mondi
2025-08-08 1:01 ` Cao, Bingbu
2025-08-08 7:22 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 64/65] media: staging: ipu7: " Jacopo Mondi
2025-08-07 9:07 ` Sakari Ailus
2025-08-07 17:01 ` Laurent Pinchart
2025-08-08 7:22 ` Sakari Ailus
2025-08-02 9:23 ` [PATCH 65/65] media: v4l2-ioctl: Stop passing fh pointer to ioctl handlers Jacopo Mondi
2025-08-07 7:26 ` Hans Verkuil
2025-08-07 7:58 ` Hans Verkuil
2025-08-07 20:33 ` Laurent Pinchart
2025-08-07 20:55 ` Hans Verkuil
2025-08-08 7:00 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=175438795943.1641235.15440393062572657340@ping.linuxembedded.co.uk \
--to=kieran.bingham+renesas@ideasonboard.com \
--cc=imx@lists.linux.dev \
--cc=jacopo.mondi@ideasonboard.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mjpeg-users@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).