Commit 3403aca2 authored by Mike McCormack's avatar Mike McCormack Committed by David S. Miller

sky2: Avoid allocating memory in sky2_resume

Allocating memory can fail, and since we have the memory we need
in sky2_resume when sky2_suspend is called, just stop the hardware
without freeing the memory it's using.

This avoids the possibility of failing because we can't allocate
memory in sky2_resume(), and allows sharing code with sky2_restart().
Signed-off-by: default avatarMike McCormack <mikem@ring3k.org>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d72ff8fa
...@@ -4926,12 +4926,12 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4926,12 +4926,12 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
cancel_work_sync(&hw->restart_work); cancel_work_sync(&hw->restart_work);
rtnl_lock(); rtnl_lock();
sky2_all_down(hw);
for (i = 0; i < hw->ports; i++) { for (i = 0; i < hw->ports; i++) {
struct net_device *dev = hw->dev[i]; struct net_device *dev = hw->dev[i];
struct sky2_port *sky2 = netdev_priv(dev); struct sky2_port *sky2 = netdev_priv(dev);
sky2_detach(dev);
if (sky2->wol) if (sky2->wol)
sky2_wol_init(sky2); sky2_wol_init(sky2);
...@@ -4940,8 +4940,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4940,8 +4940,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
device_set_wakeup_enable(&pdev->dev, wol != 0); device_set_wakeup_enable(&pdev->dev, wol != 0);
sky2_write32(hw, B0_IMSK, 0);
napi_disable(&hw->napi);
sky2_power_aux(hw); sky2_power_aux(hw);
rtnl_unlock(); rtnl_unlock();
...@@ -4956,12 +4954,11 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4956,12 +4954,11 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
static int sky2_resume(struct pci_dev *pdev) static int sky2_resume(struct pci_dev *pdev)
{ {
struct sky2_hw *hw = pci_get_drvdata(pdev); struct sky2_hw *hw = pci_get_drvdata(pdev);
int i, err; int err;
if (!hw) if (!hw)
return 0; return 0;
rtnl_lock();
err = pci_set_power_state(pdev, PCI_D0); err = pci_set_power_state(pdev, PCI_D0);
if (err) if (err)
goto out; goto out;
...@@ -4979,20 +4976,13 @@ static int sky2_resume(struct pci_dev *pdev) ...@@ -4979,20 +4976,13 @@ static int sky2_resume(struct pci_dev *pdev)
goto out; goto out;
} }
rtnl_lock();
sky2_reset(hw); sky2_reset(hw);
sky2_write32(hw, B0_IMSK, Y2_IS_BASE); sky2_all_up(hw);
napi_enable(&hw->napi);
for (i = 0; i < hw->ports; i++) {
err = sky2_reattach(hw->dev[i]);
if (err)
goto out;
}
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
out: out:
rtnl_unlock();
dev_err(&pdev->dev, "resume failed (%d)\n", err); dev_err(&pdev->dev, "resume failed (%d)\n", err);
pci_disable_device(pdev); pci_disable_device(pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment