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

phy: broadcom: brcm-sata: 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-2-5b4d82582644@linaro.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent e33525de
...@@ -751,11 +751,11 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) ...@@ -751,11 +751,11 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
{ {
const char *rxaeq_mode; const char *rxaeq_mode;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *dn = dev->of_node, *child; struct device_node *dn = dev->of_node;
const struct of_device_id *of_id; const struct of_device_id *of_id;
struct brcm_sata_phy *priv; struct brcm_sata_phy *priv;
struct phy_provider *provider; struct phy_provider *provider;
int ret, count = 0; int count = 0;
if (of_get_child_count(dn) == 0) if (of_get_child_count(dn) == 0)
return -ENODEV; return -ENODEV;
...@@ -782,26 +782,23 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) ...@@ -782,26 +782,23 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
return PTR_ERR(priv->ctrl_base); return PTR_ERR(priv->ctrl_base);
} }
for_each_available_child_of_node(dn, child) { for_each_available_child_of_node_scoped(dn, child) {
unsigned int id; unsigned int id;
struct brcm_sata_port *port; struct brcm_sata_port *port;
if (of_property_read_u32(child, "reg", &id)) { if (of_property_read_u32(child, "reg", &id)) {
dev_err(dev, "missing reg property in node %pOFn\n", dev_err(dev, "missing reg property in node %pOFn\n",
child); child);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
if (id >= MAX_PORTS) { if (id >= MAX_PORTS) {
dev_err(dev, "invalid reg: %u\n", id); dev_err(dev, "invalid reg: %u\n", id);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
if (priv->phys[id].phy) { if (priv->phys[id].phy) {
dev_err(dev, "already registered port %u\n", id); dev_err(dev, "already registered port %u\n", id);
ret = -EINVAL; return -EINVAL;
goto put_child;
} }
port = &priv->phys[id]; port = &priv->phys[id];
...@@ -822,8 +819,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) ...@@ -822,8 +819,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc");
if (IS_ERR(port->phy)) { if (IS_ERR(port->phy)) {
dev_err(dev, "failed to create PHY\n"); dev_err(dev, "failed to create PHY\n");
ret = PTR_ERR(port->phy); return PTR_ERR(port->phy);
goto put_child;
} }
phy_set_drvdata(port->phy, port); phy_set_drvdata(port->phy, port);
...@@ -839,9 +835,6 @@ static int brcm_sata_phy_probe(struct platform_device *pdev) ...@@ -839,9 +835,6 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
dev_info(dev, "registered %d port(s)\n", count); dev_info(dev, "registered %d port(s)\n", count);
return 0; return 0;
put_child:
of_node_put(child);
return ret;
} }
static struct platform_driver brcm_sata_phy_driver = { static struct platform_driver brcm_sata_phy_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