aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2013-07-21 12:25:02 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-22 19:50:31 -0400
commit13a097bd35a15bbec00479adfb2ef5360e8eabef (patch)
tree94ee9e5d07875faf0b87c8f1456ee1ebfc7b6af0
parent79820e725f3ac5db694c49c75088d79fde78b671 (diff)
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: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c66
1 files changed, 54 insertions, 12 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 0a4ace782c1f..fc2cccd887ea 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2103,12 +2103,25 @@ fec_probe(struct platform_device *pdev)
2103 fep->bufdesc_ex = 0; 2103 fep->bufdesc_ex = 0;
2104 } 2104 }
2105 2105
2106 clk_prepare_enable(fep->clk_ahb); 2106 ret = clk_prepare_enable(fep->clk_ahb);
2107 clk_prepare_enable(fep->clk_ipg); 2107 if (ret)
2108 if (fep->clk_enet_out) 2108 goto failed_clk;
2109 clk_prepare_enable(fep->clk_enet_out); 2109
2110 if (fep->clk_ptp) 2110 ret = clk_prepare_enable(fep->clk_ipg);
2111 clk_prepare_enable(fep->clk_ptp); 2111 if (ret)
2112 goto failed_clk_ipg;
2113
2114 if (fep->clk_enet_out) {
2115 ret = clk_prepare_enable(fep->clk_enet_out);
2116 if (ret)
2117 goto failed_clk_enet_out;
2118 }
2119
2120 if (fep->clk_ptp) {
2121 ret = clk_prepare_enable(fep->clk_ptp);
2122 if (ret)
2123 goto failed_clk_ptp;
2124 }
2112 2125
2113 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy"); 2126 fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
2114 if (!IS_ERR(fep->reg_phy)) { 2127 if (!IS_ERR(fep->reg_phy)) {
@@ -2181,9 +2194,12 @@ failed_init:
2181failed_regulator: 2194failed_regulator:
2182 if (fep->clk_ptp) 2195 if (fep->clk_ptp)
2183 clk_disable_unprepare(fep->clk_ptp); 2196 clk_disable_unprepare(fep->clk_ptp);
2197failed_clk_ptp:
2184 if (fep->clk_enet_out) 2198 if (fep->clk_enet_out)
2185 clk_disable_unprepare(fep->clk_enet_out); 2199 clk_disable_unprepare(fep->clk_enet_out);
2200failed_clk_enet_out:
2186 clk_disable_unprepare(fep->clk_ipg); 2201 clk_disable_unprepare(fep->clk_ipg);
2202failed_clk_ipg:
2187 clk_disable_unprepare(fep->clk_ahb); 2203 clk_disable_unprepare(fep->clk_ahb);
2188failed_clk: 2204failed_clk:
2189failed_ioremap: 2205failed_ioremap:
@@ -2260,18 +2276,44 @@ fec_resume(struct device *dev)
2260 return ret; 2276 return ret;
2261 } 2277 }
2262 2278
2263 clk_prepare_enable(fep->clk_ahb); 2279 ret = clk_prepare_enable(fep->clk_ahb);
2264 clk_prepare_enable(fep->clk_ipg); 2280 if (ret)
2265 if (fep->clk_enet_out) 2281 goto failed_clk_ahb;
2266 clk_prepare_enable(fep->clk_enet_out); 2282
2267 if (fep->clk_ptp) 2283 ret = clk_prepare_enable(fep->clk_ipg);
2268 clk_prepare_enable(fep->clk_ptp); 2284 if (ret)
2285 goto failed_clk_ipg;
2286
2287 if (fep->clk_enet_out) {
2288 ret = clk_prepare_enable(fep->clk_enet_out);
2289 if (ret)
2290 goto failed_clk_enet_out;
2291 }
2292
2293 if (fep->clk_ptp) {
2294 ret = clk_prepare_enable(fep->clk_ptp);
2295 if (ret)
2296 goto failed_clk_ptp;
2297 }
2298
2269 if (netif_running(ndev)) { 2299 if (netif_running(ndev)) {
2270 fec_restart(ndev, fep->full_duplex); 2300 fec_restart(ndev, fep->full_duplex);
2271 netif_device_attach(ndev); 2301 netif_device_attach(ndev);
2272 } 2302 }
2273 2303
2274 return 0; 2304 return 0;
2305
2306failed_clk_ptp:
2307 if (fep->clk_enet_out)
2308 clk_disable_unprepare(fep->clk_enet_out);
2309failed_clk_enet_out:
2310 clk_disable_unprepare(fep->clk_ipg);
2311failed_clk_ipg:
2312 clk_disable_unprepare(fep->clk_ahb);
2313failed_clk_ahb:
2314 if (fep->reg_phy)
2315 regulator_disable(fep->reg_phy);
2316 return ret;
2275} 2317}
2276#endif /* CONFIG_PM_SLEEP */ 2318#endif /* CONFIG_PM_SLEEP */
2277 2319