net: bcmgenet: abort suspend on error
[linux-2.6-microblaze.git] / drivers / net / ethernet / broadcom / genet / bcmgenet.c
index 2d6f090..983245c 100644 (file)
@@ -1169,7 +1169,7 @@ static int bcmgenet_power_down(struct bcmgenet_priv *priv,
                break;
        }
 
-       return 0;
+       return ret;
 }
 
 static void bcmgenet_power_up(struct bcmgenet_priv *priv,
@@ -3612,36 +3612,6 @@ static int bcmgenet_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-static int bcmgenet_suspend(struct device *d)
-{
-       struct net_device *dev = dev_get_drvdata(d);
-       struct bcmgenet_priv *priv = netdev_priv(dev);
-       int ret = 0;
-
-       if (!netif_running(dev))
-               return 0;
-
-       netif_device_detach(dev);
-
-       bcmgenet_netif_stop(dev);
-
-       if (!device_may_wakeup(d))
-               phy_suspend(dev->phydev);
-
-       /* Prepare the device for Wake-on-LAN and switch to the slow clock */
-       if (device_may_wakeup(d) && priv->wolopts) {
-               ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC);
-               clk_prepare_enable(priv->clk_wol);
-       } else if (priv->internal_phy) {
-               ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
-       }
-
-       /* Turn off the clocks */
-       clk_disable_unprepare(priv->clk);
-
-       return ret;
-}
-
 static int bcmgenet_resume(struct device *d)
 {
        struct net_device *dev = dev_get_drvdata(d);
@@ -3719,6 +3689,39 @@ out_clk_disable:
        clk_disable_unprepare(priv->clk);
        return ret;
 }
+
+static int bcmgenet_suspend(struct device *d)
+{
+       struct net_device *dev = dev_get_drvdata(d);
+       struct bcmgenet_priv *priv = netdev_priv(dev);
+       int ret = 0;
+
+       if (!netif_running(dev))
+               return 0;
+
+       netif_device_detach(dev);
+
+       bcmgenet_netif_stop(dev);
+
+       if (!device_may_wakeup(d))
+               phy_suspend(dev->phydev);
+
+       /* Prepare the device for Wake-on-LAN and switch to the slow clock */
+       if (device_may_wakeup(d) && priv->wolopts) {
+               ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC);
+               clk_prepare_enable(priv->clk_wol);
+       } else if (priv->internal_phy) {
+               ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
+       }
+
+       /* Turn off the clocks */
+       clk_disable_unprepare(priv->clk);
+
+       if (ret)
+               bcmgenet_resume(d);
+
+       return ret;
+}
 #endif /* CONFIG_PM_SLEEP */
 
 static SIMPLE_DEV_PM_OPS(bcmgenet_pm_ops, bcmgenet_suspend, bcmgenet_resume);