* [PATCH v2 0/3] media: i2c: Automate fwnode lifecycle with __free() scope guards
@ 2026-06-16 8:15 Biren Pandya
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Biren Pandya @ 2026-06-16 8:15 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, linux-media
Cc: Dave Stevenson, Manivannan Sadhasivam, Steve Longerbeam,
Biren Pandya
This series updates the firmware node parsing logic across three highly
active V4L2 I2C sensor drivers (ov5640, imx290, and imx219) to utilize
the modern __free(fwnode_handle) scoped guard macro introduced in
<linux/cleanup.h>.
By binding the lifecycle of the fwnode_handle directly to the
variable's scope, we eliminate the need for manual fwnode_handle_put()
calls. This permanently removes the risk of subtle early-free or
missing-put memory leaks in error-handling paths and establishes a
cleaner pattern for newly merged drivers to follow.
Biren Pandya (3):
media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based
cleanup
media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based
cleanup
media: i2c: imx219: Drop manual fwnode_handle_put() via scope-based
cleanup
drivers/media/i2c/imx219.c | 4 ++--
drivers/media/i2c/imx290.c | 4 ++--
drivers/media/i2c/ov5640.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
base-commit: 424280953322cf66314f3ba5e2d1ef345f21c770
--
2.50.1 (Apple Git-155)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 [PATCH v2 0/3] media: i2c: Automate fwnode lifecycle with __free() scope guards Biren Pandya
@ 2026-06-16 8:15 ` Biren Pandya
2026-07-08 8:54 ` Sakari Ailus
2026-07-08 12:49 ` [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
2026-06-16 8:15 ` [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-06-16 8:15 ` [PATCH v2 3/3] media: i2c: imx219: " Biren Pandya
2 siblings, 2 replies; 11+ messages in thread
From: Biren Pandya @ 2026-06-16 8:15 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, linux-media
Cc: Dave Stevenson, Manivannan Sadhasivam, Steve Longerbeam,
Biren Pandya
Utilize the __free(fwnode_handle) scoped guard macro from
<linux/cleanup.h> to automate the lifecycle management of the endpoint
fwnode in ov5640_probe().
This eliminates the need for the manual fwnode_handle_put() call,
preventing potential memory leaks in error paths and simplifying the
probe routine.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
drivers/media/i2c/ov5640.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 85ecc23b3587..418cade11d00 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -4,6 +4,7 @@
* Copyright (C) 2014-2017 Mentor Graphics Inc.
*/
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
@@ -3845,7 +3846,7 @@ static int ov5640_check_chip_id(struct ov5640_dev *sensor)
static int ov5640_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
- struct fwnode_handle *endpoint;
+ struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
struct ov5640_dev *sensor;
int ret;
@@ -3878,7 +3879,6 @@ static int ov5640_probe(struct i2c_client *client)
}
ret = v4l2_fwnode_endpoint_parse(endpoint, &sensor->ep);
- fwnode_handle_put(endpoint);
if (ret) {
dev_err(dev, "Could not parse endpoint\n");
return ret;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 [PATCH v2 0/3] media: i2c: Automate fwnode lifecycle with __free() scope guards Biren Pandya
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
@ 2026-06-16 8:15 ` Biren Pandya
2026-06-17 5:42 ` Manivannan Sadhasivam
2026-07-08 13:16 ` [PATCH v3] " Biren Pandya
2026-06-16 8:15 ` [PATCH v2 3/3] media: i2c: imx219: " Biren Pandya
2 siblings, 2 replies; 11+ messages in thread
From: Biren Pandya @ 2026-06-16 8:15 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, linux-media
Cc: Dave Stevenson, Manivannan Sadhasivam, Steve Longerbeam,
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>
---
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 21cbc81cb2ed..5c369c7ee21f 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 related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] media: i2c: imx219: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 [PATCH v2 0/3] media: i2c: Automate fwnode lifecycle with __free() scope guards Biren Pandya
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-06-16 8:15 ` [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
@ 2026-06-16 8:15 ` Biren Pandya
2026-06-17 9:30 ` Dave Stevenson
2026-07-08 13:17 ` [PATCH v3] " Biren Pandya
2 siblings, 2 replies; 11+ messages in thread
From: Biren Pandya @ 2026-06-16 8:15 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, linux-media
Cc: Dave Stevenson, Manivannan Sadhasivam, Steve Longerbeam,
Biren Pandya
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@gmail.com>
---
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 7da02ce5da15..d76eae880d73 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)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 ` [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
@ 2026-06-17 5:42 ` Manivannan Sadhasivam
2026-07-08 13:16 ` [PATCH v3] " Biren Pandya
1 sibling, 0 replies; 11+ messages in thread
From: Manivannan Sadhasivam @ 2026-06-17 5:42 UTC (permalink / raw)
To: Biren Pandya
Cc: Sakari Ailus, Mauro Carvalho Chehab, linux-media, Dave Stevenson,
Steve Longerbeam
On Tue, Jun 16, 2026 at 01:45:16PM +0530, Biren Pandya wrote:
> 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>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
- Mani
> ---
> 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 21cbc81cb2ed..5c369c7ee21f 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] 11+ messages in thread
* Re: [PATCH v2 3/3] media: i2c: imx219: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 ` [PATCH v2 3/3] media: i2c: imx219: " Biren Pandya
@ 2026-06-17 9:30 ` Dave Stevenson
2026-07-08 13:17 ` [PATCH v3] " Biren Pandya
1 sibling, 0 replies; 11+ messages in thread
From: Dave Stevenson @ 2026-06-17 9:30 UTC (permalink / raw)
To: Biren Pandya
Cc: Sakari Ailus, Mauro Carvalho Chehab, linux-media,
Manivannan Sadhasivam, Steve Longerbeam
On Tue, 16 Jun 2026 at 09:15, Biren Pandya <birenpandya@gmail.com> wrote:
>
> 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@gmail.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> ---
> 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 7da02ce5da15..d76eae880d73 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)
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
@ 2026-07-08 8:54 ` Sakari Ailus
2026-07-08 12:49 ` [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
1 sibling, 0 replies; 11+ messages in thread
From: Sakari Ailus @ 2026-07-08 8:54 UTC (permalink / raw)
To: Biren Pandya
Cc: Mauro Carvalho Chehab, linux-media, Dave Stevenson,
Manivannan Sadhasivam, Steve Longerbeam
Hi Biren,
On Tue, Jun 16, 2026 at 01:45:15PM +0530, Biren Pandya wrote:
> Utilize the __free(fwnode_handle) scoped guard macro from
> <linux/cleanup.h> to automate the lifecycle management of the endpoint
> fwnode in ov5640_probe().
>
> This eliminates the need for the manual fwnode_handle_put() call,
> preventing potential memory leaks in error paths and simplifying the
> probe routine.
>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
> drivers/media/i2c/ov5640.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index 85ecc23b3587..418cade11d00 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -4,6 +4,7 @@
> * Copyright (C) 2014-2017 Mentor Graphics Inc.
> */
>
> +#include <linux/cleanup.h>
> #include <linux/clk.h>
> #include <linux/clk-provider.h>
> #include <linux/clkdev.h>
> @@ -3845,7 +3846,7 @@ static int ov5640_check_chip_id(struct ov5640_dev *sensor)
> static int ov5640_probe(struct i2c_client *client)
> {
> struct device *dev = &client->dev;
> - struct fwnode_handle *endpoint;
> + struct fwnode_handle *endpoint __free(fwnode_handle) = NULL;
The recommended pattern in __free() use is to assign something else than
NULL to it in declaration unless required otherwise.
> struct ov5640_dev *sensor;
> int ret;
>
> @@ -3878,7 +3879,6 @@ static int ov5640_probe(struct i2c_client *client)
> }
>
> ret = v4l2_fwnode_endpoint_parse(endpoint, &sensor->ep);
> - fwnode_handle_put(endpoint);
> if (ret) {
> dev_err(dev, "Could not parse endpoint\n");
> return ret;
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08 8:54 ` Sakari Ailus
@ 2026-07-08 12:49 ` Biren Pandya
2026-07-08 13:27 ` Sakari Ailus
1 sibling, 1 reply; 11+ messages in thread
From: Biren Pandya @ 2026-07-08 12:49 UTC (permalink / raw)
To: slongerbeam, sakari.ailus, 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 ov5640_probe().
This eliminates the need for manual fwnode_handle_put() calls.
Additionally, drop the redundant !endpoint check before
v4l2_fwnode_endpoint_parse(), as the parse function already handles
NULL endpoints safely.
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
---
v3: adopted __free scoped guard (Laurent); explicitly dropped redundant endpoint check (Sakari).
---
drivers/media/i2c/ov5640.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 8deb5f5501faf..29d4dee9690b9 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -4,6 +4,7 @@
* Copyright (C) 2014-2017 Mentor Graphics Inc.
*/
+#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
@@ -3844,7 +3845,6 @@ static int ov5640_check_chip_id(struct ov5640_dev *sensor)
static int ov5640_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
- struct fwnode_handle *endpoint;
struct ov5640_dev *sensor;
int ret;
@@ -3869,15 +3869,10 @@ static int ov5640_probe(struct i2c_client *client)
sensor->ae_target = 52;
- endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev),
- NULL);
- if (!endpoint) {
- dev_err(dev, "endpoint node not found\n");
- return -EINVAL;
- }
+ struct fwnode_handle *endpoint __free(fwnode_handle) =
+ fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL);
ret = v4l2_fwnode_endpoint_parse(endpoint, &sensor->ep);
- fwnode_handle_put(endpoint);
if (ret) {
dev_err(dev, "Could not parse endpoint\n");
return ret;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 ` [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-06-17 5:42 ` Manivannan Sadhasivam
@ 2026-07-08 13:16 ` Biren Pandya
1 sibling, 0 replies; 11+ messages 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 related [flat|nested] 11+ messages in thread
* [PATCH v3] media: i2c: imx219: Drop manual fwnode_handle_put() via scope-based cleanup
2026-06-16 8:15 ` [PATCH v2 3/3] media: i2c: imx219: " Biren Pandya
2026-06-17 9:30 ` Dave Stevenson
@ 2026-07-08 13:17 ` Biren Pandya
1 sibling, 0 replies; 11+ messages in thread
From: Biren Pandya @ 2026-07-08 13:17 UTC (permalink / raw)
To: sakari.ailus, dave.stevenson, 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 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@gmail.com>
v3: picked up Reviewed-by tag.
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
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)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup
2026-07-08 12:49 ` [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
@ 2026-07-08 13:27 ` Sakari Ailus
0 siblings, 0 replies; 11+ messages in thread
From: Sakari Ailus @ 2026-07-08 13:27 UTC (permalink / raw)
To: Biren Pandya; +Cc: slongerbeam, mchehab, linux-media, linux-kernel
Hi Biren,
On Wed, Jul 08, 2026 at 06:19:55PM +0530, Biren Pandya wrote:
> Utilize the __free(fwnode_handle) scoped guard macro from
> <linux/cleanup.h> to automate the lifecycle management of the endpoint
> fwnode in ov5640_probe().
>
> This eliminates the need for manual fwnode_handle_put() calls.
> Additionally, drop the redundant !endpoint check before
> v4l2_fwnode_endpoint_parse(), as the parse function already handles
> NULL endpoints safely.
>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
> v3: adopted __free scoped guard (Laurent); explicitly dropped redundant endpoint check (Sakari).
Please don't include git tags in changelog; git am will pick the lines as
tags to the changelog.
The threading appears to be broken in the set; please resend v3 (three
patches) as you sent v2.
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-07-08 13:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 8:15 [PATCH v2 0/3] media: i2c: Automate fwnode lifecycle with __free() scope guards Biren Pandya
2026-06-16 8:15 ` [PATCH v2 1/3] media: i2c: ov5640: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-07-08 8:54 ` Sakari Ailus
2026-07-08 12:49 ` [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup Biren Pandya
2026-07-08 13:27 ` Sakari Ailus
2026-06-16 8:15 ` [PATCH v2 2/3] media: i2c: imx290: Drop manual fwnode_handle_put() via scope-based cleanup Biren Pandya
2026-06-17 5:42 ` Manivannan Sadhasivam
2026-07-08 13:16 ` [PATCH v3] " Biren Pandya
2026-06-16 8:15 ` [PATCH v2 3/3] media: i2c: imx219: " Biren Pandya
2026-06-17 9:30 ` Dave Stevenson
2026-07-08 13:17 ` [PATCH v3] " Biren Pandya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox