[PATCH v3] media: i2c: imx219: Drop manual fwnode_handle_put() via scope-based cleanup
From: Biren Pandya
Date: Wed Jul 08 2026 - 09:19:12 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>
v3: picked up Reviewed-by tag.
Reviewed-by: Dave Stevenson <dave.stevenson@xxxxxxxxxxxxxxx>
---
v3: picked up Reviewed-by tag.
---
drivers/media/i2c/imx219.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 7da02ce5da154..d76eae880d730 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,7 +1111,7 @@ static int imx219_identify_module(struct imx219 *imx219)
static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)
{
- struct fwnode_handle *endpoint;
+ struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
struct v4l2_fwnode_endpoint ep_cfg = {
.bus_type = V4L2_MBUS_CSI2_DPHY
};
@@ -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)