aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/phy/phy-bcm-cygnus-pcie.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/phy/phy-bcm-cygnus-pcie.c b/drivers/phy/phy-bcm-cygnus-pcie.c
index 7ad72b7d2b98..082c03f6438f 100644
--- a/drivers/phy/phy-bcm-cygnus-pcie.c
+++ b/drivers/phy/phy-bcm-cygnus-pcie.c
@@ -128,6 +128,7 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
128 struct phy_provider *provider; 128 struct phy_provider *provider;
129 struct resource *res; 129 struct resource *res;
130 unsigned cnt = 0; 130 unsigned cnt = 0;
131 int ret;
131 132
132 if (of_get_child_count(node) == 0) { 133 if (of_get_child_count(node) == 0) {
133 dev_err(dev, "PHY no child node\n"); 134 dev_err(dev, "PHY no child node\n");
@@ -154,24 +155,28 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
154 if (of_property_read_u32(child, "reg", &id)) { 155 if (of_property_read_u32(child, "reg", &id)) {
155 dev_err(dev, "missing reg property for %s\n", 156 dev_err(dev, "missing reg property for %s\n",
156 child->name); 157 child->name);
157 return -EINVAL; 158 ret = -EINVAL;
159 goto put_child;
158 } 160 }
159 161
160 if (id >= MAX_NUM_PHYS) { 162 if (id >= MAX_NUM_PHYS) {
161 dev_err(dev, "invalid PHY id: %u\n", id); 163 dev_err(dev, "invalid PHY id: %u\n", id);
162 return -EINVAL; 164 ret = -EINVAL;
165 goto put_child;
163 } 166 }
164 167
165 if (core->phys[id].phy) { 168 if (core->phys[id].phy) {
166 dev_err(dev, "duplicated PHY id: %u\n", id); 169 dev_err(dev, "duplicated PHY id: %u\n", id);
167 return -EINVAL; 170 ret = -EINVAL;
171 goto put_child;
168 } 172 }
169 173
170 p = &core->phys[id]; 174 p = &core->phys[id];
171 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); 175 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops);
172 if (IS_ERR(p->phy)) { 176 if (IS_ERR(p->phy)) {
173 dev_err(dev, "failed to create PHY\n"); 177 dev_err(dev, "failed to create PHY\n");
174 return PTR_ERR(p->phy); 178 ret = PTR_ERR(p->phy);
179 goto put_child;
175 } 180 }
176 181
177 p->core = core; 182 p->core = core;
@@ -191,6 +196,9 @@ static int cygnus_pcie_phy_probe(struct platform_device *pdev)
191 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); 196 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt);
192 197
193 return 0; 198 return 0;
199put_child:
200 of_node_put(child);
201 return ret;
194} 202}
195 203
196static const struct of_device_id cygnus_pcie_phy_match_table[] = { 204static const struct of_device_id cygnus_pcie_phy_match_table[] = {