Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped()
@ 2026-06-25 14:17 Frank.Li
  2026-06-25 14:17 ` [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Frank.Li
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Frank.Li @ 2026-06-25 14:17 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Mauro Carvalho Chehab, Dafna Hirschfeld, Laurent Pinchart,
	Heiko Stuebner, Bryan O'Donoghue, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

Add new helper macro fwnode_graph_for_each_endpoint_scoped() and use it
simplify media code.

Typical example should qualcomm's driver (camss.c), the v4l2_mc.c and
rkisp1-dev.c only silience improvement.

Anyways, *_for_each_*_scoped() already use widely and make code clean.

Build test only.

Sakari Ailus:
	when I try to improve the patch
"Add common helper library for 1-to-1 subdev registration", I found need
camss.c pattern, so I create this small improvement firstly.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v3:
- colllect luarent pinchart's reviewed-by tags
- fix miss tab before \
- Link to v2: https://patch.msgid.link/20260624-fw_scoped-v2-0-0a8db472af4a@nxp.com

Changes in v2:
- colllect review by tags
- fix typo and indent.
- see each patch's change log.
- Link to v1: https://patch.msgid.link/20260622-fw_scoped-v1-0-a37d0aac0a68@nxp.com

---
Frank Li (4):
      device property: Introduce fwnode_graph_for_each_endpoint_scoped()
      media: mc: use fwnode_graph_for_each_endpoint_scoped() to simpilfy code
      media: rkisp1: use fwnode_graph_for_each_endpoint_scoped() to simplify code
      media: qcom: camss: use fwnode_graph_for_each_endpoint_scoped() to simplify code

 drivers/media/platform/qcom/camss/camss.c           | 17 +++++------------
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c |  4 +---
 drivers/media/v4l2-core/v4l2-mc.c                   |  5 +----
 include/linux/property.h                            |  5 +++++
 4 files changed, 12 insertions(+), 19 deletions(-)
---
base-commit: 3ce97bd3c4f18608335e709c24d6a40e7036cab8
change-id: 20260620-fw_scoped-5dab644510a1

Best regards,
--  
Frank Li <Frank.Li@nxp.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped()
  2026-06-25 14:17 [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped() Frank.Li
@ 2026-06-25 14:17 ` Frank.Li
  2026-07-28  6:27   ` Sakari Ailus
  2026-06-25 14:17 ` [PATCH v3 2/4] media: mc: use fwnode_graph_for_each_endpoint_scoped() to simpilfy code Frank.Li
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Frank.Li @ 2026-06-25 14:17 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Mauro Carvalho Chehab, Dafna Hirschfeld, Laurent Pinchart,
	Heiko Stuebner, Bryan O'Donoghue, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

From: Frank Li <Frank.Li@nxp.com>

Similar to recently propose for_each_child_of_node_scoped() this new
version of the loop macro instantiates a new local struct fwnode_handle *
that uses the __free(fwnode_handle) auto cleanup handling so that if a
reference to a node is held on early exit from the loop the reference will
be released. If the loop runs to completion, the child pointer will be NULL
and no action will be taken.

The reason this is useful is that it removes the need for
fwnode_handle_put() on early loop exits. If there is a need to retain the
reference, then return_ptr(child) or no_free_ptr(child) may be used to
safely disable the auto cleanup.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change in v3
- fix missed a tab before \

change in v2
- collect Andy and Guoniu's reviewed-by tags
- fix indention
- remove extra space in commit message
---
 include/linux/property.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/property.h b/include/linux/property.h
index 14c304db46648..c71177ca16a95 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -545,6 +545,11 @@ unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode,
 	for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child;	\
 	     child = fwnode_graph_get_next_endpoint(fwnode, child))
 
+#define fwnode_graph_for_each_endpoint_scoped(fwnode, child)			\
+	for (struct fwnode_handle *child __free(fwnode_handle) =		\
+		fwnode_graph_get_next_endpoint(fwnode, NULL);			\
+	     child; child = fwnode_graph_get_next_endpoint(fwnode, child))
+
 int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 				struct fwnode_endpoint *endpoint);
 

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 2/4] media: mc: use fwnode_graph_for_each_endpoint_scoped() to simpilfy code
  2026-06-25 14:17 [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped() Frank.Li
  2026-06-25 14:17 ` [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Frank.Li
@ 2026-06-25 14:17 ` Frank.Li
  2026-06-25 14:17 ` [PATCH v3 3/4] media: rkisp1: use fwnode_graph_for_each_endpoint_scoped() to simplify code Frank.Li
  2026-06-25 14:17 ` [PATCH v3 4/4] media: qcom: camss: " Frank.Li
  3 siblings, 0 replies; 8+ messages in thread
From: Frank.Li @ 2026-06-25 14:17 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Mauro Carvalho Chehab, Dafna Hirschfeld, Laurent Pinchart,
	Heiko Stuebner, Bryan O'Donoghue, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

From: Frank Li <Frank.Li@nxp.com>

Use cleanup helper fwnode_graph_for_each_endpoint_scoped() to simpilfy
code.

Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/media/v4l2-core/v4l2-mc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
index 937d358697e19..5d7fcd67dc42e 100644
--- a/drivers/media/v4l2-core/v4l2-mc.c
+++ b/drivers/media/v4l2-core/v4l2-mc.c
@@ -324,12 +324,10 @@ EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source);
 int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
 				    struct media_pad *sink, u32 flags)
 {
-	struct fwnode_handle *endpoint;
-
 	if (!(sink->flags & MEDIA_PAD_FL_SINK))
 		return -EINVAL;
 
-	fwnode_graph_for_each_endpoint(src_sd->fwnode, endpoint) {
+	fwnode_graph_for_each_endpoint_scoped(src_sd->fwnode, endpoint) {
 		struct fwnode_handle *remote_ep;
 		int src_idx, sink_idx, ret;
 		struct media_pad *src;
@@ -397,7 +395,6 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
 				src_sd->entity.name, src_idx,
 				sink->entity->name, sink_idx, ret);
 
-			fwnode_handle_put(endpoint);
 			return ret;
 		}
 	}

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 3/4] media: rkisp1: use fwnode_graph_for_each_endpoint_scoped() to simplify code
  2026-06-25 14:17 [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped() Frank.Li
  2026-06-25 14:17 ` [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Frank.Li
  2026-06-25 14:17 ` [PATCH v3 2/4] media: mc: use fwnode_graph_for_each_endpoint_scoped() to simpilfy code Frank.Li
@ 2026-06-25 14:17 ` Frank.Li
  2026-06-25 14:17 ` [PATCH v3 4/4] media: qcom: camss: " Frank.Li
  3 siblings, 0 replies; 8+ messages in thread
From: Frank.Li @ 2026-06-25 14:17 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Mauro Carvalho Chehab, Dafna Hirschfeld, Laurent Pinchart,
	Heiko Stuebner, Bryan O'Donoghue, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Laurent Pinchart

From: Frank Li <Frank.Li@nxp.com>

Use fwnode_graph_for_each_endpoint_scoped() to simplify code.

No functional changes.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Andy: Keep original code because too much break. and I am working on more
generally solution, so the whole function can be replaced.
---
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
index 1791c02a40ae1..f90e01301943c 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
@@ -187,7 +187,6 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
 {
 	struct v4l2_async_notifier *ntf = &rkisp1->notifier;
 	struct fwnode_handle *fwnode = dev_fwnode(rkisp1->dev);
-	struct fwnode_handle *ep;
 	unsigned int index = 0;
 	int ret = 0;
 
@@ -195,7 +194,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
 
 	ntf->ops = &rkisp1_subdev_notifier_ops;
 
-	fwnode_graph_for_each_endpoint(fwnode, ep) {
+	fwnode_graph_for_each_endpoint_scoped(fwnode, ep) {
 		struct fwnode_handle *port;
 		struct v4l2_fwnode_endpoint vep = { };
 		struct rkisp1_sensor_async *rk_asd;
@@ -286,7 +285,6 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
 	}
 
 	if (ret) {
-		fwnode_handle_put(ep);
 		v4l2_async_nf_cleanup(ntf);
 		return ret;
 	}

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v3 4/4] media: qcom: camss: use fwnode_graph_for_each_endpoint_scoped() to simplify code
  2026-06-25 14:17 [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped() Frank.Li
                   ` (2 preceding siblings ...)
  2026-06-25 14:17 ` [PATCH v3 3/4] media: rkisp1: use fwnode_graph_for_each_endpoint_scoped() to simplify code Frank.Li
@ 2026-06-25 14:17 ` Frank.Li
  2026-07-29 11:38   ` Bryan O'Donoghue
  3 siblings, 1 reply; 8+ messages in thread
From: Frank.Li @ 2026-06-25 14:17 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Mauro Carvalho Chehab, Dafna Hirschfeld, Laurent Pinchart,
	Heiko Stuebner, Bryan O'Donoghue, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

From: Frank Li <Frank.Li@nxp.com>

Use fwnode_graph_for_each_endpoint_scoped() to simplify code.

No functional changes.

Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
change in v2
- fix typo simplify
- collect andy, gouniou and loic's review tags
---
 drivers/media/platform/qcom/camss/camss.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 2123f6388e3d7..23f3cc30a15a5 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -4793,30 +4793,23 @@ static int camss_parse_endpoint_node(struct device *dev,
 static int camss_parse_ports(struct camss *camss)
 {
 	struct device *dev = camss->dev;
-	struct fwnode_handle *fwnode = dev_fwnode(dev), *ep;
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	int ret;
 
-	fwnode_graph_for_each_endpoint(fwnode, ep) {
+	fwnode_graph_for_each_endpoint_scoped(fwnode, ep) {
 		struct camss_async_subdev *csd;
 
 		csd = v4l2_async_nf_add_fwnode_remote(&camss->notifier, ep,
 						      typeof(*csd));
-		if (IS_ERR(csd)) {
-			ret = PTR_ERR(csd);
-			goto err_cleanup;
-		}
+		if (IS_ERR(csd))
+			return PTR_ERR(csd);
 
 		ret = camss_parse_endpoint_node(dev, ep, csd);
 		if (ret < 0)
-			goto err_cleanup;
+			return ret;
 	}
 
 	return 0;
-
-err_cleanup:
-	fwnode_handle_put(ep);
-
-	return ret;
 }
 
 /*

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped()
  2026-06-25 14:17 ` [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Frank.Li
@ 2026-07-28  6:27   ` Sakari Ailus
  2026-09-08 13:09     ` Danilo Krummrich
  0 siblings, 1 reply; 8+ messages in thread
From: Sakari Ailus @ 2026-07-28  6:27 UTC (permalink / raw)
  To: Frank.Li, Rafael J. Wysocki, Danilo Krummrich
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Greg Kroah-Hartman, Mauro Carvalho Chehab, Dafna Hirschfeld,
	Laurent Pinchart, Heiko Stuebner, Bryan O'Donoghue,
	Vladimir Zapolskiy, Loic Poulain, driver-core, linux-acpi,
	linux-kernel, linux-media, linux-rockchip, linux-arm-kernel,
	linux-arm-msm, imx, Guoniu Zhou, Frank Li, Guoniu Zhou,
	Laurent Pinchart

Hi Rafael, Danilo,

Can we merge this via the media tree (assuming you're fine with the
change)?

On Thu, Jun 25, 2026 at 10:17:21AM -0400, Frank.Li@oss.nxp.com wrote:
> From: Frank Li <Frank.Li@nxp.com>
> 
> Similar to recently propose for_each_child_of_node_scoped() this new
> version of the loop macro instantiates a new local struct fwnode_handle *
> that uses the __free(fwnode_handle) auto cleanup handling so that if a
> reference to a node is held on early exit from the loop the reference will
> be released. If the loop runs to completion, the child pointer will be NULL
> and no action will be taken.
> 
> The reason this is useful is that it removes the need for
> fwnode_handle_put() on early loop exits. If there is a need to retain the
> reference, then return_ptr(child) or no_free_ptr(child) may be used to
> safely disable the auto cleanup.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> change in v3
> - fix missed a tab before \
> 
> change in v2
> - collect Andy and Guoniu's reviewed-by tags
> - fix indention
> - remove extra space in commit message
> ---
>  include/linux/property.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 14c304db46648..c71177ca16a95 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -545,6 +545,11 @@ unsigned int fwnode_graph_get_endpoint_count(const struct fwnode_handle *fwnode,
>  	for (child = fwnode_graph_get_next_endpoint(fwnode, NULL); child;	\
>  	     child = fwnode_graph_get_next_endpoint(fwnode, child))
>  
> +#define fwnode_graph_for_each_endpoint_scoped(fwnode, child)			\
> +	for (struct fwnode_handle *child __free(fwnode_handle) =		\
> +		fwnode_graph_get_next_endpoint(fwnode, NULL);			\
> +	     child; child = fwnode_graph_get_next_endpoint(fwnode, child))
> +
>  int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
>  				struct fwnode_endpoint *endpoint);
>  
> 

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 4/4] media: qcom: camss: use fwnode_graph_for_each_endpoint_scoped() to simplify code
  2026-06-25 14:17 ` [PATCH v3 4/4] media: qcom: camss: " Frank.Li
@ 2026-07-29 11:38   ` Bryan O'Donoghue
  0 siblings, 0 replies; 8+ messages in thread
From: Bryan O'Donoghue @ 2026-07-29 11:38 UTC (permalink / raw)
  To: Frank.Li, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki,
	Danilo Krummrich, Mauro Carvalho Chehab, Dafna Hirschfeld,
	Laurent Pinchart, Heiko Stuebner, Vladimir Zapolskiy,
	Loic Poulain
  Cc: driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

On 25/06/2026 15:17, Frank.Li@oss.nxp.com wrote:
> From: Frank Li <Frank.Li@nxp.com>
> 
> Use fwnode_graph_for_each_endpoint_scoped() to simplify code.
> 
> No functional changes.
> 
> Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
> Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> change in v2
> - fix typo simplify
> - collect andy, gouniou and loic's review tags
> ---
>   drivers/media/platform/qcom/camss/camss.c | 17 +++++------------
>   1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 2123f6388e3d7..23f3cc30a15a5 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -4793,30 +4793,23 @@ static int camss_parse_endpoint_node(struct device *dev,
>   static int camss_parse_ports(struct camss *camss)
>   {
>   	struct device *dev = camss->dev;
> -	struct fwnode_handle *fwnode = dev_fwnode(dev), *ep;
> +	struct fwnode_handle *fwnode = dev_fwnode(dev);
>   	int ret;
>   
> -	fwnode_graph_for_each_endpoint(fwnode, ep) {
> +	fwnode_graph_for_each_endpoint_scoped(fwnode, ep) {
>   		struct camss_async_subdev *csd;
>   
>   		csd = v4l2_async_nf_add_fwnode_remote(&camss->notifier, ep,
>   						      typeof(*csd));
> -		if (IS_ERR(csd)) {
> -			ret = PTR_ERR(csd);
> -			goto err_cleanup;
> -		}
> +		if (IS_ERR(csd))
> +			return PTR_ERR(csd);
>   
>   		ret = camss_parse_endpoint_node(dev, ep, csd);
>   		if (ret < 0)
> -			goto err_cleanup;
> +			return ret;
>   	}
>   
>   	return 0;
> -
> -err_cleanup:
> -	fwnode_handle_put(ep);
> -
> -	return ret;
>   }
>   
>   /*
> 
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped()
  2026-07-28  6:27   ` Sakari Ailus
@ 2026-09-08 13:09     ` Danilo Krummrich
  0 siblings, 0 replies; 8+ messages in thread
From: Danilo Krummrich @ 2026-09-08 13:09 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Frank.Li, Rafael J. Wysocki, Andy Shevchenko, Daniel Scally,
	Heikki Krogerus, Greg Kroah-Hartman, Mauro Carvalho Chehab,
	Dafna Hirschfeld, Laurent Pinchart, Heiko Stuebner,
	Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	driver-core, linux-acpi, linux-kernel, linux-media,
	linux-rockchip, linux-arm-kernel, linux-arm-msm, imx, Guoniu Zhou,
	Frank Li, Guoniu Zhou, Laurent Pinchart

On Tue Jul 28, 2026 at 8:27 AM CEST, Sakari Ailus wrote:
> Hi Rafael, Danilo,
>
> Can we merge this via the media tree (assuming you're fine with the
> change)?

Acked-by: Danilo Krummrich <dakr@kernel.org>

> On Thu, Jun 25, 2026 at 10:17:21AM -0400, Frank.Li@oss.nxp.com wrote:
>> From: Frank Li <Frank.Li@nxp.com>
>> 
>> Similar to recently propose for_each_child_of_node_scoped() this new
>> version of the loop macro instantiates a new local struct fwnode_handle *
>> that uses the __free(fwnode_handle) auto cleanup handling so that if a
>> reference to a node is held on early exit from the loop the reference will
>> be released. If the loop runs to completion, the child pointer will be NULL
>> and no action will be taken.
>> 
>> The reason this is useful is that it removes the need for
>> fwnode_handle_put() on early loop exits. If there is a need to retain the
>> reference, then return_ptr(child) or no_free_ptr(child) may be used to
>> safely disable the auto cleanup.
>> 
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Reviewed-by: Guoniu Zhou <guoniu.zhou@oss.nxp.com>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>> Signed-off-by: Frank Li <Frank.Li@nxp.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25 14:17 [PATCH v3 0/4] media: add and use fwnode_graph_for_each_endpoint_scoped() Frank.Li
2026-06-25 14:17 ` [PATCH v3 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped() Frank.Li
2026-07-28  6:27   ` Sakari Ailus
2026-09-08 13:09     ` Danilo Krummrich
2026-06-25 14:17 ` [PATCH v3 2/4] media: mc: use fwnode_graph_for_each_endpoint_scoped() to simpilfy code Frank.Li
2026-06-25 14:17 ` [PATCH v3 3/4] media: rkisp1: use fwnode_graph_for_each_endpoint_scoped() to simplify code Frank.Li
2026-06-25 14:17 ` [PATCH v3 4/4] media: qcom: camss: " Frank.Li
2026-07-29 11:38   ` Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox