Commit c8303d10 authored by Mark Hindley's avatar Mark Hindley Committed by David S. Miller

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: default avatarMark Hindley <mark@hindley.org.uk>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 79ef4a4d
...@@ -705,7 +705,7 @@ static struct { ...@@ -705,7 +705,7 @@ static struct {
static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq, static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
int chip_idx, int card_idx); int chip_idx, int card_idx);
static void vortex_up(struct net_device *dev); static int vortex_up(struct net_device *dev);
static void vortex_down(struct net_device *dev, int final); static void vortex_down(struct net_device *dev, int final);
static int vortex_open(struct net_device *dev); static int vortex_open(struct net_device *dev);
static void mdio_sync(void __iomem *ioaddr, int bits); static void mdio_sync(void __iomem *ioaddr, int bits);
...@@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev) ...@@ -841,8 +841,11 @@ static int vortex_resume(struct pci_dev *pdev)
return -EBUSY; return -EBUSY;
} }
if (netif_running(dev)) { if (netif_running(dev)) {
vortex_up(dev); err = vortex_up(dev);
netif_device_attach(dev); if (err)
return err;
else
netif_device_attach(dev);
} }
} }
return 0; return 0;
...@@ -1484,19 +1487,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init) ...@@ -1484,19 +1487,24 @@ static void vortex_check_media(struct net_device *dev, unsigned int init)
} }
} }
static void static int
vortex_up(struct net_device *dev) vortex_up(struct net_device *dev)
{ {
struct vortex_private *vp = netdev_priv(dev); struct vortex_private *vp = netdev_priv(dev);
void __iomem *ioaddr = vp->ioaddr; void __iomem *ioaddr = vp->ioaddr;
unsigned int config; unsigned int config;
int i, mii_reg1, mii_reg5; int i, mii_reg1, mii_reg5, err;
if (VORTEX_PCI(vp)) { if (VORTEX_PCI(vp)) {
pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
if (vp->pm_state_valid) if (vp->pm_state_valid)
pci_restore_state(VORTEX_PCI(vp)); pci_restore_state(VORTEX_PCI(vp));
pci_enable_device(VORTEX_PCI(vp)); err = pci_enable_device(VORTEX_PCI(vp));
if (err) {
printk(KERN_WARNING "%s: Could not enable device \n",
dev->name);
goto err_out;
}
} }
/* Before initializing select the active media port. */ /* Before initializing select the active media port. */
...@@ -1661,6 +1669,8 @@ vortex_up(struct net_device *dev) ...@@ -1661,6 +1669,8 @@ vortex_up(struct net_device *dev)
if (vp->cb_fn_base) /* The PCMCIA people are idiots. */ if (vp->cb_fn_base) /* The PCMCIA people are idiots. */
iowrite32(0x8000, vp->cb_fn_base + 4); iowrite32(0x8000, vp->cb_fn_base + 4);
netif_start_queue (dev); netif_start_queue (dev);
err_out:
return err;
} }
static int static int
...@@ -1674,7 +1684,7 @@ vortex_open(struct net_device *dev) ...@@ -1674,7 +1684,7 @@ vortex_open(struct net_device *dev)
if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ?
&boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) { &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) {
printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
goto out; goto err;
} }
if (vp->full_bus_master_rx) { /* Boomerang bus master. */ if (vp->full_bus_master_rx) { /* Boomerang bus master. */
...@@ -1703,20 +1713,22 @@ vortex_open(struct net_device *dev) ...@@ -1703,20 +1713,22 @@ vortex_open(struct net_device *dev)
} }
} }
retval = -ENOMEM; retval = -ENOMEM;
goto out_free_irq; goto err_free_irq;
} }
/* Wrap the ring. */ /* Wrap the ring. */
vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma); vp->rx_ring[i-1].next = cpu_to_le32(vp->rx_ring_dma);
} }
vortex_up(dev); retval = vortex_up(dev);
return 0; if (!retval)
goto out;
out_free_irq: err_free_irq:
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
out: err:
if (vortex_debug > 1) if (vortex_debug > 1)
printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval); printk(KERN_ERR "%s: vortex_open() fails: returning %d\n", dev->name, retval);
out:
return retval; return retval;
} }
......
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