Commit 13a097bd authored by Fabio Estevam's avatar Fabio Estevam Committed by David S. Miller

fec: Check the return value from clk_prepare_enable()

clk_prepare_enable() may fail, so let's check its return value and propagate it
in the case of error.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 79820e72
...@@ -2103,12 +2103,25 @@ fec_probe(struct platform_device *pdev) ...@@ -2103,12 +2103,25 @@ fec_probe(struct platform_device *pdev)
fep->bufdesc_ex = 0; fep->bufdesc_ex = 0;
} }
clk_prepare_enable(fep->clk_ahb); ret = clk_prepare_enable(fep->clk_ahb);
clk_prepare_enable(fep->clk_ipg); if (ret)
if (fep->clk_enet_out) goto failed_clk;
clk_prepare_enable(fep->clk_enet_out);
if (fep->clk_ptp) ret = clk_prepare_enable(fep->clk_ipg);
clk_prepare_enable(fep->clk_ptp); if (ret)
goto failed_clk_ipg;
if (fep->clk_enet_out) {
ret = clk_prepare_enable(fep->clk_enet_out);
if (ret)
goto failed_clk_enet_out;
}
if (fep->clk_ptp) {
ret = clk_prepare_enable(fep->clk_ptp);
if (ret)
goto failed_clk_ptp;
}
fep->reg_phy = devm_regulator_get(&pdev->dev, "phy"); fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
if (!IS_ERR(fep->reg_phy)) { if (!IS_ERR(fep->reg_phy)) {
...@@ -2181,9 +2194,12 @@ fec_probe(struct platform_device *pdev) ...@@ -2181,9 +2194,12 @@ fec_probe(struct platform_device *pdev)
failed_regulator: failed_regulator:
if (fep->clk_ptp) if (fep->clk_ptp)
clk_disable_unprepare(fep->clk_ptp); clk_disable_unprepare(fep->clk_ptp);
failed_clk_ptp:
if (fep->clk_enet_out) if (fep->clk_enet_out)
clk_disable_unprepare(fep->clk_enet_out); clk_disable_unprepare(fep->clk_enet_out);
failed_clk_enet_out:
clk_disable_unprepare(fep->clk_ipg); clk_disable_unprepare(fep->clk_ipg);
failed_clk_ipg:
clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_ahb);
failed_clk: failed_clk:
failed_ioremap: failed_ioremap:
...@@ -2260,18 +2276,44 @@ fec_resume(struct device *dev) ...@@ -2260,18 +2276,44 @@ fec_resume(struct device *dev)
return ret; return ret;
} }
clk_prepare_enable(fep->clk_ahb); ret = clk_prepare_enable(fep->clk_ahb);
clk_prepare_enable(fep->clk_ipg); if (ret)
if (fep->clk_enet_out) goto failed_clk_ahb;
clk_prepare_enable(fep->clk_enet_out);
if (fep->clk_ptp) ret = clk_prepare_enable(fep->clk_ipg);
clk_prepare_enable(fep->clk_ptp); if (ret)
goto failed_clk_ipg;
if (fep->clk_enet_out) {
ret = clk_prepare_enable(fep->clk_enet_out);
if (ret)
goto failed_clk_enet_out;
}
if (fep->clk_ptp) {
ret = clk_prepare_enable(fep->clk_ptp);
if (ret)
goto failed_clk_ptp;
}
if (netif_running(ndev)) { if (netif_running(ndev)) {
fec_restart(ndev, fep->full_duplex); fec_restart(ndev, fep->full_duplex);
netif_device_attach(ndev); netif_device_attach(ndev);
} }
return 0; return 0;
failed_clk_ptp:
if (fep->clk_enet_out)
clk_disable_unprepare(fep->clk_enet_out);
failed_clk_enet_out:
clk_disable_unprepare(fep->clk_ipg);
failed_clk_ipg:
clk_disable_unprepare(fep->clk_ahb);
failed_clk_ahb:
if (fep->reg_phy)
regulator_disable(fep->reg_phy);
return ret;
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment