From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 BFFCC22D4C0 for ; Tue, 5 Aug 2025 07:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754379733; cv=none; b=q3KMFM5q+8ESJms7a3vw5c4AmPL4SZPFFodYISX1kNujDirWWwX0aLdqazzCF9YZq2JHW6UgdjPxVPFQ63mv33943r0CaLAh39Rp7YUJiYv2WBloZ75qqxu/fnq4UsQHeTFE+TC62NUfUYU/Ic/2+kqDdE/4CWlCqrgTwdMcGqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754379733; c=relaxed/simple; bh=1qW0jic5qgSouRAJ0K8gWbRDvMtLz1uULmdexDci+H4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fIwQIpbd5o9C13Fk5ZlPZNVNRL5d+vtCf5bTYBuM0gakivYKL510xkHYbJa/jsvHA+Mi5gQ9dsw5ahDRp7ofYvvgbaLnHRi6ngdQsPEhZIiqbgnSS4MetV/6FKqhb17sgXcq5juEr1hQ519oRakyi3pR954NHWGRaZGNHpzzuPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ujCHA-0005yv-K9; Tue, 05 Aug 2025 09:40:00 +0200 Received: from pty.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::c5]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ujCGr-00C0Ka-13; Tue, 05 Aug 2025 09:39:41 +0200 Received: from mtr by pty.whiteo.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1ujCGr-00A7fC-02; Tue, 05 Aug 2025 09:39:41 +0200 Date: Tue, 5 Aug 2025 09:39:40 +0200 From: Michael Tretter To: Jacopo Mondi Cc: 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 , 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 , Niklas =?utf-8?Q?S=C3=B6derlund?= , Robert Foss , Todor Tomov , Vladimir Zapolskiy , Corentin Labbe , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Stanislaw Gruszka , 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 29/65] media: allegro: Access v4l2_fh from file Message-ID: Mail-Followup-To: Michael Tretter , Jacopo Mondi , 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 , 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 , Niklas =?utf-8?Q?S=C3=B6derlund?= , Robert Foss , Todor Tomov , Vladimir Zapolskiy , Corentin Labbe , Sakari Ailus , Bingbu Cao , Tianshu Qiu , Stanislaw Gruszka , 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 References: <20250802-media-private-data-v1-0-eb140ddd6a9d@ideasonboard.com> <20250802-media-private-data-v1-29-eb140ddd6a9d@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20250802-media-private-data-v1-29-eb140ddd6a9d@ideasonboard.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-doc@vger.kernel.org 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 Reviewed-by: Michael Tretter > --- > 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 > >