Merge tag 'pci-v4.20-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaa...
[sfrench/cifs-2.6.git] / drivers / pci / controller / pcie-cadence.c
index 975bcdd6b5c0a73e0c75a947574c0b6b9b774e10..cd795f6fc1e231521a3dca7e0da8443839ff39bc 100644 (file)
@@ -190,14 +190,16 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
 
        for (i = 0; i < phy_count; i++) {
                of_property_read_string_index(np, "phy-names", i, &name);
-               phy[i] = devm_phy_optional_get(dev, name);
-               if (IS_ERR(phy))
-                       return PTR_ERR(phy);
-
+               phy[i] = devm_phy_get(dev, name);
+               if (IS_ERR(phy[i])) {
+                       ret = PTR_ERR(phy[i]);
+                       goto err_phy;
+               }
                link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
                if (!link[i]) {
+                       devm_phy_put(dev, phy[i]);
                        ret = -EINVAL;
-                       goto err_link;
+                       goto err_phy;
                }
        }
 
@@ -207,13 +209,15 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
 
        ret =  cdns_pcie_enable_phy(pcie);
        if (ret)
-               goto err_link;
+               goto err_phy;
 
        return 0;
 
-err_link:
-       while (--i >= 0)
+err_phy:
+       while (--i >= 0) {
                device_link_del(link[i]);
+               devm_phy_put(dev, phy[i]);
+       }
 
        return ret;
 }