1 From d0423d3e4fa7ae305729cb50369427f075ccb279 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Sat, 25 Feb 2017 12:41:28 +0100
4 Subject: [PATCH 1/6] bcm63xx_enet: correct clock usage
6 Check the return code of prepare_enable and change one last instance of
7 enable only to prepare_enable. Also properly disable and release the
8 clock in error paths and on remove for enetsw.
10 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
12 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++-------
13 1 file changed, 23 insertions(+), 8 deletions(-)
15 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
16 +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
17 @@ -1790,7 +1790,9 @@ static int bcm_enet_probe(struct platfor
18 ret = PTR_ERR(priv->mac_clk);
21 - clk_prepare_enable(priv->mac_clk);
22 + ret = clk_prepare_enable(priv->mac_clk);
24 + goto out_put_clk_mac;
26 /* initialize default and fetch platform data */
27 priv->rx_ring_size = BCMENET_DEF_RX_DESC;
28 @@ -1822,9 +1824,11 @@ static int bcm_enet_probe(struct platfor
29 if (IS_ERR(priv->phy_clk)) {
30 ret = PTR_ERR(priv->phy_clk);
32 - goto out_put_clk_mac;
33 + goto out_disable_clk_mac;
35 - clk_prepare_enable(priv->phy_clk);
36 + ret = clk_prepare_enable(priv->phy_clk);
38 + goto out_put_clk_phy;
41 /* do minimal hardware init to be able to probe mii bus */
42 @@ -1915,13 +1919,16 @@ out_free_mdio:
44 /* turn off mdc clock */
45 enet_writel(priv, 0, ENET_MIISC_REG);
46 - if (priv->phy_clk) {
48 clk_disable_unprepare(priv->phy_clk);
52 clk_put(priv->phy_clk);
57 clk_disable_unprepare(priv->mac_clk);
59 clk_put(priv->mac_clk);
62 @@ -2766,7 +2773,9 @@ static int bcm_enetsw_probe(struct platf
63 ret = PTR_ERR(priv->mac_clk);
66 - clk_enable(priv->mac_clk);
67 + ret = clk_prepare_enable(priv->mac_clk);
73 @@ -2787,7 +2796,7 @@ static int bcm_enetsw_probe(struct platf
75 ret = register_netdev(dev);
78 + goto out_disable_clk;
80 netif_carrier_off(dev);
81 platform_set_drvdata(pdev, dev);
82 @@ -2796,6 +2805,9 @@ static int bcm_enetsw_probe(struct platf
87 + clk_disable_unprepare(priv->mac_clk);
90 clk_put(priv->mac_clk);
92 @@ -2827,6 +2839,9 @@ static int bcm_enetsw_remove(struct plat
93 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
94 release_mem_region(res->start, resource_size(res));
96 + clk_disable_unprepare(priv->mac_clk);
97 + clk_put(priv->mac_clk);