Skip to content

Commit 8905f8b

Browse files
Zhang Zekunkwilczynski
authored andcommitted
PCI: mt7621: 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: Sergio Paracuellos <[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 a51adf8 commit 8905f8b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/pci/controller/pcie-mt7621.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,30 +258,25 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
258258
{
259259
struct device *dev = pcie->dev;
260260
struct platform_device *pdev = to_platform_device(dev);
261-
struct device_node *node = dev->of_node, *child;
261+
struct device_node *node = dev->of_node;
262262
int err;
263263

264264
pcie->base = devm_platform_ioremap_resource(pdev, 0);
265265
if (IS_ERR(pcie->base))
266266
return PTR_ERR(pcie->base);
267267

268-
for_each_available_child_of_node(node, child) {
268+
for_each_available_child_of_node_scoped(node, child) {
269269
int slot;
270270

271271
err = of_pci_get_devfn(child);
272-
if (err < 0) {
273-
of_node_put(child);
274-
dev_err(dev, "failed to parse devfn: %d\n", err);
275-
return err;
276-
}
272+
if (err < 0)
273+
return dev_err_probe(dev, err, "failed to parse devfn\n");
277274

278275
slot = PCI_SLOT(err);
279276

280277
err = mt7621_pcie_parse_port(pcie, child, slot);
281-
if (err) {
282-
of_node_put(child);
278+
if (err)
283279
return err;
284-
}
285280
}
286281

287282
return 0;

0 commit comments

Comments
 (0)