usb: ohci-exynos: Simplify with scoped for each OF child loop

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/20240821071752.2335406-1-ruanjinjie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jinjie Ruan 2024-08-21 15:17:52 +08:00 committed by Greg Kroah-Hartman
parent 3cc92765a5
commit e24ed5e2f9

View File

@ -37,7 +37,6 @@ struct exynos_ohci_hcd {
static int exynos_ohci_get_phy(struct device *dev, static int exynos_ohci_get_phy(struct device *dev,
struct exynos_ohci_hcd *exynos_ohci) struct exynos_ohci_hcd *exynos_ohci)
{ {
struct device_node *child;
struct phy *phy; struct phy *phy;
int phy_number, num_phys; int phy_number, num_phys;
int ret; int ret;
@ -55,26 +54,22 @@ static int exynos_ohci_get_phy(struct device *dev,
return 0; return 0;
/* Get PHYs using legacy bindings */ /* 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); ret = of_property_read_u32(child, "reg", &phy_number);
if (ret) { if (ret) {
dev_err(dev, "Failed to parse device tree\n"); dev_err(dev, "Failed to parse device tree\n");
of_node_put(child);
return ret; return ret;
} }
if (phy_number >= PHY_NUMBER) { if (phy_number >= PHY_NUMBER) {
dev_err(dev, "Invalid number of PHYs\n"); dev_err(dev, "Invalid number of PHYs\n");
of_node_put(child);
return -EINVAL; return -EINVAL;
} }
phy = devm_of_phy_optional_get(dev, child, NULL); phy = devm_of_phy_optional_get(dev, child, NULL);
exynos_ohci->phy[phy_number] = phy; exynos_ohci->phy[phy_number] = phy;
if (IS_ERR(phy)) { if (IS_ERR(phy))
of_node_put(child);
return PTR_ERR(phy); return PTR_ERR(phy);
}
} }
exynos_ohci->legacy_phy = true; exynos_ohci->legacy_phy = true;