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

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
 drivers/crypto/nx/nx-common-powernv.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/nx/nx-common-powernv.c 
b/drivers/crypto/nx/nx-common-powernv.c
index 0493041ea088..56aa1c29d782 100644
--- a/drivers/crypto/nx/nx-common-powernv.c
+++ b/drivers/crypto/nx/nx-common-powernv.c
@@ -908,7 +908,6 @@ static int __init nx_powernv_probe_vas(struct device_node 
*pn)
 {
        int chip_id, vasid, ret = 0;
        int ct_842 = 0, ct_gzip = 0;
-       struct device_node *dn;
 
        chip_id = of_get_ibm_chip_id(pn);
        if (chip_id < 0) {
@@ -922,7 +921,7 @@ static int __init nx_powernv_probe_vas(struct device_node 
*pn)
                return -EINVAL;
        }
 
-       for_each_child_of_node(pn, dn) {
+       for_each_child_of_node_scoped(pn, dn) {
                ret = find_nx_device_tree(dn, chip_id, vasid, NX_CT_842,
                                        "ibm,p9-nx-842", &ct_842);
 
@@ -930,10 +929,8 @@ static int __init nx_powernv_probe_vas(struct device_node 
*pn)
                        ret = find_nx_device_tree(dn, chip_id, vasid,
                                NX_CT_GZIP, "ibm,p9-nx-gzip", &ct_gzip);
 
-               if (ret) {
-                       of_node_put(dn);
+               if (ret)
                        return ret;
-               }
        }
 
        if (!ct_842 || !ct_gzip) {
-- 
2.51.0


Reply via email to