]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: ehci-exynos: Simplify with scoped for each OF child loop
authorJinjie Ruan <ruanjinjie@huawei.com>
Wed, 21 Aug 2024 07:18:56 +0000 (15:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Aug 2024 09:17:29 +0000 (17:17 +0800)
Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Anand Moon <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20240821071856.2335529-1-ruanjinjie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-exynos.c

index f40bc2a7a1247eac3484a223629e17e16c3cde1d..e3a961d3f5fc960994b9cbfcfd1d15496a693419 100644 (file)
@@ -48,7 +48,6 @@ struct exynos_ehci_hcd {
 static int exynos_ehci_get_phy(struct device *dev,
                                struct exynos_ehci_hcd *exynos_ehci)
 {
-       struct device_node *child;
        struct phy *phy;
        int phy_number, num_phys;
        int ret;
@@ -66,26 +65,22 @@ static int exynos_ehci_get_phy(struct device *dev,
                return 0;
 
        /* Get PHYs using legacy bindings */
-       for_each_available_child_of_node(dev->of_node, child) {
+       for_each_available_child_of_node_scoped(dev->of_node, child) {
                ret = of_property_read_u32(child, "reg", &phy_number);
                if (ret) {
                        dev_err(dev, "Failed to parse device tree\n");
-                       of_node_put(child);
                        return ret;
                }
 
                if (phy_number >= PHY_NUMBER) {
                        dev_err(dev, "Invalid number of PHYs\n");
-                       of_node_put(child);
                        return -EINVAL;
                }
 
                phy = devm_of_phy_optional_get(dev, child, NULL);
                exynos_ehci->phy[phy_number] = phy;
-               if (IS_ERR(phy)) {
-                       of_node_put(child);
+               if (IS_ERR(phy))
                        return PTR_ERR(phy);
-               }
        }
 
        exynos_ehci->legacy_phy = true;