Skip to content

Commit a51adf8

Browse files
Zhang Zekunkwilczynski
authored andcommitted
PCI: mediatek: 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 d523347 commit a51adf8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/pci/controller/pcie-mediatek.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,24 +1041,22 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie)
10411041
static int mtk_pcie_setup(struct mtk_pcie *pcie)
10421042
{
10431043
struct device *dev = pcie->dev;
1044-
struct device_node *node = dev->of_node, *child;
1044+
struct device_node *node = dev->of_node;
10451045
struct mtk_pcie_port *port, *tmp;
10461046
int err, slot;
10471047

10481048
slot = of_get_pci_domain_nr(dev->of_node);
10491049
if (slot < 0) {
1050-
for_each_available_child_of_node(node, child) {
1050+
for_each_available_child_of_node_scoped(node, child) {
10511051
err = of_pci_get_devfn(child);
1052-
if (err < 0) {
1053-
dev_err(dev, "failed to get devfn: %d\n", err);
1054-
goto error_put_node;
1055-
}
1052+
if (err < 0)
1053+
return dev_err_probe(dev, err, "failed to get devfn\n");
10561054

10571055
slot = PCI_SLOT(err);
10581056

10591057
err = mtk_pcie_parse_port(pcie, child, slot);
10601058
if (err)
1061-
goto error_put_node;
1059+
return err;
10621060
}
10631061
} else {
10641062
err = mtk_pcie_parse_port(pcie, node, slot);
@@ -1079,9 +1077,6 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)
10791077
mtk_pcie_subsys_powerdown(pcie);
10801078

10811079
return 0;
1082-
error_put_node:
1083-
of_node_put(child);
1084-
return err;
10851080
}
10861081

10871082
static int mtk_pcie_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)