devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Mehdi Djait <mehdi.djait@bootlin.com>,
	mchehab@kernel.org, heiko@sntech.de, hverkuil-cisco@xs4all.nl,
	krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org,
	conor+dt@kernel.org, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com,
	maxime.chevallier@bootlin.com, michael.riesch@wolfvision.net
Subject: Re: [PATCH v9 2/3] media: rockchip: Add a driver for Rockchip's camera interface
Date: Tue, 31 Oct 2023 10:53:30 +0100	[thread overview]
Message-ID: <ZUDOmgmkIifE2w87@aptenodytes> (raw)
In-Reply-To: <79231ec3-8da1-4c73-8f5b-efa445e6c35d@wanadoo.fr>

[-- Attachment #1: Type: text/plain, Size: 2226 bytes --]

Hi,

On Tue 31 Oct 23, 10:46, Christophe JAILLET wrote:
> Le 31/10/2023 à 10:33, Mehdi Djait a écrit :
> > Hello Christophe,
> > 
> > On Mon, Oct 30, 2023 at 01:47:17PM +0100, Christophe JAILLET wrote:
> > > > +	/* Create & register platform subdev. */
> > > > +	ret = cif_register_stream_vdev(cif_dev);
> > > > +	if (ret < 0)
> > > > +		goto err_unreg_media_dev;
> > > > +
> > > > +	ret = cif_subdev_notifier(cif_dev);
> > > > +	if (ret < 0) {
> > > > +		v4l2_err(&cif_dev->v4l2_dev,
> > > > +			 "Failed to register subdev notifier(%d)\n", ret);
> > > > +		cif_unregister_stream_vdev(cif_dev);
> > > > +		goto err_unreg_media_dev;
> > > 
> > > Should there be another label with cif_unregister_stream_vdev(cif_dev); if
> > > an error occurs here?
> > > 
> > > CJ
> > 
> > cif_subdev_notifier() is the last function call in the probe with error
> > handling. So it will undo the last successful register:
> > cif_register_stream_vdev and use the goto to unregister the rest.
> 
> Ah, I didn't see the cif_unregister_stream_vdev() call here.
> Sorry for the noise.
> 
> > 
> > I can add a label err_unreg_stream_vdev but it will be only used in the
> > error handling of cif_subdev_notifier() and I don't see the benefit.
> 
> The main benefit is to be more consistent in the way the error path is
> written, and to be more future proof.

Indeed the fact that there is only a single user of the label is not a reason
to avoid the label. As soon as you need to use labels/gotos for error handling,
you should do it for all steps involved and avoid mixing unregistration in the
error-checking condition and using a previous label.

Cheers,

Paul

> 
> CJ
> > 
> > --
> > Kind Regards
> > Mehdi Djait
> > 
> > > > +	}
> > > > +
> > > > +	cif_set_default_format(cif_dev);
> > > > +	pm_runtime_enable(&pdev->dev);
> > > > +
> > > > +	return 0;
> > > > +
> > > > +err_unreg_media_dev:
> > > > +	media_device_unregister(&cif_dev->media_dev);
> > > > +err_unreg_v4l2_dev:
> > > > +	v4l2_device_unregister(&cif_dev->v4l2_dev);
> > > > +	return ret;
> > > > +}
> > 
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-10-31  9:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 12:25 [PATCH v9 0/3] media: rockchip: Add a driver for Rockchip's camera interface Mehdi Djait
2023-10-30 12:25 ` [PATCH v9 1/3] media: dt-bindings: media: add bindings for Rockchip CIF Mehdi Djait
2023-10-30 19:32   ` Rob Herring
2023-10-31  9:51     ` Paul Kocialkowski
2023-11-01 15:44       ` Conor Dooley
2023-11-01 16:56         ` Paul Kocialkowski
2023-10-30 12:25 ` [PATCH v9 2/3] media: rockchip: Add a driver for Rockchip's camera interface Mehdi Djait
2023-10-30 12:47   ` Christophe JAILLET
2023-10-31  9:33     ` Mehdi Djait
2023-10-31  9:46       ` Christophe JAILLET
2023-10-31  9:53         ` Paul Kocialkowski [this message]
2023-10-31 22:23   ` Michael Riesch
2023-11-03  8:23     ` Mehdi Djait
2023-11-08  8:50       ` Michael Riesch
2023-11-08 10:46         ` Mehdi Djait
2023-11-02 10:39   ` Paul Kocialkowski
2023-10-30 12:25 ` [PATCH v9 3/3] arm64: dts: rockchip: Add the " Mehdi Djait

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=ZUDOmgmkIifE2w87@aptenodytes \
    --to=paul.kocialkowski@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mchehab@kernel.org \
    --cc=mehdi.djait@bootlin.com \
    --cc=michael.riesch@wolfvision.net \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /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).