From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 04/11] rcar-vin: Improve reuse of parallel notifier
Date: Wed, 7 Jul 2021 10:51:27 +0200 [thread overview]
Message-ID: <YOVrD1Mkv9s9jK4/@oden.dyn.berto.se> (raw)
In-Reply-To: <20210706165141.adzayyndbfwzocpr@uno.localdomain>
Hi Jacopo,
Thanks for your feedback.
On 2021-07-06 18:51:41 +0200, Jacopo Mondi wrote:
> Hi Niklas,
>
> On Tue, Apr 13, 2021 at 08:02:46PM +0200, Niklas Söderlund wrote:
> > In preparation for adding a new media graph layout move the code reuse
> > of the parallel notifier setup from probe directly to the current media
> > graph initialization function. This is needed as there will be no
> > parallel interface in the new graph layout.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/media/platform/rcar-vin/rcar-core.c | 48 ++++++++++-----------
> > 1 file changed, 22 insertions(+), 26 deletions(-)
> >
> > diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> > index da23d55aa72b7f0d..81574bf33116ad59 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-core.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> > @@ -702,9 +702,8 @@ static int rvin_parallel_init(struct rvin_dev *vin)
> > if (ret)
> > return ret;
> >
> > - /* If using mc, it's fine not to have any input registered. */
> > if (!vin->parallel.asd)
> > - return vin->info->use_mc ? 0 : -ENODEV;
> > + return -ENODEV;
>
> Nit: isn't it better to keep the error handling here ?
I'm trying to reduce the number of use_mc checks and if needed only keep
it in code paths where it's relevant. I like moving it to the _csi2_
functions. But I agree _csi2_ is a bad prefix, it should likely be
renamed somewhen in the future as it now really means _gen3_ minus v3u
:-)
>
> >
> > vin_dbg(vin, "Found parallel subdevice %pOF\n",
> > to_of_node(vin->parallel.asd->match.fwnode));
> > @@ -955,11 +954,9 @@ static int rvin_mc_parse_of_graph(struct rvin_dev *vin)
> >
> > static void rvin_csi2_cleanup(struct rvin_dev *vin)
> > {
> > - if (!vin->info->use_mc)
> > - return;
> > -
> > rvin_group_notifier_cleanup(vin);
> > rvin_group_put(vin);
> > + rvin_free_controls(vin);
> > }
> >
> > static int rvin_csi2_init(struct rvin_dev *vin)
> > @@ -979,11 +976,18 @@ static int rvin_csi2_init(struct rvin_dev *vin)
> > if (ret)
> > goto err_controls;
> >
> > - ret = rvin_mc_parse_of_graph(vin);
> > - if (ret)
> > + /* It's OK to not have a parallel subdevice. */
> > + ret = rvin_parallel_init(vin);
> > + if (ret && ret != -ENODEV)
> > goto err_group;
> >
> > + ret = rvin_mc_parse_of_graph(vin);
> > + if (ret)
> > + goto err_parallel;
> > +
> > return 0;
> > +err_parallel:
> > + rvin_parallel_cleanup(vin);
> > err_group:
> > rvin_group_put(vin);
> > err_controls:
> > @@ -1469,27 +1473,20 @@ static int rcar_vin_probe(struct platform_device *pdev)
> >
> > platform_set_drvdata(pdev, vin);
> >
> > - if (vin->info->use_mc) {
> > + if (vin->info->use_mc)
> > ret = rvin_csi2_init(vin);
> > - if (ret)
> > - goto error_dma_unregister;
> > - }
> > + else
> > + ret = rvin_parallel_init(vin);
> >
> > - ret = rvin_parallel_init(vin);
> > - if (ret)
> > - goto error_group_unregister;
> > + if (ret) {
> > + rvin_dma_unregister(vin);
> > + return ret;
> > + }
> >
> > pm_suspend_ignore_children(&pdev->dev, true);
> > pm_runtime_enable(&pdev->dev);
> >
> > return 0;
> > -error_group_unregister:
> > - rvin_free_controls(vin);
> > - rvin_csi2_cleanup(vin);
> > -error_dma_unregister:
> > - rvin_dma_unregister(vin);
> > -
> > - return ret;
>
> This looks much much better and seems correct to me!
>
> > }
> >
> > static int rcar_vin_remove(struct platform_device *pdev)
> > @@ -1500,11 +1497,10 @@ static int rcar_vin_remove(struct platform_device *pdev)
> >
> > rvin_v4l2_unregister(vin);
> >
> > - rvin_parallel_cleanup(vin);
> > -
> > - rvin_csi2_cleanup(vin);
> > -
> > - rvin_free_controls(vin);
> > + if (vin->info->use_mc)
> > + rvin_csi2_cleanup(vin);
> > + else
> > + rvin_parallel_cleanup(vin);
>
> In the case use_mc == true but a parallel input was registered as well
> this won't clean up the parallel notifier it seems.
Good catch! rvin_parallel_cleanup() should be called from
rvin_csi2_cleanup() as rvin_parallel_init() is called form
rvin_csi2_init(). I will fix.
>
> Does it hurt to clean it up unconditionally ?
>
> Thanks
> j
> >
> > rvin_dma_unregister(vin);
> >
> > --
> > 2.31.1
> >
--
Regards,
Niklas Söderlund
next prev parent reply other threads:[~2021-07-07 8:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 18:02 [PATCH 00/11] rcar-vin: Add r8a779a0 support Niklas Söderlund
2021-04-13 18:02 ` [PATCH 01/11] rcar-vin: Refactor controls creation for video device Niklas Söderlund
2021-07-06 16:04 ` Jacopo Mondi
2021-07-06 16:16 ` Niklas Söderlund
2021-07-06 16:58 ` Jacopo Mondi
2021-07-08 13:40 ` Sakari Ailus
2021-07-08 14:05 ` Niklas Söderlund
2021-07-08 14:42 ` Sakari Ailus
2021-07-06 16:08 ` Jacopo Mondi
2021-07-06 16:17 ` Niklas Söderlund
2021-04-13 18:02 ` [PATCH 02/11] rcar-vin: Fix error paths for rvin_mc_init() Niklas Söderlund
2021-07-06 16:09 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 03/11] rcar-vin: Improve async notifier cleanup paths Niklas Söderlund
2021-07-06 16:41 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 04/11] rcar-vin: Improve reuse of parallel notifier Niklas Söderlund
2021-07-06 16:51 ` Jacopo Mondi
2021-07-07 8:51 ` Niklas Söderlund [this message]
2021-04-13 18:02 ` [PATCH 05/11] rcar-vin: Rename array storing subdevice information Niklas Söderlund
2021-07-06 16:53 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 06/11] rcar-vin: Move group async notifier Niklas Söderlund
2021-07-06 16:58 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 07/11] rcar-vin: Extend group notifier DT parser to work with any port Niklas Söderlund
2021-07-07 10:24 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 08/11] rcar-vin: Create a callback to setup media links Niklas Söderlund
2021-07-07 10:33 ` Jacopo Mondi
2021-07-08 15:46 ` Niklas Söderlund
2021-04-13 18:02 ` [PATCH 09/11] rcar-vin: Specify media device ops at group creation time Niklas Söderlund
2021-07-07 10:40 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 10/11] rcar-vin: Move and rename CSI-2 link notifications Niklas Söderlund
2021-07-07 10:46 ` Jacopo Mondi
2021-04-13 18:02 ` [PATCH 11/11] rcar-vin: Add r8a779a0 support Niklas Söderlund
2021-07-07 11:09 ` Jacopo Mondi
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=YOVrD1Mkv9s9jK4/@oden.dyn.berto.se \
--to=niklas.soderlund+renesas@ragnatech.se \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jacopo@jmondi.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/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).