[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200808202352.m7KNq2qP006044@imap1.linux-foundation.org>
Date: Wed, 20 Aug 2008 16:52:02 -0700
From: akpm@...ux-foundation.org
To: jeff@...zik.org
Cc: netdev@...r.kernel.org, akpm@...ux-foundation.org, rjw@...k.pl,
jbarnes@...tuousgeek.org, stephen.hemminger@...tta.com
Subject: [patch 05/12] skty2: adapt to the reworked PCI PM
From: "Rafael J. Wysocki" <rjw@...k.pl>
Adapt the sky2 driver to the reworked PCI PM
* Use device_set_wakeup_enable() and friends as needed
* Remove an open-coded reference to the standard PCI PM registers
* Use pci_prepare_to_sleep() and pci_back_from_sleep() in the
->suspend() and ->resume() callbacks
* Use the observation that it is sufficient to call pci_enable_wake()
once, unless it fails
Tested on Asus M3A32-MVP (Yukon-2 EC Ultra rev 3).
Signed-off-by: Rafael J. Wysocki <rjw@...k.pl>
Cc: Jeff Garzik <jeff@...zik.org>
Cc: Jesse Barnes <jbarnes@...tuousgeek.org>
Cc: Stephen Hemminger <stephen.hemminger@...tta.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
---
drivers/net/sky2.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff -puN drivers/net/sky2.c~skty2-adapt-to-the-reworked-pci-pm drivers/net/sky2.c
--- a/drivers/net/sky2.c~skty2-adapt-to-the-reworked-pci-pm
+++ a/drivers/net/sky2.c
@@ -3034,7 +3034,8 @@ static int sky2_set_wol(struct net_devic
struct sky2_port *sky2 = netdev_priv(dev);
struct sky2_hw *hw = sky2->hw;
- if (wol->wolopts & ~sky2_wol_supported(sky2->hw))
+ if ((wol->wolopts & ~sky2_wol_supported(sky2->hw))
+ || !device_can_wakeup(&hw->pdev->dev))
return -EOPNOTSUPP;
sky2->wol = wol->wolopts;
@@ -3045,6 +3046,8 @@ static int sky2_set_wol(struct net_devic
sky2_write32(hw, B0_CTST, sky2->wol
? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
+ device_set_wakeup_enable(&hw->pdev->dev, sky2->wol);
+
if (!netif_running(dev))
sky2_wol_init(sky2);
return 0;
@@ -4166,18 +4169,6 @@ static int __devinit sky2_test_msi(struc
return err;
}
-static int __devinit pci_wake_enabled(struct pci_dev *dev)
-{
- int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
- u16 value;
-
- if (!pm)
- return 0;
- if (pci_read_config_word(dev, pm + PCI_PM_CTRL, &value))
- return 0;
- return value & PCI_PM_CTRL_PME_ENABLE;
-}
-
/* This driver supports yukon2 chipset only */
static const char *sky2_name(u8 chipid, char *buf, int sz)
{
@@ -4238,7 +4229,7 @@ static int __devinit sky2_probe(struct p
}
}
- wol_default = pci_wake_enabled(pdev) ? WAKE_MAGIC : 0;
+ wol_default = device_may_wakeup(&pdev->dev) ? WAKE_MAGIC : 0;
err = -ENOMEM;
hw = kzalloc(sizeof(*hw), GFP_KERNEL);
@@ -4403,7 +4394,7 @@ static void __devexit sky2_remove(struct
static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct sky2_hw *hw = pci_get_drvdata(pdev);
- int i, wol = 0;
+ int i;
if (!hw)
return 0;
@@ -4421,8 +4412,6 @@ static int sky2_suspend(struct pci_dev *
if (sky2->wol)
sky2_wol_init(sky2);
-
- wol |= sky2->wol;
}
sky2_write32(hw, B0_IMSK, 0);
@@ -4430,8 +4419,7 @@ static int sky2_suspend(struct pci_dev *
sky2_power_aux(hw);
pci_save_state(pdev);
- pci_enable_wake(pdev, pci_choose_state(pdev, state), wol);
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ pci_prepare_to_sleep(pdev);
return 0;
}
@@ -4444,7 +4432,7 @@ static int sky2_resume(struct pci_dev *p
if (!hw)
return 0;
- err = pci_set_power_state(pdev, PCI_D0);
+ err = pci_back_from_sleep(pdev);
if (err)
goto out;
@@ -4452,8 +4440,6 @@ static int sky2_resume(struct pci_dev *p
if (err)
goto out;
- pci_enable_wake(pdev, PCI_D0, 0);
-
/* Re-enable all clocks */
if (hw->chip_id == CHIP_ID_YUKON_EX ||
hw->chip_id == CHIP_ID_YUKON_EC_U ||
@@ -4512,8 +4498,8 @@ static void sky2_shutdown(struct pci_dev
if (wol)
sky2_power_aux(hw);
- pci_enable_wake(pdev, PCI_D3hot, wol);
- pci_enable_wake(pdev, PCI_D3cold, wol);
+ if (pci_enable_wake(pdev, PCI_D3cold, wol))
+ pci_enable_wake(pdev, PCI_D3hot, wol);
pci_disable_device(pdev);
pci_set_power_state(pdev, PCI_D3hot);
_
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists