From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jeff Garzik <jeff@garzik.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
pm list <linux-pm@lists.linux-foundation.org>,
netdev@vger.kernel.org, Stephen Hemminger <shemminger@vyatta.com>
Subject: [PATCH 4/4] sky2: Adapt sky2 to use reworked PCI PM
Date: Sat, 19 Jul 2008 14:42:51 +0200 [thread overview]
Message-ID: <200807191442.52759.rjw@sisk.pl> (raw)
In-Reply-To: <200807191436.40726.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
Adapt the sky2 driver to use the reworked PCI PM.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/net/sky2.c | 42 +++++++++++++++---------------------------
1 file changed, 15 insertions(+), 27 deletions(-)
Index: linux-2.6/drivers/net/sky2.c
===================================================================
--- linux-2.6.orig/drivers/net/sky2.c
+++ linux-2.6/drivers/net/sky2.c
@@ -2988,7 +2988,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;
@@ -2999,8 +3000,8 @@ static int sky2_set_wol(struct net_devic
sky2_write32(hw, B0_CTST, sky2->wol
? Y2_HW_WOL_ON : Y2_HW_WOL_OFF);
- if (!netif_running(dev))
- sky2_wol_init(sky2);
+ device_set_wakeup_enable(&hw->pdev->dev, sky2->wol);
+
return 0;
}
@@ -4120,18 +4121,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;
-}
-
static int __devinit sky2_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -4170,7 +4159,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);
@@ -4335,7 +4324,8 @@ 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;
+ bool wol = false;
if (!hw)
return 0;
@@ -4351,10 +4341,10 @@ static int sky2_suspend(struct pci_dev *
if (netif_running(dev))
sky2_down(dev);
- if (sky2->wol)
+ if (sky2->wol) {
+ wol = true;
sky2_wol_init(sky2);
-
- wol |= sky2->wol;
+ }
}
sky2_write32(hw, B0_IMSK, 0);
@@ -4362,8 +4352,8 @@ 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;
}
@@ -4376,7 +4366,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;
@@ -4384,8 +4374,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 ||
@@ -4444,8 +4432,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);
next prev parent reply other threads:[~2008-07-19 12:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-19 12:36 [PATCH 0/4] Use new PCI PM code for Wake-on-LAN in some drivers Rafael J. Wysocki
2008-07-19 12:38 ` [PATCH 1/4] skge: Adapt skge to use reworked PCI PM Rafael J. Wysocki
2008-07-19 12:39 ` [PATCH 2/4] PCI PM: Make more PCI PM core functionality available to drivers Rafael J. Wysocki
2008-07-22 21:26 ` Jesse Barnes
2008-07-19 12:40 ` [PATCH 3/4] tg3: Adapt tg3 to use reworked PCI PM code Rafael J. Wysocki
2008-07-19 12:42 ` Rafael J. Wysocki [this message]
2008-07-21 2:07 ` [PATCH 4/4] sky2: Adapt sky2 to use reworked PCI PM Andrew Morton
2008-07-24 20:50 ` Rafael J. Wysocki
2008-07-24 20:52 ` Jesse Barnes
2008-07-24 20:59 ` Stephen Hemminger
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=200807191442.52759.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=jbarnes@virtuousgeek.org \
--cc=jeff@garzik.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/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 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®