public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: samsung: exynos4-is: Simplify with scoped for each OF child loop
@ 2026-01-02 12:49 Krzysztof Kozlowski
  2026-01-05 10:41 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-02 12:49 UTC (permalink / raw)
  To: Sylwester Nawrocki, Mauro Carvalho Chehab, Krzysztof Kozlowski,
	Alim Akhtar, linux-media, linux-arm-kernel, linux-samsung-soc,
	linux-kernel
  Cc: Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/media/platform/samsung/exynos4-is/fimc-is.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index 0827fdaf455a..14d84cc96831 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -200,7 +200,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
 
 static int fimc_is_register_subdevs(struct fimc_is *is)
 {
-	struct device_node *i2c_bus, *child;
+	struct device_node *i2c_bus;
 	int ret, index = 0;
 
 	ret = fimc_isp_subdev_create(&is->isp);
@@ -208,11 +208,10 @@ static int fimc_is_register_subdevs(struct fimc_is *is)
 		return ret;
 
 	for_each_compatible_node(i2c_bus, NULL, "samsung,exynos4212-i2c-isp") {
-		for_each_available_child_of_node(i2c_bus, child) {
+		for_each_available_child_of_node_scoped(i2c_bus, child) {
 			ret = fimc_is_parse_sensor_config(is, index, child);
 
 			if (ret < 0 || index >= FIMC_IS_SENSORS_NUM) {
-				of_node_put(child);
 				of_node_put(i2c_bus);
 				return ret;
 			}
-- 
2.51.0


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

* Re: [PATCH] media: samsung: exynos4-is: Simplify with scoped for each OF child loop
  2026-01-02 12:49 [PATCH] media: samsung: exynos4-is: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-05 10:41 ` Jonathan Cameron
  2026-01-05 11:43   ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2026-01-05 10:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Sylwester Nawrocki, Mauro Carvalho Chehab, Krzysztof Kozlowski,
	Alim Akhtar, linux-media, linux-arm-kernel, linux-samsung-soc,
	linux-kernel

On Fri,  2 Jan 2026 13:49:56 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> wrote:

> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Change is fine but I wonder it it is worth going further.  See inline.
> ---
>  drivers/media/platform/samsung/exynos4-is/fimc-is.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
> index 0827fdaf455a..14d84cc96831 100644
> --- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
> +++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
> @@ -200,7 +200,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
>  
>  static int fimc_is_register_subdevs(struct fimc_is *is)
>  {
> -	struct device_node *i2c_bus, *child;
> +	struct device_node *i2c_bus;
>  	int ret, index = 0;
>  
>  	ret = fimc_isp_subdev_create(&is->isp);
> @@ -208,11 +208,10 @@ static int fimc_is_register_subdevs(struct fimc_is *is)
>  		return ret;
>  
>  	for_each_compatible_node(i2c_bus, NULL, "samsung,exynos4212-i2c-isp") {
I haven't checked how frequently this would help, but at least in this case
I'd consider adding a
	for_each_compatible_node_scoped() following same approach as
other scoped loops.


> -		for_each_available_child_of_node(i2c_bus, child) {
> +		for_each_available_child_of_node_scoped(i2c_bus, child) {
>  			ret = fimc_is_parse_sensor_config(is, index, child);
>  
>  			if (ret < 0 || index >= FIMC_IS_SENSORS_NUM) {
> -				of_node_put(child);
>  				of_node_put(i2c_bus);
>  				return ret;
>  			}


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

* Re: [PATCH] media: samsung: exynos4-is: Simplify with scoped for each OF child loop
  2026-01-05 10:41 ` Jonathan Cameron
@ 2026-01-05 11:43   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 11:43 UTC (permalink / raw)
  To: Jonathan Cameron, Krzysztof Kozlowski
  Cc: Sylwester Nawrocki, Mauro Carvalho Chehab, Alim Akhtar,
	linux-media, linux-arm-kernel, linux-samsung-soc, linux-kernel

On 05/01/2026 11:41, Jonathan Cameron wrote:
>> diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
>> index 0827fdaf455a..14d84cc96831 100644
>> --- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
>> +++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
>> @@ -200,7 +200,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
>>  
>>  static int fimc_is_register_subdevs(struct fimc_is *is)
>>  {
>> -	struct device_node *i2c_bus, *child;
>> +	struct device_node *i2c_bus;
>>  	int ret, index = 0;
>>  
>>  	ret = fimc_isp_subdev_create(&is->isp);
>> @@ -208,11 +208,10 @@ static int fimc_is_register_subdevs(struct fimc_is *is)
>>  		return ret;
>>  
>>  	for_each_compatible_node(i2c_bus, NULL, "samsung,exynos4212-i2c-isp") {
> I haven't checked how frequently this would help, but at least in this case
> I'd consider adding a
> 	for_each_compatible_node_scoped() following same approach as
> other scoped loops.

yes, yes, that's on my TODO list. :)

I saw it in several places already.

Best regards,
Krzysztof

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

end of thread, other threads:[~2026-01-05 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-02 12:49 [PATCH] media: samsung: exynos4-is: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-05 10:41 ` Jonathan Cameron
2026-01-05 11:43   ` Krzysztof Kozlowski

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