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

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: 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-1-5b4d82582644@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
e33525de b48baf69

+6 -14
+6 -14
drivers/phy/broadcom/phy-bcm-cygnus-pcie.c
··· 113 113 static int cygnus_pcie_phy_probe(struct platform_device *pdev) 114 114 { 115 115 struct device *dev = &pdev->dev; 116 - struct device_node *node = dev->of_node, *child; 116 + struct device_node *node = dev->of_node; 117 117 struct cygnus_pcie_phy_core *core; 118 118 struct phy_provider *provider; 119 119 unsigned cnt = 0; 120 - int ret; 121 120 122 121 if (of_get_child_count(node) == 0) { 123 122 dev_err(dev, "PHY no child node\n"); ··· 135 136 136 137 mutex_init(&core->lock); 137 138 138 - for_each_available_child_of_node(node, child) { 139 + for_each_available_child_of_node_scoped(node, child) { 139 140 unsigned int id; 140 141 struct cygnus_pcie_phy *p; 141 142 142 143 if (of_property_read_u32(child, "reg", &id)) { 143 144 dev_err(dev, "missing reg property for %pOFn\n", 144 145 child); 145 - ret = -EINVAL; 146 - goto put_child; 146 + return -EINVAL; 147 147 } 148 148 149 149 if (id >= MAX_NUM_PHYS) { 150 150 dev_err(dev, "invalid PHY id: %u\n", id); 151 - ret = -EINVAL; 152 - goto put_child; 151 + return -EINVAL; 153 152 } 154 153 155 154 if (core->phys[id].phy) { 156 155 dev_err(dev, "duplicated PHY id: %u\n", id); 157 - ret = -EINVAL; 158 - goto put_child; 156 + return -EINVAL; 159 157 } 160 158 161 159 p = &core->phys[id]; 162 160 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); 163 161 if (IS_ERR(p->phy)) { 164 162 dev_err(dev, "failed to create PHY\n"); 165 - ret = PTR_ERR(p->phy); 166 - goto put_child; 163 + return PTR_ERR(p->phy); 167 164 } 168 165 169 166 p->core = core; ··· 179 184 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); 180 185 181 186 return 0; 182 - put_child: 183 - of_node_put(child); 184 - return ret; 185 187 } 186 188 187 189 static const struct of_device_id cygnus_pcie_phy_match_table[] = {