mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/4] staging: et131x: Remove error path from suspend/resume code
@ 2011-10-07 21:52 Mark Einon
  2011-10-07 21:52 ` [PATCH 3/4] staging: et131x: Move pm calls from pci device to driver device Mark Einon
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Einon @ 2011-10-07 21:52 UTC (permalink / raw)
  To: gregkh; +Cc: romieu, rjw, devel, linux-kernel, Mark Einon

Removing an error path from et131x suspend/resume functions.

Also added a call to phy_stop() to complement the phy_start() call
during device start/stop routine.

Thanks to Francois Romieu <romieu@fr.zoreil.com> for pointing this out.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
 drivers/staging/et131x/et131x.h         |    2 +
 drivers/staging/et131x/et131x_initpci.c |   35 +++++++++-----------------
 drivers/staging/et131x/et131x_netdev.c  |   40 ++++++++++++++++++++++++-------
 3 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h
index c8f5ab1..e832234 100644
--- a/drivers/staging/et131x/et131x.h
+++ b/drivers/staging/et131x/et131x.h
@@ -85,6 +85,8 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter);
 /* et131x_netdev.c */
 int et131x_open(struct net_device *netdev);
 int et131x_close(struct net_device *netdev);
+void et131x_up(struct net_device *netdev);
+void et131x_down(struct net_device *netdev);
 struct net_device *et131x_device_alloc(void);
 void et131x_enable_txrx(struct net_device *netdev);
 void et131x_disable_txrx(struct net_device *netdev);
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index 9795310..95a1aff 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -874,14 +874,12 @@ static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 
-	if (!netif_running(netdev))
-		return 0;
-
-	et131x_close(netdev);
-	netif_device_detach(netdev);
-
-	pci_save_state(pdev);
-	pci_set_power_state(pdev, pci_choose_state(pdev, state));
+	if (netif_running(netdev)) {
+		netif_device_detach(netdev);
+		et131x_down(netdev);
+		pci_save_state(pdev);
+		pci_set_power_state(pdev, pci_choose_state(pdev, state));
+	}
 
 	return 0;
 }
@@ -889,24 +887,15 @@ static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 static int et131x_pci_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
-	int err = 0;
 
-	if (!netif_running(netdev))
-		return 0;
-
-	pci_set_power_state(pdev, PCI_D0);
-	pci_restore_state(pdev);
-
-	err = et131x_open(netdev);
-	if (err) {
-		dev_err(&pdev->dev, "Can't resume interface!\n");
-		goto out;
+	if (netif_running(netdev)) {
+		pci_set_power_state(pdev, PCI_D0);
+		pci_restore_state(pdev);
+		et131x_up(netdev);
+		netif_device_attach(netdev);
 	}
 
-	netif_device_attach(netdev);
-
-out:
-	return err;
+	return 0;
 }
 
 static struct pci_device_id et131x_pci_table[] __devinitdata = {
diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c
index 79127de..16373bb 100644
--- a/drivers/staging/et131x/et131x_netdev.c
+++ b/drivers/staging/et131x/et131x_netdev.c
@@ -178,6 +178,18 @@ void et131x_disable_txrx(struct net_device *netdev)
 }
 
 /**
+ * et131x_up - Bring up a device for use.
+ * @netdev: device to be opened
+ */
+void et131x_up(struct net_device *netdev)
+{
+	struct et131x_adapter *adapter = netdev_priv(netdev);
+
+	et131x_enable_txrx(netdev);
+	phy_start(adapter->phydev);
+}
+
+/**
  * et131x_open - Open the device for use.
  * @netdev: device to be opened
  *
@@ -205,13 +217,28 @@ int et131x_open(struct net_device *netdev)
 	}
 
 	adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE;
-	et131x_enable_txrx(netdev);
-	phy_start(adapter->phydev);
+
+	et131x_up(netdev);
 
 	return result;
 }
 
 /**
+ * et131x_down - Bring down the device
+ * @netdev: device to be broght down
+ */
+void et131x_down(struct net_device *netdev)
+{
+	struct et131x_adapter *adapter = netdev_priv(netdev);
+
+	/* Save the timestamp for the TX watchdog, prevent a timeout */
+	netdev->trans_start = jiffies;
+
+	phy_stop(adapter->phydev);
+	et131x_disable_txrx(netdev);
+}
+
+/**
  * et131x_close - Close the device
  * @netdev: device to be closed
  *
@@ -221,18 +248,13 @@ int et131x_close(struct net_device *netdev)
 {
 	struct et131x_adapter *adapter = netdev_priv(netdev);
 
-	/* Save the timestamp for the TX watchdog, prevent a timeout */
-	netdev->trans_start = jiffies;
-
-	et131x_disable_txrx(netdev);
+	et131x_down(netdev);
 
-	/* Deregistering ISR */
 	adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE;
 	free_irq(netdev->irq, netdev);
 
 	/* Stop the error timer */
-	del_timer_sync(&adapter->error_timer);
-	return 0;
+	return del_timer_sync(&adapter->error_timer);
 }
 
 /**
-- 
1.7.6.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 3/4] staging: et131x: Move pm calls from pci device to driver device
  2011-10-07 21:52 [PATCH 2/4] staging: et131x: Remove error path from suspend/resume code Mark Einon
@ 2011-10-07 21:52 ` Mark Einon
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Einon @ 2011-10-07 21:52 UTC (permalink / raw)
  To: gregkh; +Cc: romieu, rjw, devel, linux-kernel, Mark Einon

Move the pci driver suspend/resume calls up to the driver.pm ops
structure, as they are not pci device specific.

Thanks to Francois Romieu <romieu@fr.zoreil.com> for pointing this out.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
---
 drivers/staging/et131x/et131x_initpci.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index 95a1aff..2f03ba0 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -870,26 +870,27 @@ static void __devexit et131x_pci_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
-static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int et131x_suspend(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct net_device *netdev = pci_get_drvdata(pdev);
 
 	if (netif_running(netdev)) {
 		netif_device_detach(netdev);
 		et131x_down(netdev);
 		pci_save_state(pdev);
-		pci_set_power_state(pdev, pci_choose_state(pdev, state));
 	}
 
 	return 0;
 }
 
-static int et131x_pci_resume(struct pci_dev *pdev)
+static int et131x_resume(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct net_device *netdev = pci_get_drvdata(pdev);
 
 	if (netif_running(netdev)) {
-		pci_set_power_state(pdev, PCI_D0);
 		pci_restore_state(pdev);
 		et131x_up(netdev);
 		netif_device_attach(netdev);
@@ -898,6 +899,12 @@ static int et131x_pci_resume(struct pci_dev *pdev)
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
+#define ET131X_PM_OPS (&et131x_pm_ops)
+#else
+#define ET131X_PM_OPS NULL
+#endif
+
 static struct pci_device_id et131x_pci_table[] __devinitdata = {
 	{ET131X_PCI_VENDOR_ID, ET131X_PCI_DEVICE_ID_GIG, PCI_ANY_ID,
 	 PCI_ANY_ID, 0, 0, 0UL},
@@ -913,10 +920,7 @@ static struct pci_driver et131x_driver = {
 	.id_table	= et131x_pci_table,
 	.probe		= et131x_pci_setup,
 	.remove		= __devexit_p(et131x_pci_remove),
-#ifdef CONFIG_PM
-	.suspend	= et131x_pci_suspend,
-	.resume		= et131x_pci_resume,
-#endif
+	.driver.pm	= ET131X_PM_OPS,
 };
 
 /**
-- 
1.7.6.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-07 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 21:52 [PATCH 2/4] staging: et131x: Remove error path from suspend/resume code Mark Einon
2011-10-07 21:52 ` [PATCH 3/4] staging: et131x: Move pm calls from pci device to driver device Mark Einon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®