diff options
author | Mark Hindley <mark@hindley.org.uk> | 2007-08-16 06:28:40 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:46 -0400 |
commit | c8303d10daeacb5dd7714d99f03e15cc6b91a71e (patch) | |
tree | 5f848df320f98a213f1c61244bfca374eb089514 /drivers/net/3c59x.c | |
parent | 79ef4a4dd44cd4f9942975b0f625bd01549a2aa9 (diff) |
3c59x: check return of pci_enable_device()
Check return of pci_enable_device in vortex_up().
Also modify vortex_up to return error to callers. Handle failure of
vortex_up in vortex_open and vortex_resume.
Signed-off-by: Mark Hindley <mark@hindley.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/3c59x.c')
-rw-r--r-- | drivers/net/3c59x.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index a8c0f436cdd2..29e558913eb5 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c | |||
@@ -705,7 +705,7 @@ static struct { | |||
705 | 705 | ||
706 | static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, | 706 | static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, |
707 | int chip_idx, int card_idx); | 707 | int chip_idx, int card_idx); |
708 | static void vortex_up(struct net_device *dev); | 708 | static int vortex_up(struct net_device *dev); |
709 | static void vortex_down(struct net_device *dev, int final); | 709 | static void vortex_down(struct net_device *dev, int final); |
710 | static int vortex_open(struct net_device *dev); | 710 | static int vortex_open(struct net_device *dev); |
711 | static void mdio_sync(void __iomem *ioaddr, int bits); | 711 | static void mdio_sync(void __iomem *ioaddr, int bits); |
@@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) | |||
841 | return -EBUSY; | 841 | return -EBUSY; |
842 | } | 842 | } |
843 | if (netif_running(dev)) { | 843 | if (netif_running(dev)) { |
844 | vortex_up(dev); | 844 | err = vortex_up(dev); |
845 | netif_device_attach(dev); | 845 | if (err) |
846 | return err; | ||
847 | else | ||
848 | netif_device_attach(dev); | ||
846 | } | 849 | } |
847 | } | 850 | } |
848 | return 0; | 851 | return 0; |
@@ -1484,19 +1487,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init) | |||
1484 | } | 1487 | } |
1485 | } | 1488 | } |
1486 | 1489 | ||
1487 | static void | 1490 | static int |
1488 | vortex_up(struct net_device *dev) | 1491 | vortex_up(struct net_device *dev) |
1489 | { | 1492 | { |
1490 | struct vortex_private *vp = netdev_priv(dev); | 1493 | struct vortex_private *vp = netdev_priv(dev); |
1491 | void __iomem *ioaddr = vp->ioaddr; | 1494 | void __iomem *ioaddr = vp->ioaddr; |
1492 | unsigned int config; | 1495 | unsigned int config; |
1493 | int i, mii_reg1, mii_reg5; | 1496 | int i, mii_reg1, mii_reg5, err; |
1494 | 1497 | ||
1495 | if (VORTEX_PCI(vp)) { | 1498 | if (VORTEX_PCI(vp)) { |
1496 | pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ | 1499 | pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ |
1497 | if (vp->pm_state_valid) | 1500 | if (vp->pm_state_valid) |
1498 | pci_restore_state(VORTEX_PCI(vp)); | 1501 | pci_restore_state(VORTEX_PCI(vp)); |
1499 | pci_enable_device(VORTEX_PCI(vp)); | 1502 | err = pci_enable_device(VORTEX_PCI(vp)); |
1503 | if (err) { | ||
1504 | printk(KERN_WARNING "%s: Could not enable device \n", | ||
1505 | dev->name); | ||
1506 | goto err_out; | ||
1507 | } | ||
1500 | } | 1508 | } |
1501 | 1509 | ||
1502 | /* Before initializing select the active media port. */ | 1510 | /* Before initializing select the active media port. */ |
@@ -1661,6 +1669,8 @@ vortex_up(struct net_device *dev) | |||
1661 | if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ | 1669 | if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ |
1662 | iowrite32(0x8000, vp->cb_fn_base + 4); | 1670 | iowrite32(0x8000, vp->cb_fn_base + 4); |
1663 | netif_start_queue (dev); | 1671 | netif_start_queue (dev); |
1672 | err_out: | ||
1673 | return err; | ||
1664 | } | 1674 | } |
1665 | 1675 | ||
1666 | static int | 1676 | static int |
@@ -1674,7 +1684,7 @@ vortex_open(struct net_device *dev) | |||
1674 | if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? | 1684 | if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? |
1675 | &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) { | 1685 | &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) { |
1676 | printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); | 1686 | printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); |
1677 | goto out; | 1687 | goto err; |
1678 | } | 1688 | } |
1679 | 1689 | ||
1680 | if (vp->full_bus_master_rx) { /* Boomerang bus master. */ | 1690 | if (vp->full_bus_master_rx) { /* Boomerang bus master. */ |
@@ -1703,20 +1713,22 @@ vortex_open(struct net_device *dev) | |||
1703 | } | 1713 | } |
1704 | } | 1714 | } |
1705 | retval = -ENOMEM; | 1715 | retval = -ENOMEM; |
1706 | goto out_free_irq; | 1716 | goto err_free_irq; |
1707 | } | 1717 | } |
1708 | /* Wrap the ring. */ | 1718 | /* Wrap the ring. */ |
1709 | vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); | 1719 | vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); |
1710 | } | 1720 | } |
1711 | 1721 | ||
1712 | vortex_up(dev); | 1722 | retval = vortex_up(dev); |
1713 | return 0; | 1723 | if (!retval) |
1724 | goto out; | ||
1714 | 1725 | ||
1715 | out_free_irq: | 1726 | err_free_irq: |
1716 | free_irq(dev->irq, dev); | 1727 | free_irq(dev->irq, dev); |
1717 | out: | 1728 | err: |
1718 | if (vortex_debug > 1) | 1729 | if (vortex_debug > 1) |
1719 | printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval); | 1730 | printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval); |
1731 | out: | ||
1720 | return retval; | 1732 | return retval; |
1721 | } | 1733 | } |
1722 | 1734 | ||