Skip to content

Commit d271441

Browse files
krzkvinodkoul
authored andcommitted
phy: mediatek: tphy: Simplify with scoped for each OF child loop
Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 93cab07 commit d271441

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

drivers/phy/mediatek/phy-mtk-tphy.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,12 +1577,11 @@ static int mtk_tphy_probe(struct platform_device *pdev)
15771577
{
15781578
struct device *dev = &pdev->dev;
15791579
struct device_node *np = dev->of_node;
1580-
struct device_node *child_np;
15811580
struct phy_provider *provider;
15821581
struct resource *sif_res;
15831582
struct mtk_tphy *tphy;
15841583
struct resource res;
1585-
int port, retval;
1584+
int port;
15861585

15871586
tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL);
15881587
if (!tphy)
@@ -1623,40 +1622,36 @@ static int mtk_tphy_probe(struct platform_device *pdev)
16231622
}
16241623

16251624
port = 0;
1626-
for_each_child_of_node(np, child_np) {
1625+
for_each_child_of_node_scoped(np, child_np) {
16271626
struct mtk_phy_instance *instance;
16281627
struct clk_bulk_data *clks;
16291628
struct device *subdev;
16301629
struct phy *phy;
1630+
int retval;
16311631

16321632
instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
1633-
if (!instance) {
1634-
retval = -ENOMEM;
1635-
goto put_child;
1636-
}
1633+
if (!instance)
1634+
return -ENOMEM;
16371635

16381636
tphy->phys[port] = instance;
16391637

16401638
phy = devm_phy_create(dev, child_np, &mtk_tphy_ops);
16411639
if (IS_ERR(phy)) {
16421640
dev_err(dev, "failed to create phy\n");
1643-
retval = PTR_ERR(phy);
1644-
goto put_child;
1641+
return PTR_ERR(phy);
16451642
}
16461643

16471644
subdev = &phy->dev;
16481645
retval = of_address_to_resource(child_np, 0, &res);
16491646
if (retval) {
16501647
dev_err(subdev, "failed to get address resource(id-%d)\n",
16511648
port);
1652-
goto put_child;
1649+
return retval;
16531650
}
16541651

16551652
instance->port_base = devm_ioremap_resource(subdev, &res);
1656-
if (IS_ERR(instance->port_base)) {
1657-
retval = PTR_ERR(instance->port_base);
1658-
goto put_child;
1659-
}
1653+
if (IS_ERR(instance->port_base))
1654+
return PTR_ERR(instance->port_base);
16601655

16611656
instance->phy = phy;
16621657
instance->index = port;
@@ -1668,19 +1663,16 @@ static int mtk_tphy_probe(struct platform_device *pdev)
16681663
clks[1].id = "da_ref"; /* analog clock */
16691664
retval = devm_clk_bulk_get_optional(subdev, TPHY_CLKS_CNT, clks);
16701665
if (retval)
1671-
goto put_child;
1666+
return retval;
16721667

16731668
retval = phy_type_syscon_get(instance, child_np);
16741669
if (retval)
1675-
goto put_child;
1670+
return retval;
16761671
}
16771672

16781673
provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
16791674

16801675
return PTR_ERR_OR_ZERO(provider);
1681-
put_child:
1682-
of_node_put(child_np);
1683-
return retval;
16841676
}
16851677

16861678
static struct platform_driver mtk_tphy_driver = {

0 commit comments

Comments
 (0)