Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <krzysztof.kozlowski@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20240826-phy-of-node-scope-v1-2-5b4d82582644@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
a7f1dbf4 e33525de

+7 -14
+7 -14
drivers/phy/broadcom/phy-brcm-sata.c
··· 751 751 { 752 752 const char *rxaeq_mode; 753 753 struct device *dev = &pdev->dev; 754 - struct device_node *dn = dev->of_node, *child; 754 + struct device_node *dn = dev->of_node; 755 755 const struct of_device_id *of_id; 756 756 struct brcm_sata_phy *priv; 757 757 struct phy_provider *provider; 758 - int ret, count = 0; 758 + int count = 0; 759 759 760 760 if (of_get_child_count(dn) == 0) 761 761 return -ENODEV; ··· 782 782 return PTR_ERR(priv->ctrl_base); 783 783 } 784 784 785 - for_each_available_child_of_node(dn, child) { 785 + for_each_available_child_of_node_scoped(dn, child) { 786 786 unsigned int id; 787 787 struct brcm_sata_port *port; 788 788 789 789 if (of_property_read_u32(child, "reg", &id)) { 790 790 dev_err(dev, "missing reg property in node %pOFn\n", 791 791 child); 792 - ret = -EINVAL; 793 - goto put_child; 792 + return -EINVAL; 794 793 } 795 794 796 795 if (id >= MAX_PORTS) { 797 796 dev_err(dev, "invalid reg: %u\n", id); 798 - ret = -EINVAL; 799 - goto put_child; 797 + return -EINVAL; 800 798 } 801 799 if (priv->phys[id].phy) { 802 800 dev_err(dev, "already registered port %u\n", id); 803 - ret = -EINVAL; 804 - goto put_child; 801 + return -EINVAL; 805 802 } 806 803 807 804 port = &priv->phys[id]; ··· 819 822 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); 820 823 if (IS_ERR(port->phy)) { 821 824 dev_err(dev, "failed to create PHY\n"); 822 - ret = PTR_ERR(port->phy); 823 - goto put_child; 825 + return PTR_ERR(port->phy); 824 826 } 825 827 826 828 phy_set_drvdata(port->phy, port); ··· 835 839 dev_info(dev, "registered %d port(s)\n", count); 836 840 837 841 return 0; 838 - put_child: 839 - of_node_put(child); 840 - return ret; 841 842 } 842 843 843 844 static struct platform_driver brcm_sata_phy_driver = {