From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07DBCCA0EED for ; Mon, 18 Aug 2025 08:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=27ojVdn4KudAaDjdW26lRW3QSVadYZVwYLq9k3jM570=; b=o6p9UufH3ZZHVe p2OuNyoAuTRuXW54zlgQOwh32d86WfjZXXkIxrA+upEpPlVRXBeM3/tPwQ6+ppl09QtmmBYYfgMMM 1JMaM1CgR6PXplsm3ELqizhnfPl2Q5FvFUCix93MyQzZpV9kSh6KdmWbnD88I0HXW5ds5bPIWztJC b0JPzeiNV+k2O4FoWWj8SuYx6B/vjkOOXohOeLc1rYg2SPi9+N6xUNamRgXZMmmKXLWCWuk7zWFht mmL/A7eVZVjLgZgX1mCyBSYepYorZWeSKoPw46qKgelh8ZZordqJY8uvOUBxmCn/8CGLTyyY2ux43 5RUUH5VPpVkcN35jjfUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1unuox-00000006th8-35xm; Mon, 18 Aug 2025 08:02:23 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1ujCGu-0000000C2fK-0KXp for linux-amlogic@lists.infradead.org; Tue, 05 Aug 2025 07:39:45 +0000 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 1ujCGr-0005yg-GC; Tue, 05 Aug 2025 09:39:41 +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-00C0KZ-0d; 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> MIME-Version: 1.0 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-amlogic@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250805_003944_292238_80E4B051 X-CRM114-Status: GOOD ( 24.42 ) X-Mailman-Approved-At: Mon, 18 Aug 2025 01:02:16 -0700 X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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 > > _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic