Skip to content

Commit 9a0f3c5

Browse files
Zhang Zekunkwilczynski
authored andcommitted
PCI: kirin: Use helper function for_each_available_child_of_node_scoped()
The for_each_available_child_of_node_scoped() helper provides a scope-based clean-up functionality to put the device_node automatically, and as such, there is no need to call of_node_put() directly. Thus, use this helper to simplify the code. Signed-off-by: Zhang Zekun <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent 2014c95 commit 9a0f3c5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/pci/controller/dwc/pcie-kirin.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
452452
struct platform_device *pdev)
453453
{
454454
struct device *dev = &pdev->dev;
455-
struct device_node *child, *node = dev->of_node;
455+
struct device_node *node = dev->of_node;
456456
void __iomem *apb_base;
457457
int ret;
458458

@@ -477,17 +477,13 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie,
477477
return ret;
478478

479479
/* Parse OF children */
480-
for_each_available_child_of_node(node, child) {
480+
for_each_available_child_of_node_scoped(node, child) {
481481
ret = kirin_pcie_parse_port(kirin_pcie, pdev, child);
482482
if (ret)
483-
goto put_node;
483+
return ret;
484484
}
485485

486486
return 0;
487-
488-
put_node:
489-
of_node_put(child);
490-
return ret;
491487
}
492488

493489
static void kirin_pcie_sideband_dbi_w_mode(struct kirin_pcie *kirin_pcie,

0 commit comments

Comments
 (0)