Skip to content

Commit a7f1dbf

Browse files
krzkvinodkoul
authored andcommitted
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: Krzysztof Kozlowski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent e33525d commit a7f1dbf

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

drivers/phy/broadcom/phy-brcm-sata.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,11 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
751751
{
752752
const char *rxaeq_mode;
753753
struct device *dev = &pdev->dev;
754-
struct device_node *dn = dev->of_node, *child;
754+
struct device_node *dn = dev->of_node;
755755
const struct of_device_id *of_id;
756756
struct brcm_sata_phy *priv;
757757
struct phy_provider *provider;
758-
int ret, count = 0;
758+
int count = 0;
759759

760760
if (of_get_child_count(dn) == 0)
761761
return -ENODEV;
@@ -782,26 +782,23 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
782782
return PTR_ERR(priv->ctrl_base);
783783
}
784784

785-
for_each_available_child_of_node(dn, child) {
785+
for_each_available_child_of_node_scoped(dn, child) {
786786
unsigned int id;
787787
struct brcm_sata_port *port;
788788

789789
if (of_property_read_u32(child, "reg", &id)) {
790790
dev_err(dev, "missing reg property in node %pOFn\n",
791791
child);
792-
ret = -EINVAL;
793-
goto put_child;
792+
return -EINVAL;
794793
}
795794

796795
if (id >= MAX_PORTS) {
797796
dev_err(dev, "invalid reg: %u\n", id);
798-
ret = -EINVAL;
799-
goto put_child;
797+
return -EINVAL;
800798
}
801799
if (priv->phys[id].phy) {
802800
dev_err(dev, "already registered port %u\n", id);
803-
ret = -EINVAL;
804-
goto put_child;
801+
return -EINVAL;
805802
}
806803

807804
port = &priv->phys[id];
@@ -822,8 +819,7 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
822819
port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc");
823820
if (IS_ERR(port->phy)) {
824821
dev_err(dev, "failed to create PHY\n");
825-
ret = PTR_ERR(port->phy);
826-
goto put_child;
822+
return PTR_ERR(port->phy);
827823
}
828824

829825
phy_set_drvdata(port->phy, port);
@@ -839,9 +835,6 @@ static int brcm_sata_phy_probe(struct platform_device *pdev)
839835
dev_info(dev, "registered %d port(s)\n", count);
840836

841837
return 0;
842-
put_child:
843-
of_node_put(child);
844-
return ret;
845838
}
846839

847840
static struct platform_driver brcm_sata_phy_driver = {

0 commit comments

Comments
 (0)