lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aJG1PC0poVY-QZRb@pengutronix.de>
Date: Tue, 5 Aug 2025 09:39:40 +0200
From: Michael Tretter <m.tretter@...gutronix.de>
To: Jacopo Mondi <jacopo.mondi@...asonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>,
	Devarsh Thakkar <devarsht@...com>, Benoit Parrot <bparrot@...com>,
	Hans Verkuil <hverkuil@...nel.org>, Mike Isely <isely@...ox.com>,
	Laurent Pinchart <laurent.pinchart@...asonboard.com>,
	Hans de Goede <hansg@...nel.org>,
	Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>,
	Christian Gromm <christian.gromm@...rochip.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Alex Shi <alexs@...nel.org>, Yanteng Si <si.yanteng@...ux.dev>,
	Dongliang Mu <dzm91@...t.edu.cn>, Jonathan Corbet <corbet@....net>,
	Tomasz Figa <tfiga@...omium.org>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Andy Walls <awalls@...metrocast.net>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Bin Liu <bin.liu@...iatek.com>,
	Matthias Brugger <matthias.bgg@...il.com>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Dmitry Osipenko <digetx@...il.com>,
	Thierry Reding <thierry.reding@...il.com>,
	Jonathan Hunter <jonathanh@...dia.com>,
	Mirela Rabulea <mirela.rabulea@....com>,
	Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>,
	Kieran Bingham <kieran.bingham+renesas@...asonboard.com>,
	Michal Simek <michal.simek@....com>, Ming Qian <ming.qian@....com>,
	Zhou Peng <eagle.zhou@....com>,
	Xavier Roumegue <xavier.roumegue@....nxp.com>,
	Philipp Zabel <p.zabel@...gutronix.de>,
	Vikash Garodia <quic_vgarodia@...cinc.com>,
	Dikshita Agarwal <quic_dikshita@...cinc.com>,
	Abhinav Kumar <abhinav.kumar@...ux.dev>,
	Bryan O'Donoghue <bryan.odonoghue@...aro.org>,
	Sylwester Nawrocki <sylvester.nawrocki@...il.com>,
	Jernej Skrabec <jernej.skrabec@...il.com>,
	Chen-Yu Tsai <wens@...e.org>, Samuel Holland <samuel@...lland.org>,
	Daniel Almeida <daniel.almeida@...labora.com>,
	Neil Armstrong <neil.armstrong@...aro.org>,
	Kevin Hilman <khilman@...libre.com>,
	Jerome Brunet <jbrunet@...libre.com>,
	Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
	Nas Chung <nas.chung@...psnmedia.com>,
	Jackson Lee <jackson.lee@...psnmedia.com>,
	Minghsiu Tsai <minghsiu.tsai@...iatek.com>,
	Houlong Wei <houlong.wei@...iatek.com>,
	Andrew-CT Chen <andrew-ct.chen@...iatek.com>,
	Tiffany Lin <tiffany.lin@...iatek.com>,
	Yunfei Dong <yunfei.dong@...iatek.com>,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	Magnus Damm <magnus.damm@...il.com>,
	Mikhail Ulyanov <mikhail.ulyanov@...entembedded.com>,
	Jacob Chen <jacob-chen@...wrt.com>,
	Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
	Heiko Stuebner <heiko@...ech.de>,
	Detlev Casanova <detlev.casanova@...labora.com>,
	Krzysztof Kozlowski <krzk@...nel.org>,
	Alim Akhtar <alim.akhtar@...sung.com>,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	Łukasz Stelmach <l.stelmach@...sung.com>,
	Andrzej Pietrasiewicz <andrzejtp2010@...il.com>,
	Jacek Anaszewski <jacek.anaszewski@...il.com>,
	Andrzej Hajda <andrzej.hajda@...el.com>,
	Fabien Dessenne <fabien.dessenne@...s.st.com>,
	Hugues Fruchet <hugues.fruchet@...s.st.com>,
	Jean-Christophe Trotin <jean-christophe.trotin@...s.st.com>,
	Maxime Coquelin <mcoquelin.stm32@...il.com>,
	Alexandre Torgue <alexandre.torgue@...s.st.com>,
	Nicolas Dufresne <nicolas.dufresne@...labora.com>,
	Benjamin Gaignard <benjamin.gaignard@...labora.com>,
	Steve Longerbeam <slongerbeam@...il.com>,
	Maxime Ripard <mripard@...nel.org>,
	Paul Kocialkowski <paulk@...-base.io>,
	Niklas Söderlund <niklas.soderlund@...natech.se>,
	Robert Foss <rfoss@...nel.org>, Todor Tomov <todor.too@...il.com>,
	Vladimir Zapolskiy <vladimir.zapolskiy@...aro.org>,
	Corentin Labbe <clabbe@...libre.com>,
	Sakari Ailus <sakari.ailus@...ux.intel.com>,
	Bingbu Cao <bingbu.cao@...el.com>,
	Tianshu Qiu <tian.shu.qiu@...el.com>,
	Stanislaw Gruszka <stanislaw.gruszka@...ux.intel.com>,
	linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-staging@...ts.linux.dev, linux-doc@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-mediatek@...ts.infradead.org, linux-tegra@...r.kernel.org,
	imx@...ts.linux.dev, linux-renesas-soc@...r.kernel.org,
	linux-arm-msm@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
	linux-sunxi@...ts.linux.dev, linux-usb@...r.kernel.org,
	linux-amlogic@...ts.infradead.org,
	linux-rockchip@...ts.infradead.org,
	linux-stm32@...md-mailman.stormreply.com,
	mjpeg-users@...ts.sourceforge.net
Subject: Re: [PATCH 29/65] media: allegro: Access v4l2_fh from file

Hi Jacopo,

On Sat, 02 Aug 2025 11:22:51 +0200, Jacopo Mondi wrote:
> 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 only left user of fh_to_channel() and remove
> the macro completely.

Thanks for the cleanup!

Minor suggestion below, but even without it

> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@...asonboard.com>

Reviewed-by: Michael Tretter <m.tretter@...gutronix.de>

> ---
>  drivers/media/platform/allegro-dvt/allegro-core.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
> index 5e3b1f5d7206d84b8ccb9ea3b3f3f1fe75becf99..81c6afcf2d06f9e39015e49d355346238c5033d8 100644
> --- a/drivers/media/platform/allegro-dvt/allegro-core.c
> +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
> @@ -197,8 +197,6 @@ static const struct regmap_config allegro_sram_config = {
>  	.cache_type = REGCACHE_NONE,
>  };
>  
> -#define fh_to_channel(__fh) container_of(__fh, struct allegro_channel, fh)
> -
>  struct allegro_channel {
>  	struct allegro_dev *dev;
>  	struct v4l2_fh fh;
> @@ -3284,7 +3282,7 @@ static int allegro_enum_fmt_vid(struct file *file, void *fh,
>  static int allegro_g_fmt_vid_cap(struct file *file, void *fh,
>  				 struct v4l2_format *f)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  
>  	f->fmt.pix.field = V4L2_FIELD_NONE;
>  	f->fmt.pix.width = channel->width;
> @@ -3326,7 +3324,7 @@ static int allegro_try_fmt_vid_cap(struct file *file, void *fh,
>  static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
>  				 struct v4l2_format *f)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  	struct vb2_queue *vq;
>  	int err;
>  
> @@ -3350,7 +3348,7 @@ static int allegro_s_fmt_vid_cap(struct file *file, void *fh,
>  static int allegro_g_fmt_vid_out(struct file *file, void *fh,
>  				 struct v4l2_format *f)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  
>  	f->fmt.pix.field = V4L2_FIELD_NONE;
>  
> @@ -3397,7 +3395,7 @@ static int allegro_try_fmt_vid_out(struct file *file, void *fh,
>  static int allegro_s_fmt_vid_out(struct file *file, void *fh,
>  				 struct v4l2_format *f)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  	int err;
>  
>  	err = allegro_try_fmt_vid_out(file, fh, f);
> @@ -3438,7 +3436,7 @@ static int allegro_channel_cmd_start(struct allegro_channel *channel)
>  static int allegro_encoder_cmd(struct file *file, void *fh,
>  			       struct v4l2_encoder_cmd *cmd)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  	int err;
>  
>  	err = v4l2_m2m_ioctl_try_encoder_cmd(file, fh, cmd);
> @@ -3488,7 +3486,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
>  				  enum v4l2_buf_type type)
>  {
>  	struct v4l2_fh *fh = file_to_v4l2_fh(file);
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);

You could remove the local fh entirely, if you change

	return v4l2_m2m_streamon(file, fh->m2m_ctx, type);

to

	return v4l2_m2m_streamon(file, channel->fh.m2m_ctx, type);

in the allegro_ioctl_streamon() function.

Michael

>  	int err;
>  
>  	if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> @@ -3503,7 +3501,7 @@ static int allegro_ioctl_streamon(struct file *file, void *priv,
>  static int allegro_g_parm(struct file *file, void *fh,
>  			  struct v4l2_streamparm *a)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  	struct v4l2_fract *timeperframe;
>  
>  	if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
> @@ -3520,7 +3518,7 @@ static int allegro_g_parm(struct file *file, void *fh,
>  static int allegro_s_parm(struct file *file, void *fh,
>  			  struct v4l2_streamparm *a)
>  {
> -	struct allegro_channel *channel = fh_to_channel(fh);
> +	struct allegro_channel *channel = file_to_channel(file);
>  	struct v4l2_fract *timeperframe;
>  	int div;
>  
> 
> -- 
> 2.49.0
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ