diff options
author | Mike McCormack <mikem@ring3k.org> | 2010-05-13 02:12:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-14 06:06:22 -0400 |
commit | 3403aca2320274dc5c617dc2f0cc358771a51be9 (patch) | |
tree | 450028ec2e3851f26e4cb4c5f7993e04af655079 /drivers/net/sky2.c | |
parent | d72ff8fa7f8b344382963721f842256825c4660b (diff) |
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: Mike McCormack <mikem@ring3k.org>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r-- | drivers/net/sky2.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index cc6f312a412f..c2d6117b7dbf 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -4926,12 +4926,12 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4926 | cancel_work_sync(&hw->restart_work); | 4926 | cancel_work_sync(&hw->restart_work); |
4927 | 4927 | ||
4928 | rtnl_lock(); | 4928 | rtnl_lock(); |
4929 | |||
4930 | sky2_all_down(hw); | ||
4929 | for (i = 0; i < hw->ports; i++) { | 4931 | for (i = 0; i < hw->ports; i++) { |
4930 | struct net_device *dev = hw->dev[i]; | 4932 | struct net_device *dev = hw->dev[i]; |
4931 | struct sky2_port *sky2 = netdev_priv(dev); | 4933 | struct sky2_port *sky2 = netdev_priv(dev); |
4932 | 4934 | ||
4933 | sky2_detach(dev); | ||
4934 | |||
4935 | if (sky2->wol) | 4935 | if (sky2->wol) |
4936 | sky2_wol_init(sky2); | 4936 | sky2_wol_init(sky2); |
4937 | 4937 | ||
@@ -4940,8 +4940,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4940 | 4940 | ||
4941 | device_set_wakeup_enable(&pdev->dev, wol != 0); | 4941 | device_set_wakeup_enable(&pdev->dev, wol != 0); |
4942 | 4942 | ||
4943 | sky2_write32(hw, B0_IMSK, 0); | ||
4944 | napi_disable(&hw->napi); | ||
4945 | sky2_power_aux(hw); | 4943 | sky2_power_aux(hw); |
4946 | rtnl_unlock(); | 4944 | rtnl_unlock(); |
4947 | 4945 | ||
@@ -4956,12 +4954,11 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) | |||
4956 | static int sky2_resume(struct pci_dev *pdev) | 4954 | static int sky2_resume(struct pci_dev *pdev) |
4957 | { | 4955 | { |
4958 | struct sky2_hw *hw = pci_get_drvdata(pdev); | 4956 | struct sky2_hw *hw = pci_get_drvdata(pdev); |
4959 | int i, err; | 4957 | int err; |
4960 | 4958 | ||
4961 | if (!hw) | 4959 | if (!hw) |
4962 | return 0; | 4960 | return 0; |
4963 | 4961 | ||
4964 | rtnl_lock(); | ||
4965 | err = pci_set_power_state(pdev, PCI_D0); | 4962 | err = pci_set_power_state(pdev, PCI_D0); |
4966 | if (err) | 4963 | if (err) |
4967 | goto out; | 4964 | goto out; |
@@ -4979,20 +4976,13 @@ static int sky2_resume(struct pci_dev *pdev) | |||
4979 | goto out; | 4976 | goto out; |
4980 | } | 4977 | } |
4981 | 4978 | ||
4979 | rtnl_lock(); | ||
4982 | sky2_reset(hw); | 4980 | sky2_reset(hw); |
4983 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); | 4981 | sky2_all_up(hw); |
4984 | napi_enable(&hw->napi); | ||
4985 | |||
4986 | for (i = 0; i < hw->ports; i++) { | ||
4987 | err = sky2_reattach(hw->dev[i]); | ||
4988 | if (err) | ||
4989 | goto out; | ||
4990 | } | ||
4991 | rtnl_unlock(); | 4982 | rtnl_unlock(); |
4992 | 4983 | ||
4993 | return 0; | 4984 | return 0; |
4994 | out: | 4985 | out: |
4995 | rtnl_unlock(); | ||
4996 | 4986 | ||
4997 | dev_err(&pdev->dev, "resume failed (%d)\n", err); | 4987 | dev_err(&pdev->dev, "resume failed (%d)\n", err); |
4998 | pci_disable_device(pdev); | 4988 | pci_disable_device(pdev); |