diff mbox

[net-next-2.6] jme: Support WoL after shutdown

Message ID 1287711220-20075-1-git-send-email-cooldavid@cooldavid.org
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Guo-Fu Tseng Oct. 22, 2010, 1:33 a.m. UTC
From: Guo-Fu Tseng <cooldavid@cooldavid.org>

Adding shutdown function that setup wake if wol is enabled.
Add jme_phy_on in jme_set_100m_half in case it is shutting down
or suspending when interface is down(phy_off by default).

Reported_and_helped_by: Сtac <Taoga@yandex.ru>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
---
 drivers/net/jme.c |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

Comments

David Miller Oct. 24, 2010, 10:42 p.m. UTC | #1
From: "Guo-Fu Tseng" <cooldavid@cooldavid.org>
Date: Fri, 22 Oct 2010 09:33:40 +0800

> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
> 
> Adding shutdown function that setup wake if wol is enabled.
> Add jme_phy_on in jme_set_100m_half in case it is shutting down
> or suspending when interface is down(phy_off by default).
> 
> Reported_and_helped_by: Сtac <Taoga@yandex.ru>
> Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Oct. 24, 2010, 10:51 p.m. UTC | #2
From: David Miller <davem@davemloft.net>
Date: Sun, 24 Oct 2010 15:42:27 -0700 (PDT)

> From: "Guo-Fu Tseng" <cooldavid@cooldavid.org>
> Date: Fri, 22 Oct 2010 09:33:40 +0800
> 
>> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
>> 
>> Adding shutdown function that setup wake if wol is enabled.
>> Add jme_phy_on in jme_set_100m_half in case it is shutting down
>> or suspending when interface is down(phy_off by default).
>> 
>> Reported_and_helped_by: Сtac <Taoga@yandex.ru>
>> Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
> 
> Applied.

Actually, I had to undo this patch.  It generates build
failures:

drivers/net/jme.c: In function 'jme_powersave_phy':
drivers/net/jme.c:1672:3: error: implicit declaration of function 'jme_set_100m_half'
drivers/net/jme.c:1675:4: error: implicit declaration of function 'jme_wait_link'

I guess I'm one of the few people who build with CONFIG_PM
disabled :-)

Please fix this up and resubmit your patch.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index d7a975e..9f5c146 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -1629,6 +1629,7 @@  jme_set_100m_half(struct jme_adapter *jme)
 {
 	u32 bmcr, tmp;
 
+	jme_phy_on(jme);
 	bmcr = jme_mdio_read(jme->dev, jme->mii_if.phy_id, MII_BMCR);
 	tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
 		       BMCR_SPEED1000 | BMCR_FULLDPLX);
@@ -1664,6 +1665,21 @@  jme_phy_off(struct jme_adapter *jme)
 	jme_mdio_write(jme->dev, jme->mii_if.phy_id, MII_BMCR, BMCR_PDOWN);
 }
 
+static void
+jme_powersave_phy(struct jme_adapter *jme)
+{
+	if (jme->reg_pmcs) {
+		jme_set_100m_half(jme);
+
+		if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
+			jme_wait_link(jme);
+
+		jwrite32(jme, JME_PMCS, jme->reg_pmcs);
+	} else {
+		jme_phy_off(jme);
+	}
+}
+
 static int
 jme_close(struct net_device *netdev)
 {
@@ -2991,6 +3007,16 @@  jme_remove_one(struct pci_dev *pdev)
 
 }
 
+static void
+jme_shutdown(struct pci_dev *pdev)
+{
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct jme_adapter *jme = netdev_priv(netdev);
+
+	jme_powersave_phy(jme);
+	pci_pme_active(pdev, true);
+}
+
 #ifdef CONFIG_PM
 static int
 jme_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -3028,19 +3054,9 @@  jme_suspend(struct pci_dev *pdev, pm_message_t state)
 	tasklet_hi_enable(&jme->rxempty_task);
 
 	pci_save_state(pdev);
-	if (jme->reg_pmcs) {
-		jme_set_100m_half(jme);
-
-		if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
-			jme_wait_link(jme);
-
-		jwrite32(jme, JME_PMCS, jme->reg_pmcs);
-
-		pci_enable_wake(pdev, PCI_D3cold, true);
-	} else {
-		jme_phy_off(jme);
-	}
-	pci_set_power_state(pdev, PCI_D3cold);
+	jme_powersave_phy(jme);
+	pci_enable_wake(jme->pdev, PCI_D3hot, true);
+	pci_set_power_state(pdev, PCI_D3hot);
 
 	return 0;
 }
@@ -3087,6 +3103,7 @@  static struct pci_driver jme_driver = {
 	.suspend        = jme_suspend,
 	.resume         = jme_resume,
 #endif /* CONFIG_PM */
+	.shutdown       = jme_shutdown,
 };
 
 static int __init