diff mbox series

[v2,02/13] memory: atmel-ebi: simplify with scoped for each OF child loop

Message ID 20240816-cleanup-h-of-node-put-memory-v2-2-9eed0ee16b78@linaro.org
State Accepted
Commit 50e40b71598cd19d59683c989bc5b89140e70d28
Headers show
Series memory: simplify with scoped/cleanup.h for device nodes | expand

Commit Message

Krzysztof Kozlowski Aug. 16, 2024, 10:54 a.m. UTC
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/memory/atmel-ebi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Nicolas Ferre Aug. 27, 2024, 10:30 a.m. UTC | #1
On 16/08/2024 at 12:54, Krzysztof Kozlowski wrote:
> Use scoped for_each_available_child_of_node_scoped() when iterating over
> device nodes to make code a bit simpler.
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Thanks!
Regards,
   Nicolas

> ---
>   drivers/memory/atmel-ebi.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
> index 8f5b3302ee30..8db970da9af9 100644
> --- a/drivers/memory/atmel-ebi.c
> +++ b/drivers/memory/atmel-ebi.c
> @@ -518,7 +518,7 @@ static int atmel_ebi_dev_disable(struct atmel_ebi *ebi, struct device_node *np)
>   static int atmel_ebi_probe(struct platform_device *pdev)
>   {
>          struct device *dev = &pdev->dev;
> -       struct device_node *child, *np = dev->of_node;
> +       struct device_node *np = dev->of_node;
>          struct atmel_ebi *ebi;
>          int ret, reg_cells;
>          struct clk *clk;
> @@ -592,7 +592,7 @@ static int atmel_ebi_probe(struct platform_device *pdev)
> 
>          reg_cells += val;
> 
> -       for_each_available_child_of_node(np, child) {
> +       for_each_available_child_of_node_scoped(np, child) {
>                  if (!of_property_present(child, "reg"))
>                          continue;
> 
> @@ -602,10 +602,8 @@ static int atmel_ebi_probe(struct platform_device *pdev)
>                                  child);
> 
>                          ret = atmel_ebi_dev_disable(ebi, child);
> -                       if (ret) {
> -                               of_node_put(child);
> +                       if (ret)
>                                  return ret;
> -                       }
>                  }
>          }
> 
> 
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
index 8f5b3302ee30..8db970da9af9 100644
--- a/drivers/memory/atmel-ebi.c
+++ b/drivers/memory/atmel-ebi.c
@@ -518,7 +518,7 @@  static int atmel_ebi_dev_disable(struct atmel_ebi *ebi, struct device_node *np)
 static int atmel_ebi_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *child, *np = dev->of_node;
+	struct device_node *np = dev->of_node;
 	struct atmel_ebi *ebi;
 	int ret, reg_cells;
 	struct clk *clk;
@@ -592,7 +592,7 @@  static int atmel_ebi_probe(struct platform_device *pdev)
 
 	reg_cells += val;
 
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		if (!of_property_present(child, "reg"))
 			continue;
 
@@ -602,10 +602,8 @@  static int atmel_ebi_probe(struct platform_device *pdev)
 				child);
 
 			ret = atmel_ebi_dev_disable(ebi, child);
-			if (ret) {
-				of_node_put(child);
+			if (ret)
 				return ret;
-			}
 		}
 	}