All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: netdev@vger.kernel.org
Cc: rl@hellgate.ch, Bjarke Istrup Pedersen <gurligebis@gentoo.org>,
	David Miller <davem@davemloft.net>
Subject: [PATCH net-next 7/7] via-rhine: rework suspend and resume.
Date: Sat, 7 Jan 2012 23:52:41 +0100	[thread overview]
Message-ID: <20120107225241.GG25021@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20120107224856.GA24928@electric-eye.fr.zoreil.com>

Cover of 861ab44059350e5cab350238606cf8814abab93b.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
---
 drivers/net/ethernet/via/via-rhine.c |   41 ++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index e39802f..10b18eb 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -2291,17 +2291,18 @@ static void rhine_shutdown (struct pci_dev *pdev)
 
 	spin_unlock(&rp->lock);
 
-	/* Hit power state D3 (sleep) */
-	if (!avoid_D3)
+	if (system_state == SYSTEM_POWER_OFF && !avoid_D3) {
 		iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW);
 
-	/* TODO: Check use of pci_enable_wake() */
-
+		pci_wake_from_d3(pdev, true);
+		pci_set_power_state(pdev, PCI_D3hot);
+	}
 }
 
-#ifdef CONFIG_PM
-static int rhine_suspend(struct pci_dev *pdev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int rhine_suspend(struct device *device)
 {
+	struct pci_dev *pdev = to_pci_dev(device);
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
 
@@ -2313,28 +2314,21 @@ static int rhine_suspend(struct pci_dev *pdev, pm_message_t state)
 	napi_disable(&rp->napi);
 
 	netif_device_detach(dev);
-	pci_save_state(pdev);
 
 	rhine_shutdown(pdev);
 
 	return 0;
 }
 
-static int rhine_resume(struct pci_dev *pdev)
+static int rhine_resume(struct device *device)
 {
+	struct pci_dev *pdev = to_pci_dev(device);
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct rhine_private *rp = netdev_priv(dev);
-	int ret;
 
 	if (!netif_running(dev))
 		return 0;
 
-	ret = pci_set_power_state(pdev, PCI_D0);
-	netif_info(rp, drv, dev, "Entering power state D0 %s (%d)\n",
-		   ret ? "failed" : "succeeded", ret);
-
-	pci_restore_state(pdev);
-
 #ifdef USE_MMIO
 	enable_mmio(rp->pioaddr, rp->quirks);
 #endif
@@ -2352,18 +2346,23 @@ static int rhine_resume(struct pci_dev *pdev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
+
+static SIMPLE_DEV_PM_OPS(rhine_pm_ops, rhine_suspend, rhine_resume);
+#define RHINE_PM_OPS	(&rhine_pm_ops)
+
+#else
+
+#define RHINE_PM_OPS	NULL
+
+#endif /* !CONFIG_PM_SLEEP */
 
 static struct pci_driver rhine_driver = {
 	.name		= DRV_NAME,
 	.id_table	= rhine_pci_tbl,
 	.probe		= rhine_init_one,
 	.remove		= __devexit_p(rhine_remove_one),
-#ifdef CONFIG_PM
-	.suspend	= rhine_suspend,
-	.resume		= rhine_resume,
-#endif /* CONFIG_PM */
-	.shutdown =	rhine_shutdown,
+	.shutdown	= rhine_shutdown,
+	.driver.pm	= RHINE_PM_OPS,
 };
 
 static struct dmi_system_id __initdata rhine_dmi_table[] = {
-- 
1.7.6.4

  parent reply	other threads:[~2012-01-07 23:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-07 22:48 [PATCH net-next 0/7] via-rhine NAPI rework and misc Francois Romieu
2012-01-07 22:49 ` [PATCH net-next 1/7] via-rhine: factor out tx_thresh handling Francois Romieu
2012-01-08  4:41   ` Bjarke Istrup Pedersen
2012-01-08  5:13     ` Bjarke Istrup Pedersen
2012-01-08  9:39     ` Francois Romieu
2012-01-07 22:50 ` [PATCH net-next 2/7] via-rhine: balance interrupt acknowledge and events retrieval Francois Romieu
2012-01-07 22:50 ` [PATCH net-next 3/7] via-rhine: remove useless forward declarations Francois Romieu
2012-01-07 22:51 ` [PATCH net-next 4/7] via-rhine: move work from irq handler to softirq and beyond Francois Romieu
2012-01-07 22:51 ` [PATCH net-next 5/7] via-rhine: RHINE_WAIT_FOR macro removal Francois Romieu
2012-01-07 22:52 ` [PATCH net-next 6/7] via-rhine: per device debug level Francois Romieu
2012-01-07 22:52 ` Francois Romieu [this message]
2012-01-08 11:57 ` [PATCH net-next 0/7] via-rhine NAPI rework and misc Bjarke Istrup Pedersen
2012-01-10 22:55 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120107225241.GG25021@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=davem@davemloft.net \
    --cc=gurligebis@gentoo.org \
    --cc=netdev@vger.kernel.org \
    --cc=rl@hellgate.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.