diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-10-29 17:22:14 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-10-31 00:52:17 -0400 |
commit | 5177b3240a6608fc0c9c05cc32f4855c6540f8d5 (patch) | |
tree | a3a8063d2b722e5df04853f82483ee23759e85c7 /drivers/net/skge.c | |
parent | c8db3fec5b02f4cefe441903fe1c142ff14e1771 (diff) |
skge: adapt skge to use reworked PCI PM
Adapt the skge 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 L5D (Yukon-Lite rev 7).
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/skge.c')
-rw-r--r-- | drivers/net/skge.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 467f53dc09c8..7911839f7375 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c | |||
@@ -149,24 +149,6 @@ static u32 wol_supported(const struct skge_hw *hw) | |||
149 | return WAKE_MAGIC | WAKE_PHY; | 149 | return WAKE_MAGIC | WAKE_PHY; |
150 | } | 150 | } |
151 | 151 | ||
152 | static u32 pci_wake_enabled(struct pci_dev *dev) | ||
153 | { | ||
154 | int pm = pci_find_capability(dev, PCI_CAP_ID_PM); | ||
155 | u16 value; | ||
156 | |||
157 | /* If device doesn't support PM Capabilities, but request is to disable | ||
158 | * wake events, it's a nop; otherwise fail */ | ||
159 | if (!pm) | ||
160 | return 0; | ||
161 | |||
162 | pci_read_config_word(dev, pm + PCI_PM_PMC, &value); | ||
163 | |||
164 | value &= PCI_PM_CAP_PME_MASK; | ||
165 | value >>= ffs(PCI_PM_CAP_PME_MASK) - 1; /* First bit of mask */ | ||
166 | |||
167 | return value != 0; | ||
168 | } | ||
169 | |||
170 | static void skge_wol_init(struct skge_port *skge) | 152 | static void skge_wol_init(struct skge_port *skge) |
171 | { | 153 | { |
172 | struct skge_hw *hw = skge->hw; | 154 | struct skge_hw *hw = skge->hw; |
@@ -254,10 +236,14 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | |||
254 | struct skge_port *skge = netdev_priv(dev); | 236 | struct skge_port *skge = netdev_priv(dev); |
255 | struct skge_hw *hw = skge->hw; | 237 | struct skge_hw *hw = skge->hw; |
256 | 238 | ||
257 | if (wol->wolopts & ~wol_supported(hw)) | 239 | if ((wol->wolopts & ~wol_supported(hw)) |
240 | || !device_can_wakeup(&hw->pdev->dev)) | ||
258 | return -EOPNOTSUPP; | 241 | return -EOPNOTSUPP; |
259 | 242 | ||
260 | skge->wol = wol->wolopts; | 243 | skge->wol = wol->wolopts; |
244 | |||
245 | device_set_wakeup_enable(&hw->pdev->dev, skge->wol); | ||
246 | |||
261 | return 0; | 247 | return 0; |
262 | } | 248 | } |
263 | 249 | ||
@@ -3856,7 +3842,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port, | |||
3856 | skge->speed = -1; | 3842 | skge->speed = -1; |
3857 | skge->advertising = skge_supported_modes(hw); | 3843 | skge->advertising = skge_supported_modes(hw); |
3858 | 3844 | ||
3859 | if (pci_wake_enabled(hw->pdev)) | 3845 | if (device_may_wakeup(&hw->pdev->dev)) |
3860 | skge->wol = wol_supported(hw) & WAKE_MAGIC; | 3846 | skge->wol = wol_supported(hw) & WAKE_MAGIC; |
3861 | 3847 | ||
3862 | hw->dev[port] = dev; | 3848 | hw->dev[port] = dev; |
@@ -4081,8 +4067,8 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4081 | } | 4067 | } |
4082 | 4068 | ||
4083 | skge_write32(hw, B0_IMSK, 0); | 4069 | skge_write32(hw, B0_IMSK, 0); |
4084 | pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); | 4070 | |
4085 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | 4071 | pci_prepare_to_sleep(pdev); |
4086 | 4072 | ||
4087 | return 0; | 4073 | return 0; |
4088 | } | 4074 | } |
@@ -4095,7 +4081,7 @@ static int skge_resume(struct pci_dev *pdev) | |||
4095 | if (!hw) | 4081 | if (!hw) |
4096 | return 0; | 4082 | return 0; |
4097 | 4083 | ||
4098 | err = pci_set_power_state(pdev, PCI_D0); | 4084 | err = pci_back_from_sleep(pdev); |
4099 | if (err) | 4085 | if (err) |
4100 | goto out; | 4086 | goto out; |
4101 | 4087 | ||
@@ -4103,8 +4089,6 @@ static int skge_resume(struct pci_dev *pdev) | |||
4103 | if (err) | 4089 | if (err) |
4104 | goto out; | 4090 | goto out; |
4105 | 4091 | ||
4106 | pci_enable_wake(pdev, PCI_D0, 0); | ||
4107 | |||
4108 | err = skge_reset(hw); | 4092 | err = skge_reset(hw); |
4109 | if (err) | 4093 | if (err) |
4110 | goto out; | 4094 | goto out; |
@@ -4145,8 +4129,8 @@ static void skge_shutdown(struct pci_dev *pdev) | |||
4145 | wol |= skge->wol; | 4129 | wol |= skge->wol; |
4146 | } | 4130 | } |
4147 | 4131 | ||
4148 | pci_enable_wake(pdev, PCI_D3hot, wol); | 4132 | if (pci_enable_wake(pdev, PCI_D3cold, wol)) |
4149 | pci_enable_wake(pdev, PCI_D3cold, wol); | 4133 | pci_enable_wake(pdev, PCI_D3hot, wol); |
4150 | 4134 | ||
4151 | pci_disable_device(pdev); | 4135 | pci_disable_device(pdev); |
4152 | pci_set_power_state(pdev, PCI_D3hot); | 4136 | pci_set_power_state(pdev, PCI_D3hot); |