mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] media: i2c: ov5640: use scoped fwnode_handle endpoint cleanup
       [not found] <20260616081517.44685-2-birenpandya@gmail.com>
@ 2026-07-08 12:49 ` Biren Pandya
  2026-07-08 13:27   ` Sakari Ailus
  0 siblings, 1 reply; 2+ 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	[flat|nested] 2+ 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; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-07-08 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260616081517.44685-2-birenpandya@gmail.com>
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

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®