Commit d2714416 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Vinod Koul

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240826-phy-of-node-scope-v1-5-5b4d82582644@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 93cab07a
...@@ -1577,12 +1577,11 @@ static int mtk_tphy_probe(struct platform_device *pdev) ...@@ -1577,12 +1577,11 @@ static int mtk_tphy_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct device_node *child_np;
struct phy_provider *provider; struct phy_provider *provider;
struct resource *sif_res; struct resource *sif_res;
struct mtk_tphy *tphy; struct mtk_tphy *tphy;
struct resource res; struct resource res;
int port, retval; int port;
tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL); tphy = devm_kzalloc(dev, sizeof(*tphy), GFP_KERNEL);
if (!tphy) if (!tphy)
...@@ -1623,25 +1622,23 @@ static int mtk_tphy_probe(struct platform_device *pdev) ...@@ -1623,25 +1622,23 @@ static int mtk_tphy_probe(struct platform_device *pdev)
} }
port = 0; port = 0;
for_each_child_of_node(np, child_np) { for_each_child_of_node_scoped(np, child_np) {
struct mtk_phy_instance *instance; struct mtk_phy_instance *instance;
struct clk_bulk_data *clks; struct clk_bulk_data *clks;
struct device *subdev; struct device *subdev;
struct phy *phy; struct phy *phy;
int retval;
instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL);
if (!instance) { if (!instance)
retval = -ENOMEM; return -ENOMEM;
goto put_child;
}
tphy->phys[port] = instance; tphy->phys[port] = instance;
phy = devm_phy_create(dev, child_np, &mtk_tphy_ops); phy = devm_phy_create(dev, child_np, &mtk_tphy_ops);
if (IS_ERR(phy)) { if (IS_ERR(phy)) {
dev_err(dev, "failed to create phy\n"); dev_err(dev, "failed to create phy\n");
retval = PTR_ERR(phy); return PTR_ERR(phy);
goto put_child;
} }
subdev = &phy->dev; subdev = &phy->dev;
...@@ -1649,14 +1646,12 @@ static int mtk_tphy_probe(struct platform_device *pdev) ...@@ -1649,14 +1646,12 @@ static int mtk_tphy_probe(struct platform_device *pdev)
if (retval) { if (retval) {
dev_err(subdev, "failed to get address resource(id-%d)\n", dev_err(subdev, "failed to get address resource(id-%d)\n",
port); port);
goto put_child; return retval;
} }
instance->port_base = devm_ioremap_resource(subdev, &res); instance->port_base = devm_ioremap_resource(subdev, &res);
if (IS_ERR(instance->port_base)) { if (IS_ERR(instance->port_base))
retval = PTR_ERR(instance->port_base); return PTR_ERR(instance->port_base);
goto put_child;
}
instance->phy = phy; instance->phy = phy;
instance->index = port; instance->index = port;
...@@ -1668,19 +1663,16 @@ static int mtk_tphy_probe(struct platform_device *pdev) ...@@ -1668,19 +1663,16 @@ static int mtk_tphy_probe(struct platform_device *pdev)
clks[1].id = "da_ref"; /* analog clock */ clks[1].id = "da_ref"; /* analog clock */
retval = devm_clk_bulk_get_optional(subdev, TPHY_CLKS_CNT, clks); retval = devm_clk_bulk_get_optional(subdev, TPHY_CLKS_CNT, clks);
if (retval) if (retval)
goto put_child; return retval;
retval = phy_type_syscon_get(instance, child_np); retval = phy_type_syscon_get(instance, child_np);
if (retval) if (retval)
goto put_child; return retval;
} }
provider = devm_of_phy_provider_register(dev, mtk_phy_xlate); provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
return PTR_ERR_OR_ZERO(provider); return PTR_ERR_OR_ZERO(provider);
put_child:
of_node_put(child_np);
return retval;
} }
static struct platform_driver mtk_tphy_driver = { static struct platform_driver mtk_tphy_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment