All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	 Philippe Baetens <philippebaetens@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	 Jai Luthra <jai.luthra@ideasonboard.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] media: i2c: mira016: Add driver for Mira016
Date: Tue, 8 Sep 2026 12:34:00 +0200	[thread overview]
Message-ID: <ap_kY7s1545jn1xz@zed> (raw)
In-Reply-To: <ap_fLLHSEmw0J8yN@kekkonen.localdomain>

Hi Sakari

On Tue, Sep 08, 2026 at 01:10:52PM +0300, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Tue, Sep 08, 2026 at 11:21:51AM +0200, Jacopo Mondi wrote:
> > Hi Sakari
> >
> > On Tue, Sep 08, 2026 at 11:12:45AM +0300, Sakari Ailus wrote:
> > > On Tue, Sep 08, 2026 at 09:17:15AM +0200, Jacopo Mondi wrote:
> > > > Hi Sakari
> > > >
> > > > On Mon, Sep 07, 2026 at 09:45:16AM +0200, Jacopo Mondi wrote:
> > > > > Hi Sakari, thanks for the review
> > > > >
> > > >
> > > > [snip]
> > > >
> > > > > > > +
> > > > > > > +static int mira016_parse_endpoint(struct device *dev, struct mira016 *mira016)
> > > > > > > +{
> > > > > > > +	struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
> > > > > > > +	struct v4l2_fwnode_endpoint ep_cfg = {
> > > > > > > +		.bus_type = V4L2_MBUS_CSI2_DPHY
> > > > > > > +	};
> > > > > > > +
> > > > > > > +	endpoint = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, 0);
> > > > > > > +	if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep_cfg))
> > > > > > > +		return dev_err_probe(dev, -EINVAL, "Failed to parse endpoint\n");
> > > > > >
> > > > > > Don't mask error codes! Just return the error code returned by
> > > > > > v4l2_fwnode_endpoint_alloc_parse().
> > > > > >
> > > > >
> > > > > With PTR_ERR() I presume
> > > > >
> > > > > > > +
> > > > > > > +	/*
> > > > > > > +	 * Link frequencies: the driver supports a single link frequency,
> > > > > > > +	 * no need to check bitmap after this call.
> > > > > > > +	 */
> > > > > > > +	if (v4l2_link_freq_to_bitmap(dev, ep_cfg.link_frequencies,
> > > > > > > +				     ep_cfg.nr_of_link_frequencies,
> > > > > > > +				     mira016_link_freqs,
> > > > > > > +				     ARRAY_SIZE(mira016_link_freqs),
> > > > > > > +				     &mira016->link_freq_bitmap)) {
> > > > > >
> > > > > > Ditto.
> > > > > >
> > > > > > > +		v4l2_fwnode_endpoint_free(&ep_cfg);
> > > > > > > +		return -EINVAL;
> > > > > > > +	}
> > > > > > > +
> > > > > > > +	/* TODO: Implement D-PHY configuration to support continuous clock. */
> > > > > > > +	if (!(ep_cfg.bus.mipi_csi2.flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)) {
> > > > > > > +		v4l2_fwnode_endpoint_free(&ep_cfg);
> > > > > >
> > > > > > Instead of callind v4l2_fwnode_endpoint_free() here and above, I'd add a
> > > > > > label for error handling.
> > > > > >
> > > > >
                   ^
                   |-- Here ?

> > > > > ack
> > > >
> > > > I'll actually backtrack on this.
> > > >
> > > > Sashiko pointed out that mixing gotos and cleanups is probably not a good idea
> > > > and this time, the bot is right.
> > >
> > > I'm not quite sure what you mean. The general practice is that if error
> > > handling is trivial and there's only a single location to unwind something,
> > > you should do it on the site. In more complex cases use labels and gotos.
> > > That's what we have here. (There are of course more complicated cases where
> > > it's not that simple, but this isn't what we're discussing here.)
> >
> > include/linux/cleanup.h
> >
> >  * Lastly, given that the benefit of cleanup helpers is removal of
> >  * "goto", and that the "goto" statement can jump between scopes, the
> >  * expectation is that usage of "goto" and cleanup helpers is never
> >  * mixed in the same function. I.e. for a given routine, convert all
> >  * resources that need a "goto" cleanup to scope-based cleanup, or
> >  * convert none of them.
> >
> > I take it as "do not mix gotos and cleanups"
> >
> > As the 2 cleanup paths are trivial, I would rather do not mix the two.
>
> I don't recall asking for that.
>

Anyway, in v3 I added gotos, in the next version I removed it.

> --
> Sakari Ailus

  reply	other threads:[~2026-09-08 10:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 10:43 [PATCH v2 0/2] media: i2c: Add driver for Mira016 Jacopo Mondi
2026-09-04 10:43 ` [PATCH v2 1/2] dt-bindings: media: i2c: Add Mira016 image sensor Jacopo Mondi
2026-09-04 15:13   ` Conor Dooley
2026-09-04 10:43 ` [PATCH v2 2/2] media: i2c: mira016: Add driver for Mira016 Jacopo Mondi
2026-09-04 11:02   ` sashiko-bot
2026-09-06 20:28   ` Sakari Ailus
2026-09-07  7:45     ` Jacopo Mondi
2026-09-07  8:50       ` Sakari Ailus
2026-09-07  9:16         ` Jacopo Mondi
2026-09-08  8:09           ` Sakari Ailus
2026-09-08  7:17       ` Jacopo Mondi
2026-09-08  8:12         ` Sakari Ailus
2026-09-08  9:21           ` Jacopo Mondi
2026-09-08 10:10             ` Sakari Ailus
2026-09-08 10:34               ` Jacopo Mondi [this message]
2026-09-12 11:47                 ` Sakari Ailus

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=ap_kY7s1545jn1xz@zed \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jai.luthra@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=philippebaetens@gmail.com \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.