diff options
author | Andrew Donnellan <andrew.donnellan@au1.ibm.com> | 2016-07-28 23:55:34 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-10-04 01:19:23 -0400 |
commit | 735840b44bcc998e2574faf63d1aaaf9b41f2827 (patch) | |
tree | eb9215202f80d8ac08e08926cbc4c7a204d124d6 /drivers/misc/cxl/of.c | |
parent | aaa2245ed836824f21f8e42e0ab63b1637d1cb20 (diff) |
cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Rewrite the cxl_guest_init_afu() loop in cxl_of_probe() to use
for_each_child_of_node() rather than a hand-coded for loop.
Remove the useless of_node_put(afu_np) call after the loop, where it's
guaranteed that afu_np == NULL.
Reported-by: SF Markus Elfring <elfring@users.sourceforge.net>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/of.c')
-rw-r--r-- | drivers/misc/cxl/of.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/misc/cxl/of.c b/drivers/misc/cxl/of.c index edc458395f68..ec175ea5dfba 100644 --- a/drivers/misc/cxl/of.c +++ b/drivers/misc/cxl/of.c | |||
@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev) | |||
460 | struct device_node *afu_np = NULL; | 460 | struct device_node *afu_np = NULL; |
461 | struct cxl *adapter = NULL; | 461 | struct cxl *adapter = NULL; |
462 | int ret; | 462 | int ret; |
463 | int slice, slice_ok; | 463 | int slice = 0, slice_ok = 0; |
464 | 464 | ||
465 | pr_devel("in %s\n", __func__); | 465 | pr_devel("in %s\n", __func__); |
466 | 466 | ||
@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) | |||
476 | } | 476 | } |
477 | 477 | ||
478 | /* init afu */ | 478 | /* init afu */ |
479 | slice_ok = 0; | 479 | for_each_child_of_node(np, afu_np) { |
480 | for (afu_np = NULL, slice = 0; (afu_np = of_get_next_child(np, afu_np)); slice++) { | ||
481 | if ((ret = cxl_guest_init_afu(adapter, slice, afu_np))) | 480 | if ((ret = cxl_guest_init_afu(adapter, slice, afu_np))) |
482 | dev_err(&pdev->dev, "AFU %i failed to initialise: %i\n", | 481 | dev_err(&pdev->dev, "AFU %i failed to initialise: %i\n", |
483 | slice, ret); | 482 | slice, ret); |
484 | else | 483 | else |
485 | slice_ok++; | 484 | slice_ok++; |
485 | slice++; | ||
486 | } | 486 | } |
487 | 487 | ||
488 | if (slice_ok == 0) { | 488 | if (slice_ok == 0) { |
@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) | |||
490 | adapter->slices = 0; | 490 | adapter->slices = 0; |
491 | } | 491 | } |
492 | 492 | ||
493 | if (afu_np) | ||
494 | of_node_put(afu_np); | ||
495 | return 0; | 493 | return 0; |
496 | } | 494 | } |
497 | 495 | ||