Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121535
b: refs/heads/master
c: 5177b32
h: refs/heads/master
i:
  121533: acde2d9
  121531: 699ee6c
  121527: 237c767
  121519: 16d6ece
  121503: bdc2676
  121471: 1d97de2
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Jeff Garzik committed Oct 31, 2008
1 parent 398a895 commit d988dc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8db3fec5b02f4cefe441903fe1c142ff14e1771
refs/heads/master: 5177b3240a6608fc0c9c05cc32f4855c6540f8d5
38 changes: 11 additions & 27 deletions trunk/drivers/net/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,6 @@ static u32 wol_supported(const struct skge_hw *hw)
return WAKE_MAGIC | WAKE_PHY;
}

static u32 pci_wake_enabled(struct pci_dev *dev)
{
int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
u16 value;

/* If device doesn't support PM Capabilities, but request is to disable
* wake events, it's a nop; otherwise fail */
if (!pm)
return 0;

pci_read_config_word(dev, pm + PCI_PM_PMC, &value);

value &= PCI_PM_CAP_PME_MASK;
value >>= ffs(PCI_PM_CAP_PME_MASK) - 1; /* First bit of mask */

return value != 0;
}

static void skge_wol_init(struct skge_port *skge)
{
struct skge_hw *hw = skge->hw;
Expand Down Expand Up @@ -254,10 +236,14 @@ static int skge_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
struct skge_port *skge = netdev_priv(dev);
struct skge_hw *hw = skge->hw;

if (wol->wolopts & ~wol_supported(hw))
if ((wol->wolopts & ~wol_supported(hw))
|| !device_can_wakeup(&hw->pdev->dev))
return -EOPNOTSUPP;

skge->wol = wol->wolopts;

device_set_wakeup_enable(&hw->pdev->dev, skge->wol);

return 0;
}

Expand Down Expand Up @@ -3856,7 +3842,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
skge->speed = -1;
skge->advertising = skge_supported_modes(hw);

if (pci_wake_enabled(hw->pdev))
if (device_may_wakeup(&hw->pdev->dev))
skge->wol = wol_supported(hw) & WAKE_MAGIC;

hw->dev[port] = dev;
Expand Down Expand Up @@ -4081,8 +4067,8 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
}

skge_write32(hw, B0_IMSK, 0);
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;
}
Expand All @@ -4095,16 +4081,14 @@ static int skge_resume(struct pci_dev *pdev)
if (!hw)
return 0;

err = pci_set_power_state(pdev, PCI_D0);
err = pci_back_from_sleep(pdev);
if (err)
goto out;

err = pci_restore_state(pdev);
if (err)
goto out;

pci_enable_wake(pdev, PCI_D0, 0);

err = skge_reset(hw);
if (err)
goto out;
Expand Down Expand Up @@ -4145,8 +4129,8 @@ static void skge_shutdown(struct pci_dev *pdev)
wol |= skge->wol;
}

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);
Expand Down

0 comments on commit d988dc7

Please sign in to comment.