From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 594BD1A6811; Tue, 8 Sep 2026 09:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788859320; cv=none; b=ru1Atm7jAZPCPYeWuR2DEaDO39Mfd0gqmkWviLCJ08Uz+crAQeAVuPAeQNhnE7Rl5hz7zPuATjzsZj4Z4/BQXmOOCNeus2h9Z0d4786yoM2U3WERDO7bXgD0g0YRzN5d3yMoOP0/UWLzEZaSCNOdY3lCl4IbXKOWKN8EWqYWHZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788859320; c=relaxed/simple; bh=cbzkP+UYnNAHcLX7mr1OdaawPQAm0XvDJnTZSas9abA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qeAYh5XxclNPX0pNwqadq289/wjWDAS1DjsbXMDQC97tN4bfzWTzaOKXsI4vuznWMkhd0NzPQxEQpK7OWybulZXHW8IWgYKH2GzaftH4mQcImtLzXa2IdNwwj+yxewkFAURyKge97++STV6Mgf7SBjwItsXrEzloAiu4XfL9K3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=nBAJb68C; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nBAJb68C" Received: from ideasonboard.com (mob-109-113-65-131.net.vodafone.it [109.113.65.131]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 364C5981; Tue, 8 Sep 2026 11:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1788859220; bh=cbzkP+UYnNAHcLX7mr1OdaawPQAm0XvDJnTZSas9abA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nBAJb68CZfYfVFSJvBeITMi8imJ1gdTigtnqYeaNenEBuzg0CWRbhU6K/INH9zRpg /JqZXM/TG+6S4NPe0pBUo3834BBa/G8LC7eFWwAhrFUtoXuK1A0hJWAOnM25k4/Mdj YyAcMxDZY3JhEcYNxYWrMA0PtJ3UFQN4j31sIdIk= Date: Tue, 8 Sep 2026 11:21:51 +0200 From: Jacopo Mondi To: Sakari Ailus Cc: Jacopo Mondi , Philippe Baetens , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kieran Bingham , Jai Luthra , 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 Message-ID: References: <20260904-mira016-v2-0-1dcf7b3a807e@ideasonboard.com> <20260904-mira016-v2-2-1dcf7b3a807e@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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. > > > > > > > > > > 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. > > -- > Sakari Ailus >