Message ID | 20240828073825.43072-5-zhangzekun11@huawei.com |
---|---|
State | New |
Headers | show |
Series | Simplify code with _scoped() helper functions | expand |
On Wed, 28 Aug 2024 15:38:24 +0800 Zhang Zekun <zhangzekun11@huawei.com> wrote: > for_each_child_of_node_scoped() provides a scope-based cleanup > functinality to put the device_node automatically, and we don't need to > call of_node_put() directly. Let's simplify the code a bit with the > use of these functions. > > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index fefab2758a06..f1bd20a64b67 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -764,7 +764,6 @@ static int apple_pcie_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; struct platform_device *platform = to_platform_device(dev); - struct device_node *of_port; struct apple_pcie *pcie; int ret; @@ -787,11 +786,10 @@ static int apple_pcie_init(struct pci_config_window *cfg) if (ret) return ret; - for_each_child_of_node(dev->of_node, of_port) { + for_each_child_of_node_scoped(dev->of_node, of_port) { ret = apple_pcie_setup_port(pcie, of_port); if (ret) { dev_err(pcie->dev, "Port %pOF setup fail: %d\n", of_port, ret); - of_node_put(of_port); return ret; } }
for_each_child_of_node_scoped() provides a scope-based cleanup functinality to put the device_node automatically, and we don't need to call of_node_put() directly. Let's simplify the code a bit with the use of these functions. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> --- drivers/pci/controller/pcie-apple.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)