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

phy: hisilicon: usb2: Simplify with scoped for each OF child loop

Use scoped for_each_child_of_node_scoped() when iterating over device
nodes to make code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240826-phy-of-node-scope-v1-4-5b4d82582644@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Vinod Koul
93cab07a 612f9fcb

+3 -9
+3 -9
drivers/phy/hisilicon/phy-hisi-inno-usb2.c
··· 138 138 struct device_node *np = dev->of_node; 139 139 struct hisi_inno_phy_priv *priv; 140 140 struct phy_provider *provider; 141 - struct device_node *child; 142 141 int i = 0; 143 142 int ret; 144 143 ··· 161 162 162 163 priv->type = (uintptr_t) of_device_get_match_data(dev); 163 164 164 - for_each_child_of_node(np, child) { 165 + for_each_child_of_node_scoped(np, child) { 165 166 struct reset_control *rst; 166 167 struct phy *phy; 167 168 168 169 rst = of_reset_control_get_exclusive(child, NULL); 169 - if (IS_ERR(rst)) { 170 - of_node_put(child); 170 + if (IS_ERR(rst)) 171 171 return PTR_ERR(rst); 172 - } 173 172 174 173 priv->ports[i].utmi_rst = rst; 175 174 priv->ports[i].priv = priv; 176 175 177 176 phy = devm_phy_create(dev, child, &hisi_inno_phy_ops); 178 - if (IS_ERR(phy)) { 179 - of_node_put(child); 177 + if (IS_ERR(phy)) 180 178 return PTR_ERR(phy); 181 - } 182 179 183 180 phy_set_bus_width(phy, 8); 184 181 phy_set_drvdata(phy, &priv->ports[i]); ··· 182 187 183 188 if (i >= INNO_PHY_PORT_NUM) { 184 189 dev_warn(dev, "Support %d ports in maximum\n", i); 185 - of_node_put(child); 186 190 break; 187 191 } 188 192 }