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

phy: broadcom: bcm-cygnus-pcie: 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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20240826-phy-of-node-scope-v1-1-5b4d82582644@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent b48baf69
...@@ -113,11 +113,10 @@ static const struct phy_ops cygnus_pcie_phy_ops = { ...@@ -113,11 +113,10 @@ static const struct phy_ops cygnus_pcie_phy_ops = {
static int cygnus_pcie_phy_probe(struct platform_device *pdev) static int cygnus_pcie_phy_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node, *child; struct device_node *node = dev->of_node;
struct cygnus_pcie_phy_core *core; struct cygnus_pcie_phy_core *core;
struct phy_provider *provider; struct phy_provider *provider;
unsigned cnt = 0; unsigned cnt = 0;
int ret;
if (of_get_child_count(node) == 0) { if (of_get_child_count(node) == 0) {
dev_err(dev, "PHY no child node\n"); dev_err(dev, "PHY no child node\n");
...@@ -136,35 +135,31 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) ...@@ -136,35 +135,31 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
mutex_init(&core->lock); mutex_init(&core->lock);
for_each_available_child_of_node(node, child) { for_each_available_child_of_node_scoped(node, child) {
unsigned int id; unsigned int id;
struct cygnus_pcie_phy *p; struct cygnus_pcie_phy *p;
if (of_property_read_u32(child, "reg", &id)) { if (of_property_read_u32(child, "reg", &id)) {
dev_err(dev, "missing reg property for %pOFn\n", dev_err(dev, "missing reg property for %pOFn\n",
child); child);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
if (id >= MAX_NUM_PHYS) { if (id >= MAX_NUM_PHYS) {
dev_err(dev, "invalid PHY id: %u\n", id); dev_err(dev, "invalid PHY id: %u\n", id);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
if (core->phys[id].phy) { if (core->phys[id].phy) {
dev_err(dev, "duplicated PHY id: %u\n", id); dev_err(dev, "duplicated PHY id: %u\n", id);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
p = &core->phys[id]; p = &core->phys[id];
p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops);
if (IS_ERR(p->phy)) { if (IS_ERR(p->phy)) {
dev_err(dev, "failed to create PHY\n"); dev_err(dev, "failed to create PHY\n");
ret = PTR_ERR(p->phy); return PTR_ERR(p->phy);
goto put_child;
} }
p->core = core; p->core = core;
...@@ -184,9 +179,6 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev) ...@@ -184,9 +179,6 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt);
return 0; return 0;
put_child:
of_node_put(child);
return ret;
} }
static const struct of_device_id cygnus_pcie_phy_match_table[] = { static const struct of_device_id cygnus_pcie_phy_match_table[] = {
......
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