drivers: net: xgene: Check for IS_ERR rather than NULL for clock.
authorSuman Tripathi <stripathi@apm.com>
Tue, 23 Jun 2015 09:17:17 +0000 (14:47 +0530)
committerDavid S. Miller <davem@davemloft.net>
Tue, 23 Jun 2015 14:19:21 +0000 (07:19 -0700)
This patches fixes the code to check for IS_ERR rather
than NULL for clock interface.

Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: Suman Tripathi <stripathi@apm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c

index 8ff736d5971cbb357e49fc9f096b414ab5266854..a626c4315a89b92560e96532ba1abeeedea27e99 100644 (file)
@@ -610,7 +610,7 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
        if (!xgene_ring_mgr_init(pdata))
                return -ENODEV;
 
-       if (pdata->clk) {
+       if (!IS_ERR(pdata->clk)) {
                clk_prepare_enable(pdata->clk);
                clk_disable_unprepare(pdata->clk);
                clk_prepare_enable(pdata->clk);
@@ -629,7 +629,8 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 
 static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
 {
-       clk_disable_unprepare(pdata->clk);
+       if (!IS_ERR(pdata->clk))
+               clk_disable_unprepare(pdata->clk);
 }
 
 static int xgene_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
index 6c4e7ac9226f7f7239dcd3005772deb4fa5bd67b..b334f279ce8dee064c94ea215cb90f17ae63c133 100644 (file)
@@ -1036,7 +1036,7 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
        pdata->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(pdata->clk)) {
                /* Firmware may have set up the clock already. */
-               pdata->clk = NULL;
+               dev_info(dev, "clocks have been setup already\n");
        }
 
        if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
index ff240b3cb2b877cf968fa80fcb933eb6ddfc89ac..05b817e56fdeb2637413b6ae199301c1797851aa 100644 (file)
@@ -334,9 +334,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p)
        if (!xgene_ring_mgr_init(p))
                return -ENODEV;
 
-       clk_prepare_enable(p->clk);
-       clk_disable_unprepare(p->clk);
-       clk_prepare_enable(p->clk);
+       if (!IS_ERR(p->clk)) {
+               clk_prepare_enable(p->clk);
+               clk_disable_unprepare(p->clk);
+               clk_prepare_enable(p->clk);
+       }
 
        xgene_enet_ecc_init(p);
        xgene_enet_config_ring_if_assoc(p);
@@ -369,7 +371,8 @@ static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p,
 
 static void xgene_enet_shutdown(struct xgene_enet_pdata *p)
 {
-       clk_disable_unprepare(p->clk);
+       if (!IS_ERR(p->clk))
+               clk_disable_unprepare(p->clk);
 }
 
 static void xgene_enet_link_state(struct work_struct *work)
index 27ba2fe3fca61888d6267eddfc3c9844e2140454..05edb847cf26161b4fdce76002b3acaf9c1807e4 100644 (file)
@@ -256,9 +256,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
        if (!xgene_ring_mgr_init(pdata))
                return -ENODEV;
 
-       clk_prepare_enable(pdata->clk);
-       clk_disable_unprepare(pdata->clk);
-       clk_prepare_enable(pdata->clk);
+       if (!IS_ERR(pdata->clk)) {
+               clk_prepare_enable(pdata->clk);
+               clk_disable_unprepare(pdata->clk);
+               clk_prepare_enable(pdata->clk);
+       }
 
        xgene_enet_ecc_init(pdata);
        xgene_enet_config_ring_if_assoc(pdata);
@@ -285,7 +287,8 @@ static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata,
 
 static void xgene_enet_shutdown(struct xgene_enet_pdata *pdata)
 {
-       clk_disable_unprepare(pdata->clk);
+       if (!IS_ERR(pdata->clk))
+               clk_disable_unprepare(pdata->clk);
 }
 
 static void xgene_enet_link_state(struct work_struct *work)