]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: apple: Use helper function for_each_child_of_node_scoped()
authorZhang Zekun <zhangzekun11@huawei.com>
Sat, 31 Aug 2024 04:04:12 +0000 (12:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:00:09 +0000 (11:00 +0200)
[ Upstream commit f60b4e06a945f25d463ae065c6e41c6e24faee0a ]

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 <zhangzekun11@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20240831040413.126417-6-zhangzekun11@huawei.com
[kwilczynski: commit log]
Signed-off-by: Krzysztof WilczyƄski <kwilczynski@kernel.org>
Stable-dep-of: 751bec089c4e ("PCI: apple: Set only available ports up")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pci/controller/pcie-apple.c

index 08b7070f05d82494d086f1856349f4f90030a54e..66f8854fc341020fcfc7b2615b11f2f26b7d534d 100644 (file)
@@ -767,7 +767,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;
 
@@ -790,11 +789,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;
                }
        }