From 92c11b3278f0e8d7429f8794f62ae726ea6792a8 Mon Sep 17 00:00:00 2001 From: Cristian Sovaiala Date: Fri, 18 Apr 2014 16:01:25 +0300 Subject: dpaa_eth: Cleaning up port suspend/resume error paths Add goto labels and relevant error messages when RX/TX port suspend/resume or set WoL fail. Returning a != 0 value from suspend callback we trigger a rollback of the suspend sequence. In resume callback, in case RX port resume fails we suspend the TX port and keep WoL disabled. Change-Id: I330249c06525785d7045c627dcf218d031028857 Signed-off-by: Cristian Sovaiala Reviewed-on: http://git.am.freescale.net:8181/11367 Tested-by: Review Code-CDREVIEW Reviewed-by: Bogdan Hamciuc Reviewed-by: Madalin-Cristian Bucur (cherry picked from commit 56956b78e098c2ae9166bfe93efaaac97758c0cf) Reviewed-on: http://git.am.freescale.net:8181/11437 Tested-by: Madalin-Cristian Bucur diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c index 862357a..3231725 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c @@ -124,22 +124,34 @@ static int dpaa_suspend_noirq(struct device *dev) mac_dev = priv->mac_dev; err = fm_port_suspend(mac_dev->port_dev[RX]); - if (err) - goto port_suspend_failed; + if (err) { + netdev_err(net_dev, "fm_port_suspend(RX) = %d\n", err); + goto rx_port_suspend_failed; + } err = fm_port_suspend(mac_dev->port_dev[TX]); - if (err) - err = fm_port_resume(mac_dev->port_dev[RX]); + if (err) { + netdev_err(net_dev, "fm_port_suspend(TX) = %d\n", err); + goto tx_port_suspend_failed; + } if (priv->wol & DPAA_WOL_MAGIC) { err = priv->mac_dev->set_wol(mac_dev->port_dev[RX], priv->mac_dev->get_mac_handle(mac_dev), true); - if (unlikely(err < 0)) + if (err) { netdev_err(net_dev, "set_wol() = %d\n", err); + goto set_wol_failed; + } } } -port_suspend_failed: + return 0; + +set_wol_failed: + fm_port_resume(mac_dev->port_dev[TX]); +tx_port_suspend_failed: + fm_port_resume(mac_dev->port_dev[RX]); +rx_port_suspend_failed: return err; } @@ -159,20 +171,31 @@ static int dpaa_resume_noirq(struct device *dev) if (priv->wol & DPAA_WOL_MAGIC) { err = priv->mac_dev->set_wol(mac_dev->port_dev[RX], priv->mac_dev->get_mac_handle(mac_dev), false); - if (unlikely(err < 0)) + if (err) { netdev_err(net_dev, "set_wol() = %d\n", err); + goto set_wol_failed; + } } err = fm_port_resume(mac_dev->port_dev[TX]); - if (err) - goto port_resume_failed; + if (err) { + netdev_err(net_dev, "fm_port_resume(TX) = %d\n", err); + goto tx_port_resume_failed; + } err = fm_port_resume(mac_dev->port_dev[RX]); - if (err) - err = fm_port_suspend(mac_dev->port_dev[TX]); + if (err) { + netdev_err(net_dev, "fm_port_resume(RX) = %d\n", err); + goto rx_port_resume_failed; + } } -port_resume_failed: + return 0; + +rx_port_resume_failed: + fm_port_suspend(mac_dev->port_dev[TX]); +tx_port_resume_failed: +set_wol_failed: return err; } -- cgit v0.10.2