Skip to content

Commit 93cab07

Browse files
krzkvinodkoul
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 612f9fc commit 93cab07

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/phy/hisilicon/phy-hisi-inno-usb2.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
138138
struct device_node *np = dev->of_node;
139139
struct hisi_inno_phy_priv *priv;
140140
struct phy_provider *provider;
141-
struct device_node *child;
142141
int i = 0;
143142
int ret;
144143

@@ -162,32 +161,27 @@ static int hisi_inno_phy_probe(struct platform_device *pdev)
162161

163162
priv->type = (uintptr_t) of_device_get_match_data(dev);
164163

165-
for_each_child_of_node(np, child) {
164+
for_each_child_of_node_scoped(np, child) {
166165
struct reset_control *rst;
167166
struct phy *phy;
168167

169168
rst = of_reset_control_get_exclusive(child, NULL);
170-
if (IS_ERR(rst)) {
171-
of_node_put(child);
169+
if (IS_ERR(rst))
172170
return PTR_ERR(rst);
173-
}
174171

175172
priv->ports[i].utmi_rst = rst;
176173
priv->ports[i].priv = priv;
177174

178175
phy = devm_phy_create(dev, child, &hisi_inno_phy_ops);
179-
if (IS_ERR(phy)) {
180-
of_node_put(child);
176+
if (IS_ERR(phy))
181177
return PTR_ERR(phy);
182-
}
183178

184179
phy_set_bus_width(phy, 8);
185180
phy_set_drvdata(phy, &priv->ports[i]);
186181
i++;
187182

188183
if (i >= INNO_PHY_PORT_NUM) {
189184
dev_warn(dev, "Support %d ports in maximum\n", i);
190-
of_node_put(child);
191185
break;
192186
}
193187
}

0 commit comments

Comments
 (0)