Skip to content

Commit

Permalink
drivers: net: xgene: Check for IS_ERR rather than NULL for clock.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Suman Tripathi authored and David S. Miller committed Jun 23, 2015
1 parent 822e34a commit c2d33bd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit c2d33bd

Please sign in to comment.