The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Biren Pandya <birenpandya@gmail.com>
To: linux-media@vger.kernel.org
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	linux-kernel@vger.kernel.org,
	Biren Pandya <birenpandya@gmail.com>
Subject: [PATCH 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup
Date: Tue, 16 Jun 2026 04:00:54 +0530	[thread overview]
Message-ID: <20260615223055.39953-3-birenpandya@gmail.com> (raw)
In-Reply-To: <20260615223055.39953-1-birenpandya@gmail.com>

Utilize the __free(fwnode_handle) scoped guard macro from <linux/cleanup.h> to automate the lifecycle management of the endpoint fwnode in imx290_parse_dt().

This safely ties the release of the fwnode_handle to its compiler scope, allowing us to drop the manual fwnode_handle_put() call and removing the risk of missed puts if new early returns are added in the future.

Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
 drivers/media/i2c/imx290.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 21cbc81cb2ed..b0fd3e1dec2e 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -8,6 +8,7 @@
  * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  */
 
+#include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
@@ -1514,20 +1515,19 @@ static int imx290_parse_dt(struct imx290 *imx290)
 	struct v4l2_fwnode_endpoint ep = {
 		.bus_type = V4L2_MBUS_CSI2_DPHY
 	};
-	struct fwnode_handle *endpoint;
 	int ret;
 	s64 fq;
 
 	imx290->model = of_device_get_match_data(imx290->dev);
 
-	endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(imx290->dev), NULL);
+	struct fwnode_handle *endpoint __free(fwnode_handle) =
+		fwnode_graph_get_next_endpoint(dev_fwnode(imx290->dev), NULL);
 	if (!endpoint) {
 		dev_err(imx290->dev, "Endpoint node not found\n");
 		return -EINVAL;
 	}
 
 	ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep);
-	fwnode_handle_put(endpoint);
 	if (ret == -ENXIO) {
 		dev_err(imx290->dev, "Unsupported bus type, should be CSI2\n");
 		goto done;
-- 
2.50.1 (Apple Git-155)


  parent reply	other threads:[~2026-06-15 22:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 22:30 [PATCH 0/3] media: i2c: Adopt scope-based fwnode_handle_put Biren Pandya
2026-06-15 22:30 ` [PATCH 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08  8:49   ` Sakari Ailus
2026-06-15 22:30 ` Biren Pandya [this message]
2026-06-15 22:30 ` [PATCH 3/3] media: i2c: imx219: " Biren Pandya
     [not found] ` <20260708134403.45935-5-birenpandya@gmail.com>
2026-07-08 13:44   ` [PATCH v3 1/3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
2026-07-08 13:44   ` [PATCH v3 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08 13:44   ` [PATCH v3 3/3] media: i2c: imx219: " Biren Pandya

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=20260615223055.39953-3-birenpandya@gmail.com \
    --to=birenpandya@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=slongerbeam@gmail.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