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 v5 2/2] media: i2c: mira016: Add driver for Mira016
Date: Thu, 1 Oct 2026 12:07:16 +0200 [thread overview]
Message-ID: <ar4ve6qfiOVQc1Kd@zed> (raw)
In-Reply-To: <ar4RQ2OnP20BOhC7@kekkonen.localdomain>
On Thu, Oct 01, 2026 at 10:52:35AM +0300, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Thu, Oct 01, 2026 at 09:19:02AM +0200, Jacopo Mondi wrote:
> > Hi Sakari
> >
> > On Thu, Oct 01, 2026 at 09:46:08AM +0300, Sakari Ailus wrote:
> > > Hi Jacopo,
> > >
> > > On Wed, Sep 30, 2026 at 12:51:20PM +0200, Jacopo Mondi wrote:
> > > > Add driver for the ams OSRAM Mira016 sensor.
> > > >
> > > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> > > > +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
> > > > + };
> > > > + int ret;
> > > > +
> > > > + endpoint = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, 0);
> > > > + if (!endpoint)
> > > > + return -ENODEV;
> > > > +
> > > > + ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep_cfg);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > > > + /*
> > > > + * Link frequencies: the driver supports a single link frequency,
> > > > + * no need to check bitmap after this call.
> > > > + */
> > > > + ret = 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);
> > > > + if (ret) {
> > > > + v4l2_fwnode_endpoint_free(&ep_cfg);
> > >
> > > I recall commenting about this at in least three occasions earlier.
> >
> > And, again, I have replied twice to your comment without receiving a
> > response: https://lore.kernel.org/linux-media/arPJ_-yKVMXE-Gav@zed/
> >
> > I'll repeat here anyway: do not mix cleanups and gotos. In this case
> > it's harmless, but why contradict the usage notes to avoid typing out
> > v4l2_fwnode_endpoint_free() 2 times ?
>
> It's not about typing but correct error handling. It's much easier to miss
> unwinding whatever needs to be unwound in multiple places when you're not
> using goto's.
>
> In other words, the pattern you're following is bad, please stop using it.
>
You seem to be missing my main point, and if you think it's not
correct please tell me why instead of keep repeating the same thing
over and over.
This routine uses cleanups because of
struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
functions using cleanups shall not use gotos
from 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.
As said, in this case is harmless, but given that this function might
be extended I wouldn't introduce a goto now to later having to care if
it gets in the way of the cleanup path or not.
> >
> > >
> > > Also applies to the other driver.
> > >
> > > > + return ret;
> > > > + }
> > > > +
> > > > + /* TODO: Implement D-PHY configuration to support continuous clock. */
> > > > + if (!(ep_cfg.bus.mipi_csi2.flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK)) {
> > > > + dev_err(dev, "Continuous clock is not supported\n");
> > > > + v4l2_fwnode_endpoint_free(&ep_cfg);
> > > > + return -EINVAL;
> > > > + }
> > > > +
> > > > + mira016->bus_config = ep_cfg.bus.mipi_csi2.flags;
> > > > +
> > > > + v4l2_fwnode_endpoint_free(&ep_cfg);
> > > > +
> > > > + return 0;
> > > > +}
> > >
>
> --
> Kind regards,
>
> Sakari Ailus
next prev parent reply other threads:[~2026-10-01 10:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 10:51 [PATCH v5 0/2] media: i2c: " Jacopo Mondi
2026-09-30 10:51 ` [PATCH v5 1/2] dt-bindings: media: i2c: Add Mira016 image sensor Jacopo Mondi
2026-09-30 10:51 ` [PATCH v5 2/2] media: i2c: mira016: Add driver for Mira016 Jacopo Mondi
2026-09-30 13:47 ` Tarang Raval
2026-09-30 16:34 ` Jacopo Mondi
2026-10-01 6:51 ` Sakari Ailus
2026-10-01 6:46 ` Sakari Ailus
2026-10-01 7:19 ` Jacopo Mondi
2026-10-01 7:52 ` Sakari Ailus
2026-10-01 10:07 ` Jacopo Mondi [this message]
2026-10-01 10:58 ` 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=ar4ve6qfiOVQc1Kd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®