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

From: Biren Pandya

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


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

This inherently guarantees that the endpoint node is released when it goes out of scope. Consequently, the manual fwnode_handle_put() call in the error_out label is no longer needed and has been removed.

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

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 7da02ce5da15..14dd5acee284 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -14,6 +14,7 @@
*
*/

+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
@@ -1110,14 +1111,14 @@ static int imx219_identify_module(struct imx219 *imx219)

static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)
{
- struct fwnode_handle *endpoint;
struct v4l2_fwnode_endpoint ep_cfg = {
.bus_type = V4L2_MBUS_CSI2_DPHY
};
unsigned long link_freq_bitmap;
int ret = -EINVAL;

- endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
+ struct fwnode_handle *endpoint __free(fwnode_handle) =
+ fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
if (!endpoint)
return dev_err_probe(dev, -EINVAL, "endpoint node not found\n");

@@ -1172,7 +1173,6 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)

error_out:
v4l2_fwnode_endpoint_free(&ep_cfg);
- fwnode_handle_put(endpoint);

return ret;
}
--
2.50.1 (Apple Git-155)