From 3722ba8322c869171910d9ac1befc96a72f11858 Mon Sep 17 00:00:00 2001 From: Soren Brinkmann Date: Mon, 3 Sep 2012 07:36:26 -0700 Subject: [PATCH] Xilinx: ARM: xemacps: Enable clocks before accessing HW This patch fixes an issue where hardware registers may be accessed before the device clocks are enabled. Also, error handling is improved in the questionable code section. Signed-off-by: Soren Brinkmann --- drivers/net/ethernet/xilinx/xilinx_emacps.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_emacps.c b/drivers/net/ethernet/xilinx/xilinx_emacps.c index 8eeb2ac9691..21456bde98f 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emacps.c +++ b/drivers/net/ethernet/xilinx/xilinx_emacps.c @@ -2221,15 +2221,19 @@ static int xemacps_open(struct net_device *ndev) return rc; } + rc = pm_runtime_get(&lp->pdev->dev); + if (rc < 0) { + pr_err("%s pm_runtime_get() failed, rc %d\n", ndev->name, rc); + goto err_free_rings; + } + rc = xemacps_setup_ring(lp); if (rc) { printk(KERN_ERR "%s Unable to setup BD rings, rc %d\n", ndev->name, rc); - return rc; + goto err_pm_put; } - pm_runtime_get(&lp->pdev->dev); - xemacps_init_hw(lp); napi_enable(&lp->napi); rc = xemacps_mii_probe(ndev); @@ -2240,8 +2244,8 @@ static int xemacps_open(struct net_device *ndev) kfree(lp->mii_bus->irq); mdiobus_free(lp->mii_bus); } - pm_runtime_put(&lp->pdev->dev); - return -ENXIO; + rc = -ENXIO; + goto err_pm_put; } netif_carrier_on(ndev); @@ -2249,6 +2253,13 @@ static int xemacps_open(struct net_device *ndev) netif_start_queue(ndev); return 0; + +err_pm_put: + pm_runtime_put(&lp->pdev->dev); +err_free_rings: + xemacps_descriptor_free(lp); + + return rc; } /** -- 2.11.4.GIT