From nobody Sun Oct 5 16:18:51 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DFEE2367A6; Sat, 2 Aug 2025 09:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754127193; cv=none; b=ZW6oLpcwSkypxbiyKVQR90Qa7YcOyjZJzK6whBelxEg4C55pEIY25qg9MMAYl6hyjgB1oh5rNytR207sHcZwsetVvi/AG9z75ToQLxihEY/ypHZRr8EKZIek82AXDWs4I93HBKRxR11wk9H1VQtG/x8Z6Tyeghbz0XXXM4/siPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754127193; c=relaxed/simple; bh=miW0R2xYtxU5IpQyW/2QNq3ARYOqYEt7oDwJXWluDGc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K2vXWV4H+BchBrU74Dv/9oX9/KnAO6PnO5Ez+ySOUDr0VZMFM7P2fR4fIH/43rM/3okvvxekdkxZVwMVIz+GINBBaUUaJhTnAI867ca2hin9d8eRleKCr/P/Ld5bYTLEQGdKAkIAnznF9GDmIcLSt2TGm+9JZv8/U/kfLHlmXr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=az8gjqsy; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="az8gjqsy" Received: from [192.168.0.172] (mob-5-90-138-121.net.vodafone.it [5.90.138.121]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A4ED4370; Sat, 2 Aug 2025 11:32:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1754127143; bh=miW0R2xYtxU5IpQyW/2QNq3ARYOqYEt7oDwJXWluDGc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=az8gjqsyXEti0JeVSm77geSmA7AkpCysThF60WhNPtJM1uNt7bbBCDUakaT72hVhp l1GEVpO9e8XGH0VXe1MBRi2SnPKVb88n3ZKKaA2ZQlRkgmHZNFLOH75+TXNUtFCuFY RzGTt8HUu1W6qrgy51RvHIBcPJ9wsdrXruX+PJT8= From: Jacopo Mondi Date: Sat, 02 Aug 2025 11:23:18 +0200 Subject: [PATCH 56/65] media: cx18: Access v4l2_fh from file Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250802-media-private-data-v1-56-eb140ddd6a9d@ideasonboard.com> References: <20250802-media-private-data-v1-0-eb140ddd6a9d@ideasonboard.com> In-Reply-To: <20250802-media-private-data-v1-0-eb140ddd6a9d@ideasonboard.com> To: Mauro Carvalho Chehab , Devarsh Thakkar , Benoit Parrot , Hans Verkuil , Mike Isely , Laurent Pinchart , Hans de Goede , Parthiban Veerasooran , Christian Gromm , Greg Kroah-Hartman , Alex Shi , Yanteng Si , Dongliang Mu , Jonathan Corbet , Tomasz Figa , Marek Szyprowski , Andy Walls , Michael Tretter , Pengutronix Kernel Team , Bin Liu , Matthias Brugger , AngeloGioacchino Del Regno , Dmitry Osipenko , Thierry Reding , Jonathan Hunter , Mirela Rabulea , Shawn Guo , Sascha Hauer , Fabio Estevam , Kieran Bingham , Michal Simek , Ming Qian , Zhou Peng , Xavier Roumegue , Philipp Zabel , Vikash Garodia , Dikshita Agarwal , Abhinav Kumar , Bryan O'Donoghue , Sylwester Nawrocki , Jernej Skrabec , Chen-Yu Tsai , Samuel Holland , Daniel Almeida , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Nas Chung , Jackson Lee , Minghsiu Tsai , Houlong Wei , Andrew-CT Chen , Tiffany Lin , Yunfei Dong , Geert Uytterhoeven , Magnus Damm , Mikhail Ulyanov , Jacob Chen , Ezequiel Garcia , Heiko Stuebner , Detlev Casanova , Krzysztof Kozlowski , Alim Akhtar , Sylwester Nawrocki , =?utf-8?q?=C5=81ukasz_Stelmach?= , Andrzej Pietrasiewicz , Jacek Anaszewski , Andrzej Hajda , Fabien Dessenne , Hugues Fruchet , Jean-Christophe Trotin , Maxime Coquelin , Alexandre Torgue , Nicolas Dufresne , Benjamin Gaignard , Steve Longerbeam , Maxime Ripard , Paul Kocialkowski , =?utf-8?q?Niklas_S=C3=B6derlund?= , Robert Foss , Todor Tomov , Vladimir Zapolskiy , Corentin Labbe , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Stanislaw Gruszka 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, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=11351; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=miW0R2xYtxU5IpQyW/2QNq3ARYOqYEt7oDwJXWluDGc=; b=kA0DAAoBcjQGjxahVjwByyZiAGiN2P6hMeCxCr0Vka9Jl65Kl6jOUQEBXEv4+uSblIpUX075K YkCMwQAAQoAHRYhBLXEPUiAmiCKj1g4wHI0Bo8WoVY8BQJojdj+AAoJEHI0Bo8WoVY8yzYP/jvk Cn3ngJT9BnSoIQGO0difqKYaY1cOKFJbaTdTzoLYKZ69MckDT1/9I3IehU8xvX/UhTdz5n6QdKD BAQS9lATwrt7P4Xq5uAKscHSkqZWRqV2OCe62nOwrWce6tsEaSznl9IIW9IltgMfA7LzjugyXed pzGRV0ByLbznHIYPOjUfErQNkQ4HlLMIXRSdSdCM21OZb2eYnEgRDKQv66Kh3kZWlUM3PnOnSAS 82Xha7svCmWPYkLpOTtSuPaUveRcfcmkz3IBjsJY3JX34RZDY6IGhgNPYzNAVyCdkz6QI7LuFj6 9phgs8UVK17Dd45xpXRFdgKVmKkM7uJayjqrWAVeuiyvJXKCT4DPMgMCf2LyxX9u3vE3z0x8pE9 GG5jEhOBFOh8QJNV7BuWk8ivRC6QBX6h1BxwBCjCUTgo8/ktEcuaNR6AA7Y3FlgQRbKSR2XyZ5q NkiBoasrxsyCUPw5hhXrXTPJDIVRrV85Y2uT5wyiXTUuflm5bIbRQO3Pb3qDMDNU6/l/KsJo37N cvU+EkKMPwpJe6rktlQWrLqLW0TT2HQArsVlpZrTUmuQ8wVJJafbqFYwcEitbxi3ZqAQF22uiVn 17W9hTzoSrtIKSM8NAfNewUYnTvyQPQ7/oEQVj3m3/HLXss/LiU6hE2+R0lnThzbpJNCVXBYjSQ 5ybBH X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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 --- drivers/media/pci/cx18/cx18-ioctl.c | 64 ++++++++++++++++++---------------= ---- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/c= x18-ioctl.c index 9a1512b1ccaafd991c0422616a0d7b3e6c7c49cc..bf16d36448f888d9326b5f4a8f9= c8f0e13d0c3a1 100644 --- a/drivers/media/pci/cx18/cx18-ioctl.c +++ b/drivers/media/pci/cx18/cx18-ioctl.c @@ -52,7 +52,7 @@ static const struct v4l2_fmtdesc cx18_formats_mpeg[] =3D { static int cx18_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; struct cx18_stream *s =3D &cx->streams[id->type]; struct v4l2_pix_format *pixfmt =3D &fmt->fmt.pix; @@ -76,7 +76,7 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh, static int cx18_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; struct v4l2_pix_format *pixfmt =3D &fmt->fmt.pix; int w =3D pixfmt->width; @@ -121,7 +121,7 @@ static int cx18_try_fmt_vid_cap(struct file *file, void= *fh, static int cx18_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; struct v4l2_subdev_format format =3D { .which =3D V4L2_SUBDEV_FORMAT_ACTIVE, @@ -261,7 +261,7 @@ u16 cx18_get_service_set(struct v4l2_sliced_vbi_format = *fmt) static int cx18_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; struct v4l2_vbi_format *vbifmt =3D &fmt->fmt.vbi; =20 vbifmt->sampling_rate =3D 27000000; @@ -280,7 +280,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *= fh, static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; struct v4l2_sliced_vbi_format *vbifmt =3D &fmt->fmt.sliced; =20 /* sane, V4L2 spec compliant, defaults */ @@ -311,7 +311,7 @@ static int cx18_try_fmt_vbi_cap(struct file *file, void= *fh, static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; struct v4l2_sliced_vbi_format *vbifmt =3D &fmt->fmt.sliced; =20 vbifmt->io_size =3D sizeof(struct v4l2_sliced_vbi_data) * 36; @@ -330,7 +330,7 @@ static int cx18_try_fmt_sliced_vbi_cap(struct file *fil= e, void *fh, static int cx18_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; int ret; =20 @@ -360,7 +360,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *= fh, static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_format *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; int ret; struct v4l2_sliced_vbi_format *vbifmt =3D &fmt->fmt.sliced; @@ -392,7 +392,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file,= void *fh, static int cx18_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (reg->reg & 0x3) return -EINVAL; @@ -406,7 +406,7 @@ static int cx18_g_register(struct file *file, void *fh, static int cx18_s_register(struct file *file, void *fh, const struct v4l2_dbg_register *reg) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (reg->reg & 0x3) return -EINVAL; @@ -420,7 +420,7 @@ static int cx18_s_register(struct file *file, void *fh, static int cx18_querycap(struct file *file, void *fh, struct v4l2_capability *vcap) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; =20 strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); @@ -431,14 +431,14 @@ static int cx18_querycap(struct file *file, void *fh, =20 static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *= vin) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 return cx18_get_audio_input(cx, vin->index, vin); } =20 static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vi= n) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 vin->index =3D cx->audio_input; return cx18_get_audio_input(cx, vin->index, vin); @@ -446,7 +446,7 @@ static int cx18_g_audio(struct file *file, void *fh, st= ruct v4l2_audio *vin) =20 static int cx18_s_audio(struct file *file, void *fh, const struct v4l2_aud= io *vout) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (vout->index >=3D cx->nof_audio_inputs) return -EINVAL; @@ -457,7 +457,7 @@ static int cx18_s_audio(struct file *file, void *fh, co= nst struct v4l2_audio *vo =20 static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input = *vin) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 /* set it to defaults from our table */ return cx18_get_input(cx, vin->index, vin); @@ -466,7 +466,7 @@ static int cx18_enum_input(struct file *file, void *fh,= struct v4l2_input *vin) static int cx18_g_pixelaspect(struct file *file, void *fh, int type, struct v4l2_fract *f) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -479,7 +479,7 @@ static int cx18_g_pixelaspect(struct file *file, void *= fh, static int cx18_g_selection(struct file *file, void *fh, struct v4l2_selection *sel) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (sel->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; @@ -499,7 +499,7 @@ static int cx18_g_selection(struct file *file, void *fh, static int cx18_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *fmt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); =20 if (id->type =3D=3D CX18_ENC_STREAM_TYPE_YUV) { if (fmt->index >=3D ARRAY_SIZE(cx18_formats_yuv)) @@ -515,7 +515,7 @@ static int cx18_enum_fmt_vid_cap(struct file *file, voi= d *fh, =20 static int cx18_g_input(struct file *file, void *fh, unsigned int *i) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 *i =3D cx->active_input; return 0; @@ -523,7 +523,7 @@ static int cx18_g_input(struct file *file, void *fh, un= signed int *i) =20 int cx18_s_input(struct file *file, void *fh, unsigned int inp) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; v4l2_std_id std =3D V4L2_STD_ALL; const struct cx18_card_video_input *card_input =3D @@ -561,7 +561,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned = int inp) static int cx18_g_frequency(struct file *file, void *fh, struct v4l2_frequency *vf) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (vf->tuner !=3D 0) return -EINVAL; @@ -572,7 +572,7 @@ static int cx18_g_frequency(struct file *file, void *fh, =20 int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_freque= ncy *vf) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; =20 if (vf->tuner !=3D 0) @@ -587,7 +587,7 @@ int cx18_s_frequency(struct file *file, void *fh, const= struct v4l2_frequency *v =20 static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 *std =3D cx->std; return 0; @@ -595,7 +595,7 @@ static int cx18_g_std(struct file *file, void *fh, v4l2= _std_id *std) =20 int cx18_s_std(struct file *file, void *fh, v4l2_std_id std) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; =20 if ((std & V4L2_STD_ALL) =3D=3D 0) @@ -644,7 +644,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id= std) =20 static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tun= er *vt) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; =20 if (vt->index !=3D 0) @@ -656,7 +656,7 @@ static int cx18_s_tuner(struct file *file, void *fh, co= nst struct v4l2_tuner *vt =20 static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 if (vt->index !=3D 0) return -EINVAL; @@ -673,7 +673,7 @@ static int cx18_g_tuner(struct file *file, void *fh, st= ruct v4l2_tuner *vt) static int cx18_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; int set =3D cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; int f, l; =20 @@ -794,7 +794,7 @@ static int cx18_process_idx_data(struct cx18_stream *s,= struct cx18_mdl *mdl, static int cx18_g_enc_index(struct file *file, void *fh, struct v4l2_enc_idx *idx) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; struct cx18_stream *s =3D &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; s32 tmp; struct cx18_mdl *mdl; @@ -841,7 +841,7 @@ static int cx18_g_enc_index(struct file *file, void *fh, static int cx18_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc) { - struct cx18_open_id *id =3D fh2id(fh); + struct cx18_open_id *id =3D file2id(file); struct cx18 *cx =3D id->cx; u32 h; =20 @@ -900,7 +900,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh, static int cx18_try_encoder_cmd(struct file *file, void *fh, struct v4l2_encoder_cmd *enc) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 switch (enc->cmd) { case V4L2_ENC_CMD_START: @@ -932,7 +932,7 @@ static int cx18_try_encoder_cmd(struct file *file, void= *fh, =20 static int cx18_log_status(struct file *file, void *fh) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; struct v4l2_input vidin; struct v4l2_audio audin; int i; @@ -976,7 +976,7 @@ static int cx18_log_status(struct file *file, void *fh) static long cx18_default(struct file *file, void *fh, bool valid_prio, unsigned int cmd, void *arg) { - struct cx18 *cx =3D fh2id(fh)->cx; + struct cx18 *cx =3D file2id(file)->cx; =20 switch (cmd) { case VIDIOC_INT_RESET: { --=20 2.49.0