mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup
       [not found] <20260616081517.44685-3-birenpandya@gmail.com>
@ 2026-07-08 13:16 ` Biren Pandya
  0 siblings, 0 replies; only message in thread
From: Biren Pandya @ 2026-07-08 13:16 UTC (permalink / raw)
  To: sakari.ailus, mani, mchehab, linux-media, linux-kernel; +Cc: Biren Pandya

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>

 v3: picked up Reviewed-by tag.
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
---
 v3: picked up Reviewed-by tag.
---
 drivers/media/i2c/imx290.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 21cbc81cb2edc..5c369c7ee21f7 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,7 +1515,7 @@ static int imx290_parse_dt(struct imx290 *imx290)
 	struct v4l2_fwnode_endpoint ep = {
 		.bus_type = V4L2_MBUS_CSI2_DPHY
 	};
-	struct fwnode_handle *endpoint;
+	struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
 	int ret;
 	s64 fq;
 
@@ -1527,7 +1528,6 @@ static int imx290_parse_dt(struct imx290 *imx290)
 	}
 
 	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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-08 13:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260616081517.44685-3-birenpandya@gmail.com>
2026-07-08 13:16 ` [PATCH v3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya

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®