Commit 51763947 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: [drivers] pci_enable_device() before finding irq

Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46b2c02f
...@@ -2228,18 +2228,13 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev) ...@@ -2228,18 +2228,13 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
spin_lock_init (&dev->rxq[pool].lock); spin_lock_init (&dev->rxq[pool].lock);
} }
static int setup_pci_dev(struct pci_dev *pci_dev) static void setup_pci_dev(struct pci_dev *pci_dev)
{ {
unsigned char lat; unsigned char lat;
int ret;
// enable bus master accesses // enable bus master accesses
pci_set_master(pci_dev); pci_set_master(pci_dev);
ret = pci_enable_device(pci_dev);
if (ret < 0)
goto out;
// frobnicate latency (upwards, usually) // frobnicate latency (upwards, usually)
pci_read_config_byte (pci_dev, PCI_LATENCY_TIMER, &lat); pci_read_config_byte (pci_dev, PCI_LATENCY_TIMER, &lat);
...@@ -2251,22 +2246,27 @@ static int setup_pci_dev(struct pci_dev *pci_dev) ...@@ -2251,22 +2246,27 @@ static int setup_pci_dev(struct pci_dev *pci_dev)
lat, pci_lat); lat, pci_lat);
pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, pci_lat); pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, pci_lat);
} }
out:
return ret;
} }
static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent) static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
{ {
amb_dev * dev; amb_dev * dev;
int err; int err;
unsigned int irq;
err = pci_enable_device(pci_dev);
if (err < 0) {
PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
goto out;
}
// read resources from PCI configuration space // read resources from PCI configuration space
unsigned int irq = pci_dev->irq; irq = pci_dev->irq;
if (pci_dev->device == PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD) { if (pci_dev->device == PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD) {
PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card"); PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
err = -EINVAL; err = -EINVAL;
goto out; goto out_disable;
} }
PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at" PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at"
...@@ -2277,7 +2277,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2277,7 +2277,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
err = pci_request_region(pci_dev, 1, DEV_LABEL); err = pci_request_region(pci_dev, 1, DEV_LABEL);
if (err < 0) { if (err < 0) {
PRINTK (KERN_ERR, "IO range already in use!"); PRINTK (KERN_ERR, "IO range already in use!");
goto out; goto out_disable;
} }
dev = kmalloc (sizeof(amb_dev), GFP_KERNEL); dev = kmalloc (sizeof(amb_dev), GFP_KERNEL);
...@@ -2295,15 +2295,13 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2295,15 +2295,13 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
goto out_free; goto out_free;
} }
err = setup_pci_dev(pci_dev); setup_pci_dev(pci_dev);
if (err < 0)
goto out_reset;
// grab (but share) IRQ and install handler // grab (but share) IRQ and install handler
err = request_irq(irq, interrupt_handler, SA_SHIRQ, DEV_LABEL, dev); err = request_irq(irq, interrupt_handler, SA_SHIRQ, DEV_LABEL, dev);
if (err < 0) { if (err < 0) {
PRINTK (KERN_ERR, "request IRQ failed!"); PRINTK (KERN_ERR, "request IRQ failed!");
goto out_disable; goto out_reset;
} }
dev->atm_dev = atm_dev_register (DEV_LABEL, &amb_ops, -1, NULL); dev->atm_dev = atm_dev_register (DEV_LABEL, &amb_ops, -1, NULL);
...@@ -2337,14 +2335,14 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2337,14 +2335,14 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
out_free_irq: out_free_irq:
free_irq(irq, dev); free_irq(irq, dev);
out_disable:
pci_disable_device(pci_dev);
out_reset: out_reset:
amb_reset(dev, 0); amb_reset(dev, 0);
out_free: out_free:
kfree(dev); kfree(dev);
out_release: out_release:
pci_release_region(pci_dev, 1); pci_release_region(pci_dev, 1);
out_disable:
pci_disable_device(pci_dev);
goto out; goto out;
} }
......
...@@ -2706,18 +2706,18 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2706,18 +2706,18 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
// adapter slot free, read resources from PCI configuration space // adapter slot free, read resources from PCI configuration space
u32 iobase = pci_resource_start (pci_dev, 0); u32 iobase = pci_resource_start (pci_dev, 0);
u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1)); u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1));
u8 irq = pci_dev->irq; unsigned int irq;
unsigned char lat; unsigned char lat;
PRINTD (DBG_FLOW, "hrz_probe"); PRINTD (DBG_FLOW, "hrz_probe");
/* XXX DEV_LABEL is a guess */ if (pci_enable_device(pci_dev))
if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL))
return -EINVAL; return -EINVAL;
if (pci_enable_device(pci_dev)) { /* XXX DEV_LABEL is a guess */
err = -EINVAL; if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL)) {
goto out_release; return -EINVAL;
goto out_disable;
} }
dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL); dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
...@@ -2725,7 +2725,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2725,7 +2725,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
// perhaps we should be nice: deregister all adapters and abort? // perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory"); PRINTD(DBG_ERR, "out of memory");
err = -ENOMEM; err = -ENOMEM;
goto out_disable; goto out_release;
} }
memset(dev, 0, sizeof(hrz_dev)); memset(dev, 0, sizeof(hrz_dev));
...@@ -2733,6 +2733,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2733,6 +2733,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
pci_set_drvdata(pci_dev, dev); pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible // grab IRQ and install handler - move this someplace more sensible
irq = pci_dev->irq;
if (request_irq(irq, if (request_irq(irq,
interrupt_handler, interrupt_handler,
SA_SHIRQ, /* irqflags guess */ SA_SHIRQ, /* irqflags guess */
...@@ -2846,10 +2847,10 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_ ...@@ -2846,10 +2847,10 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
out_free: out_free:
kfree(dev); kfree(dev);
out_disable:
pci_disable_device(pci_dev);
out_release: out_release:
release_region(iobase, HRZ_IO_EXTENT); release_region(iobase, HRZ_IO_EXTENT);
out_disable:
pci_disable_device(pci_dev);
goto out; goto out;
} }
......
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