提交 f7087a37 编写于 作者: A Alan Douglas 提交者: Greg Kroah-Hartman

PCI: cadence: Correct probe behaviour when failing to get PHY

[ Upstream commit aa77e55d48124d0d78456eabf872fffb5decdbe1 ]

Test the correct value to see whether the PHY get failed.

Use devm_phy_get() instead of devm_phy_optional_get(), since it is
only called if phy name is given in devicetree and so should exist.
If failure when getting or linking PHY, put any PHYs which were
already got and unlink them.

Fixes: dfb80534 ("PCI: cadence: Add generic PHY support to host and EP drivers")
Reported-by: NColin King <colin.king@canonical.com>
Signed-off-by: NAlan Douglas <adouglas@cadence.com>
Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 6596e997
...@@ -190,14 +190,16 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) ...@@ -190,14 +190,16 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
for (i = 0; i < phy_count; i++) { for (i = 0; i < phy_count; i++) {
of_property_read_string_index(np, "phy-names", i, &name); of_property_read_string_index(np, "phy-names", i, &name);
phy[i] = devm_phy_optional_get(dev, name); phy[i] = devm_phy_get(dev, name);
if (IS_ERR(phy)) if (IS_ERR(phy[i])) {
return PTR_ERR(phy); ret = PTR_ERR(phy[i]);
goto err_phy;
}
link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS);
if (!link[i]) { if (!link[i]) {
devm_phy_put(dev, phy[i]);
ret = -EINVAL; ret = -EINVAL;
goto err_link; goto err_phy;
} }
} }
...@@ -207,13 +209,15 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie) ...@@ -207,13 +209,15 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
ret = cdns_pcie_enable_phy(pcie); ret = cdns_pcie_enable_phy(pcie);
if (ret) if (ret)
goto err_link; goto err_phy;
return 0; return 0;
err_link: err_phy:
while (--i >= 0) while (--i >= 0) {
device_link_del(link[i]); device_link_del(link[i]);
devm_phy_put(dev, phy[i]);
}
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册