[PATCH 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup

From: Biren Pandya

Date: Mon Jun 15 2026 - 18:36:13 EST


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@xxxxxxxxx>
---
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@xxxxxxxxxx>
*/

+#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)