Skip to content

Commit e33525d

Browse files
krzkvinodkoul
authored andcommitted
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 <[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 b48baf6 commit e33525d

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/phy/broadcom/phy-bcm-cygnus-pcie.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ static const struct phy_ops cygnus_pcie_phy_ops = {
113113
static int cygnus_pcie_phy_probe(struct platform_device *pdev)
114114
{
115115
struct device *dev = &pdev->dev;
116-
struct device_node *node = dev->of_node, *child;
116+
struct device_node *node = dev->of_node;
117117
struct cygnus_pcie_phy_core *core;
118118
struct phy_provider *provider;
119119
unsigned cnt = 0;
120-
int ret;
121120

122121
if (of_get_child_count(node) == 0) {
123122
dev_err(dev, "PHY no child node\n");
@@ -136,35 +135,31 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
136135

137136
mutex_init(&core->lock);
138137

139-
for_each_available_child_of_node(node, child) {
138+
for_each_available_child_of_node_scoped(node, child) {
140139
unsigned int id;
141140
struct cygnus_pcie_phy *p;
142141

143142
if (of_property_read_u32(child, "reg", &id)) {
144143
dev_err(dev, "missing reg property for %pOFn\n",
145144
child);
146-
ret = -EINVAL;
147-
goto put_child;
145+
return -EINVAL;
148146
}
149147

150148
if (id >= MAX_NUM_PHYS) {
151149
dev_err(dev, "invalid PHY id: %u\n", id);
152-
ret = -EINVAL;
153-
goto put_child;
150+
return -EINVAL;
154151
}
155152

156153
if (core->phys[id].phy) {
157154
dev_err(dev, "duplicated PHY id: %u\n", id);
158-
ret = -EINVAL;
159-
goto put_child;
155+
return -EINVAL;
160156
}
161157

162158
p = &core->phys[id];
163159
p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops);
164160
if (IS_ERR(p->phy)) {
165161
dev_err(dev, "failed to create PHY\n");
166-
ret = PTR_ERR(p->phy);
167-
goto put_child;
162+
return PTR_ERR(p->phy);
168163
}
169164

170165
p->core = core;
@@ -184,9 +179,6 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
184179
dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt);
185180

186181
return 0;
187-
put_child:
188-
of_node_put(child);
189-
return ret;
190182
}
191183

192184
static const struct of_device_id cygnus_pcie_phy_match_table[] = {

0 commit comments

Comments
 (0)